Add header
authorMaxime Bourget <bmx007@gmail.com>
Mon, 27 May 2013 21:09:27 +0000 (22:09 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 27 May 2013 21:09:27 +0000 (22:09 +0100)
haxe/ItemScheduler.hx

index 8efb21ad10b27cbcc4a90ce34114f206ba22c416..1cde71ae226c98667663a11a814a820dcadb7f6e 100644 (file)
@@ -41,12 +41,14 @@ class FA {
 }
 class ItemScheduler {
        var stock_id:String;
+       var qoh: Int;
        function new(stock_id: String) {
                this.stock_id = stock_id;
+               qoh =  untyped __call__('get_qoh_on_date', this.stock_id, 'DEF');
        }
 
        function tableHeader() {
-               return ["A", "B", "C"];
+               return ["Order", "Customer", "Quantity", "Left", "On Hand", "Loc", "Required Date"];
        }
 
        function generateTable(): Void {
@@ -57,7 +59,31 @@ class ItemScheduler {
 
        function formatRow(row) {
                var array = php.Lib.hashOfAssociativeArray(row);
-               php.Lib.print('<tr><td>'+array.get('stock_id')+'</td></tr>');
+               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<Dynamic> = [
+                       array.get('order_id')
+                       ,array.get('deliver_to')
+                       ,quantity
+                       ,quantity_available-quantity
+                       ,quantity_available
+                       ,array.get('from_stk_loc')
+                       ,array.get('delivery_date')
+               ];
+
+               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>');
+               
                
        }
 
@@ -66,7 +92,9 @@ class ItemScheduler {
                var sql : String = "SELECT *  
                                                FROM "+tb+"denorm_order_details_queue 
                                                JOIN  "+tb+"sales_orders ON (order_no = order_id)
-                                               WHERE stock_id = '"+this.stock_id+"'";
+                                               WHERE stock_id = '"+this.stock_id+"'
+                                               ORDER by quantity_before";
+       
                return FA.query(sql);
        }
 }