protected function saveCustomer() { // save customer $user = JbFactory::getAccount(); AImporter::table('customer'); $this->customer['state'] = 1; $customer = new TableCustomer($this->_db); if ($user->user->id) { if ($user->is_agent) { //return fasle if there are no customer record is assign to the user if (!$user->customer->table->id) { $app = JFactory::getApplication(); $app->enqueueMessage('You must update your information before booking', 'warning'); $app->redirect('index.php?option=com_bookpro&view=mypage&form=profile'); return false; } if ($this->customer['sunpass']) { $customer->load(array('sunpass' => $this->customer['sunpass'])); } } else { $customer = $user->customer->table; } } else { $customer->load(array('sunpass' => $this->customer['sunpass'])); } if ($customer->save($this->customer)) { return $customer->id; } return false; }
/** * Create BookproUser * @param $id id of JUser */ public function __construct($id = null) { $this->customer = new BookproCustomer(); $config = JbFactory::getConfig(); if ($id) { $this->id = $id; $this->user = JFactory::getUser($this->id); if ($this->user->id) { $this->customer->load(array('user' => $this->user->id)); if (in_array($config->agent_usergroup, $this->user->groups)) { $this->is_agent = 1; } else { $this->is_agent = 0; } if ($this->customer->id) { $this->authorise = json_decode($this->customer->params); } } } $this->_db = JFactory::getDbo(); }