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