X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fincludes%2Finventory_db.inc;h=ddc817ad3bdb30848a2621ebba799e05bcf00568;hb=0cbe5791fbc7f09ab9dda6b92d1ae27e61d26953;hp=e922102e1a8193fcfbf72c0af5950e06353f3402;hpb=f44132511cc91b83f20f91af0625d4b112b4c26e;p=fa-stable.git diff --git a/inventory/includes/inventory_db.inc b/inventory/includes/inventory_db.inc index e922102e..ddc817ad 100644 --- a/inventory/includes/inventory_db.inc +++ b/inventory/includes/inventory_db.inc @@ -34,28 +34,30 @@ function get_stock_movements($stock_id, $StockLocation, $BeforeDate, $AfterDate) { $before_date = date2sql($BeforeDate); $after_date = date2sql($AfterDate); - $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name"; + // PO Delivery and Customer Credit Notes references should be saved in stock moves reference in 2.5 + $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name, + IF(move.type=".ST_SUPPRECEIVE.", grn.reference, IF(move.type=".ST_CUSTCREDIT.", cust_trans.reference, move.reference)) reference"; if(!$StockLocation) { $sql .= ", move.loc_code"; } - $sql.= " FROM ".TB_PREF."stock_moves move + $sql.= " FROM ".TB_PREF."stock_moves move LEFT JOIN ".TB_PREF."supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type - LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND 25=move.type + LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND move.type=".ST_SUPPRECEIVE." LEFT JOIN ".TB_PREF."suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id LEFT JOIN ".TB_PREF."debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type LEFT JOIN ".TB_PREF."debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no WHERE"; - if ($StockLocation) { - $sql.= " move.loc_code=".db_escape($StockLocation)." AND"; + if ($StockLocation) { + $sql.= " move.loc_code=".db_escape($StockLocation)." AND"; } $sql.= " move.tran_date >= '". $after_date . "' - AND move.tran_date <= '" . $before_date . "' - AND move.stock_id = ".db_escape($stock_id) . " ORDER BY move.tran_date, move.trans_id"; + AND move.tran_date <= '" . $before_date . "' + AND move.stock_id = ".db_escape($stock_id) . " ORDER BY move.tran_date, move.trans_id"; - return db_query($sql, "could not query stock moves"); + return db_query($sql, "could not query stock moves"); } function calculate_reorder_level($location, $line, &$st_ids, &$st_names, &$st_num, &$st_reorder) @@ -92,15 +94,13 @@ function send_reorder_email($loc, $st_ids, $st_names, $st_num, $st_reorder) 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']); + $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->to($loc['location_name'], $loc['email']); $mail->subject($subject); $mail->text($msg); return $mail->send();