Changed OrderFiles; name is now dropdown of predefined types; Certain
types send emails
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
class Address extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
|
||||
private $parent;
|
||||
private $childaddresses;
|
||||
private $types;
|
||||
private $attributes;
|
||||
private $permissions;
|
||||
@@ -90,20 +91,29 @@ class Address extends mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$this->parent_id) {
|
||||
$this->types = AddresstypeModel::search(['address_id' => $this->id], true);
|
||||
} else {
|
||||
// get types from parent
|
||||
|
||||
$parent = $this->getProperty("parent");
|
||||
$types = $parent->getProperty("types");
|
||||
$this->types = $types;
|
||||
}
|
||||
$all_types = AddresstypeModel::search(['address_id' => $this->id], true);
|
||||
|
||||
if($this->parent_id) {
|
||||
// get types from parent
|
||||
$parent_types = $this->getProperty("parent")->getProperty("types");
|
||||
if($parent_types) {
|
||||
$all_types = array_merge($all_types, $parent_types);
|
||||
}
|
||||
}
|
||||
$this->types = $all_types;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function getChildrenByType($type) {
|
||||
if(!$this->id || !$type) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$children = AddressModel::search(['addresstype' => [$type], "parent_id" => $this->id]);
|
||||
return $children;
|
||||
}
|
||||
|
||||
public function generateServicePin() {
|
||||
if(!$this->customer_number) {
|
||||
return false;
|
||||
@@ -152,6 +162,11 @@ class Address extends mfBaseModel {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
if($name == "childaddresses") {
|
||||
$this->childaddresses = AddressModel::search(['parent' => $this->id]);
|
||||
return $this->childaddresses;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
Reference in New Issue
Block a user