4 public function __construct($row) {
5 if(!php_Boot::$skip_constructor) {
6 $obj = php_Lib::objectOfAssociativeArray($row);
7 $this->code = $obj->loc_code;
8 $this->name = $obj->location_name;
9 $this->comment = $obj->delivery_address;
10 $config_date = OrderXtraConfig::delivery($this->code);
11 $this->delivery = (($config_date !== null) ? Date::fromString($config_date) : null);
13 public function quantityOnHand($stock_id, $date) {
14 if($this->qoh_cache === null || $stock_id !== $this->stock_id_cache) {
15 $this->qoh_cache = get_qoh_on_date($stock_id, $this->code, $date);
16 $this->stock_id_cache = $stock_id;
18 return $this->qoh_cache;
20 public function quantityOnOrder($stock_id) {
22 $sql = "SELECT SUM(quantity_ordered - quantity_received) as quantity\x0A\x09\x09\x09FROM " . $TB . "purch_order_details\x0A\x09\x09\x09NATURAL JOIN " . $TB . "purch_orders\x0A\x09\x09\x09WHERE item_code = \"" . $stock_id . "\" AND into_stock_location = \"" . $this->code . "\"\x0A\x09\x09\x09AND quantity_ordered > quantity_received\x0A\x09\x09\x09ORDER by delivery_date";
23 $result = FA::query($sql);
24 if($result->hasNext()) {
25 $row = php_Lib::objectOfAssociativeArray($result->next());
26 return $row->quantity;
31 public $stock_id_cache;
37 public function __call($m, $a) {
38 if(isset($this->$m) && is_callable($this->$m))
39 return call_user_func_array($this->$m, $a);
40 else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
41 return call_user_func_array($this->»dynamics[$m], $a);
42 else if('toString' == $m)
43 return $this->__toString();
45 throw new HException('Unable to call «'.$m.'»');
47 function __toString() { return 'Location'; }