fixed underline in db pager for sortable columns.
[fa-stable.git] / manufacturing / includes / db / work_order_requirements_db.inc
1 <?php
2
3 function get_wo_requirements($woid)
4 {
5         $sql = "SELECT ".TB_PREF."wo_requirements.*, ".TB_PREF."stock_master.description,
6                 ".TB_PREF."stock_master.mb_flag, 
7                 ".TB_PREF."locations.location_name, 
8                 ".TB_PREF."workcentres.name AS WorkCentreDescription FROM 
9                 (".TB_PREF."wo_requirements, ".TB_PREF."locations, ".TB_PREF."workcentres) INNER JOIN ".TB_PREF."stock_master ON 
10                 ".TB_PREF."wo_requirements.stock_id = ".TB_PREF."stock_master.stock_id 
11                 WHERE workorder_id=$woid
12                 AND ".TB_PREF."locations.loc_code = ".TB_PREF."wo_requirements.loc_code
13                 AND ".TB_PREF."workcentres.id=workcentre";
14
15         return db_query($sql, "The work order requirements could not be retrieved");    
16 }
17
18 //--------------------------------------------------------------------------------------
19
20 function create_wo_requirements($woid, $stock_id)
21 {
22         // create Work Order Requirements based on the bom
23         $result = get_bom($stock_id);   
24         
25         while ($myrow = db_fetch($result)) 
26         {
27                 
28                 $sql = "INSERT INTO ".TB_PREF."wo_requirements (workorder_id, stock_id, workcentre, units_req, loc_code)
29                         VALUES ($woid, '" .
30                         $myrow["component"] . "', '"    .
31                         $myrow["workcentre_added"] . "', '"     .
32                         $myrow["quantity"] . "', '"     .
33                         $myrow["loc_code"] . "')";
34                         
35         db_query($sql, "The work order requirements could not be added");
36         }               
37 }
38
39 //--------------------------------------------------------------------------------------
40
41 function delete_wo_requirements($woid)
42 {
43         $sql="DELETE FROM ".TB_PREF."wo_requirements WHERE workorder_id=$woid";
44         db_query($sql,"The work order requirements could not be deleted");      
45 }
46
47
48 //--------------------------------------------------------------------------------------
49
50 function update_wo_requirement_issued($woReqID, $quantity)
51 {
52         $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = units_issued + $quantity
53                 WHERE id = '$woReqID'";
54                                 
55         db_query($sql, "The work requirements issued quantity couldn't be updated");
56 }
57
58 //--------------------------------------------------------------------------------------
59
60 function void_wo_requirements($woid)
61 {
62         $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = 0 WHERE workorder_id = $woid";
63                                 
64         db_query($sql, "The work requirements issued quantity couldn't be voided");     
65 }
66
67 //--------------------------------------------------------------------------------------
68
69 ?>