BulkUpdater work.
[order_line_extra.git] / hincludes / lib / ItemScheduler.class.php
index e2d29ebb4a9247af499e8f3e3253da5231437b80..6527ff375a7fec72a75f4ae6543a06a4960e83a2 100644 (file)
@@ -115,14 +115,24 @@ class ItemScheduler {
                }
                $required_by = FA::sql2date($order->required_date);
                if($required_by === null) {
-                       $required_by = FA::sql2date($order->delivery_date);
+                       $required_by = FA::sql2date($order->expiry_date);
                }
-               if($required_by->getTime() < $date->getTime()) {
+               if($required_by !== null && $required_by->getTime() < $date->getTime()) {
                        $classes->push("late");
                } else {
-                       $classes->push("on_time");
+                       $hold_until = FA::sql2date($order->hold_until_date);
+                       php_Lib::hprint($hold_until);
+                       php_Lib::hprint($date);
+                       if($hold_until === null) {
+                               $hold_until = FA::sql2date($order->delivery_date);
+                       }
+                       if($hold_until->getTime() > $date->getTime()) {
+                               $classes->push("early");
+                       } else {
+                               $classes->push("on_time");
+                       }
                }
-               $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->delivery_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>", "<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));
                $attributes->push("class=\"" . $classes->join(" ") . "\"");
                $this->printRow($cells, $attributes);
        }
@@ -171,8 +181,9 @@ class ItemScheduler {
                                        unset($quantityForLocation);
                                }
                                $left -= $quantity;
-                               $this->formatOrder($order, $left, $location->delivery);
-                               unset($quantity,$order);
+                               $now = Date::now();
+                               $this->formatOrder($order, $left, ItemScheduler_4($this, $_g, $_g1, $left, $location, $locationIter, $locations, $now, $order, $qoh, $quantity, $startDate));
+                               unset($quantity,$order,$now);
                        }
                }
                while(0 >= $left && $locationIter->hasNext()) {
@@ -246,3 +257,10 @@ function ItemScheduler_3(&$locations, &$startDate, $a, $b) {
                }
        }
 }
+function ItemScheduler_4(&$»this, &$_g, &$_g1, &$left, &$location, &$locationIter, &$locations, &$now, &$order, &$qoh, &$quantity, &$startDate) {
+       if($now->getTime() > $location->delivery->getTime()) {
+               return $now;
+       } else {
+               return $location->delivery;
+       }
+}