From: Maxime Bourget Date: Fri, 14 Jun 2013 12:44:27 +0000 (+0100) Subject: Display to pick quantity box in item schedule. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=9ac8e06a4df87446e241df8a7315656f8056c8f8;p=order_line_extra.git Display to pick quantity box in item schedule. --- diff --git a/haxe/FA.hx b/haxe/FA.hx index 0dc9d04..54718b3 100644 --- a/haxe/FA.hx +++ b/haxe/FA.hx @@ -16,4 +16,8 @@ class FA { var offset:Int = untyped __php__('OrderXtraConfig::$pre_hold_offset'); return offset*3600*24*1000; } + + static public function pick_query():String { + return untyped __call__('pick_query'); + } } diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index 0622c00..ffb8959 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -94,7 +94,7 @@ class ItemScheduler { } function tableHeader() { - return ["Order", "Customer", "Quantity", "Before", "After", "Loc", "From", "Required Date", "Comment"]; + return ["Order", "Customer", "Quantity", "Before", "After", "Loc", "From", "Required Date", "Comment", "To Pick"]; } function generateTable(): Void { @@ -213,13 +213,14 @@ class ItemScheduler { var cells : Array = [ order.order_id , ''+order.deliver_to+'' - ,'' + , order.quantity // '' ,before ,left ,order.from_stk_loc ,order.hold_until_date ,order.required_date ,order.comment + ,quantity_box(row_id, order.to_pick, order.quantity, order.quantity > left ? left: order.quantity) ]; attributes.push('class="'+classes.join(' ')+'"'); @@ -227,6 +228,22 @@ class ItemScheduler { } + function quantity_box(row_id, quantity:Int, maxQuantity:Int, available:Int) { + if(maxQuantity > 12) { + return ''; + } + else { + var inputs : Array = []; + for(q in 0...(maxQuantity+1)) { + var checked = untyped __php__(' $q == $quantity ? "checked" : ""'); + var klass : String = q > available ? 'early' : ""; + inputs.push(''+q+''); + } + + return inputs.join(''); + } + } + function formatLocation(location : Location, type: String, left : Int) { var cells = [ type @@ -254,10 +271,11 @@ return cast(locations(), Array); private function loadOrders() { var tb : String = untyped __php__('TB_PREF'); - var sql : String = "SELECT * , d.quantity as qty, d.priority AS pp + var sql : String = "SELECT * , d.quantity as qty, d.priority AS pp, p.quantity AS to_pick FROM "+tb+"denorm_order_details_queue d JOIN "+tb+"sales_order_details od ON (od.id = d.id) JOIN "+tb+"sales_orders so ON (so.order_no = d.order_id) + LEFT JOIN ("+FA.pick_query()+") p ON (p.detail_id = od.id) WHERE stock_id = '"+this.stock_id+"' AND od.trans_type = 30 ORDER by quantity_before, d.priority"; diff --git a/hincludes/lib/FA.class.php b/hincludes/lib/FA.class.php index 94b2868..535f250 100644 --- a/hincludes/lib/FA.class.php +++ b/hincludes/lib/FA.class.php @@ -16,5 +16,8 @@ class FA { $offset = OrderXtraConfig::$pre_hold_offset; return $offset * 3600 * 24 * 1000; } + static function pick_query() { + return pick_query(); + } function __toString() { return 'FA'; } } diff --git a/hincludes/lib/ItemScheduler.class.php b/hincludes/lib/ItemScheduler.class.php index c0831ef..6cc36d7 100644 --- a/hincludes/lib/ItemScheduler.class.php +++ b/hincludes/lib/ItemScheduler.class.php @@ -92,13 +92,31 @@ class ItemScheduler { } public function loadOrders() { $tb = TB_PREF; - $sql = "SELECT * , d.quantity as qty, d.priority AS pp\x0A\x09\x09FROM " . $tb . "denorm_order_details_queue d\x0A\x09\x09JOIN " . $tb . "sales_order_details od ON (od.id = d.id)\x0A\x09\x09JOIN " . $tb . "sales_orders so ON (so.order_no = d.order_id)\x0A\x09\x09WHERE stock_id = '" . $this->stock_id . "'\x0A\x09\x09AND od.trans_type = 30\x0A\x09\x09ORDER by quantity_before, d.priority"; + $sql = "SELECT * , d.quantity as qty, d.priority AS pp, p.quantity AS to_pick\x0A\x09\x09FROM " . $tb . "denorm_order_details_queue d\x0A\x09\x09JOIN " . $tb . "sales_order_details od ON (od.id = d.id)\x0A\x09\x09JOIN " . $tb . "sales_orders so ON (so.order_no = d.order_id)\x0A\x09\x09LEFT JOIN (" . FA::pick_query() . ") p ON (p.detail_id = od.id)\x0A\x09\x09WHERE stock_id = '" . $this->stock_id . "'\x0A\x09\x09AND od.trans_type = 30\x0A\x09\x09ORDER by quantity_before, d.priority"; return FA::query($sql); } public function formatLocation($location, $type, $left) { $cells = new _hx_array(array($type, $location->name, $location->quantityOnHand($this->stock_id, null), $left - $location->quantityOnHand($this->stock_id, null), $left, $location->code, ((_hx_equal($location->delivery->getTime(), 0)) ? "" : DateTools::format($location->delivery, "%F")), "", "")); $this->printRow($cells, new _hx_array(array("class = \"tableheader location\"", "id = \"loc_" . $location->code . "\""))); } + public function quantity_box($row_id, $quantity, $maxQuantity, $available) { + if($maxQuantity > 12) { + return ""; + } else { + $inputs = new _hx_array(array()); + { + $_g1 = 0; $_g = $maxQuantity + 1; + while($_g1 < $_g) { + $q = $_g1++; + $checked = $q == $quantity ? "checked" : ""; + $klass = (($q > $available) ? "early" : ""); + $inputs->push("" . _hx_string_rec($q, "") . ""); + unset($q,$klass,$checked); + } + } + return $inputs->join(""); + } + } public function formatOrder($order, $left, $date, $now) { $row_id = ItemScheduler::orderId($order); $attributes = new _hx_array(array("id = \"" . $row_id . "\"")); @@ -134,7 +152,7 @@ class ItemScheduler { if($expiry_date !== null && $now->getTime() > $expiry_date->getTime()) { $classes->push("expired"); } - $cells = new _hx_array(array($order->order_id, "debtor_no) . "\">" . Std::string($order->deliver_to) . "", "quantity) . "\">", $before, $left, $order->from_stk_loc, $order->hold_until_date, $order->required_date, $order->comment)); + $cells = new _hx_array(array($order->order_id, "debtor_no) . "\">" . Std::string($order->deliver_to) . "", $order->quantity, $before, $left, $order->from_stk_loc, $order->hold_until_date, $order->required_date, $order->comment, $this->quantity_box($row_id, $order->to_pick, $order->quantity, ItemScheduler_3($this, $attributes, $before, $classes, $date, $expiry_date, $left, $now, $order, $required_by, $row_id)))); $attributes->push("class=\"" . $classes->join(" ") . "\""); $this->printRow($cells, $attributes); } @@ -160,7 +178,7 @@ class ItemScheduler { public function generateTable() { $startDate = Date::fromTime(0); $locations = $this->locations(); - $locations->sort(array(new _hx_lambda(array(&$locations, &$startDate), "ItemScheduler_3"), 'execute')); + $locations->sort(array(new _hx_lambda(array(&$locations, &$startDate), "ItemScheduler_4"), 'execute')); $locationIter = $locations->iterator(); $location = $locationIter->next(); $qoh = $location->quantityOnHand($this->stock_id, null); @@ -184,7 +202,7 @@ class ItemScheduler { } $left -= $quantity; $now = Date::now(); - $this->formatOrder($order, $left, ItemScheduler_4($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate), $now); + $this->formatOrder($order, $left, ItemScheduler_5($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate), $now); unset($quantity,$order,$now); } } @@ -200,7 +218,7 @@ class ItemScheduler { } } public function tableHeader() { - return new _hx_array(array("Order", "Customer", "Quantity", "Before", "After", "Loc", "From", "Required Date", "Comment")); + return new _hx_array(array("Order", "Customer", "Quantity", "Before", "After", "Loc", "From", "Required Date", "Comment", "To Pick")); } public $qoh; public $parameters; @@ -244,7 +262,14 @@ function ItemScheduler_2(&$_g, &$orderList, &$rows, $a, $b) { return $_g->parameters->priority($a) - $_g->parameters->priority($b); } } -function ItemScheduler_3(&$locations, &$startDate, $a, $b) { +function ItemScheduler_3(&$»this, &$attributes, &$before, &$classes, &$date, &$expiry_date, &$left, &$now, &$order, &$required_by, &$row_id) { + if($order->quantity > $left) { + return $left; + } else { + return $order->quantity; + } +} +function ItemScheduler_4(&$locations, &$startDate, $a, $b) { { $as = $a->delivery->getTime(); $bs = $b->delivery->getTime(); @@ -259,7 +284,7 @@ function ItemScheduler_3(&$locations, &$startDate, $a, $b) { } } } -function ItemScheduler_4(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) { +function ItemScheduler_5(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) { if($now->getTime() > $location->delivery->getTime()) { return $now; } else { diff --git a/includes/order_lines.inc b/includes/order_lines.inc index b38e0a7..928c70e 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -1,5 +1,6 @@ and from a string * generated by the above *_cell function. @@ -272,14 +273,6 @@ function get_order_details_extra($customer_id, $location, $item_like) { return array('select' => $select, 'from' => $from, 'where' => $where); } -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(); diff --git a/includes/picking.inc b/includes/picking.inc index 8bdb1bf..828e0b7 100644 --- a/includes/picking.inc +++ b/includes/picking.inc @@ -112,4 +112,12 @@ class Picker { } +function pick_query() { + return "SELECT detail_id, -sum(quantity) as quantity + FROM ".TB_PREF."topick + WHERE type IN ('order', 'booked') + GROUP BY detail_id "; + +} + diff --git a/item_schedule.php b/item_schedule.php index 929f7dc..39c8de5 100644 --- a/item_schedule.php +++ b/item_schedule.php @@ -20,6 +20,7 @@ include_once($path_to_root . "/reporting/includes/reporting.inc"); //include_once("includes/item_scheduler.inc"); include_once("hincludes/lib/php/Boot.class.php"); include_once("includes/db_order_lines.inc"); +include_once("includes/picking.inc"); include_once("config.php"); $page_security = 'SA_ORDERLINEX_SCHEDULE';