php 8 error. class.mail.inc. line 149. #5 parameter cannot be null.
[fa-stable.git] / includes / db / manufacturing_db.inc
index 8adddc696142f8fe850a355c15396904d0eac473..93027b764b9f32e65beda3e463c4c6ba280ecfb8 100644 (file)
@@ -50,7 +50,7 @@ function load_stock_levels($location)
        return $qoh_stock;
 }
 
-// recursion fixed by Tom Moulton. Max 10 recursion levels.
+// recursion fixed. Max 10 recursion levels.
 function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level=0) 
 {
        global $bom_list, $qoh_stock;
@@ -149,29 +149,14 @@ function get_on_porder_qty($stock_id, $location)
 
 function get_on_worder_qty($stock_id, $location)
 {
-       $sql = "SELECT SUM((wo.units_reqd-wo.units_issued) * (req.units_req-req.units_issued)) AS qoo
-               FROM ".TB_PREF."wo_requirements req
-                       INNER JOIN ".TB_PREF."workorders wo     ON req.workorder_id=wo.id
-               WHERE req.stock_id=".db_escape($stock_id)
-                       ." AND wo.released=1";
-       if ($location != "")
-               $sql .= " AND req.loc_code=".db_escape($location);
-
-       $qoo_result = db_query($sql,"could not receive quantity on order for item");
-       if (db_num_rows($qoo_result) == 1)
-       {
-               $qoo_row = db_fetch_row($qoo_result);
-               $qoo =  $qoo_row[0];
-       }
-       else
-               $qoo = 0.0;
+       $qoo = 0.0;
        $flag = get_mb_flag($stock_id);
        if ($flag == 'M')
        {
                $sql = "SELECT SUM((units_reqd-units_issued)) AS qoo
                        FROM ".TB_PREF."workorders
                        WHERE stock_id=".db_escape($stock_id)
-                               ." AND released=1";
+                               ." AND released AND NOT closed";
 
                if ($location != "")
                        $sql .= " AND loc_code=".db_escape($location);
@@ -180,7 +165,7 @@ function get_on_worder_qty($stock_id, $location)
                if (db_num_rows($qoo_result) == 1)
                {
                        $qoo_row = db_fetch_row($qoo_result);
-                       $qoo +=  $qoo_row[0];
+                       $qoo = $qoo_row[0];
                }
        }
        return $qoo;
@@ -222,8 +207,8 @@ function get_bom($item)
        $sql = "SELECT bom.*, loc.location_name,
                centre.name AS WorkCentreDescription,
        item.description, item.mb_flag AS ResourceType, 
-       item.material_cost+item.labour_cost+item.overhead_cost AS standard_cost, units,
-       bom.quantity * (item.material_cost+ item.labour_cost+ item.overhead_cost) AS ComponentCost 
+       item.material_cost AS ProductCost, units,
+       bom.quantity * item.material_cost AS ComponentCost 
        FROM ".TB_PREF."workcentres centre,
                ".TB_PREF."locations loc,
                ".TB_PREF."bom bom