- $sql = "SELECT ".TB_PREF."bom.*, ".TB_PREF."locations.location_name, ".TB_PREF."workcentres.name AS WorkCentreDescription,
- ".TB_PREF."stock_master.description, ".TB_PREF."stock_master.mb_flag AS ResourceType,
- ".TB_PREF."stock_master.material_cost+ ".TB_PREF."stock_master.labour_cost+".TB_PREF."stock_master.overhead_cost AS standard_cost, units,
- ".TB_PREF."bom.quantity * (".TB_PREF."stock_master.material_cost+ ".TB_PREF."stock_master.labour_cost+ ".TB_PREF."stock_master.overhead_cost) AS ComponentCost
- FROM (".TB_PREF."workcentres, ".TB_PREF."locations, ".TB_PREF."bom) INNER JOIN ".TB_PREF."stock_master ON ".TB_PREF."bom.component = ".TB_PREF."stock_master.stock_id
- WHERE ".TB_PREF."bom.parent = ".db_escape($item)."
- AND ".TB_PREF."workcentres.id=".TB_PREF."bom.workcentre_added
- AND ".TB_PREF."bom.loc_code = ".TB_PREF."locations.loc_code ORDER BY ".TB_PREF."bom.id";
+ $sql = "SELECT bom.*, loc.location_name,
+ centre.name AS WorkCentreDescription,
+ item.description, item.mb_flag AS ResourceType,
+ 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
+ INNER JOIN ".TB_PREF."stock_master item ON bom.component = item.stock_id
+ WHERE bom.parent = ".db_escape($item)."
+ AND centre.id=bom.workcentre_added
+ AND bom.loc_code = loc.loc_code ORDER BY bom.id";