@@ -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 }
0 commit comments