diff --git a/install/sql/incremental/upd_0060.sql b/install/sql/incremental/upd_0060.sql new file mode 100644 index 0000000000000000000000000000000000000000..64c9a0d64cc05cac1361b1c9670cc08be10e76fa --- /dev/null +++ b/install/sql/incremental/upd_0060.sql @@ -0,0 +1,8 @@ +ALTER TABLE `client` ADD `customer_no_template` VARCHAR( 255 ) NULL DEFAULT 'C[CUSTOMER_NO]' AFTER `ssh_rsa` , +ADD `customer_no_start` INT NOT NULL DEFAULT '1' AFTER `customer_no_template` , +ADD `customer_no_counter` INT NOT NULL DEFAULT '0' AFTER `customer_no_start` , +ADD `added_date` DATE NOT NULL default '0000-00-00' AFTER `customer_no_counter` , +ADD `added_by` VARCHAR( 255 ) NULL AFTER `added_date` ; +ALTER TABLE `web_domain` ADD `added_date` DATE NOT NULL default '0000-00-00' AFTER `rewrite_rules` , +ADD `added_by` VARCHAR( 255 ) NULL AFTER `added_date` ; +ALTER TABLE `sys_session` ADD `permanent` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `last_updated`; \ No newline at end of file diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index e215de44db37ae69820c419323ef5fc8268d3b70..09a8607c61f2ff98823eba03fe3aaa3f3496695d 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -232,6 +232,11 @@ CREATE TABLE `client` ( `tmp_data` mediumblob, `id_rsa` varchar(2000) NOT NULL DEFAULT '', `ssh_rsa` varchar(600) NOT NULL DEFAULT '', + `customer_no_template` varchar(255) DEFAULT 'C[CUSTOMER_NO]', + `customer_no_start` int(11) NOT NULL DEFAULT '1', + `customer_no_counter` int(11) NOT NULL DEFAULT '0', + `added_date` date NOT NULL DEFAULT '0000-00-00', + `added_by` varchar(255) DEFAULT NULL, PRIMARY KEY (`client_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1797,6 +1802,8 @@ CREATE TABLE `web_domain` ( `proxy_directives` mediumtext, `last_quota_notification` date NULL default NULL, `rewrite_rules` mediumtext, + `added_date` date NOT NULL DEFAULT '0000-00-00', + `added_by` varchar(255) DEFAULT NULL, PRIMARY KEY (`domain_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index efbf8ab652e56b8436a607ab5c059303cc28737c..52b70209c8183299ea850b58328d384a6ce9261e 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -171,6 +171,45 @@ class page_action extends tform_actions { $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(); diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 16e68c01e635908f6a57bccf073cd6235fdfdac6..5869776795b64fa0c8e4f5419bd283933a158a8a 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -472,6 +472,28 @@ $form["tabs"]['address'] = array ( 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), + 'added_date' => array ( + 'datatype' => 'DATE', + 'formtype' => 'TEXT', + 'default' => date($app->lng('conf_format_dateshort')), + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '15', + 'rows' => '', + 'cols' => '' + ), + 'added_by' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => $_SESSION['s']['user']['username'], + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), //################################# // END Datatable fields //################################# diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index fad0cd7653683a823c1ad56d43e4710402a8385b..77e1f63a6ad4eac098368e4b2af7ac6a79d4397e 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -469,6 +469,28 @@ $form["tabs"]['address'] = array ( 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), + 'added_date' => array ( + 'datatype' => 'DATE', + 'formtype' => 'TEXT', + 'default' => date($app->lng('conf_format_dateshort')), + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '15', + 'rows' => '', + 'cols' => '' + ), + 'added_by' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => $_SESSION['s']['user']['username'], + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), //################################# // END Datatable fields //################################# @@ -1080,6 +1102,34 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'customer_no_template' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/', + 'errmsg'=> 'customer_no_template_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'customer_no_start' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'customer_no_counter' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), //################################# // END Datatable fields //################################# diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index 7c4ee2688448c31899ad012f80ee5effedab78ae..ad268a7873dd3984424f34c928da8d6d6a123b66 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -152,4 +152,6 @@ $wb['canceled_txt'] = 'Canceled (disables client login)'; $wb['gender_txt'] = 'Title'; $wb['gender_m_txt'] = 'Mr.'; $wb['gender_f_txt'] = 'Ms.'; +$wb['added_by_txt'] = 'Added by'; +$wb['added_date_txt'] = 'Added date'; ?> diff --git a/interface/web/client/lib/lang/en_reseller.lng b/interface/web/client/lib/lang/en_reseller.lng index 4076dd5cb999bdad3ffc61a2f9c55c260e5ac00a..e58d4e3fcd227af274bceb86fe2b4b4b03336a33 100644 --- a/interface/web/client/lib/lang/en_reseller.lng +++ b/interface/web/client/lib/lang/en_reseller.lng @@ -150,4 +150,10 @@ $wb['canceled_txt'] = 'Canceled'; $wb['gender_m_txt'] = 'Mr.'; $wb['gender_f_txt'] = 'Ms.'; $wb['gender_txt'] = 'Title'; +$wb['customer_no_template_txt'] = 'Customer No. template'; +$wb['customer_no_template_error_regex_txt'] = 'The customer No. template contains invalid characters'; +$wb['customer_no_start_txt'] = 'Customer No. start value'; +$wb['customer_no_counter_txt'] = 'Customer No. counter'; +$wb['added_by_txt'] = 'Added by'; +$wb['added_date_txt'] = 'Added date'; ?> diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php index 6c67aee5dc294c00da231b3a09176d7e7e17e584..20273b763aeeaca60c6580b9a66a06bd0e16dad8 100644 --- a/interface/web/client/reseller_edit.php +++ b/interface/web/client/reseller_edit.php @@ -139,6 +139,25 @@ class page_action extends tform_actions { } $app->tpl->setVar('template_additional_list', $text); + + //* Set the 'customer no' default value + if($this->id == 0) { + //* 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); + } + } parent::onShowEnd(); diff --git a/interface/web/client/templates/client_edit_address.htm b/interface/web/client/templates/client_edit_address.htm index 018d1d5b6e3de4af9d88700566e3286392d69160..839282072e05e8503b853ca9ce4c4c50e5446614 100644 --- a/interface/web/client/templates/client_edit_address.htm +++ b/interface/web/client/templates/client_edit_address.htm @@ -135,6 +135,14 @@