WIP Contractqueue
This commit is contained in:
@@ -1,8 +1,164 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
class Contractqueue extends mfBaseModel {
|
||||
protected $forcestr = ["product_name","product_info","matchcode"];
|
||||
|
||||
private $crediting_partner;
|
||||
private $reseller;
|
||||
private $owner;
|
||||
private $billingaddress;
|
||||
private $product;
|
||||
private $orderproduct;
|
||||
private $termination;
|
||||
private $sla;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function generateMatchcode() {
|
||||
$owner_address = $this->getProperty("owner")->street.", ".$this->getProperty("owner")->zip." ".$this->getProperty("owner")->city;
|
||||
|
||||
// phone
|
||||
if($this->getProperty("product")->productgroup->mathcodeorigin == "voicenumber") {
|
||||
|
||||
}
|
||||
// domain
|
||||
if($this->getProperty("product")->productgroup->mathcodeorigin == "domain") {
|
||||
|
||||
}
|
||||
|
||||
if($this->termination_id) {
|
||||
$termination = new Termination($this->termination_id);
|
||||
$termination_address = $termination->building->street.", ".$termination->building->zip." ".$termination->building->city;
|
||||
return $termination_address;
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
// everything else
|
||||
|
||||
return $owner_address;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCredit() {
|
||||
$crediting = [];
|
||||
|
||||
if(!$this->crediting_partner_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$crediting["partner"] = $this->getProperty("crediting_partner");
|
||||
|
||||
if($this->crediting_partner_rate) {
|
||||
// use rate
|
||||
$crediting["rate_source"] = "rate";
|
||||
$crediting["rate"] = round($this->price / 100 * $this->crediting_partner_rate, 4);
|
||||
} else {
|
||||
$crediting["rate_source"] = "nne";
|
||||
}
|
||||
|
||||
return $crediting;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "billingaddress" && $this->billingaddress_id) {
|
||||
$this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
|
||||
if($this->billingaddress === null) {
|
||||
$this->billingaddress = new Address($this->billingaddress_id);
|
||||
if($this->billingaddress->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
|
||||
}
|
||||
}
|
||||
return $this->billingaddress;
|
||||
}
|
||||
|
||||
if($name == "owner" && $this->owner_id) {
|
||||
$this->owner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->owner_id);
|
||||
if($this->owner === null) {
|
||||
$this->owner = new Address($this->owner_id);
|
||||
if($this->owner->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->owner_id, $this->owner);
|
||||
}
|
||||
}
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
if($name == "crediting_partner" && $this->crediting_partner_id) {
|
||||
$this->crediting_partner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->crediting_partner_id);
|
||||
if($this->crediting_partner === null) {
|
||||
$this->crediting_partner = new Address($this->crediting_partner_id);
|
||||
if($this->crediting_partner->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->crediting_partner_id, $this->crediting_partner);
|
||||
}
|
||||
}
|
||||
return $this->crediting_partner;
|
||||
}
|
||||
|
||||
if($name == "product") {
|
||||
$this->product = mfValuecache::singleton()->get("mfObjectmodel-Product-".$this->product_id);
|
||||
if($this->product === null) {
|
||||
$this->product = new Product($this->product_id);
|
||||
if($this->product->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Product-".$this->product_id, $this->product);
|
||||
}
|
||||
}
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
if($name == "orderproduct") {
|
||||
$this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id);
|
||||
if($this->orderproduct === null) {
|
||||
$this->orderproduct = new OrderProduct($this->orderproduct_id);
|
||||
if($this->orderproduct->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->orderproduct);
|
||||
}
|
||||
}
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
|
||||
if($name == "creator" && $this->id) {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor" && $this->id) {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user