Added fullcustomer (Xinonkunde) as addresstype, will create fibu account
This commit is contained in:
@@ -20,7 +20,7 @@ class Address extends mfBaseModel {
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
protected function afterSave() {
|
||||
public function afterSave() {
|
||||
// prevent potential infinite loop
|
||||
if($this->in_after_save) return true;
|
||||
$this->in_after_save++;
|
||||
@@ -91,13 +91,26 @@ class Address extends mfBaseModel {
|
||||
} elseif(OrderModel::getFirst(["billingaddress_id" => $this->id])) {
|
||||
$create_fibu_num = true;
|
||||
}
|
||||
|
||||
if(is_array($this->getProperty("types")) && array_key_exists("fullcustomer", $this->getProperty("types")) && $this->getProperty("types")["fullcustomer"]) {
|
||||
$create_fibu_num = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$create_fibu_num) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$this->customer_number) {
|
||||
// create customer number first
|
||||
$new_custnum = $this->getNewCustomerNumber();
|
||||
if(!$new_custnum) {
|
||||
return false;
|
||||
}
|
||||
$this->customer_number = $new_custnum;
|
||||
$this->save();
|
||||
|
||||
}
|
||||
|
||||
$fibu_account_number = Address::getNextFibuAccountNumber();
|
||||
if(!$fibu_account_number) {
|
||||
|
||||
@@ -461,6 +461,9 @@ class AddressController extends mfBaseController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// run afterSave() again in case anything importand has changed
|
||||
$address->afterSave();
|
||||
|
||||
$sq = "";
|
||||
$query = [];
|
||||
|
||||
Reference in New Issue
Block a user