From a73cdbbda185c9a43ef3870f5ab95d3e861b9f87 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Tue, 4 Jun 2013 18:46:30 +0100 Subject: [PATCH] Add OrderXtraConfig to configure location. --- haxe/ItemScheduler.hx | 18 ++++++++++++++---- haxe/Location.hx | 3 ++- includes/order_xtra_config.inc | 20 ++++++++++++++++++++ item_schedule.php | 3 ++- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 includes/order_xtra_config.inc diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index ab4e9ac..6da4043 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -1,4 +1,5 @@ import php.Lib; +using DateTools; typedef Detail = { id : String, @@ -89,7 +90,7 @@ class ItemScheduler { this.stock_id = stock_id; this.startLocation = startLocation; this.parameters = parameters; - qoh = untyped __call__('get_qoh_on_date', this.stock_id, 'DEF'); + qoh = untyped __call__('get_qoh_on_date', this.stock_id, startLocation); } function tableHeader() { @@ -102,7 +103,13 @@ class ItemScheduler { // Sort location by date var locations = this.locations(); locations.sort(function(a, b) { - return cast(a.delivery.getTime() - b.delivery.getTime(), Int ); + var as = a.delivery.getTime(); + var bs = b.delivery.getTime(); + if(as < bs) + return -1; + else if(as > bs) + return 1; + else return 0; }); // Get the start location, it should be the first one @@ -121,7 +128,7 @@ class ItemScheduler { while(0 >= left && locationIter.hasNext()) { location = locationIter.next(); var quantityForLocation : Int = location.quantityOnHand(stock_id, null); - if(quantityForLocation == null || quantityForLocation == 0) continue; + if(quantityForLocation == null || quantityForLocation == 0 || location.delivery == null) continue; left += quantityForLocation; formatLocation(location, "Delivery", left); } @@ -213,7 +220,7 @@ class ItemScheduler { ,left-location.quantityOnHand(stock_id, null) ,left ,location.code - ,location.delivery + ,location.delivery.getTime() == 0 ? '' : location.delivery.format("%F") ,"" ,"" ]; @@ -278,6 +285,9 @@ function locations() { if(location.code == startLocation) { location.delivery = Date.fromTime(0); } + else if(location.delivery == null) { + continue; + } _locs.push(location); } diff --git a/haxe/Location.hx b/haxe/Location.hx index b5a529d..50f2807 100644 --- a/haxe/Location.hx +++ b/haxe/Location.hx @@ -17,7 +17,8 @@ class Location { code = obj.loc_code; name = obj.location_name; comment = obj.delivery_address; - delivery = Date.fromString("2013-06-10"); + var config_date = untyped __call__('OrderXtraConfig::delivery', code); + delivery = config_date != null ? Date.fromString(config_date) : null; } public function quantityOnHand(stock_id, date) : Null { diff --git a/includes/order_xtra_config.inc b/includes/order_xtra_config.inc new file mode 100644 index 0000000..6ef484b --- /dev/null +++ b/includes/order_xtra_config.inc @@ -0,0 +1,20 @@ + { delivery, parent } + // Location not listed are excluded + static $locations= array(); + + static function delivery($location) { + if(isset(self::$locations[$location])) { + $parameters = self::$locations[$location]; + return @$parameters['delivery']; + } + else { + return null; + } + } +} +?> diff --git a/item_schedule.php b/item_schedule.php index 1937108..5e47ec5 100644 --- a/item_schedule.php +++ b/item_schedule.php @@ -20,6 +20,7 @@ include_once($path_to_root . "/reporting/includes/reporting.inc"); //include_once("includes/item_scheduler.inc"); include_once("hincludes/lib/php/Boot.class.php"); include_once("includes/db_order_lines.inc"); +include_once("config.php"); $page_security = 'SA_ORDERLINEX_EDIT'; add_access_extensions(); @@ -77,7 +78,7 @@ else { // save parameters form update $_SESSION['schedule_parameters'] = $_POST; } -$scheduler = new ItemScheduler($stock_id, 'DEF', $params); +$scheduler = new ItemScheduler($stock_id, OrderXtraConfig::$default_location, $params); $scheduler->action(); start_table(TABLESTYLE); -- 2.30.2