2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 function get_wo_requirements($woid)
14 $sql = "SELECT req.*, item.description, item.mb_flag, loc.location_name,
15 center.name AS WorkCentreDescription
16 FROM (".TB_PREF."wo_requirements req,"
17 .TB_PREF."locations loc,"
18 .TB_PREF."workcentres center)
19 INNER JOIN ".TB_PREF."stock_master item ON req.stock_id=item.stock_id
20 WHERE workorder_id=".db_escape($woid)."
21 AND loc.loc_code = req.loc_code
22 AND center.id=workcentre";
24 return db_query($sql, "The work order requirements could not be retrieved");
27 //--------------------------------------------------------------------------------------
29 function create_wo_requirements($woid, $stock_id)
31 // create Work Order Requirements based on the bom
32 $result = get_bom($stock_id);
34 while ($myrow = db_fetch($result))
37 $sql = "INSERT INTO ".TB_PREF."wo_requirements (workorder_id, stock_id, workcentre, units_req, loc_code)
38 VALUES (".db_escape($woid).", '" .
39 $myrow["component"] . "', '" .
40 $myrow["workcentre_added"] . "', '" .
41 $myrow["quantity"] . "', '" .
42 $myrow["loc_code"] . "')";
44 db_query($sql, "The work order requirements could not be added");
48 //--------------------------------------------------------------------------------------
50 function delete_wo_requirements($woid)
52 $sql="DELETE FROM ".TB_PREF."wo_requirements WHERE workorder_id=".db_escape($woid);
53 db_query($sql,"The work order requirements could not be deleted");
57 //--------------------------------------------------------------------------------------
59 function update_wo_requirement_issued($woid, $stock_id, $quantity)
61 $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = units_issued + ".db_escape($quantity)."
62 WHERE workorder_id = ".db_escape($woid)." AND stock_id = ".db_escape($stock_id);
64 db_query($sql, "The work requirements issued quantity couldn't be updated");
67 //--------------------------------------------------------------------------------------
69 function void_wo_requirements($woid)
71 $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = 0 WHERE workorder_id = "
74 db_query($sql, "The work requirements issued quantity couldn't be voided");