Marius Cramer
2015-04-07 cc7a82756b4f4d7ab18e928527c37489adbaf564
interface/web/client/client_edit.php
@@ -59,11 +59,11 @@
         // Get the limits of the client
         $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");
         $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.
         if($client["limit_client"] >= 0) {
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id");
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
            if($tmp["number"] >= $client["limit_client"]) {
               $app->error($app->tform->wordbook["limit_client_txt"]);
            }
@@ -82,11 +82,11 @@
         // Get the limits of the client
         $client_group_id = $_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");
         $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.
         if($client["limit_client"] >= 0) {
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id");
            $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
            if($tmp["number"] >= $client["limit_client"]) {
               $app->error($app->tform->wordbook["limit_client_txt"]);
            }
@@ -96,6 +96,10 @@
      //* Resellers shall not be able to create another reseller
      if($_SESSION["s"]["user"]["typ"] == 'user') {
         $this->dataRecord['limit_client'] = 0;
      } else {
         if($this->dataRecord["reseller"]) {
            $this->dataRecord["limit_client"] = 1; // allow 1 client, template limits will be applied later, if we set -1 it would override template limits
         }
      }
      if($this->id != 0) {
@@ -223,7 +227,7 @@
      
      if($app->auth->is_admin()) {
         // Fill the client select field
         $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client > 0 ORDER BY client.company_name, client.contact_name, sys_group.name";
         $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = "<option value='0'>- ".$app->tform->lng('none_txt')." -</option>";
         //$tmp_data_record = $app->tform->getDataRecord($this->id);