X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fincludes%2Finventory_db.inc;h=5c2aec1781457b62e9352a95afe609de8670370c;hb=5dc5289c7042dfcf44dfdcdc9321eac86ffd32c6;hp=b48fc54aa5b5fddab0f8e8e50ec7277f7505dcea;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/inventory/includes/inventory_db.inc b/inventory/includes/inventory_db.inc index b48fc54a..5c2aec17 100644 --- a/inventory/includes/inventory_db.inc +++ b/inventory/includes/inventory_db.inc @@ -1,5 +1,14 @@ . +***********************************************************************/ include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/banking.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); @@ -7,10 +16,65 @@ include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/inventory/includes/db/items_category_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_trans_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_prices_db.inc"); +include_once($path_to_root . "/inventory/includes/db/items_purchases_db.inc"); +include_once($path_to_root . "/inventory/includes/db/items_codes_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_locations_db.inc"); include_once($path_to_root . "/inventory/includes/db/movement_types_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_adjust_db.inc"); include_once($path_to_root . "/inventory/includes/db/items_transfer_db.inc"); +include_once($path_to_root . "/inventory/includes/db/items_units_db.inc"); + +function item_img_name($stock_id) +{ + $stock_id = strtr($stock_id, "><\\/:|*?", '________'); + return clean_file_name($stock_id); +} + +function calculate_reorder_level($location, $line, &$st_ids, &$st_names, &$st_num, &$st_reorder) +{ + $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 = '" . $line->stock_id . "' + AND ".TB_PREF."loc_stock.loc_code = '" . $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, $location); + $qoh -= get_demand_qty($line->stock_id, $location); + $qoh -= get_demand_asm_qty($line->stock_id, $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']; + } + } + return $loc; +} -?> \ No newline at end of file +function send_reorder_email($loc, $st_ids, $st_names, $st_num, $st_reorder) +{ + global $path_to_root; + + require_once($path_to_root . "/reporting/includes/class.mail.inc"); + $company = get_company_prefs(); + $mail = new email($company['coy_name'], $company['email']); + $from = $company['coy_name'] . " <" . $company['email'] . ">"; + $to = $loc['location_name'] . " <" . $loc['email'] . ">"; + $subject = _("Stocks below Re-Order Level at " . $loc['location_name']); + $msg = "\n"; + for ($i = 0; $i < count($st_ids); $i++) + $msg .= $st_ids[$i] . " " . $st_names[$i] . ", " . _("Re-Order Level") . ": " . $st_reorder[$i] . ", " . _("Below") . ": " . $st_num[$i] . "\n"; + $msg .= "\n" . _("Please reorder") . "\n\n"; + $msg .= $company['coy_name']; + $mail->to($to); + $mail->subject($subject); + $mail->text($msg); + return $mail->send(); +} +?>