<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
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
, 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
)
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
, 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;
// 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'
);
}
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'),
_("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'),
);
}