More Contract stuff
This commit is contained in:
@@ -10,12 +10,100 @@ class Contract extends mfBaseModel {
|
||||
private $contractConfigGroups;
|
||||
private $contractConfigItems;
|
||||
private $configgroups;
|
||||
private $links;
|
||||
private $linkFrom;
|
||||
private $linkTo;
|
||||
private $upgradeFrom;
|
||||
private $upgradeTo;
|
||||
private $downgradeFrom;
|
||||
private $downgradeTo;
|
||||
private $productchangeFrom;
|
||||
private $productchangeTo;
|
||||
private $relocationFrom;
|
||||
private $relocationTo;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
private function getLinks() {
|
||||
$this->linkFrom = [];
|
||||
$this->linkTo = [];
|
||||
$this->upgradeFrom = [];
|
||||
$this->upgradeTo = [];
|
||||
$this->downgradeFrom = [];
|
||||
$this->downgradeTo = [];
|
||||
$this->productchangeFrom = [];
|
||||
$this->productchangeTo = [];
|
||||
$this->relocationFrom = [];
|
||||
$this->relocationTo = [];
|
||||
|
||||
// Links targeting this contract (to)
|
||||
foreach(ContractLinkModel::search(['origin_contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeTo[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeTo[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeTo[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationTo[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ContractLinkModel::search(['contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeFrom[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeFrom[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeFrom[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationFrom[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*$this->links = mfValuecache::singleton()->get("ContractLinks-origin-".$this->id);
|
||||
if(!$this->links) {
|
||||
$this->links = [];
|
||||
foreach(ContractLinkModel::search(["origin_contract_id" => $this->id]) as $link) {
|
||||
if(array_key_exists($link->type, $this->links)) {
|
||||
$this->links[$link->type] = [];
|
||||
}
|
||||
$this->links[$link->type][] = $link;
|
||||
}
|
||||
}
|
||||
if(count($this->links)) {
|
||||
mfValuecache::singleton()->set("ContractLinks-origin-".$this->id, $this->links);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -96,6 +184,18 @@ class Contract extends mfBaseModel {
|
||||
return $this->contractConfigItems;
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
if(in_array($name, ['linkFrom','linkTo','upgradeFrom','upgradeTo','downgradeFrom','downgradeTo','productchangeFrom','productchangeTo','relocationFrom','relocationTo'])) {
|
||||
if($this->$name === null) {
|
||||
$this->getLinks();
|
||||
}
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if($name == "finisher") {
|
||||
$this->finisher = mfValuecache::singleton()->get("Worker-id-".$this->finish_date_by);
|
||||
if($this->finisher === null) {
|
||||
|
||||
Reference in New Issue
Block a user