More Contract stuff
This commit is contained in:
49
application/Contractconfiggroup/Contractconfiggroup.php
Normal file
49
application/Contractconfiggroup/Contractconfiggroup.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Contractconfiggroup extends mfBaseModel {
|
||||
private $items;
|
||||
private $contract_id;
|
||||
|
||||
public function setContractId($contract_id) {
|
||||
if(!is_numeric($contract_id)) {
|
||||
return false;
|
||||
}
|
||||
$this->contract_id = $contract_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
/*if($name == "items") {
|
||||
$this->items = ContractconfigItemModel::search(['group_id' => $this->id]);
|
||||
return $this->items;
|
||||
}*/
|
||||
|
||||
if($name == "items") {
|
||||
if($this->contract_id) {
|
||||
foreach(ContractconfigItemModel::search(['contractconfiggroup_id' => $this->id]) as $item) {
|
||||
$item->setContractId($this->contract_id);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
} else {
|
||||
$this->items = ContractconfigItemModel::search(['contractconfiggroup_id' => $this->id]);
|
||||
}
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user