Extract misc classes into relevant files.
authorMaxime Bourget <bmx007@gmail.com>
Sat, 1 Jun 2013 11:14:14 +0000 (12:14 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sat, 1 Jun 2013 11:15:48 +0000 (12:15 +0100)
haxe/FA.hx [new file with mode: 0644]
haxe/ItemScheduler.hx
haxe/QueryIterator.hx [new file with mode: 0644]

diff --git a/haxe/FA.hx b/haxe/FA.hx
new file mode 100644 (file)
index 0000000..1de6e1c
--- /dev/null
@@ -0,0 +1,14 @@
+class FA {
+       static public function query(sql: String) {
+               var result = untyped __call__('db_query', sql, sql);
+               return new QueryIterator(result);
+       }
+
+       static public function tb() : String {
+               return untyped __php__('TB_PREF');
+       }
+
+       static public function sql2date(sqlDate:Dynamic) : Null<Date> {
+               return sqlDate == null ? null : Date.fromString(sqlDate);
+       }
+}
index be596ac4d121b87f0f547ed3e59984c3c4dbf2fd..e5b539686da010f9e6baa73732cba0cfa2889e5e 100644 (file)
@@ -1,52 +1,5 @@
 import php.Lib;
 
-enum Maybe<T> {
-       Nothing;
-       Just(v : T);
-}
-
-class QueryIterator<T> {
-       var result : Dynamic;
-       var nextValue : Maybe<T>;
-       public function new(result) {
-               this.result= result;
-               /* We fetch the first row , so we can answer hasNext */
-               fetch();
-       }
-
-       private function fetch() {
-               var next : Dynamic = untyped __call__('db_fetch', this.result);
-               nextValue = if(next) Just(next) else Nothing;
-       }
-
-       public function  hasNext() : Bool {
-               return this.nextValue != Nothing;
-       }
-
-       public function next() : T {
-               switch(this.nextValue) {
-               case Nothing : throw 'Iterator exhausted';
-               case Just(v) :  {
-                       this.fetch();
-                       return v;
-               };
-               }
-       }
-}
-class FA {
-       static public function query(sql: String) {
-               var result = untyped __call__('db_query', sql, sql);
-               return new QueryIterator(result);
-       }
-
-       static public function tb() : String {
-               return untyped __php__('TB_PREF');
-       }
-
-       static public function sql2date(sqlDate:Dynamic) : Null<Date> {
-               return sqlDate == null ? null : Date.fromString(sqlDate);
-       }
-}
 class ItemScheduler {
        var stock_id:String;
        var startLocation:String;
@@ -61,17 +14,6 @@ class ItemScheduler {
                return ["Order", "Customer", "Quantity", "Before", "After", "Loc", "From",  "Required Date", "Comment"];
        }
 
-/*
-       function generateTablex(): Void {
-               for(location in locations()) {
-                       formatLocation(location, null);
-               }
-               for(order in this.orders()) {
-                       this.formatRow(order);
-               }
-       }
-*/
-
        function generateTable(): Void {
                        var startDate = Date.fromTime(0);
                        for(order in orders()) {
@@ -174,35 +116,6 @@ class ItemScheduler {
 
        }
 
-       function formatRow(row) {
-               var array = php.Lib.hashOfAssociativeArray(row);
-               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')
-                       ,'<input type="text" name="quantity">'+quantity+'</input>'
-                       ,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>');
-               
-               
-       }
-
        function formatLocation(location : Location, type: String,  left : Int) {
                var cells = [
                        type
diff --git a/haxe/QueryIterator.hx b/haxe/QueryIterator.hx
new file mode 100644 (file)
index 0000000..5eec9aa
--- /dev/null
@@ -0,0 +1,33 @@
+enum Maybe<T> {
+       Nothing;
+       Just(v : T);
+}
+
+class QueryIterator<T> {
+       var result : Dynamic;
+       var nextValue : Maybe<T>;
+       public function new(result) {
+               this.result= result;
+               /* We fetch the first row , so we can answer hasNext */
+               fetch();
+       }
+
+       private function fetch() {
+               var next : Dynamic = untyped __call__('db_fetch', this.result);
+               nextValue = if(next) Just(next) else Nothing;
+       }
+
+       public function  hasNext() : Bool {
+               return this.nextValue != Nothing;
+       }
+
+       public function next() : T {
+               switch(this.nextValue) {
+               case Nothing : throw 'Iterator exhausted';
+               case Just(v) :  {
+                       this.fetch();
+                       return v;
+               };
+               }
+       }
+}