From 6bc9ca9013cbc6aa695df47cdc77a68c29650fb7 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Thu, 13 Jun 2013 15:52:07 +0100 Subject: [PATCH] Display quantity/amount to pick. --- includes/order_lines.inc | 35 +++++++++++++++++++++++++++++++---- order_lines_view.php | 8 +++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 0e5a83f..f0dd375 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -219,6 +219,20 @@ function input_check_details($row, $dummy) { "; } +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; diff --git a/order_lines_view.php b/order_lines_view.php index cee3f39..02ffdb2 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -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").' array('insert'=>true, 'fun'=>'pick_checkbox'), ); } -- 2.30.2