From: Maxime Bourget Date: Fri, 14 Jun 2013 14:54:24 +0000 (+0100) Subject: ADd user to pick field. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c97b64d6af749a17d7691d2c8868fb75bfe6894e;p=order_line_extra.git ADd user to pick field. --- diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index ffb8959..0e00bf6 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -3,7 +3,7 @@ using DateTools; typedef Detail = { id : String, - quantity : Int, + to_pick : Int, position : Int, } @@ -39,16 +39,16 @@ class ScheduleParameters { 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; @@ -73,6 +73,13 @@ class ScheduleParameters { } + public function to_pick(order: {id:String}) : Null { + 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); @@ -210,6 +217,7 @@ class ItemScheduler { // 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 = [ order.order_id , ''+order.deliver_to+'' @@ -220,7 +228,7 @@ class ItemScheduler { ,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(' ')+'"'); @@ -228,17 +236,32 @@ class ItemScheduler { } - 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 ''; + return ''; } else { - var inputs : Array = []; + var inputs : Array = ['']; 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(''+q+''); + inputs.push(''); + inputs.push(current_pick && differs ? ''+q+'' : ''+q); + inputs.push(''); + if(last_available) { + inputs.push(''); + inputs.push(''); + } } + inputs.push(''); return inputs.join(''); } @@ -255,6 +278,7 @@ class ItemScheduler { ,location.delivery.getTime() == 0 ? '' : location.delivery.format("%F") ,"" ,"" + ,"" ]; printRow(cells, ['class = "tableheader location"', 'id = "loc_'+location.code+'"']); diff --git a/hincludes/lib/ItemScheduler.class.php b/hincludes/lib/ItemScheduler.class.php index 6cc36d7..5989280 100644 --- a/hincludes/lib/ItemScheduler.class.php +++ b/hincludes/lib/ItemScheduler.class.php @@ -96,24 +96,41 @@ class ItemScheduler { 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 ""; + return ""; } else { - $inputs = new _hx_array(array()); + $inputs = new _hx_array(array("")); { $_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("" . _hx_string_rec($q, "") . ""); - unset($q,$klass,$checked); + $inputs->push(""); + $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(""); + if($last_available) { + $inputs->push(""); + $inputs->push(""); + } + unset($q,$last_available,$klass,$differs,$current_pick,$checked); } } + $inputs->push(""); return $inputs->join(""); } } @@ -152,7 +169,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) . "", $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, "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, $left))); $attributes->push("class=\"" . $classes->join(" ") . "\""); $this->printRow($cells, $attributes); } @@ -178,7 +195,7 @@ class ItemScheduler { 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); @@ -202,7 +219,7 @@ class ItemScheduler { } $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); } } @@ -262,14 +279,21 @@ function ItemScheduler_2(&$_g, &$orderList, &$rows, $a, $b) { 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 "" . _hx_string_rec($q, "") . ""; + } else { + return "" . _hx_string_rec($q, ""); + } +} +function ItemScheduler_5(&$locations, &$startDate, $a, $b) { { $as = $a->delivery->getTime(); $bs = $b->delivery->getTime(); @@ -284,7 +308,7 @@ function ItemScheduler_4(&$locations, &$startDate, $a, $b) { } } } -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 { diff --git a/hincludes/lib/ScheduleParameters.class.php b/hincludes/lib/ScheduleParameters.class.php index a44b89b..29f8f7f 100644 --- a/hincludes/lib/ScheduleParameters.class.php +++ b/hincludes/lib/ScheduleParameters.class.php @@ -17,15 +17,15 @@ class ScheduleParameters { $id = $row_ids[$_g]; ++$_g; $d = $data->get($id); - $quantity = null; + $to_pick = null; if($d !== null) { $o = php_Lib::objectOfAssociativeArray($d); - $quantity = Std::parseInt($o->quantity); + $to_pick = Std::parseInt($o->to_pick); unset($o); } - $this->rowDetails->set($id, _hx_anonymous(array("id" => $id, "quantity" => $quantity, "position" => $position))); + $this->rowDetails->set($id, _hx_anonymous(array("id" => $id, "to_pick" => $to_pick, "position" => $position))); $position += 1; - unset($quantity,$id,$d); + unset($to_pick,$id,$d); } } } @@ -35,6 +35,13 @@ class ScheduleParameters { $orderPosition = $this->position($orderId); return (($orderPosition !== null) ? $orderPosition : $order->priority->getTime()); } + public function to_pick($order) { + $orderId = ItemScheduler::orderId($order); + if($this->rowDetails === null) { + return null; + } + return $this->rowDetails->get($orderId)->to_pick; + } public function position($id) { if($this->rowDetails === null) { return null; diff --git a/item_schedule.php b/item_schedule.php index 39c8de5..9ce95fc 100644 --- a/item_schedule.php +++ b/item_schedule.php @@ -144,6 +144,18 @@ tr.tDnD_whileDrag :nth-child(4), tr.tDnD_whileDrag :nth-child(5) { color: transparent; background: transparent; } + +span.picked { + color: darkred; + font-weight: bold; +} + +tr.partial span.pickable { + background: #cfc; +} +span.partial { + background: transparent; +}