From: Maxime Bourget Date: Sat, 1 Jun 2013 14:08:21 +0000 (+0100) Subject: Refactoring orders() X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=255ac317e56e14b812446e7e84e49876e3b6192b;p=order_line_extra.git Refactoring orders() --- diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index e5b5396..f8bfc0a 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -16,10 +16,6 @@ class ItemScheduler { function generateTable(): Void { var startDate = Date.fromTime(0); - for(order in orders()) { - var obj = php.Lib.objectOfAssociativeArray(order); - - } // Sort location by datae var locations = this.locations(); @@ -37,8 +33,7 @@ class ItemScheduler { // We display the order ordered by priority // But insert the location when needed (meaning // when we run out of item available - for(orderRow in orders()) { - var order = php.Lib.objectOfAssociativeArray(orderRow); + for(order in orders()) { var quantity : Int = Std.parseInt(order.quantity); while(0 > left && locationIter.hasNext()) { @@ -141,7 +136,7 @@ class ItemScheduler { } */ - function orders() { + private function loadOrders() { var tb : String = untyped __php__('TB_PREF'); var sql : String = "SELECT * FROM "+tb+"denorm_order_details_queue d @@ -149,10 +144,23 @@ class ItemScheduler { JOIN "+tb+"sales_orders so ON (so.order_no = d.order_id) WHERE stock_id = '"+this.stock_id+"' AND od.trans_type = 30 - ORDER by quantity_before"; + ORDER by d.priority"; return FA.query(sql); } + + function orders() { + var rows = loadOrders(); + var orderList = []; + for(row in rows) { + var order = php.Lib.objectOfAssociativeArray(row); + orderList.push(order); + }; + + return orderList; + } + + function locations() { var TB = FA.tb();