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;
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);
if (db_num_rows($qoo_result) == 1)
{
$qoo_row = db_fetch_row($qoo_result);
- $qoo += $qoo_row[0];
+ $qoo = $qoo_row[0];
}
}
return $qoo;
$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