X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=haxe%2FItemScheduler.hx;h=06b0b9c0fe13810bdc3f37b35c686dccfad322cb;hb=94b18430b11353c6cf14e28fd3062d49007506bc;hp=5cb2682eeb8757948bad4f4bbcc52b9e1c7047fb;hpb=32c1762ad84bf66d4b57041fcf53c53f0e37ee2c;p=order_line_extra.git diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index 5cb2682..06b0b9c 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -8,30 +8,32 @@ typedef Detail = { class ScheduleParameters { var row_id : String; - var row_ids : Array; var rowDetails: Hash; + function new(rawData : Dynamic) { - var data = php.Lib.objectOfAssociativeArray(rawData); - row_id = data.row_id; - row_ids = data.row_ids; - - rowDetails = new Hash(); - $type(rowDetails); - - var position = 1; - for(id in row_ids) { - rowDetails.set(id, { - id: id - ,quantity: null - ,position: position++ - }); + var data = php.Lib.hashOfAssociativeArray(rawData); + row_id = data.get('row_id'); + var raw_order : Dynamic = data.get('row_order'); + + var row_ids = php.Lib.toHaxeArray(raw_order); + if (row_ids!= null) { + rowDetails = new Hash(); + var position = 1; + for(id in row_ids) { + rowDetails.set(id, { + id: id + ,quantity: null + ,position: position++ + }); + } } + php.Lib.dump(rowDetails); } - public function position(id: String) : Int { - return rowDetails.get(id).position; - - } +public function position(id: String) : Int { + return rowDetails == null ? rowDetails.get(id).position : null; + +} } @@ -39,7 +41,7 @@ class ItemScheduler { var stock_id:String; var startLocation:String; var qoh: Int; - function new(stock_id: String, startLocation) { + function new(stock_id: String, startLocation, parameters : Null) { this.stock_id = stock_id; this.startLocation = startLocation; qoh = untyped __call__('get_qoh_on_date', this.stock_id, 'DEF'); @@ -50,11 +52,11 @@ class ItemScheduler { } function generateTable(): Void { - var startDate = Date.fromTime(0); + var startDate = Date.fromTime(0); - // Sort location by datae - var locations = this.locations(); - locations.sort(function(a, b) { + // Sort location by datae + var locations = this.locations(); + locations.sort(function(a, b) { return cast(a.delivery.getTime() - b.delivery.getTime(), Int ); }); @@ -81,9 +83,9 @@ class ItemScheduler { left -= quantity; formatOrder(order, left, location.delivery); - + } - + } function printRow(tds : Array, attributes : Array) { @@ -99,28 +101,28 @@ class ItemScheduler { } function formatOrder(order : Dynamic, left : Int, date : Date) { - var row_id = 'order_'+order.id; - var attributes = ['id = "'+row_id+'"']; - var classes = []; - var before : Int = left + order.quantity; - /* We have basically 3 different cases; - * - the order can be fullfilled - * - the order can be partially - * - not at all - */ - if (before < 0 ) { - classes.push('soldout'); - } - else if(left < 0) { - classes.push('partial'); - } - else { - classes.push('full'); - } + var row_id = 'order_'+order.id; + var attributes = ['id = "'+row_id+'"']; + var classes = []; + var before : Int = left + order.quantity; + /* We have basically 3 different cases; + * - the order can be fullfilled + * - the order can be partially + * - not at all + */ + if (before < 0 ) { + classes.push('soldout'); + } + else if(left < 0) { + classes.push('partial'); + } + else { + classes.push('full'); + } - /* The order can also be late if we need - * to wait for a delivery to get it - */ + /* The order can also be late if we need + * to wait for a delivery to get it + */ var required_by : Date = FA.sql2date(order.required_date); if(required_by == null) required_by = FA.sql2date(order.delivery_date); if(required_by.getTime() < date.getTime()) { @@ -129,20 +131,20 @@ class ItemScheduler { else { classes.push('on_time'); } - var cells : Array = [ - order.order_id - , ''+order.deliver_to+'' + var cells : Array = [ + order.order_id + , ''+order.deliver_to+'' ,'' - ,before - ,left - ,order.from_stk_loc - ,order.delivery_date - ,order.required_date - ,order.comment + ,before + ,left + ,order.from_stk_loc + ,order.delivery_date + ,order.required_date + ,order.comment ]; - attributes.push('class="'+classes.join(' ')+'"'); - printRow(cells, attributes); + attributes.push('class="'+classes.join(' ')+'"'); + printRow(cells, attributes); } @@ -157,67 +159,67 @@ class ItemScheduler { ,location.delivery ,"" ,"" - ]; + ]; printRow(cells, ['class = "tableheader location"', 'id = "loc_'+location.code+'"']); } -/* - function schedules() { - //return orders()+locations(); - //return orders(); - return cast(locations(), Array); + /* + function schedules() { +//return orders()+locations(); +//return orders(); +return cast(locations(), Array); - } -*/ - - private function loadOrders() { - var tb : String = untyped __php__('TB_PREF'); - var sql : String = "SELECT * - FROM "+tb+"denorm_order_details_queue d - JOIN "+tb+"sales_order_details od ON (od.id = d.id) - 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 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; - } +} + */ + +private function loadOrders() { + var tb : String = untyped __php__('TB_PREF'); + var sql : String = "SELECT * + FROM "+tb+"denorm_order_details_queue d + JOIN "+tb+"sales_order_details od ON (od.id = d.id) + 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 d.priority"; + + return FA.query(sql); +} - - - function locations() { - var TB = FA.tb(); - var sql = 'SELECT * - FROM '+TB+'locations'; - var _locs = []; - for(row in FA.query(sql)) { - var location = new Location(row); - if(location.code == startLocation) { - location.delivery = Date.fromTime(0); - } - _locs.push(location); - } +function orders() { + var rows = loadOrders(); + var orderList = []; + for(row in rows) { + var order = php.Lib.objectOfAssociativeArray(row); + orderList.push(order); + }; - return _locs; - - } + return orderList; +} - function purcharseOrders() { + +function locations() { + var TB = FA.tb(); + var sql = 'SELECT * + FROM '+TB+'locations'; + var _locs = []; + for(row in FA.query(sql)) { + var location = new Location(row); + if(location.code == startLocation) { + location.delivery = Date.fromTime(0); + } + _locs.push(location); } + return _locs; + +} + + +function purcharseOrders() { +} + }