Merge branch 'fronkdev' into 'master'
Address::fibu_account_number generated automatically See merge request fronk/thetool!144
This commit is contained in:
@@ -21,9 +21,25 @@ class Address extends mfBaseModel {
|
||||
if($this->in_after_save) return true;
|
||||
$this->in_after_save = true;
|
||||
|
||||
$this->generateFibuAccountNumber();
|
||||
$this->syncToFibuMerge();
|
||||
}
|
||||
|
||||
private function generateFibuAccountNumber() {
|
||||
if($this->fibu_account_number || !$this->customer_number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$fibu_account_number = Address::getNextFibuAccountNumber();
|
||||
if(!$fibu_account_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->fibu_account_number = $fibu_account_number;
|
||||
$this->fibu_primary_account = 1;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
private function syncToFibuMerge() {
|
||||
if(!$this->customer_number) return true;
|
||||
|
||||
@@ -197,6 +213,24 @@ class Address extends mfBaseModel {
|
||||
}
|
||||
}*/
|
||||
|
||||
public static function getNextFibuAccountNumber() {
|
||||
$db = FronkDB::singleton();
|
||||
$res = $db->select("Address","fibu_account_number", "fibu_account_number > 0 ORDER BY fibu_account_number DESC LIMIT 1");
|
||||
if(!$db->num_rows($res)) {
|
||||
return 230001;
|
||||
}
|
||||
|
||||
$data = $db->fetch_object($res);
|
||||
$last_num = $data->fibu_account_number;
|
||||
if($last_num) {
|
||||
$new_num = $last_num + 1;
|
||||
} else {
|
||||
$new_num = 230001;
|
||||
}
|
||||
return $new_num;
|
||||
|
||||
}
|
||||
|
||||
public static function getNextSupplierNumber() {
|
||||
$db = FronkDB::singleton();
|
||||
$res = $db->select("Address","fibu_supplier_number", "fibu_supplier_number > 0 ORDER BY fibu_supplier_number DESC LIMIT 1");
|
||||
|
||||
Reference in New Issue
Block a user