BulkUpdater work.
[order_line_extra.git] / hincludes / lib / ScheduleParameters.class.php
1 <?php
2
3 class ScheduleParameters {
4         public function __construct($rawData) {
5                 if(!php_Boot::$skip_constructor) {
6                 $data = php_Lib::hashOfAssociativeArray($rawData);
7                 $this->row_id = $data->get("row_id");
8                 $raw_order = $data->get("row_order");
9                 $this->mode = ScheduleMode::$Move;
10                 $row_ids = new _hx_array($raw_order);
11                 if($row_ids !== null) {
12                         $this->rowDetails = new Hash();
13                         $position = 1;
14                         {
15                                 $_g = 0;
16                                 while($_g < $row_ids->length) {
17                                         $id = $row_ids[$_g];
18                                         ++$_g;
19                                         $d = $data->get($id);
20                                         $quantity = null;
21                                         if($d !== null) {
22                                                 $o = php_Lib::objectOfAssociativeArray($d);
23                                                 $quantity = Std::parseInt($o->quantity);
24                                                 unset($o);
25                                         }
26                                         $this->rowDetails->set($id, _hx_anonymous(array("id" => $id, "quantity" => $quantity, "position" => $position)));
27                                         $position += 1;
28                                         unset($quantity,$id,$d);
29                                 }
30                         }
31                 }
32         }}
33         public function priority($order) {
34                 $orderId = ItemScheduler::orderId($order);
35                 $orderPosition = $this->position($orderId);
36                 return (($orderPosition !== null) ? $orderPosition : $order->priority->getTime());
37         }
38         public function position($id) {
39                 if($this->rowDetails === null) {
40                         return null;
41                 }
42                 return $this->rowDetails->get($id)->position;
43         }
44         public function setMode($action) {
45                 $this->mode = ScheduleParameters_0($this, $action);
46         }
47         public $mode;
48         public $rowDetails;
49         public $row_id;
50         public function __call($m, $a) {
51                 if(isset($this->$m) && is_callable($this->$m))
52                         return call_user_func_array($this->$m, $a);
53                 else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
54                         return call_user_func_array($this->»dynamics[$m], $a);
55                 else if('toString' == $m)
56                         return $this->__toString();
57                 else
58                         throw new HException('Unable to call «'.$m.'»');
59         }
60         function __toString() { return 'ScheduleParameters'; }
61 }
62 function ScheduleParameters_0(&$»this, &$action) {
63         switch($action) {
64         case "update":{
65                 return ScheduleMode::$Update;
66         }break;
67         case "cancel":{
68                 return ScheduleMode::$Cancel;
69         }break;
70         default:{
71                 return ScheduleMode::$Move;
72         }break;
73         }
74 }