Example #1
0
 public function _new()
 {
     parent::_new();
     $customer = $this->_uses[$this->modeltype];
     if ($customer->isLoaded()) {
         $this->view->set('transaction_count', $customer->transaction_count());
         $emails = $this->getEmailAddresses($customer->company_id);
         unset($emails['']);
         $this->view->set('emails', $emails);
     } elseif (isset($this->_data['company_id'])) {
         $customer->company_id = $this->_data['company_id'];
     } else {
         $unassigned_list = $customer->getUnassignedCompanies();
         if (count($unassigned_list) > 0) {
             $this->view->set('company_list', $unassigned_list);
             $emails = $this->getEmailAddresses(key($unassigned_list));
             unset($emails['']);
             $this->view->set('emails', $emails);
             $customer->company_id = key($unassigned_list);
         } else {
             $flash = Flash::Instance();
             $flash->addMessage('All companies are assigned as customers');
             sendBack();
         }
     }
     $this->view->set('billing_addresses', $customer->getInvoiceAddresses());
     $this->view->set('despatch_actions', WHAction::getDespatchActions());
 }
Example #2
0
 public function getDespatchAction($_slmaster_id = '')
 {
     // Used by Ajax to return Default Despatch Action after selecting the Supplier
     if (isset($this->_data['ajax'])) {
         if (!empty($this->_data['slmaster_id'])) {
             $_slmaster_id = $this->_data['slmaster_id'];
         }
     }
     $customer = $this->getCustomer($_slmaster_id);
     $despatch_action = '';
     if ($customer) {
         $despatch_action = $customer->despatch_action;
     }
     if (empty($despatch_action)) {
         $despatch_actions = WHAction::getDespatchActions();
         $despatch_action = current(array_keys($despatch_actions));
     }
     if (isset($this->_data['ajax'])) {
         $this->view->set('value', $despatch_action);
         $this->setTemplateName('text_inner');
     } else {
         return $despatch_action;
     }
 }