Display quantity/amount to pick.
authorMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 14:52:07 +0000 (15:52 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Thu, 13 Jun 2013 14:52:07 +0000 (15:52 +0100)
includes/order_lines.inc
order_lines_view.php

index 0e5a83f769304e2672467663687ac768022bc7a4..f0dd3751d156dd1184aece713da67a5278beb520 100644 (file)
@@ -219,6 +219,20 @@ function input_check_details($row, $dummy) {
                <input type='checkbox' class='check_detail' name='detail[$row_id][check]'>";
 }
 
+function pick_checkbox($row)
+{
+       $id = $row['debtor_no']."_".$row['branch_code'];
+       $name = "chgpck" .$id;
+       $value = $row['type'] ? 1:0;
+       //$value = onpick($row['debtor_no'], $row['branch_code']);
+
+// save also in hidden field for testing during 'Update'
+
+ return checkbox(null, $name, $value, true,
+       _('Set this order for picking'))
+       . hidden('last['.$id.']', $value, false);
+}
+
 function get_order_details_extra($customer_id, $location, $item_like) {
        $sql = "SELECT sod.id
        , so.order_no
@@ -256,7 +270,13 @@ function get_order_details_extra($customer_id, $location, $item_like) {
 
 function get_order_summary($location) {
        $held_condition = OrderXtraConfig::sql_held_condition();
-       $sub = "SELECT debtor_no, debtor_ref, branch_ref, stk_code
+
+       $pick = "SELECT  detail_id, -sum(quantity) as quantity
+                                       FROM ".TB_PREF."topick
+                                       WHERE type IN ('order', 'booked')
+                                       GROUP BY detail_id ";
+
+       $sub = "SELECT debtor_no, debtor_ref, branch_code, branch_ref, stk_code
        , min(delivery_date)
        , sum(sod.quantity - qty_sent) as quantity
        , sum((sod.quantity - qty_sent)*unit_price*(1-discount_percent/100)) as amount
@@ -265,6 +285,8 @@ function get_order_summary($location) {
        , group_concat(distinct comment separator ';') as detail_comment
        , max(quantity_before) as quantity_before
        , sum(if($held_condition, sod.quantity - qty_sent, 0)) as quantity_held
+       , sum(p.quantity) as quantity_to_pick
+       , sum(p.quantity*unit_price) as amount_to_pick
        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
@@ -272,14 +294,16 @@ function get_order_summary($location) {
        )
        NATURAL JOIN ".TB_PREF."debtors_master
        NATURAL JOIN ".TB_PREF."cust_branch
+       LEFT JOIN ($pick) p ON (detail_id = sod.id)
        JOIN ".TB_PREF."denorm_order_details_queue  d ON (d.id = sod.id)
        WHERE sod.quantity > qty_sent AND ".ST_SALESORDER."
        GROUP BY debtor_no, branch_code, stk_code
        ";
 
        //$sub = TB_PREF."order_summary_view";
+       //
 
-       $sql = array( "select" => "debtor_no, debtor_ref, branch_ref
+       $sql = array( "select" => "debtor_no, branch_code, debtor_ref, branch_ref
        , `min(delivery_date)` as delivery_date
        , sum(sub.quantity) as quantity
        , sum(sub.amount) as amount
@@ -289,9 +313,12 @@ function get_order_summary($location) {
        ,  min(`min(required_date)`) as required_date
        , group_concat(distinct order_comment separator ';') as order_comment
        , group_concat(distinct detail_comment separator ';') as detail_comment
+       , sum(quantity_to_pick) as quantity_to_pick
+       , sum(amount_to_pick) as amount_to_pick
        ", "from" => " ($sub) sub
-                               LEFT JOIN ".TB_PREF."denorm_qoh qoh ON (stock_id = stk_code AND loc_code = '$location')
-       ", "group" => " debtor_no, debtor_ref
+                       LEFT JOIN ".TB_PREF."denorm_qoh qoh ON (stock_id = stk_code AND loc_code = '$location')
+
+       ", "group" => " debtor_no, branch_code
        ");
 
        return $sql;
index cee3f3938957aa18bde6c227d1074b5c9a3bd566..02ffdb22679fa10ba608aaa5debd14d4134ccf3c 100644 (file)
@@ -87,6 +87,7 @@ end_table(1);
 //     Orders inquiry table
 //
 if($customer_id) {
+       // Display all item for one customer
        $sql = get_order_details_extra($customer_id, 'DEF', $item_like);
        $cols = array(
                'detail_id' => 'skip'
@@ -104,9 +105,11 @@ if($customer_id) {
        );
 }
 else {
+       // Display all customers
        $sql = get_order_summary('DEF');
        $cols = array(
        'customer id' => 'skip',
+       'branch code ' => 'skip',
 _("Customer") => array('ord' => '', 'fun' => 'customer_link'),
 _("Branch") => array('ord' => ''),
 _("Delivery Date") => array('ord' => '', 'type' => 'date'),
@@ -117,7 +120,10 @@ _("Avail. A") => array('ord' => '', 'type' => 'amount', 'dec' => 0),
 _("Held. Q") => array('ord' => '', 'type' => 'qty', 'dec' => 0),
 _("required date") => array('ord' => '', 'type' => 'date'),
 _("Comments") => array('ord' => '', 'fun' => 'aggregate_comment'),
-_("comment 2 ") =>  'skip'
+_("comment 2 ") =>  'skip',
+_("Q to Pick") => array('ord' => '', 'type' => 'qty'),
+_("A to Pick") => array('ord' => '', 'type' => 'amount'),
+//_("Pick").'<input type="checkbox"/ onClick="toggleAllPick()"' => array('insert'=>true, 'fun'=>'pick_checkbox'),
        );
 }