From c4074de92868561c2f64fc1cb3326d02caa939b6 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Tue, 28 May 2013 20:34:58 +0100 Subject: [PATCH] Add Location class. --- haxe/ItemScheduler.hx | 51 +++++++++++++++++++++++++++++++++++++++++-- haxe/Location.hx | 17 +++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 haxe/Location.hx diff --git a/haxe/ItemScheduler.hx b/haxe/ItemScheduler.hx index 1cde71a..2244eee 100644 --- a/haxe/ItemScheduler.hx +++ b/haxe/ItemScheduler.hx @@ -38,6 +38,10 @@ class FA { var result = untyped __call__('db_query', sql, sql); return new QueryIterator(result); } + + static public function tb() : String { + return untyped __php__('TB_PREF'); + } } class ItemScheduler { var stock_id:String; @@ -52,8 +56,11 @@ class ItemScheduler { } function generateTable(): Void { - for(schedule in this.schedules()) { - this.formatRow(schedule); + for(location in locations()) { + formatLocation(location); + } + for(order in this.orders()) { + this.formatRow(order); } } @@ -87,7 +94,29 @@ class ItemScheduler { } + function formatLocation(location : Location) { + var cells = [ + location.code + ,location.name + ]; + var status = 'header'; + php.Lib.print(''); + for(cell in cells) { + php.Lib.print(''); + php.Lib.print(cell); + php.Lib.print(''); + } + php.Lib.print(''); + } + function schedules() { + //return orders()+locations(); + //return orders(); + return cast(locations(), Array); + + } + + function orders() { var tb : String = untyped __php__('TB_PREF'); var sql : String = "SELECT * FROM "+tb+"denorm_order_details_queue @@ -97,6 +126,24 @@ class ItemScheduler { return FA.query(sql); } + + function locations() { + var TB = FA.tb(); + var sql = 'SELECT * + FROM '+TB+'locations'; + var _locs = []; + for(row in FA.query(sql)) { + _locs.push(new Location(row)); + } + + return _locs; + + } + + + function purcharseOrders() { + } + } diff --git a/haxe/Location.hx b/haxe/Location.hx new file mode 100644 index 0000000..198464b --- /dev/null +++ b/haxe/Location.hx @@ -0,0 +1,17 @@ +/* +enum Either { + +}; +*/ +class Location { + public var code : String; + public var name : String; + public var comment : String; + + public function new(row : Dynamic) { + var obj = php.Lib.objectOfAssociativeArray(row); + code = obj.loc_code; + name = obj.location_name; + comment = obj.delivery_address; + } +} -- 2.30.2