import php.Lib;
+using DateTools;
typedef Detail = {
id : String,
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() {
// 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
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);
}
,left-location.quantityOnHand(stock_id, null)
,left
,location.code
- ,location.delivery
+ ,location.delivery.getTime() == 0 ? '' : location.delivery.format("%F")
,""
,""
];
if(location.code == startLocation) {
location.delivery = Date.fromTime(0);
}
+ else if(location.delivery == null) {
+ continue;
+ }
_locs.push(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<Int> {
--- /dev/null
+<?php
+class OrderXtraConfig {
+ // Location code of the default or main location
+ static $default_location = "";
+
+ // Array location => { 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;
+ }
+ }
+}
+?>
//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();
// 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);