Insert in to_pick in progress
authorMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 21:40:07 +0000 (22:40 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 21:40:07 +0000 (22:40 +0100)
but doesn't work yet.

includes/picking.inc
order_lines_view.php

index 4947352c605a02752f50ae7134ed654f2b22171b..61283a2e284a3fd3c5124136becbbb8c61538ae9 100644 (file)
@@ -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
+                                               ";
        }
 
 }
index f1dd3fb3a73362aedef023aab1fa7f85b630e06d..c79a7b6fde568f0c3d3882ad2e41b492ce433d7b 100644 (file)
@@ -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");