Example #1
0
 public function index()
 {
     $this->lang->load('login');
     if ($this->user->islogged()) {
         redirect('dashboard');
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $data['site_name'] = $this->config->item('site_name');
     $data['reset_url'] = site_url('login/reset');
     if ($this->input->post() and $this->validateLoginForm() === TRUE) {
         if (!$this->user->login($this->input->post('user'), $this->input->post('password'))) {
             // checks if form validation routines ran successfully
             $this->alert->set('danger', $this->lang->line('alert_username_not_found'));
             redirect('login');
         } else {
             log_activity($this->user->getStaffId(), 'logged in', 'staffs', get_activity_message('activity_logged_in', array('{staff}', '{link}'), array($this->user->getStaffName(), admin_url('staffs/edit?id=' . $this->user->getStaffId()))));
             if ($previous_url = $this->session->tempdata('previous_url')) {
                 $this->session->unset_tempdata('previous_url');
                 redirect($previous_url);
             }
             redirect(referrer_url());
         }
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('login', $data);
 }
Example #2
0
 public function index()
 {
     if ($this->customer->islogged()) {
         // checks if customer is logged in then redirect to account page.
         redirect('account/account');
     }
     $this->load->model('Pages_model');
     $this->lang->load('account/login_register');
     $this->template->setTitle($this->lang->line('text_heading'));
     $data['reset_url'] = site_url('account/reset');
     $data['register_url'] = site_url('account/register');
     if ($this->input->post()) {
         // checks if $_POST data is set
         if ($this->validateForm() === TRUE) {
             $email = $this->input->post('email');
             // retrieves email value from $_POST data if set
             $password = $this->input->post('password');
             // retrieves password value from $_POST data if set
             if ($this->customer->login($email, $password) === FALSE) {
                 // invoke login method in customer library with email and password $_POST data value then check if login was unsuccessful
                 $this->alert->set('alert', $this->lang->line('alert_invalid_login'));
                 // display error message and redirect to account login page
                 redirect(current_url());
             } else {
                 // else if login was successful redirect to account page
                 log_activity($this->customer->getId(), 'logged in', 'customers', get_activity_message('activity_logged_in', array('{customer}', '{link}'), array($this->customer->getName(), admin_url('customers/edit?id=' . $this->customer->getId()))));
                 if ($redirect_url = $this->input->get('redirect')) {
                     redirect($redirect_url);
                 }
                 redirect('account/account');
             }
         }
     }
     $this->template->render('account/login', $data);
 }
Example #3
0
 private function _updateDetails()
 {
     // method to validate update details form fields
     if ($this->validateForm() === TRUE) {
         $update = array();
         // START: retrieve $_POST data if $_POST data is not same as existing customer library data
         $update['first_name'] = $this->input->post('first_name');
         $update['last_name'] = $this->input->post('last_name');
         $update['telephone'] = $this->input->post('telephone');
         $update['security_question_id'] = $this->input->post('security_question_id');
         $update['security_answer'] = $this->input->post('security_answer');
         $update['password'] = $this->input->post('new_password');
         $update['newsletter'] = $this->input->post('newsletter');
         $update['status'] = '1';
         // END: retrieve $_POST data if $_POST data is not same as existing customer library data
         if (!empty($update)) {
             // if update array is not empty then update customer details and display success message
             if ($this->Customers_model->saveCustomer($this->customer->getId(), $update)) {
                 log_activity($this->customer->getId(), 'updated', 'customers', get_activity_message('activity_updated_account', array('{customer}', '{link}'), array($this->customer->getName(), admin_url('customers/edit?id=' . $this->customer->getId()))));
                 if (!empty($update['password'])) {
                     log_activity($this->customer->getId(), 'updated', 'customers', get_activity_message('activity_changed_password', array('{customer}', '{link}'), array($this->customer->getName(), admin_url('customers/edit?id=' . $this->customer->getId()))));
                 }
                 $this->alert->set('alert', $this->lang->line('alert_updated_success'));
             }
             return TRUE;
         }
     }
 }
Example #4
0
 private function _addCustomer()
 {
     if ($this->validateForm() === TRUE) {
         $this->load->model('Customers_model');
         // load the customers model
         $this->load->model('Customer_groups_model');
         $add = array();
         // if successful CREATE an array with the following $_POST data values
         $add['first_name'] = $this->input->post('first_name');
         $add['last_name'] = $this->input->post('last_name');
         $add['email'] = $this->input->post('email');
         $add['password'] = $this->input->post('password');
         $add['telephone'] = $this->input->post('telephone');
         $add['security_question_id'] = $this->input->post('security_question');
         $add['security_answer'] = $this->input->post('security_answer');
         $add['newsletter'] = $this->input->post('newsletter');
         $add['terms_condition'] = $this->input->post('terms_condition');
         $add['customer_group_id'] = $this->config->item('customer_group_id');
         $add['date_added'] = mdate('%Y-%m-%d', time());
         $result = $this->Customer_groups_model->getCustomerGroup($this->config->item('customer_group_id'));
         if ($result['approval'] === '1') {
             $add['status'] = '0';
         } else {
             $add['status'] = '1';
         }
         if (!empty($add) and $customer_id = $this->Customers_model->saveCustomer(NULL, $add)) {
             // pass add array data to saveCustomer method in Customers model then return TRUE
             log_activity($customer_id, 'registered', 'customers', get_activity_message('activity_registered_account', array('{customer}', '{link}'), array($this->input->post('first_name') . ' ' . $this->input->post('last_name'), admin_url('customers/edit?id=' . $customer_id))));
             return TRUE;
         }
     }
 }
Example #5
0
 public function index()
 {
     $this->lang->load('login');
     log_activity($this->user->getStaffId(), 'logged out', 'staffs', get_activity_message('activity_logged_out', array('{staff}', '{link}'), array($this->user->getStaffName(), admin_url('staffs/edit?id=' . $this->user->getStaffId()))));
     $this->user->logout();
     $this->alert->set('success', $this->lang->line('alert_success_logout'));
     redirect('login');
 }
Example #6
0
 public function index()
 {
     $this->load->model('Pages_model');
     $this->lang->load('account/login_register');
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/logout');
     $this->template->setTitle($this->lang->line('text_logout_heading'));
     $this->alert->set('success', $this->lang->line('alert_logout_success'));
     log_activity($this->customer->getId(), 'logged out', 'customers', get_activity_message('activity_logged_out', array('{customer}', '{link}'), array($this->customer->getName(), admin_url('customers/edit?id=' . $this->customer->getId()))));
     $this->customer->logout();
     if ($redirect_url = $this->input->get('redirect')) {
         redirect($redirect_url);
     }
     redirect('account/login');
 }
Example #7
0
 private function _uploadExtension()
 {
     $this->user->restrict('Admin.Modules.Add', site_url('extensions/add'));
     if (isset($_FILES['extension_zip'])) {
         if ($this->validateUpload() === TRUE) {
             if ($this->Extensions_model->upload('module', $_FILES['extension_zip'])) {
                 $extension_name = basename($_FILES['extension_zip']['name'], '.zip');
                 log_activity($this->user->getStaffId(), 'uploaded', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'uploaded', 'extension', $extension_name)));
                 $alert = sprintf($this->lang->line('alert_success'), "Extension {$extension_name} uploaded ");
                 $alert .= sprintf($this->lang->line('alert_install'), site_url('extensions/install?name=') . $extension_name);
                 $this->alert->set('success', $alert);
                 return TRUE;
             }
             $this->alert->danger_now($this->lang->line('alert_error_try_again'));
         }
     }
     return FALSE;
 }
 public function addReservation($add = array())
 {
     if (empty($add)) {
         return FALSE;
     }
     if (isset($add['location_id'])) {
         $this->db->set('location_id', $add['location_id']);
     }
     if (isset($add['table_id'])) {
         $this->db->set('table_id', $add['table_id']);
     }
     if (isset($add['customer_id'])) {
         $this->db->set('customer_id', $add['customer_id']);
     }
     if (isset($add['guest_num'])) {
         $this->db->set('guest_num', $add['guest_num']);
     }
     if (isset($add['reserve_date'])) {
         $this->db->set('reserve_date', mdate('%Y-%m-%d', strtotime($add['reserve_date'])));
     }
     if (isset($add['reserve_time'])) {
         $this->db->set('reserve_time', $add['reserve_time']);
         $this->db->set('date_added', mdate('%Y-%m-%d %H:%i:%s', time()));
         $this->db->set('date_modified', mdate('%Y-%m-%d', time()));
     }
     if (isset($add['occasion_id'])) {
         $this->db->set('occasion_id', $add['occasion_id']);
     }
     if (isset($add['customer_id'])) {
         $this->db->set('customer_id', $add['customer_id']);
     }
     if (isset($add['first_name'])) {
         $this->db->set('first_name', $add['first_name']);
     }
     if (isset($add['last_name'])) {
         $this->db->set('last_name', $add['last_name']);
     }
     if (isset($add['email'])) {
         $this->db->set('email', $add['email']);
     }
     if (isset($add['telephone'])) {
         $this->db->set('telephone', $add['telephone']);
     }
     if (isset($add['comment'])) {
         $this->db->set('comment', $add['comment']);
     }
     if (isset($add['user_agent'])) {
         $this->db->set('user_agent', $add['user_agent']);
     }
     if (isset($add['ip_address'])) {
         $this->db->set('ip_address', $add['ip_address']);
     }
     if (!empty($add)) {
         if ($this->db->insert('reservations')) {
             $reservation_id = $this->db->insert_id();
             if (APPDIR === MAINDIR) {
                 log_activity($add['customer_id'], 'reserved', 'reservations', get_activity_message('activity_reserved_table', array('{customer}', '{link}', '{reservation_id}'), array($add['first_name'] . ' ' . $add['last_name'], admin_url('reservations/edit?id=' . $reservation_id), $reservation_id)));
             }
             $this->load->model('Mail_templates_model');
             $mail_data = $this->getMailData($reservation_id);
             $config_reservation_email = is_array($this->config->item('reservation_email')) ? $this->config->item('reservation_email') : array();
             $notify = '0';
             if ($this->config->item('customer_reserve_email') === '1' or in_array('customer', $config_reservation_email)) {
                 $mail_template = $this->Mail_templates_model->getTemplateData($this->config->item('mail_template_id'), 'reservation');
                 $notify = $this->sendMail($mail_data['email'], $mail_template, $mail_data);
             }
             if ($this->location->getEmail() and ($this->config->item('location_reserve_email') === '1' or in_array('location', $config_reservation_email))) {
                 $mail_template = $this->Mail_templates_model->getTemplateData($this->config->item('mail_template_id'), 'reservation_alert');
                 $this->sendMail($this->location->getEmail(), $mail_template, $mail_data);
             }
             if (in_array('admin', $config_reservation_email)) {
                 $mail_template = $this->Mail_templates_model->getTemplateData($this->config->item('mail_template_id'), 'reservation_alert');
                 $this->sendMail($this->config->item('site_email'), $mail_template, $mail_data);
             }
             $this->db->set('notify', $notify);
             $this->db->set('status', $this->config->item('default_reservation_status'));
             $this->db->where('reservation_id', $reservation_id);
             if ($this->db->update('reservations')) {
                 $this->load->model('Statuses_model');
                 $status = $this->Statuses_model->getStatus($this->config->item('default_reservation_status'));
                 $reserve_history = array('object_id' => $reservation_id, 'status_id' => $status['status_id'], 'notify' => $notify, 'comment' => $status['status_comment'], 'date_added' => mdate('%Y-%m-%d %H:%i:%s', time()));
                 $this->Statuses_model->addStatusHistory('reserve', $reserve_history);
             }
             $query = $reservation_id;
         }
     }
     return $query;
 }
 public function updateExtension($type = 'module', $name = NULL, $data = array(), $log_activity = TRUE)
 {
     if ($name === NULL) {
         return FALSE;
     }
     $name = url_title(strtolower($name), '-');
     !isset($data['data']) or $data = $data['data'];
     unset($data['save_close']);
     $query = FALSE;
     if ($this->extensionExists($name)) {
         $config = $this->extension->loadConfig($name, FALSE, TRUE);
         $meta = $this->extension->getMeta($name, $config);
         if (isset($meta['type'], $meta['title']) and $type === $meta['type']) {
             $this->db->set('data', is_array($data) ? serialize($data) : $data);
             $this->db->set('serialized', '1');
             $this->db->where('type', $meta['type']);
             $this->db->where('name', $name);
             $query = $this->db->update('extensions');
             if ($log_activity) {
                 log_activity($this->user->getStaffId(), 'updated', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'updated', 'extension ' . $meta['type'], $meta['title'])));
             }
         }
     }
     return $query;
 }
Example #10
0
 private function _savePermission()
 {
     if ($this->validateForm() === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($permission_id = $this->Permissions_model->savePermission($this->input->get('id'), $this->input->post())) {
             log_activity($this->user->getStaffId(), $save_type, 'permissions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), $save_type, 'permission', $this->input->post('name'))));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Permission ' . $save_type));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $permission_id;
     }
 }
 public function completeOrder($order_id, $order_info, $cart_contents = array())
 {
     if ($order_id and !empty($order_info)) {
         $notify = $this->sendConfirmationMail($order_id);
         $update = array('old_status_id' => '', 'order_status' => !empty($order_info['status_id']) ? (int) $order_info['status_id'] : (int) $this->config->item('default_order_status'), 'notify' => $notify);
         if ($this->updateOrder($order_id, $update)) {
             if (APPDIR === MAINDIR) {
                 log_activity($order_info['customer_id'], 'created', 'orders', get_activity_message('activity_created_order', array('{customer}', '{link}', '{order_id}'), array($order_info['first_name'] . ' ' . $order_info['last_name'], admin_url('orders/edit?id=' . $order_id), $order_id)));
             }
             Events::trigger('after_create_order', array('order_id' => $order_id));
             return TRUE;
         }
     }
 }
Example #12
0
 public function completeOrder($order_id, $order_info, $cart_contents)
 {
     if ($order_id and !empty($order_info)) {
         $this->addOrderMenus($order_id, $cart_contents);
         $order_totals = array('cart_total' => array('title' => 'Sub Total', 'value' => isset($cart_contents['cart_total']) ? $cart_contents['cart_total'] : ''), 'order_total' => array('title' => 'Order Total', 'value' => isset($cart_contents['order_total']) ? $cart_contents['order_total'] : ''), 'delivery' => array('title' => 'Delivery', 'value' => isset($cart_contents['delivery']) ? $cart_contents['delivery'] : ''), 'coupon' => array('title' => 'Coupon (' . $cart_contents['coupon']['code'] . ') ', 'value' => $cart_contents['coupon']['discount']));
         if (!empty($cart_contents['taxes'])) {
             $order_totals['taxes'] = array('title' => $cart_contents['taxes']['title'], 'value' => $cart_contents['taxes']['amount']);
         }
         $this->addOrderTotals($order_id, $order_totals);
         if (!empty($cart_contents['coupon'])) {
             $this->addOrderCoupon($order_id, $order_info['customer_id'], $cart_contents['coupon']);
         }
         $notify = $this->sendConfirmationMail($order_id);
         $update = array('old_status_id' => '', 'order_status' => !empty($order_info['status_id']) ? (int) $order_info['status_id'] : (int) $this->config->item('default_order_status'), 'notify' => $notify);
         if ($this->updateOrder($order_id, $update)) {
             if (APPDIR === MAINDIR) {
                 log_activity($order_info['customer_id'], 'created', 'orders', get_activity_message('activity_created_order', array('{customer}', '{link}', '{order_id}'), array($order_info['first_name'] . ' ' . $order_info['last_name'], admin_url('orders/edit?id=' . $order_id), $order_id)));
             }
             return TRUE;
         }
     }
 }
Example #13
0
 private function _saveReview()
 {
     if ($this->validateForm() === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($review_id = $this->Reviews_model->saveReview($this->input->get('id'), $this->input->post())) {
             log_activity($this->user->getStaffId(), $save_type, 'reviews', get_activity_message('activity_custom', array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), $save_type, 'review', current_url(), $this->input->get('id'))));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Review ' . $save_type));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $review_id;
     }
 }
 public function addReservation($add = array())
 {
     $query = FALSE;
     if (!empty($add['location_id'])) {
         $this->db->set('location_id', $add['location_id']);
     }
     if (!empty($add['table_id'])) {
         $this->db->set('table_id', $add['table_id']);
     }
     if (!empty($add['customer_id'])) {
         $this->db->set('customer_id', $add['customer_id']);
     }
     if (!empty($add['guest_num'])) {
         $this->db->set('guest_num', $add['guest_num']);
     }
     if (!empty($add['reserve_date'])) {
         $this->db->set('reserve_date', mdate('%Y-%m-%d', strtotime($add['reserve_date'])));
     }
     if (!empty($add['reserve_time'])) {
         $this->db->set('reserve_time', $add['reserve_time']);
         $this->db->set('date_added', mdate('%Y-%m-%d %H:%i:%s', time()));
         $this->db->set('date_modified', mdate('%Y-%m-%d', time()));
     }
     if (!empty($add['occasion_id'])) {
         $this->db->set('occasion_id', $add['occasion_id']);
     }
     if (!empty($add['customer_id'])) {
         $this->db->set('customer_id', $add['customer_id']);
     }
     if (!empty($add['first_name'])) {
         $this->db->set('first_name', $add['first_name']);
     }
     if (!empty($add['last_name'])) {
         $this->db->set('last_name', $add['last_name']);
     }
     if (!empty($add['email'])) {
         $this->db->set('email', $add['email']);
     }
     if (!empty($add['telephone'])) {
         $this->db->set('telephone', $add['telephone']);
     }
     if (!empty($add['comment'])) {
         $this->db->set('comment', $add['comment']);
     }
     if (!empty($add['user_agent'])) {
         $this->db->set('user_agent', $add['user_agent']);
     }
     if (!empty($add['ip_address'])) {
         $this->db->set('ip_address', $add['ip_address']);
     }
     if (!empty($add)) {
         if ($this->db->insert('reservations')) {
             $reservation_id = $this->db->insert_id();
             if (APPDIR === MAINDIR) {
                 log_activity($add['customer_id'], 'reserved', 'reservations', get_activity_message('activity_reserved_table', array('{customer}', '{link}', '{reservation_id}'), array($add['first_name'] . ' ' . $add['last_name'], admin_url('reservations/edit?id=' . $reservation_id), $reservation_id)));
             }
             $notify = $this->_sendMail($reservation_id);
             $this->db->set('notify', $notify);
             $this->db->set('status', $this->config->item('new_reservation_status'));
             $this->db->where('reservation_id', $reservation_id);
             if ($this->db->update('reservations')) {
                 $this->load->model('Statuses_model');
                 $status = $this->Statuses_model->getStatus($this->config->item('new_reservation_status'));
                 $reserve_history = array('object_id' => $reservation_id, 'status_id' => $status['status_id'], 'notify' => $notify, 'comment' => $status['status_comment'], 'date_added' => mdate('%Y-%m-%d %H:%i:%s', time()));
                 $this->Statuses_model->addStatusHistory('reserve', $reserve_history);
             }
             $query = $reservation_id;
         }
     }
     return $query;
 }
Example #15
0
 private function _addExtension()
 {
     $this->user->restrict('Admin.Extensions.Add', site_url('extensions/add'));
     if (isset($_FILES['extension_zip'])) {
         if ($this->validateUpload() === TRUE) {
             $message = $this->Extensions_model->extractExtension($_FILES['extension_zip']);
             if ($message === TRUE) {
                 $extension_name = $_FILES['extension_zip']['name'];
                 $config = $this->extension->loadConfig($extension_name, FALSE, TRUE);
                 $extension_title = isset($config['extension_meta']['title']) ? $config['extension_meta']['title'] : '';
                 $extension_type = isset($config['extension_meta']['type']) ? $config['extension_meta']['type'] : '';
                 $alert = "Extension {$extension_title} uploaded ";
                 if ($this->Extensions_model->install($extension_type, $extension_name, $config)) {
                     log_activity($this->user->getStaffId(), 'installed', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'installed', $extension_type . ' extension', $extension_title)));
                     $alert .= "and installed ";
                 }
                 $this->alert->set('success', sprintf($this->lang->line('alert_success'), $alert));
                 return TRUE;
             }
             $this->alert->danger_now(sprintf($this->lang->line('alert_error'), $message));
         }
     }
     return FALSE;
 }
Example #16
0
 private function _addTheme()
 {
     $this->user->restrict('Site.Themes.Add', site_url('extensions/add'));
     if (isset($_FILES['theme_zip'])) {
         if ($this->validateUpload() === TRUE) {
             $message = $this->Themes_model->extractTheme($_FILES['theme_zip']);
             if ($message === TRUE) {
                 $theme_name = $_FILES['theme_zip']['name'];
                 log_activity($this->user->getStaffId(), 'added', 'themes', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'added', 'a new theme', $theme_name)));
                 $this->alert->set('success', sprintf($this->lang->line('alert_success'), "Theme {$theme_name} added "));
                 return TRUE;
             }
             $this->alert->danger_now(sprintf($this->lang->line('alert_error'), $message));
         }
     }
     return FALSE;
 }
Example #17
0
 private function _updateReservation()
 {
     if (is_numeric($this->input->get('id')) and $this->validateForm() === TRUE) {
         if ($this->Reservations_model->updateReservation($this->input->get('id'), $this->input->post())) {
             log_activity($this->user->getStaffId(), 'updated', 'reservations', get_activity_message('activity_custom', array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), 'updated', 'reservation', current_url(), $this->input->get('id'))));
             if ($this->input->post('old_assignee_id') !== $this->input->post('assignee_id')) {
                 log_activity($this->user->getStaffId(), 'assigned', 'reservations', get_activity_message('activity_assigned', array('{staff}', '{action}', '{context}', '{link}', '{item}', '{assignee}'), array($this->user->getStaffName(), 'assigned', 'reservation', current_url(), $this->input->get('id'), $this->input->post('assignee_id'))));
             }
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Reservation updated'));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), 'updated'));
         }
         return TRUE;
     }
 }
Example #18
0
 private function _uninstall()
 {
     if ($this->input->get('action') === 'uninstall') {
         if ($this->Extensions_model->uninstall('payment', $this->input->get('name'), $this->input->get('id'))) {
             log_activity($this->user->getStaffId(), 'uninstalled', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'uninstalled', 'extension payment', $this->input->get('name'))));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Payment uninstalled '));
             return TRUE;
         }
         $this->alert->danger_now($this->lang->line('alert_error_try_again'));
         return TRUE;
     }
 }
Example #19
0
 private function _saveMenu()
 {
     if ($this->validateForm() === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($menu_id = $this->Menus_model->saveMenu($this->input->get('id'), $this->input->post())) {
             log_activity($this->user->getStaffId(), $save_type, 'menus', get_activity_message('activity_custom', array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), $save_type, 'menu item', site_url('menus/edit?id=' . $menu_id), $this->input->post('menu_name'))));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Menu ' . $save_type));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $menu_id;
     }
 }
Example #20
0
 public function addOrder($order_info = array(), $cart_contents = array())
 {
     $query = FALSE;
     $current_time = time();
     if (!empty($order_info['location_id'])) {
         $this->db->set('location_id', $order_info['location_id']);
     }
     if (!empty($order_info['customer_id'])) {
         $this->db->set('customer_id', $order_info['customer_id']);
     } else {
         $this->db->set('customer_id', '0');
     }
     if (!empty($order_info['first_name'])) {
         $this->db->set('first_name', $order_info['first_name']);
     }
     if (!empty($order_info['last_name'])) {
         $this->db->set('last_name', $order_info['last_name']);
     }
     if (!empty($order_info['email'])) {
         $this->db->set('email', $order_info['email']);
     }
     if (!empty($order_info['telephone'])) {
         $this->db->set('telephone', $order_info['telephone']);
     }
     if (!empty($order_info['order_type'])) {
         $this->db->set('order_type', $order_info['order_type']);
     }
     if (!empty($order_info['order_time'])) {
         $order_time = strtotime($order_info['order_time']) < strtotime($current_time) ? $current_time : $order_info['order_time'];
         $this->db->set('order_time', mdate('%H:%i', strtotime($order_time)));
         $this->db->set('date_added', mdate('%Y-%m-%d %H:%i:%s', $current_time));
         $this->db->set('date_modified', mdate('%Y-%m-%d', $current_time));
         $this->db->set('ip_address', $this->input->ip_address());
         $this->db->set('user_agent', $this->input->user_agent());
     }
     if (!empty($order_info['address_id'])) {
         $this->db->set('address_id', $order_info['address_id']);
     }
     if (!empty($order_info['payment'])) {
         $this->db->set('payment', $order_info['payment']);
     }
     if (!empty($order_info['comment'])) {
         $this->db->set('comment', $order_info['comment']);
     }
     if (isset($cart_contents['order_total'])) {
         $this->db->set('order_total', $cart_contents['order_total']);
     }
     if (isset($cart_contents['total_items'])) {
         $this->db->set('total_items', $cart_contents['total_items']);
     }
     if (!empty($order_info)) {
         if (isset($order_info['order_id'])) {
             $_action = 'updated';
             $this->db->where('order_id', $order_info['order_id']);
             $query = $this->db->update('orders');
             $order_id = $order_info['order_id'];
         } else {
             $_action = 'added';
             $query = $this->db->insert('orders');
             $order_id = $this->db->insert_id();
         }
         if ($query and $order_id) {
             if (isset($order_info['address_id'])) {
                 $this->load->model('Addresses_model');
                 $this->Addresses_model->updateDefault($order_info['customer_id'], $order_info['address_id']);
             }
             if ($_action === 'added' and APPDIR === MAINDIR) {
                 log_activity($order_info['customer_id'], 'created', 'orders', get_activity_message('activity_created_order', array('{customer}', '{link}', '{order_id}'), array($order_info['first_name'] . ' ' . $order_info['last_name'], admin_url('orders/edit?id=' . $order_id), $order_id)));
             }
             return $order_id;
         }
     }
 }
Example #21
0
 private function _saveStaff($staff_email, $username)
 {
     if ($this->validateForm($staff_email, $username) === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($staff_id = $this->Staffs_model->saveStaff($this->input->get('id'), $this->input->post())) {
             $action = $this->input->get('id') === $this->user->getStaffId() ? $save_type . ' their' : $save_type;
             $message_lang = $this->input->get('id') === $this->user->getStaffId() ? 'activity_custom_no_link' : 'activity_custom';
             $item = $this->input->get('id') === $this->user->getStaffId() ? 'details' : ucwords($username);
             log_activity($this->user->getStaffId(), $action, 'staffs', get_activity_message($message_lang, array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), $action, 'staff', current_url(), $item)));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Staff ' . $save_type));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $staff_id;
     }
 }
Example #22
0
 private function _updateOrder()
 {
     if (is_numeric($this->input->get('id')) and $this->validateForm() === TRUE) {
         if ($this->Orders_model->updateOrder($this->input->get('id'), $this->input->post())) {
             log_activity($this->user->getStaffId(), 'updated', 'orders', get_activity_message('activity_custom', array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), 'updated', 'order', current_url(), '#' . $this->input->get('id'))));
             if ($this->input->post('assignee_id') and $this->input->post('old_assignee_id') !== $this->input->post('assignee_id')) {
                 $staff = $this->Staffs_model->getStaff($this->input->post('assignee_id'));
                 $staff_assignee = site_url('staffs/edit?id=' . $staff['staff_id']);
                 log_activity($this->user->getStaffId(), 'assigned', 'orders', get_activity_message('activity_assigned', array('{staff}', '{action}', '{context}', '{link}', '{item}', '{assignee}'), array($this->user->getStaffName(), 'assigned', 'order', current_url(), '#' . $this->input->get('id'), "<a href=\"{$staff_assignee}\">{$staff['staff_name']}</a>")));
             }
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Order updated'));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), 'updated'));
         }
         return TRUE;
     }
 }
Example #23
0
 public function updateExtension($update = array(), $serialized = '0')
 {
     $query = FALSE;
     if (!empty($update['type']) and !empty($update['name'])) {
         $update['name'] = url_title(strtolower($update['name']), '-');
         if ($this->extensionExists($update['name'])) {
             if (empty($update['extension_id'])) {
                 $update['extension_id'] = $this->install($update['type'], $update['name']);
             }
             if (isset($update['data']) and $serialized === '1') {
                 $this->db->set('data', serialize($update['data']));
             } else {
                 if (!empty($update['data'])) {
                     $this->db->set('data', $update['data']);
                 }
             }
             $this->db->set('serialized', $serialized);
             if (!empty($update['title'])) {
                 $this->db->set('title', $update['title']);
             }
             $this->db->where('type', $update['type']);
             $this->db->where('name', $update['name']);
             if (!empty($update['extension_id'])) {
                 $this->db->where('extension_id', $update['extension_id']);
                 $query = $this->db->update('extensions');
                 log_activity($this->user->getStaffId(), 'updated', 'extensions', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'updated', 'extension ' . $update['type'], $update['title'])));
             }
         }
     }
     return $query;
 }
Example #24
0
 private function _saveCustomer($customer_email)
 {
     if ($this->validateForm($customer_email) === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($customer_id = $this->Customers_model->saveCustomer($this->input->get('id'), $this->input->post())) {
             $customer_name = $this->input->post('first_name') . ' ' . $this->input->post('last_name');
             log_activity($this->user->getStaffId(), $save_type, 'customers', get_activity_message('activity_custom', array('{staff}', '{action}', '{context}', '{link}', '{item}'), array($this->user->getStaffName(), $save_type, 'customer', site_url('customers/edit?id=' . $customer_id), $customer_name)));
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Customer ' . $save_type));
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $customer_id;
     }
 }