From af02f71de22f26c124e8a8d4b25c183f35b04100 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Thu, 13 Jun 2013 22:40:07 +0100 Subject: [PATCH] Insert in to_pick in progress but doesn't work yet. --- includes/picking.inc | 60 +++++++++++++++++++++++++++++++++++++++++++- order_lines_view.php | 1 + 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/includes/picking.inc b/includes/picking.inc index 4947352..61283a2 100644 --- a/includes/picking.inc +++ b/includes/picking.inc @@ -42,12 +42,70 @@ class Picker { } function insertAllForBranch($debtor_no, $branch_code) { - display_warning("inserting for $debtor_no $branch_code"); + $this->deleteAllForBranch($debtor_no, $branch_code); + $location = OrderXtraConfig::$default_location; + $sql = "SELECT d.stock_id + , d.quantity AS quantity + ,IF(".OrderXtraConfig::sql_held_condition().", d.quantity, 0) held + ,qoh.quantity AS qoh + ,quantity_before + ,order_id + FROM ".TB_PREF."sales_order_details sod + NATURAL JOIN ".TB_PREF."sales_orders so + JOIN ".TB_PREF."denorm_order_details_queue d ON (sod.id = d.id) + JOIN ".TB_PREF."denorm_qoh qoh ON (qoh.stock_id = sod.stk_code AND loc_code = '$location') + WHERE debtor_no = $debtor_no AND branch_code = $branch_code + "; + $result = db_query($sql, $sql); + display_warning("R"); + while($row=db_fetch($result)) { + foreach($row as $key => $value) { $$key = $value; } + $available = min($quantity, max($qoh-$quantity_before-$held,0 )); + $booked = $quantity - $available; + + $sku = $stock_id; + $item_link = "/modules/order_line_extra/item_schedule.php?stock_id=$sku"; + $order_link = "/sales/sales_order_entry.php?OrderNumber=$order_id"; + $base = substr($sku, 0, 8); + $variation = substr($sku, 9); + + $sql = "INSERT INTO ".TB_PREF."topick SET + order_id = $order_id, + order_link = '$order_link', + location = '$location', + sku = '$sku', + base = '$base', + variation = '$variation', + item_link = '$item_link', + quantity = -{$quantity}, + type = 'order'"; + db_query($sql, 'There was a problem inserting the picking information.'); + # add booked quantity. Insert them as picked so they won't have to be picked + $sql = "INSERT INTO ".TB_PREF."topick SET + order_id = $order_id, + order_link = '$order_link', + location = '$location', + sku = '$sku', + item_link = '$item_link', + base = '$base', + variation = '$variation', + quantity = $booked, + type = 'booked'"; + db_query($sql, 'There was a problem inserting the picking information.'); + + } + display_warning("E"); } function deleteAllForBranch($debtor_no, $branch_code) { display_warning("deleting for $debtor_no $branch_code"); + $sql = "DELETE * + FROM ".TB_PREF."topick so + JOIN ".TB_PREF."sales_order_detals p on (sod.id = p.detail_id) + NATURAL JOIN ".TB_PREF."sales_order_details sod + WHERE debtor_no = $debtor_no AND branch_code = $branch_code + "; } } diff --git a/order_lines_view.php b/order_lines_view.php index f1dd3fb..c79a7b6 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -16,6 +16,7 @@ include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/sales/includes/sales_ui.inc"); include_once($path_to_root . "/reporting/includes/reporting.inc"); +include_once("config.php"); include_once("includes/order_lines.inc"); include_once("includes/splitter.inc"); include_once("includes/bulk_updater.inc"); -- 2.30.2