}
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 {
var cells : Array <Dynamic> = [
order.order_id
, '<a href="/modules/order_line_extra/order_lines_view.php?customer_id='+Std.string(order.debtor_no)+'">'+order.deliver_to+'</a>'
- ,'<input type="text" name="'+row_id+'[quantity]" value="'+order.quantity+'">'
+ , order.quantity // '<input type="text" name="'+row_id+'[quantity]" value="'+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(' ')+'"');
}
+ function quantity_box(row_id, quantity:Int, maxQuantity:Int, available:Int) {
+ if(maxQuantity > 12) {
+ return '<input type="text" name="'+row_id+'[to_pick]" value="'+(quantity == null ? 0 : quantity)+'">';
+ }
+ else {
+ var inputs : Array<String> = [];
+ for(q in 0...(maxQuantity+1)) {
+ var checked = untyped __php__(' $q == $quantity ? "checked" : ""');
+ var klass : String = q > available ? 'early' : "";
+ inputs.push('<input type="radio" name="'+row_id+'[to_pick]" value="'+q+'" '+checked+' class="'+klass+'">'+q+'</input>');
+ }
+
+ return inputs.join('');
+ }
+ }
+
function formatLocation(location : Location, type: String, left : Int) {
var cells = [
type
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";
}
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 "<input type=\"text\" name=\"" . $row_id . "[to_pick]\" value=\"" . _hx_string_rec(((($quantity === null) ? 0 : $quantity)), "") . "\">";
+ } 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("<input type=\"radio\" name=\"" . $row_id . "[to_pick]\" value=\"" . _hx_string_rec($q, "") . "\" " . $checked . " class=\"" . $klass . "\">" . _hx_string_rec($q, "") . "</input>");
+ 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 . "\""));
if($expiry_date !== null && $now->getTime() > $expiry_date->getTime()) {
$classes->push("expired");
}
- $cells = new _hx_array(array($order->order_id, "<a href=\"/modules/order_line_extra/order_lines_view.php?customer_id=" . Std::string($order->debtor_no) . "\">" . Std::string($order->deliver_to) . "</a>", "<input type=\"text\" name=\"" . $row_id . "[quantity]\" value=\"" . Std::string($order->quantity) . "\">", $before, $left, $order->from_stk_loc, $order->hold_until_date, $order->required_date, $order->comment));
+ $cells = new _hx_array(array($order->order_id, "<a href=\"/modules/order_line_extra/order_lines_view.php?customer_id=" . Std::string($order->debtor_no) . "\">" . Std::string($order->deliver_to) . "</a>", $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);
}
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);
}
$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);
}
}
}
}
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;
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();
}
}
}
-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 {