Add Location class.
authorMaxime Bourget <bmx007@gmail.com>
Tue, 28 May 2013 19:34:58 +0000 (20:34 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Tue, 28 May 2013 19:34:58 +0000 (20:34 +0100)
haxe/ItemScheduler.hx
haxe/Location.hx [new file with mode: 0644]

index 1cde71ae226c98667663a11a814a820dcadb7f6e..2244eeea5a004832f302eab55e32f2e7e5fb48b8 100644 (file)
@@ -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('<tr class="'+status+'">');
+               for(cell in cells) {
+                       php.Lib.print('<td>');
+                       php.Lib.print(cell);
+                       php.Lib.print('</td>');
+               }
+               php.Lib.print('</tr>');
+       }
+
        function schedules() {
+               //return orders()+locations();
+               //return  orders();
+               return cast(locations(), Array<Dynamic>);
+
+       }
+
+       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 (file)
index 0000000..198464b
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+enum Either<U,V> {
+       
+};
+*/
+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;
+       }
+}