typedef Detail = {
id : String,
- quantity : Int,
+ to_pick : Int,
position : Int,
}
for(id in row_ids) {
var d : Dynamic = data.get(id);
- var quantity : Int = null;
+ var to_pick : Int = null;
if(d != null) {
var o = php.Lib.objectOfAssociativeArray(d);
- quantity = Std.parseInt(o.quantity);
+ to_pick = Std.parseInt(o.to_pick);
}
rowDetails.set(id, {
id: id
- ,quantity: quantity
+ ,to_pick: to_pick
,position: position
});
position+=1;
}
+ public function to_pick(order: {id:String}) : Null<Int> {
+ var orderId = ItemScheduler.orderId(order);
+ if(rowDetails == null) return null;
+ return rowDetails.get(orderId).to_pick;
+
+ }
+
public function priority(order : {id: String, priority: Date}) : Int {
var orderId = ItemScheduler.orderId(order);
var orderPosition = position(orderId);
// Check if the order is expired
var expiry_date : Date = FA.sql2date(order.expiry_date);
if(expiry_date != null && (now.getTime() > expiry_date.getTime())) classes.push('expired');
+
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>'
,order.hold_until_date
,order.required_date
,order.comment
- ,quantity_box(row_id, order.to_pick, order.quantity, order.quantity > left ? left: order.quantity)
+ ,quantity_box(row_id, order, left)
];
attributes.push('class="'+classes.join(' ')+'"');
}
- function quantity_box(row_id, quantity:Int, maxQuantity:Int, available:Int) {
+ function quantity_box(row_id, order, left:Int) {
+ var maxQuantity = order.quantity;
+ var quantity = order.to_pick;
+ var available = order.quantity > left ? left : order.quantity;
+ var user_pick = parameters == null ? quantity : parameters.to_pick(order);
+ if (user_pick == null) user_pick = 0;
if(maxQuantity > 12) {
- return '<input type="text" name="'+row_id+'[to_pick]" value="'+(quantity == null ? 0 : quantity)+'">';
+ return '<input type="text" name="'+row_id+'[to_pick]" value="'+user_pick+'">';
}
else {
- var inputs : Array<String> = [];
+ var inputs : Array<String> = ['<span class="pickable">'];
for(q in 0...(maxQuantity+1)) {
- var checked = untyped __php__(' $q == $quantity ? "checked" : ""');
+ var last_available = untyped __php__(' $q == $available ? true: false');
+ var current_pick = untyped __php__(' $q == $user_pick ? true:false');
+ var differs = untyped __php__('$user_pick != $quantity');
+ var checked = current_pick ? "checked": "";
var klass : String = q > available ? 'early' : "";
- inputs.push('<input type="radio" name="'+row_id+'[to_pick]" value="'+q+'" '+checked+' class="'+klass+'">'+q+'</input>');
+ inputs.push('<input type="radio" name="'+row_id+'[to_pick]" value="'+q+'" '+checked+' class="'+klass+'">');
+ inputs.push(current_pick && differs ? '<span class="picked">'+q+'</span>' : ''+q);
+ inputs.push('</input>');
+ if(last_available) {
+ inputs.push('</span>');
+ inputs.push('<span class="partial">');
+ }
}
+ inputs.push('</span>');
return inputs.join('');
}
,location.delivery.getTime() == 0 ? '' : location.delivery.format("%F")
,""
,""
+ ,""
];
printRow(cells, ['class = "tableheader location"', 'id = "loc_'+location.code+'"']);
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")), "", ""));
+ $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) {
+ public function quantity_box($row_id, $order, $left) {
+ $maxQuantity = $order->quantity;
+ $quantity = $order->to_pick;
+ $available = ItemScheduler_3($this, $left, $maxQuantity, $order, $quantity, $row_id);
+ $user_pick = (($this->parameters === null) ? $quantity : $this->parameters->to_pick($order));
+ if($user_pick === null) {
+ $user_pick = 0;
+ }
if($maxQuantity > 12) {
- return "<input type=\"text\" name=\"" . $row_id . "[to_pick]\" value=\"" . _hx_string_rec(((($quantity === null) ? 0 : $quantity)), "") . "\">";
+ return "<input type=\"text\" name=\"" . $row_id . "[to_pick]\" value=\"" . _hx_string_rec($user_pick, "") . "\">";
} else {
- $inputs = new _hx_array(array());
+ $inputs = new _hx_array(array("<span class=\"pickable\">"));
{
$_g1 = 0; $_g = $maxQuantity + 1;
while($_g1 < $_g) {
$q = $_g1++;
- $checked = $q == $quantity ? "checked" : "";
+ $last_available = $q == $available ? true: false;
+ $current_pick = $q == $user_pick ? true:false;
+ $differs = $user_pick != $quantity;
+ $checked = (($current_pick) ? "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);
+ $inputs->push("<input type=\"radio\" name=\"" . $row_id . "[to_pick]\" value=\"" . _hx_string_rec($q, "") . "\" " . $checked . " class=\"" . $klass . "\">");
+ $inputs->push(ItemScheduler_4($this, $_g, $_g1, $available, $checked, $current_pick, $differs, $inputs, $klass, $last_available, $left, $maxQuantity, $order, $q, $quantity, $row_id, $user_pick));
+ $inputs->push("</input>");
+ if($last_available) {
+ $inputs->push("</span>");
+ $inputs->push("<span class=\"partial\">");
+ }
+ unset($q,$last_available,$klass,$differs,$current_pick,$checked);
}
}
+ $inputs->push("</span>");
return $inputs->join("");
}
}
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>", $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))));
+ $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, $left)));
$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_4"), 'execute'));
+ $locations->sort(array(new _hx_lambda(array(&$locations, &$startDate), "ItemScheduler_5"), 'execute'));
$locationIter = $locations->iterator();
$location = $locationIter->next();
$qoh = $location->quantityOnHand($this->stock_id, null);
}
$left -= $quantity;
$now = Date::now();
- $this->formatOrder($order, $left, ItemScheduler_5($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate), $now);
+ $this->formatOrder($order, $left, ItemScheduler_6($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate), $now);
unset($quantity,$order,$now);
}
}
return $_g->parameters->priority($a) - $_g->parameters->priority($b);
}
}
-function ItemScheduler_3(&$»this, &$attributes, &$before, &$classes, &$date, &$expiry_date, &$left, &$now, &$order, &$required_by, &$row_id) {
+function ItemScheduler_3(&$»this, &$left, &$maxQuantity, &$order, &$quantity, &$row_id) {
if($order->quantity > $left) {
return $left;
} else {
return $order->quantity;
}
}
-function ItemScheduler_4(&$locations, &$startDate, $a, $b) {
+function ItemScheduler_4(&$»this, &$_g, &$_g1, &$available, &$checked, &$current_pick, &$differs, &$inputs, &$klass, &$last_available, &$left, &$maxQuantity, &$order, &$q, &$quantity, &$row_id, &$user_pick) {
+ if($current_pick && $differs) {
+ return "<span class=\"picked\">" . _hx_string_rec($q, "") . "</span>";
+ } else {
+ return "" . _hx_string_rec($q, "");
+ }
+}
+function ItemScheduler_5(&$locations, &$startDate, $a, $b) {
{
$as = $a->delivery->getTime();
$bs = $b->delivery->getTime();
}
}
}
-function ItemScheduler_5(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) {
+function ItemScheduler_6(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) {
if($now->getTime() > $location->delivery->getTime()) {
return $now;
} else {