More Contract stuff

This commit is contained in:
Frank Schubert
2022-12-01 22:41:44 +01:00
parent 5ccd74dc3c
commit 88dda09d66
19 changed files with 1014 additions and 186 deletions

View 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;
}
}