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; }