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;
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()) {
}
- 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
--- /dev/null
+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;
+ };
+ }
+ }
+}