Display to pick quantity on item summary.
authorMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 10:39:31 +0000 (11:39 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Fri, 14 Jun 2013 10:39:31 +0000 (11:39 +0100)
includes/order_lines.inc
includes/picking.inc
order_lines_view.php

index ac05e350088acdd30114cc95a36b1b73f24cde36..b38e0a7953a2629042e46c6f442fa956a687ef76 100644 (file)
@@ -235,18 +235,19 @@ function pick_checkbox($row)
 }
 
 function get_order_details_extra($customer_id, $location, $item_like) {
-       $sql = "SELECT sod.id
+       $select = "sod.id
        , so.order_no
        , stk_code
        , sod.quantity - qty_sent quantity
        , GREATEST(0, LEAST(qoh.quantity  - quantity_before, sod.quantity - qty_sent))
        , quantity_before
+       , p.quantity AS quantity_to_pick
        , sod.`priority`
        , hold_until_date
        , required_date
        , expiry_date
-       ,comment
-       FROM ".TB_PREF."sales_order_details sod
+       ,comment";
+       $from =  TB_PREF."sales_order_details sod
        JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no
                AND so.trans_type = sod.trans_type
                AND so.trans_type = ".ST_SALESORDER."
@@ -254,29 +255,36 @@ function get_order_details_extra($customer_id, $location, $item_like) {
        )
        JOIN ".TB_PREF."denorm_qoh qoh ON (stock_id = stk_code AND loc_code = '$location')
        LEFT JOIN ".TB_PREF."denorm_order_details_queue  d ON (d.id = sod.id)
-       WHERE sod.quantity > qty_sent
+       LEFT JOIN (".pick_query().") p ON (detail_id = sod.id)
+       ";
+       $where = " sod.quantity > qty_sent
        ";
 
        if($item_like) {
                        if($item_like[0]=='/')  {
                                $regexp = substr($item_like, 1);
-                               $sql .= " AND stk_code RLIKE '$regexp'";
+                               $where .= " AND stk_code RLIKE '$regexp'";
                        }
                        else 
-                               $sql .= " AND stk_code LIKE '$item_like'";
+                               $where .= " AND stk_code LIKE '$item_like'";
        }
 
-       return $sql;
+       return array('select' => $select, 'from' => $from, 'where' => $where);
 }
 
-function get_order_summary($location) {
-       $held_condition = OrderXtraConfig::sql_held_condition();
-
-       $pick = "SELECT  detail_id, -sum(quantity) as quantity
+function pick_query() {
+       return "SELECT  detail_id, -sum(quantity) as quantity
                                        FROM ".TB_PREF."topick
                                        WHERE type IN ('order', 'booked')
                                        GROUP BY detail_id ";
 
+}
+
+function get_order_summary($location) {
+       $held_condition = OrderXtraConfig::sql_held_condition();
+
+       $pick = pick_query();
+
        $sub = "SELECT debtor_no, debtor_ref, branch_code, branch_ref, stk_code
        , min(delivery_date)
        , sum(d.quantity) as quantity
index 387bd8e199807194bd71d765f2d4c54738a180a9..8bdb1bfb80de2426a8560d3ec960704a783fc632 100644 (file)
@@ -11,9 +11,7 @@ function process_picking_flag() {
 
 function change_pck_flag($id, $value=null)
 {
-display_warning("value $value");
        if($value === null) $value = true;
-display_warning("value $value");
        global  $Ajax;
 
        $picker = new Picker();
@@ -58,12 +56,10 @@ class Picker {
                                                JOIN ".TB_PREF."denorm_qoh qoh ON (qoh.stock_id = sod.stk_code AND loc_code = '$pick_location')
                                                WHERE debtor_no = $debtor_no AND branch_code = $branch_code
                                                ";
-                       display_warning("$sql");
                $result = db_query($sql, $sql);
-                       display_warning("B $result");
                while($row=db_fetch($result)) {
                        foreach($row as $key => $value) { $$key = $value; }
-                       $available = min($quantity, max($qoh-$quantity_before-$held,0 ));
+                       $available = max(min($quantity-$held, $qoh-$quantity_before-$held) ,0 );
                        $booked = $quantity - $available;
 
                $sku    = $stock_id;
@@ -102,11 +98,9 @@ class Picker {
                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 ".TB_PREF."topick p
                                                FROM ".TB_PREF."topick p
                                                JOIN ".TB_PREF."sales_order_details sod on (sod.id = p.detail_id)
index 00e0258dd1e112e840e96b5fb5544a5f6c17f459..c72f043a5a1c2408e314e321e84abf739c78aba7 100644 (file)
@@ -101,6 +101,7 @@ if($customer_id) {
                ,_("Quantity") => array('type' => 'qty', 'dec' => 0)
                ,_("Available") => array('fun' => 'available_quantity', 'dec' => 0, 'ord' => '')
                ,_("Before") => 'skip'
+               ,_("To Pick") => array('type' => 'qty', 'ord' => '', 'dec' => 0)
                ,_("Priority") => array('type' => 'time', 'ord' => '')
                ,_("Hold Until") => array('fun' => 'input_hold_until_date_details', 'ord' => '')
                ,_("Require By") => array('fun' => 'input_required_date_details', 'ord' => '')