From c0726b9da99332bd94c87086c868b53e75e9a7e2 Mon Sep 17 00:00:00 2001
From: Dominik Müller <info@profi-webdesign.net>
Date: Sun, 19 Jan 2014 16:46:41 -0500
Subject: [PATCH] corrected alias-domain-form

---
 interface/web/client/client_edit.php |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php
index 3fa7837..d12f39e 100644
--- a/interface/web/client/client_edit.php
+++ b/interface/web/client/client_edit.php
@@ -58,7 +58,7 @@
 		if($_SESSION["s"]["user"]["typ"] == 'user') {
 
 			// Get the limits of the client
-			$client_group_id = $_SESSION["s"]["user"]["default_group"];
+			$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
 			$client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
 
 			// Check if the user may add another website.
@@ -171,7 +171,47 @@
 
 		$app->tpl->setVar('template_additional_list', $text);
 		$app->tpl->setVar('app_module', 'client');
+		
 
+		//* Set the 'customer no' default value
+		if($this->id == 0) {
+			
+			if($app->auth->is_admin()) {
+				//* Logged in User is admin
+				//* get the system config
+				$app->uses('getconf');
+				$system_config = $app->getconf->get_global_config();
+				if($system_config['misc']['customer_no_template'] != '') {
+				
+					//* Set customer no default
+					$customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']);
+					$customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']);
+					$app->tpl->setVar('customer_no',$customer_no_string);
+				
+					//* save new counter value
+					$system_config['misc']['customer_no_counter']++;
+					$system_config_str = $app->ini_parser->get_ini_string($system_config);
+					$app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
+				}
+			} else {
+				//* Logged in user must be a reseller
+				//* get the record of the reseller
+				$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
+				$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('[CUSTOMER_NO]',$customer_no,$reseller['customer_no_template']);
+					$app->tpl->setVar('customer_no',$customer_no_string);
+					
+					//* save new counter value
+					$customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
+					$app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id']));
+				}
+			}
+		}
+		
 		parent::onShowEnd();
 
 	}
@@ -225,7 +265,7 @@
 		$tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
 		$default_dbserver = $app->functions->intval($tmp['server_id']);
 
-		$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;
+		$sql = "UPDATE client SET mail_servers = $default_mailserver, web_servers = $default_webserver, dns_servers = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, db_servers = $default_dbserver WHERE client_id = ".$this->id;
 		$app->db->query($sql);
 
 		if(isset($this->dataRecord['template_master'])) {

--
Gitblit v1.9.1