X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=haxe%2FItemScheduler.hx;h=ea59cd19bb8d46e50d00748f1174360c5c92eb6a;hb=c430928c8da33931ee2089a2816aacfaa51a5b25;hp=2244eeea5a004832f302eab55e32f2e7e5fb48b8;hpb=c4074de92868561c2f64fc1cb3326d02caa939b6;p=order_line_extra.git diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index 2244eee..ea59cd1 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -45,9 +45,11 @@ class FA { } class ItemScheduler { var stock_id:String; + var startLocation:String; var qoh: Int; - function new(stock_id: String) { + function new(stock_id: String, startLocation) { this.stock_id = stock_id; + this.startLocation = startLocation; qoh = untyped __call__('get_qoh_on_date', this.stock_id, 'DEF'); } @@ -55,7 +57,7 @@ class ItemScheduler { return ["Order", "Customer", "Quantity", "Left", "On Hand", "Loc", "Required Date"]; } - function generateTable(): Void { + function generateTablex(): Void { for(location in locations()) { formatLocation(location); } @@ -64,13 +66,30 @@ class ItemScheduler { } } + function generateTable(): Void { + var schedules = []; + var startDate = Date.fromTime(0); + for(order in orders()) { + var obj = php.Lib.objectOfAssociativeArray(order); + schedules.push({date: Date.fromString(obj.delivery_date), order:order, location:null}); + } + for(location in locations()) { + schedules.push({date: if(location.code == startLocation) startDate else location.delivery, order:null, location:location}); + } + + schedules.sort(function(a,b ) { return cast(a.date.getTime() - b.date.getTime(), Int) ; }); + for(schedule in schedules) { + if(schedule.order != null) formatRow(schedule.order); + if(schedule.location != null) formatLocation(schedule.location); + } + } + function formatRow(row) { var array = php.Lib.hashOfAssociativeArray(row); var quantity_before : Int = array.get('quantity_before'); var quantity_available = qoh - quantity_before; var quantity: Int = array.get('quantity'); - var status : String = if(quantity_available < quantity) 'overduebg'; var cells : Array = [ @@ -98,6 +117,8 @@ class ItemScheduler { var cells = [ location.code ,location.name + ,location.quantityOnHand(stock_id, null) + ,location.delivery ]; var status = 'header'; php.Lib.print(''); @@ -109,12 +130,14 @@ class ItemScheduler { php.Lib.print(''); } +/* function schedules() { //return orders()+locations(); //return orders(); return cast(locations(), Array); } +*/ function orders() { var tb : String = untyped __php__('TB_PREF');