Merge branch 'fronkdev' into 'master'
Added fullcustomer (Xinonkunde) as addresstype, will create fibu account See merge request fronk/thetool!854
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 = [];
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddresstypeAddFullcustomer extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$addresstype = $this->table("Addresstype");
|
||||
$addresstype->changeColumn("type", "enum", ["null" => false, "values" => "systemowner,productowner,netowner,salespartner,pipeworker,lineworker,pipeplanner,lineplanner,netoperator,supplier,billing,employee,customer,fullcustomer,contact,techcontact,commercialcontact"]);
|
||||
$addresstype->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$addresstype = $this->table("Addresstype");
|
||||
$addresstype->changeColumn("type", "enum", ["null" => false, "values" => "systemowner,productowner,netowner,salespartner,pipeworker,lineworker,pipeplanner,lineplanner,netoperator,supplier,billing,employee,customer,contact,techcontact,commercialcontact"]);
|
||||
$addresstype->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ $l['planner'] = "Planer";
|
||||
$l['support'] = "Support";
|
||||
$l['employee'] = "Mitarbeiter";
|
||||
$l['customer'] = "Kunde";
|
||||
$l['fullcustomer'] = "Xinonkunde";
|
||||
$l['customers'] = "Kunden";
|
||||
$l['supplier'] = "Lieferant";
|
||||
$l['suppliers'] = "Lieferanten";
|
||||
|
||||
@@ -238,7 +238,8 @@ class mfBaseModel {
|
||||
}
|
||||
|
||||
protected function getChangedFields($include_system = false) {
|
||||
if(!$this->_old_data->id) return [];
|
||||
if(!is_object($this->_old_data) || !property_exists($this->_old_data, "id") || !$this->_old_data->id) return [];
|
||||
|
||||
if(!is_object($this->data) || !is_object($this->_old_data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user