diff --git a/Layout/default/Address/Form.php b/Layout/default/Address/Form.php index 0f806f067..9e1b4eb11 100644 --- a/Layout/default/Address/Form.php +++ b/Layout/default/Address/Form.php @@ -42,6 +42,12 @@ +
+ +
+ +
+
@@ -114,6 +120,17 @@
+
+
+
+ +
+ +
+
+
+
+
diff --git a/Layout/default/Address/Index.php b/Layout/default/Address/Index.php index 546876b92..ed4fff781 100644 --- a/Layout/default/Address/Index.php +++ b/Layout/default/Address/Index.php @@ -51,6 +51,7 @@ + @@ -60,7 +61,22 @@ - + types)):?> + types); + $l7d_types = []; + foreach($types as $type): + $l7d_types[] = __($type); + endforeach; + ?> + + + - +
TypKundennummer Firma Name Adresse
"> + + + customer_number?> + spin) ? "
".$address->spin."" : ""?> +
company)?> getFullName()?> diff --git a/Layout/default/Order/Index.php b/Layout/default/Order/Index.php index a28f59481..bb1ac768b 100644 --- a/Layout/default/Order/Index.php +++ b/Layout/default/Order/Index.php @@ -52,7 +52,10 @@ owner->getCompanyOrName())?> + owner->getCompanyOrName())?> + owner->spin) ? "
".$order->owner->spin."" : ""?> +
owner->street?>
owner->zip?> owner->city?> diff --git a/Layout/default/Workflow/items/color.php b/Layout/default/Workflow/items/color.php index c1ca48fe1..f7cd00345 100644 --- a/Layout/default/Workflow/items/color.php +++ b/Layout/default/Workflow/items/color.php @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Layout/default/Workflow/items/string.php b/Layout/default/Workflow/items/string.php index 29ffd6cb1..2543850d5 100644 --- a/Layout/default/Workflow/items/string.php +++ b/Layout/default/Workflow/items/string.php @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/application/Address/Address.php b/application/Address/Address.php index 0b738f244..3e1a7ff86 100644 --- a/application/Address/Address.php +++ b/application/Address/Address.php @@ -51,6 +51,20 @@ class Address extends mfBaseModel { } + public function generateServicePin() { + if(!$this->customer_number) { + return false; + } + $num1 = rand(65, 90); + $num2 = rand(65, 90); + + $c1 = chr($num1); + $c2 = chr($num2); + + $spin = $c1.$c2.$this->customer_number; + return $spin; + } + public function getProperty($name) { if($this->$name == null) { diff --git a/application/Address/AddressModel.php b/application/Address/AddressModel.php index 0745d6ccb..bb668d0a6 100644 --- a/application/Address/AddressModel.php +++ b/application/Address/AddressModel.php @@ -2,6 +2,8 @@ class AddressModel { public $parent_id = null; + public $customer_number = null; + public $spin = null; public $company = null; public $firstname = null; public $lastname = null; @@ -76,6 +78,17 @@ class AddressModel { } + public static function getLastCustomerNumber() { + $db = FronkDB::singleton(); + $res = $db->select("Addres","customer_number", "customer_number > 0 ORDER BY customer_number DESC LIMIT 1"); + if(!$db->num_rows($res)) { + return false; + } + + $data = $db->num_rows($res); + return $data->customer_number; + } + public static function byNetwork($network_id, $addresstype) { if(!is_numeric($network_id) || !$network_id) { return false; diff --git a/application/Dashboard/DashboardController.php b/application/Dashboard/DashboardController.php index e373f3c62..1f8f11c3d 100644 --- a/application/Dashboard/DashboardController.php +++ b/application/Dashboard/DashboardController.php @@ -21,7 +21,10 @@ class DashboardController extends mfBaseController { var_dump($b->getNewObjectCode());exit; */ - $address = AddressModel::getOne(5); - var_dump($address->types);exit; + /*$address = AddressModel::getOne(5); + var_dump($address->types);exit;*/ + + $a = new Address(1); + var_dump($a->generateServicePin());exit; } } \ No newline at end of file diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index 46e6d558d..1b2b79bb4 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -359,6 +359,30 @@ class OrderController extends mfBaseController { $this->log->warn("Unable to save OrderProduct:".print_r($product, true)); } + // if product is not external and customer is new, create customer_number and service pin + + if(!$prod->external ) { + if(!$owner->customer_number) { + $last_num = AddressModel::getLastCustomerNumber(); + + if($last_num) { + $new_num = $last_num + 1; + } else { + $new_num = TT_FIRST_CUSTNUM; + } + + $owner->customer_number = $new_num; + $owner->save(); + } + + if(!$owner->spin) { + $spin = $owner->generateServicePin(); + if($spin) { + $owner->spin = $spin; + $owner->save(); + } + } + } } }