Skip to content

Commit 23229cb

Browse files
author
Till Brehm
committed
Fixed client / reseller number increment function.
1 parent 4b7584c commit 23229cb

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

interface/web/client/client_edit.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ function onShowEnd() {
189189
$app->tpl->setVar('customer_no',$customer_no_string);
190190

191191
//* save new counter value
192+
/*
192193
$system_config['misc']['customer_no_counter']++;
193194
$system_config_str = $app->ini_parser->get_ini_string($system_config);
194195
$app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
196+
*/
195197
}
196198
} else {
197199
//* Logged in user must be a reseller
@@ -206,8 +208,10 @@ function onShowEnd() {
206208
$app->tpl->setVar('customer_no',$customer_no_string);
207209

208210
//* save new counter value
211+
/*
209212
$customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
210213
$app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id']));
214+
*/
211215
}
212216
}
213217
}
@@ -272,6 +276,33 @@ function onAfterInsert() {
272276
$app->uses('client_templates');
273277
$app->client_templates->update_client_templates($this->id, $this->_template_additional);
274278
}
279+
280+
if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
281+
if($app->auth->is_admin()) {
282+
//* Logged in User is admin
283+
//* get the system config
284+
$app->uses('getconf');
285+
$system_config = $app->getconf->get_global_config();
286+
if($system_config['misc']['customer_no_template'] != '') {
287+
288+
//* save new counter value
289+
$system_config['misc']['customer_no_counter']++;
290+
$system_config_str = $app->ini_parser->get_ini_string($system_config);
291+
$app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
292+
}
293+
} else {
294+
//* Logged in user must be a reseller
295+
//* get the record of the reseller
296+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
297+
$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);
298+
299+
if($reseller['customer_no_template'] != '') {
300+
//* save new counter value
301+
$customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
302+
$app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id']));
303+
}
304+
}
305+
}
275306

276307
parent::onAfterInsert();
277308
}

interface/web/client/reseller_edit.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ function onShowEnd() {
153153
$app->tpl->setVar('customer_no',$customer_no_string);
154154

155155
//* save new counter value
156+
/*
156157
$system_config['misc']['customer_no_counter']++;
157158
$system_config_str = $app->ini_parser->get_ini_string($system_config);
158159
$app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
160+
*/
159161
}
160162
}
161163

@@ -210,6 +212,20 @@ function onAfterInsert() {
210212

211213
$sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id;
212214
$app->db->query($sql);
215+
216+
if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
217+
//* get the system config
218+
$app->uses('getconf');
219+
$system_config = $app->getconf->get_global_config();
220+
if($system_config['misc']['customer_no_template'] != '') {
221+
222+
//* save new counter value
223+
$system_config['misc']['customer_no_counter']++;
224+
$system_config_str = $app->ini_parser->get_ini_string($system_config);
225+
$app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
226+
227+
}
228+
}
213229

214230
parent::onAfterInsert();
215231
}

interface/web/client/templates/client_edit_address.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
2222
<div class="ctrlHolder">
2323
<label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
2424
<input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
25+
<input name="customer_no_org" id="customer_no_org" value="{tmpl_var name='customer_no'}" type="hidden" />
2526
</div>
2627
<div class="ctrlHolder">
2728
<label for="username">{tmpl_var name='username_txt'}*</label>

interface/web/client/templates/reseller_edit_address.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
2222
<div class="ctrlHolder">
2323
<label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
2424
<input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
25+
<input name="customer_no_org" id="customer_no_org" value="{tmpl_var name='customer_no'}" type="hidden" />
2526
</div>
2627
<div class="ctrlHolder">
2728
<label for="username">{tmpl_var name='username_txt'}*</label>

0 commit comments

Comments
 (0)