From 3c8467b06b9a63e3d5ed088bdcaea0259dff5d42 Mon Sep 17 00:00:00 2001
From: Florian Schaal <info@schaal-24.de>
Date: Wed, 14 Sep 2016 12:14:46 +0200
Subject: [PATCH] Fixes #4160

---
 interface/web/client/client_edit.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php
index ac7f4c6fce..3f63c7ee8c 100644
--- a/interface/web/client/client_edit.php
+++ b/interface/web/client/client_edit.php
@@ -204,9 +204,12 @@ class page_action extends tform_actions {
 				$reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id);
 				
 				if($reseller['customer_no_template'] != '') {
-					//* Set customer no default
-					$customer_no = $app->functions->intval($reseller['customer_no_start']+$reseller['customer_no_counter']);
-					$customer_no_string = str_replace(array('[CUSTOMER_NO]','[CLIENTID]'),array($customer_no, $reseller['client_id']),$reseller['customer_no_template']);
+					if(isset($this->dataRecord['customer_no'])&& $this->dataRecord['customer_no']!='') $customer_no_string = $this->dataRecord['customer_no'];
+					else {
+						//* Set customer no default
+						$customer_no = $app->functions->intval($reseller['customer_no_start']+$reseller['customer_no_counter']);
+						$customer_no_string = str_replace(array('[CUSTOMER_NO]','[CLIENTID]'),array($customer_no, $reseller['client_id']),$reseller['customer_no_template']);
+					}
 					$app->tpl->setVar('customer_no',$customer_no_string);
 				}
 			}
-- 
GitLab