Files
thetool/application/IvtCreditingProduct/IvtCreditingProduct.php
2024-01-09 16:30:38 +01:00

74 lines
1.8 KiB
PHP

<?php
class IvtCreditingProduct extends mfBaseModel {
protected $forcestr = [];
/**
* Takes ID or DB row as arguments
* @param id or table row $_
*/
public function __construct($_=NULL) {
$this->log = mfLoghandler::singleton();
$this->data = new stdClass();
$this->table = "crediting_products";
$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;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "product") {
$ivtproduct = new IvtProduct($this->pid);
if($ivtproduct->id) {
$this->ivtproduct = $ivtproduct;
}
return $this->ivtproduct;
}
if($name == "customer") {
$ivtcustomer = new IvtCustomer($this->cid);
if($ivtcustomer->id) {
$this->ivtcustomer = $ivtcustomer;
}
return $this->ivtcustomer;
}
$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;
}
}