log = mfLoghandler::singleton(); $this->data = new stdClass(); $this->table = "customer_crediting"; $this->db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME); if(is_numeric($_)) { $this->fetch($_); } elseif(is_object($_)) { $this->load($_); } } public function save() { return true; } private function getCustomerId() { $customer_id = false; $m = []; if(preg_match('/(\d+)\s*$/', $this->comment, $m)) { $customer_id = $m[1]; } if(!$customer_id) { $this->log->warn(__METHOD__.": Cannot extract customer id from comment"); } return $customer_id; } public function getProperty($name) { if($this->$name == null) { if($name == "crediting_product") { $cred_prod = new IvtCreditingProduct($this->cred_id); if($cred_prod->id) { $this->crediting_product = $cred_prod; } return $this->crediting_product; } if($name == "netowner") { $netowner = new IvtCustomer($this->cust_id); if($netowner->id) { $this->netowner = $netowner; } return $this->netowner; } if($name == "customer") { $customer_id = $this->getCustomerId(); $customer = new IvtCustomer($customer_id); if($customer->id) { $this->customer = $customer; } return $this->customer; } $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield); if(!$this->$name) { $this->$name = new $classname($this->$idfield); } if($this->$name->id) { mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name); return $this->$name; } else { return null; } } return $this->$name; } public function __debugInfo() { $vars = get_object_vars($this); if(is_object($vars['db'])) $vars['db'] = "object(FronkDB)"; if(is_object($vars['log'])) $vars['log'] = 'object(mfLoghandler)'; return $vars; } }