Esempio n. 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     if (is_numeric($this->GET['company_id'])) {
         $company_id = $this->GET['company_id'];
     } else {
         if (is_numeric($this->GET['customer_id'])) {
             $customer_id = $this->GET['customer_id'];
         } else {
             return false;
         }
     }
     require_once 'models/client/client_company.php';
     $Company = new client_company();
     /**
      * find a company for customer
      */
     if ($customer_id) {
         $company_list = $Company->getCompanyListForCustomer($customer_id);
         if (count($company_list) > 0) {
             $company_id = $company_list[0]['id'];
         }
     }
     if (is_numeric($company_id)) {
         $company_data = $Company->getDetail($company_id);
         $this->tpl->assign('ITEM', $company_data);
         $this->tpl->parse('content.detail');
     } else {
         $this->tpl->parse('content.empty');
     }
     return true;
 }
Esempio n. 2
0
 /**
  * This function update client_customer and client_company
  * 
  * @param array $client_data
  * client's information for update
  * 
  * @return boolean
  * is client's information updating successfully [true/false]
  */
 function updateClient($client_data)
 {
     require_once 'models/client/client_company.php';
     $Company = new client_company();
     if (!isset($client_data['customer']['newsletter'])) {
         $client_data['customer']['newsletter'] = 0;
     }
     $client_data['customer']['modified'] = date('c');
     // company management
     if ($client_data['company']['name'] != '') {
         if ($company_id = $Company->updateCompanyForClient($client_data['company'], $client_data['customer']['id'])) {
             $client_data['customer']['company_id'] = $company_id;
         }
     }
     // unset empty values
     if (!is_numeric($client_data['customer']['company_id'])) {
         unset($client_data['customer']['company_id']);
     }
     if (!is_numeric($client_data['customer']['facebook_id'])) {
         unset($client_data['customer']['facebook_id']);
     }
     if (!is_numeric($client_data['customer']['twitter_id'])) {
         unset($client_data['customer']['twitter_id']);
     }
     if (!is_numeric($client_data['customer']['google_id'])) {
         unset($client_data['customer']['google_id']);
     }
     if ($client_data['customer']['birthday'] == '') {
         unset($client_data['customer']['birthday']);
     }
     // check if login id is available (i.e. don't overwrite by changing email address)
     if (!$this->checkLoginId($client_data['customer']) || $customer_data['customer'] == 1 && !$this->checkLoginIdPreservedOnly($customer_data['customer']['email'])) {
         msg("User email {$customer_data['customer']['email']} is already registered", 'error', 0, 'account_exists');
         return false;
     }
     if ($this->updateCustomer($client_data['customer'])) {
         msg('Customer Data Updated', 'ok', 2);
         return true;
     } else {
         msg("Can't update Customer Data", 'ok', 2);
         return false;
     }
 }