- if ($loc_notification == 1 && is_inventory_item($line->stock_id))
- {
- $sql = "SELECT ".TB_PREF."loc_stock.*, "
- .TB_PREF."locations.location_name, "
- .TB_PREF."locations.email
- FROM ".TB_PREF."loc_stock, "
- .TB_PREF."locations
- WHERE ".TB_PREF."loc_stock.loc_code=".TB_PREF."locations.loc_code
- AND ".TB_PREF."loc_stock.stock_id = ".db_escape($line->stock_id)."
- AND ".TB_PREF."loc_stock.loc_code = ".db_escape($order->Location);
- $res = db_query($sql,"a location could not be retreived");
- $loc = db_fetch($res);
- if ($loc['email'] != "")
- {
- $qoh = get_qoh_on_date($line->stock_id, $order->Location);
- $qoh -= get_demand_qty($line->stock_id, $order->Location);
- $qoh -= get_demand_asm_qty($line->stock_id, $order->Location);
- $qoh -= $line->quantity;
- if ($qoh < $loc['reorder_level'])
- {
- $st_ids[] = $line->stock_id;
- $st_names[] = $line->item_description;
- $st_num[] = $qoh - $loc['reorder_level'];
- $st_reorder[] = $loc['reorder_level'];
- }
- }
- }
+ if ($SysPrefs->loc_notification() == 1 && is_inventory_item($line->stock_id))
+ $loc = calculate_reorder_level($order->Location, $line, $st_ids, $st_names, $st_num, $st_reorder);
+