auto generate fibu_num for billingaddresses
This commit is contained in:
@@ -9,6 +9,7 @@ class Address extends mfBaseModel {
|
||||
private $childaddresses;
|
||||
private $links = [];
|
||||
private $linked_as = [];
|
||||
private $links_to = [];
|
||||
private $types;
|
||||
private $attributes;
|
||||
private $permissions;
|
||||
@@ -29,11 +30,30 @@ class Address extends mfBaseModel {
|
||||
|
||||
}
|
||||
|
||||
private function generateFibuAccountNumber() {
|
||||
if($this->fibu_account_number || !$this->customer_number) {
|
||||
public function generateFibuAccountNumber() {
|
||||
if($this->fibu_account_number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$create_fibu_num = false;
|
||||
|
||||
if($this->customer_number) {
|
||||
$create_fibu_num = true;
|
||||
} else {
|
||||
// check if we are billingaddress
|
||||
if(ContractModel::getFirst(["billingaddress_id" => $this->id])) {
|
||||
$create_fibu_num = true;
|
||||
} elseif(OrderModel::getFirst(["billingaddress_id" => $this->id])) {
|
||||
$create_fibu_num = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$create_fibu_num) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$fibu_account_number = Address::getNextFibuAccountNumber();
|
||||
if(!$fibu_account_number) {
|
||||
return false;
|
||||
@@ -615,7 +635,18 @@ class Address extends mfBaseModel {
|
||||
}
|
||||
return $this->linked_as;
|
||||
}
|
||||
|
||||
|
||||
if($name == "links_to") {
|
||||
$links_to = AddressLinkModel::search(['origin_address_id' => $this->id]);
|
||||
foreach($links_to as $link) {
|
||||
if(!array_key_exists($link->type, $this->links_to)) {
|
||||
$this->links_to[$link->type] = [];
|
||||
}
|
||||
$this->links_to[$link->type][] = $link;
|
||||
//var_dump($this->links);exit;
|
||||
}
|
||||
return $this->links_to;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
|
||||
@@ -132,6 +132,8 @@ class AddressController extends mfBaseController {
|
||||
|
||||
$address = new Address($this->request->id);
|
||||
$this->layout()->set("address", $address);
|
||||
|
||||
//var_dump($address->links_to);exit;
|
||||
|
||||
if(!$address->id) {
|
||||
$this->layout()->setFlash("Addresse nicht gefunden", "error");
|
||||
|
||||
Reference in New Issue
Block a user