typedef Order = {
id:String
,quantity:String
+ ,to_pick:String
,priority:Date
,delivery_date:String
var location = locationIter.next();
var qoh : Int = location.quantityOnHand(stock_id, null);
var left = qoh;
- formatLocation(location, "Initial", left);
+
+ // Get the total picked
+ var orders = this.orders();
+ var total_picked = 0;
+ for(order in orders) {
+ var picked : Int = Std.parseInt(order.to_pick);
+ var user_picked : Int = 0;
+ if(parameters != null) user_picked = parameters.to_pick(order);
+ total_picked += user_picked == null ? picked : user_picked;
+ }
+
+ left -= total_picked;
+ formatLocation(location, "Initial", left);
// We display the order ordered by priority
// But insert the location when needed (meaning
// when we run out of item available
- for(order in orders()) {
+
+ for(order in orders) {
var quantity : Int = Std.parseInt(order.quantity);
while(0 >= left && locationIter.hasNext()) {
for(q in 0...(maxQuantity+1)) {
var last_available = untyped __php__(' $q == $available ? true: false');
var current_pick = untyped __php__(' $q == $user_pick ? true:false');
+ var picked = untyped __php__(' $q == $quantity');
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+'">');
- inputs.push(current_pick && differs ? '<span class="picked">'+q+'</span>' : ''+q);
+ inputs.push(picked && differs ? '<span class="picked">'+q+'</span>' : ''+q);
inputs.push('</input>');
if(last_available) {
inputs.push('</span>');
orderList.sort(function(a, b) { return parameters.priority(a)-parameters.priority(b); });
}
- for(order in orderList) {
- }
+ for(order in orderList) {
+ }
return orderList;
}
location.delivery = Date.fromTime(0);
}
else if(location.delivery == null) {
- continue;
+ continue;
}
_locs.push(location);
}
}
- function purcharseOrders() {
- var TB = FA.tb();
- var sql = 'SELECT SUM(quantity_ordered - quantity_received) as quantity
- into_stock_location AS location
- FROM '+TB+'purch_order_details
- NATURAL JOIN '+TB+'purch_orders
- WHERE item_code = "'+this.stock_id+'"
- AND quantity_ordered > quantity_received
- GROUP by item_code,delivery_date, into_stock_location
- ORDER by delivery_date' ;
-
- return FA.query(sql);
- }
+function purcharseOrders() {
+ var TB = FA.tb();
+ var sql = 'SELECT SUM(quantity_ordered - quantity_received) as quantity
+ into_stock_location AS location
+ FROM '+TB+'purch_order_details
+ NATURAL JOIN '+TB+'purch_orders
+ WHERE item_code = "'+this.stock_id+'"
+ AND quantity_ordered > quantity_received
+ GROUP by item_code,delivery_date, into_stock_location
+ ORDER by delivery_date' ;
+
+ return FA.query(sql);
+}
- public function needsUpdate():Bool {
- return parameters != null && parameters.mode == ScheduleMode.Move;
- }
+public function needsUpdate():Bool {
+ return parameters != null && parameters.mode == ScheduleMode.Move;
+}
- function update() {
- var orders = this.orders();
- var priorities = Lambda.array(Lambda.map(orders, function(o) { return o.priority;}));
- priorities.sort(function(a,b) {
+function update() {
+ var orders = this.orders();
+ var priorities = Lambda.array(Lambda.map(orders, function(o) { return o.priority;}));
+ priorities.sort(function(a,b) {
var as = a.toString();
var bs = b.toString();
if (as < bs) return -1;
return 0;
});
- var iter = priorities.iterator();
- var p = iter.next();
- var position:Int = 0-priorities.length;
- for(order in orders) {
- var new_priority = DateTools.delta(p, 1000*position);
- untyped __call__ ('update_order_detail_priority', order.id, new_priority.toString());
-
- position +=1;
- p = iter.next();
- }
- untyped __call__ ('update_queue_quantity_for_item', stock_id);
-
+ var iter = priorities.iterator();
+ var p = iter.next();
+ var position:Int = 0-priorities.length;
+ for(order in orders) {
+ var new_priority = DateTools.delta(p, 1000*position);
+ untyped __call__ ('update_order_detail_priority', order.id, new_priority.toString());
+
+ position +=1;
+ p = iter.next();
}
-
- public function action() {
- if(parameters != null && parameters.mode == ScheduleMode.Update) {
- update();
- }
+ untyped __call__ ('update_queue_quantity_for_item', stock_id);
+
+}
+
+public function action() {
+ if(parameters != null && parameters.mode == ScheduleMode.Update) {
+ update();
}
+}
}
}
public function purcharseOrders() {
$TB = FA::tb();
- $sql = "SELECT SUM(quantity_ordered - quantity_received) as quantity\x0A\x09\x09\x09into_stock_location AS location\x0A\x09\x09\x09FROM " . $TB . "purch_order_details\x0A\x09\x09\x09NATURAL JOIN " . $TB . "purch_orders\x0A\x09\x09\x09WHERE item_code = \"" . $this->stock_id . "\"\x0A\x09\x09\x09AND quantity_ordered > quantity_received\x0A\x09\x09\x09GROUP by item_code,delivery_date, into_stock_location\x0A\x09\x09\x09ORDER by delivery_date";
+ $sql = "SELECT SUM(quantity_ordered - quantity_received) as quantity\x0A\x09\x09into_stock_location AS location\x0A\x09\x09FROM " . $TB . "purch_order_details\x0A\x09\x09NATURAL JOIN " . $TB . "purch_orders\x0A\x09\x09WHERE item_code = \"" . $this->stock_id . "\"\x0A\x09\x09AND quantity_ordered > quantity_received\x0A\x09\x09GROUP by item_code,delivery_date, into_stock_location\x0A\x09\x09ORDER by delivery_date";
return FA::query($sql);
}
public function locations() {
$q = $_g1++;
$last_available = $q == $available ? true: false;
$current_pick = $q == $user_pick ? true:false;
+ $picked = $q == $quantity;
$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 . "\">");
- $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(ItemScheduler_4($this, $_g, $_g1, $available, $checked, $current_pick, $differs, $inputs, $klass, $last_available, $left, $maxQuantity, $order, $picked, $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);
+ unset($q,$picked,$last_available,$klass,$differs,$current_pick,$checked);
}
}
$inputs->push("</span>");
$location = $locationIter->next();
$qoh = $location->quantityOnHand($this->stock_id, null);
$left = $qoh;
+ $orders = $this->orders();
+ $total_picked = 0;
+ {
+ $_g = 0;
+ while($_g < $orders->length) {
+ $order = $orders[$_g];
+ ++$_g;
+ $picked = Std::parseInt($order->to_pick);
+ $user_picked = 0;
+ if($this->parameters !== null) {
+ $user_picked = $this->parameters->to_pick($order);
+ }
+ $total_picked += (($user_picked === null) ? $picked : $user_picked);
+ unset($user_picked,$picked,$order);
+ }
+ }
+ $left -= $total_picked;
$this->formatLocation($location, "Initial", $left);
{
- $_g = 0; $_g1 = $this->orders();
- while($_g < $_g1->length) {
- $order = $_g1[$_g];
+ $_g = 0;
+ while($_g < $orders->length) {
+ $order = $orders[$_g];
++$_g;
$quantity = Std::parseInt($order->quantity);
while(0 >= $left && $locationIter->hasNext()) {
}
$left -= $quantity;
$now = Date::now();
- $this->formatOrder($order, $left, ItemScheduler_6($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate), $now);
+ $this->formatOrder($order, $left, ItemScheduler_6($this, $_g, $left, $location, $locationIter, $locations, $now, $order, $orders, $qoh, $quantity, $startDate, $total_picked), $now);
unset($quantity,$order,$now);
}
}
return $order->quantity;
}
}
-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) {
+function ItemScheduler_4(&$»this, &$_g, &$_g1, &$available, &$checked, &$current_pick, &$differs, &$inputs, &$klass, &$last_available, &$left, &$maxQuantity, &$order, &$picked, &$q, &$quantity, &$row_id, &$user_pick) {
+ if($picked && $differs) {
return "<span class=\"picked\">" . _hx_string_rec($q, "") . "</span>";
} else {
return "" . _hx_string_rec($q, "");
}
}
}
-function ItemScheduler_6(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) {
+function ItemScheduler_6(&$»this, &$_g, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$orders, &$qoh, &$quantity, &$startDate, &$total_picked) {
if($now->getTime() > $location->delivery->getTime()) {
return $now;
} else {