예제 #1
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $data['activities'] = $activities = array();
     $results = $this->Activities_model->getList($filter);
     foreach ($results as $result) {
         $day_elapsed = day_elapsed($result['date_added']);
         $data['activities'][$day_elapsed][] = array('activity_id' => $result['activity_id'], 'domain' => $result['domain'], 'action' => $result['action'], 'icon' => 'fa fa-tasks', 'message' => $result['message'], 'time' => mdate('%h:%i %A', strtotime($result['date_added'])), 'time_elapsed' => time_elapsed($result['date_added']), 'day_elapsed' => $day_elapsed, 'status' => $result['status'] === '1' ? 'read' : 'unread');
     }
     $config['base_url'] = site_url('activities' . $url);
     $config['total_rows'] = $this->Activities_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('activities', $data);
 }
예제 #2
0
 public function index()
 {
     $time_format = $this->config->item('time_format') ? $this->config->item('time_format') : '%h:%i %a';
     $data['inbox_total'] = $this->Messages_model->getUnreadCount($this->customer->getId());
     // retrieve total number of customer messages from getUnreadCount method in Messages model
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/account');
     $this->template->setTitle($this->lang->line('text_heading'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $data['checkout_url'] = site_url('checkout');
     $data['password_url'] = site_url('account/details');
     $data['cart_items'] = $this->cart->total_items();
     $data['cart_total'] = $this->currency->format($this->cart->order_total());
     $result = $this->Customers_model->getCustomer($this->customer->getId());
     // retrieve customer data based on customer id from getCustomer method in Customers model
     $question_result = $this->Security_questions_model->getQuestion($result['security_question_id']);
     // retrieve security questions based on security question id
     //store customer data in array
     $data['customer_info'] = array('first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'email' => $result['email'], 'telephone' => $result['telephone'], 'security_question' => isset($question_result['text']) ? $question_result['text'] : '', 'security_answer' => '******');
     $data['address_info'] = array();
     $result = $this->Addresses_model->getAddress($this->customer->getId(), $this->customer->getAddressId());
     // retrieve customer address data based on customer address id from getAddress method in Customers model
     if ($result) {
         $data['address_info'] = $this->country->addressFormat($result);
         $data['address_info_edit'] = site_url('account/address/edit/' . $this->customer->getAddressId());
     }
     $filter = array('customer_id' => $this->customer->getId(), 'limit' => '5', 'page' => '', 'order_by' => 'DESC');
     $data['orders'] = array();
     $results = $this->Orders_model->getList($filter + array('sort_by' => 'order_id'));
     // retrieve customer orders based on customer id from getMainOrders method in Orders model
     foreach ($results as $result) {
         $data['orders'][] = array('order_id' => $result['order_id'], 'order_date' => day_elapsed($result['order_date']), 'order_time' => mdate($time_format, strtotime($result['order_time'])), 'status_name' => $result['status_name'], 'view' => site_url('account/orders/view/' . $result['order_id']));
     }
     $data['reservations'] = array();
     $results = $this->Reservations_model->getList($filter + array('sort_by' => 'reserve_date'));
     // retrieve customer reservations based on customer id from getMainReservations method in Reservations model
     foreach ($results as $result) {
         $data['reservations'][] = array('reservation_id' => $result['reservation_id'], 'status_name' => $result['status_name'], 'reserve_date' => day_elapsed($result['reserve_date']), 'reserve_time' => mdate($time_format, strtotime($result['reserve_time'])), 'view' => site_url('account/reservations/view/' . $result['reservation_id']));
     }
     $data['messages'] = array();
     $results = $this->Messages_model->getList($filter + array('sort_by' => 'messages.date_added'));
     // retrieve all customer messages from getMainInbox method in Messages model
     foreach ($results as $result) {
         $data['messages'][] = array('date_added' => day_elapsed($result['date_added']), 'subject' => $result['subject'], 'body' => substr(strip_tags(html_entity_decode($result['body'], ENT_QUOTES, 'UTF-8')), 0, 50) . '..', 'state' => $result['state'] === '0' ? 'unread' : 'read', 'view' => site_url('account/inbox/view/' . $result['message_id']));
     }
     $this->template->render('account/account', $data);
 }
예제 #3
0
 public function index()
 {
     $url = '?';
     $filter = array();
     $filter['customer_id'] = (int) $this->customer->getId();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     $filter['sort_by'] = $data['sort_by'] = 'date_added';
     $filter['order_by'] = $data['order_by'] = 'DESC';
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_my_account'), 'account/account');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/orders');
     $this->template->setTitle($this->lang->line('text_heading'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $data['back_url'] = site_url('account/account');
     $this->load->library('location');
     $this->location->initialize();
     if ($this->location->local()) {
         $data['new_order_url'] = site_url('local?location_id=' . $this->location->getId());
     } else {
         $data['new_order_url'] = site_url('local/all');
     }
     $time_format = $this->config->item('time_format') ? $this->config->item('time_format') : '%h:%i %a';
     $data['orders'] = array();
     $results = $this->Orders_model->getList($filter);
     // retrieve customer orders based on customer id from getMainOrders method in Orders model
     foreach ($results as $result) {
         // if order type is equal to 1, order type is delivery else collection
         $order_type = $result['order_type'] === '1' ? $this->lang->line('text_delivery') : $this->lang->line('text_collection');
         $data['orders'][] = array('order_id' => $result['order_id'], 'location_name' => $result['location_name'], 'date_added' => day_elapsed($result['date_added']), 'order_date' => day_elapsed($result['order_date']), 'order_time' => mdate($time_format, strtotime($result['order_time'])), 'total_items' => $result['total_items'], 'order_total' => $this->currency->format($result['order_total']), 'order_type' => ucwords(strtolower($order_type)), 'status_name' => $result['status_name'], 'view' => site_url('account/orders/view/' . $result['order_id']), 'reorder' => site_url('account/orders/reorder/' . $result['order_id'] . '/' . $result['location_id']), 'leave_review' => site_url('account/reviews/add/order/' . $result['order_id'] . '/' . $result['location_id']));
     }
     $prefs['base_url'] = site_url('account/orders' . $url);
     $prefs['total_rows'] = $this->Orders_model->getCount($filter);
     $prefs['per_page'] = $filter['limit'];
     $this->load->library('pagination');
     $this->pagination->initialize($prefs);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->render('account/orders', $data);
 }
예제 #4
0
 public function index()
 {
     $url = '?';
     $filter = array();
     $filter['customer_id'] = (int) $this->customer->getId();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     $filter['sort_by'] = 'reserve_date';
     $filter['order_by'] = 'DESC';
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_my_account'), 'account/account');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/reservations');
     $this->template->setTitle($this->lang->line('text_heading'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $data['back_url'] = site_url('account/account');
     $data['new_reservation_url'] = site_url('reservation');
     $date_format = $this->config->item('date_format') ? $this->config->item('date_format') : '%d %M %y';
     $time_format = $this->config->item('time_format') ? $this->config->item('time_format') : '%h:%i %a';
     $data['reservations'] = array();
     $results = $this->Reservations_model->getList($filter);
     // retrieve customer reservations based on customer id from getMainReservations method in Reservations model
     foreach ($results as $result) {
         $data['reservations'][] = array('reservation_id' => $result['reservation_id'], 'location_name' => $result['location_name'], 'status_name' => $result['status_name'], 'reserve_date' => day_elapsed($result['reserve_date']), 'reserve_time' => mdate($time_format, strtotime($result['reserve_time'])), 'guest_num' => $result['guest_num'], 'table_name' => $result['table_name'], 'view' => site_url('account/reservations/view/' . $result['reservation_id']), 'leave_review' => site_url('account/reviews/add/reservation/' . $result['reservation_id'] . '/' . $result['location_id']));
     }
     $prefs['base_url'] = site_url('account/reservations' . $url);
     $prefs['total_rows'] = $this->Reservations_model->getCount($filter);
     $prefs['per_page'] = $filter['limit'];
     $this->load->library('pagination');
     $this->pagination->initialize($prefs);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->render('account/reservations', $data);
 }
예제 #5
0
 public function index()
 {
     $this->user->restrict('Admin.Staffs');
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_group')) {
         $filter['filter_group'] = $data['filter_group'] = $this->input->get('filter_group');
         $url .= 'filter_group=' . $filter['filter_group'] . '&';
     } else {
         $filter['filter_group'] = $data['filter_group'] = '';
     }
     if (is_numeric($this->input->get('filter_location'))) {
         $filter['filter_location'] = $data['filter_location'] = $this->input->get('filter_location');
         $url .= 'filter_location=' . $filter['filter_location'] . '&';
     } else {
         $filter['filter_location'] = $data['filter_location'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'staffs.date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('staffs' . $url . 'sort_by=staff_name&order_by=' . $order_by);
     $data['sort_group'] = site_url('staffs' . $url . 'sort_by=staff_group_name&order_by=' . $order_by);
     $data['sort_location'] = site_url('staffs' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_date'] = site_url('staffs' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $data['sort_id'] = site_url('staffs' . $url . 'sort_by=staff_id&order_by=' . $order_by);
     $data['staffs'] = array();
     $results = $this->Staffs_model->getList($filter);
     foreach ($results as $result) {
         $data['staffs'][] = array('staff_id' => $result['staff_id'], 'staff_name' => $result['staff_name'], 'staff_email' => $result['staff_email'], 'staff_group_name' => $result['staff_group_name'], 'location_name' => $result['location_name'], 'date_added' => day_elapsed($result['date_added']), 'staff_status' => $result['staff_status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'edit' => site_url('staffs/edit?id=' . $result['staff_id']));
     }
     $data['staff_groups'] = array();
     $results = $this->Staff_groups_model->getStaffGroups();
     foreach ($results as $result) {
         $data['staff_groups'][] = array('staff_group_id' => $result['staff_group_id'], 'staff_group_name' => $result['staff_group_name']);
     }
     $this->load->model('Locations_model');
     $data['locations'] = array();
     $results = $this->Locations_model->getLocations();
     foreach ($results as $result) {
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']);
     }
     $data['staff_dates'] = array();
     $staff_dates = $this->Staffs_model->getStaffDates();
     foreach ($staff_dates as $staff_date) {
         $month_year = $staff_date['year'] . '-' . $staff_date['month'];
         $data['staff_dates'][$month_year] = mdate('%F %Y', strtotime($staff_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('staffs' . $url);
     $config['total_rows'] = $this->Staffs_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteStaff() === TRUE) {
         redirect('staffs');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('staffs', $data);
 }
예제 #6
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_first'] = site_url('customers' . $url . 'sort_by=first_name&order_by=' . $order_by);
     $data['sort_last'] = site_url('customers' . $url . 'sort_by=last_name&order_by=' . $order_by);
     $data['sort_email'] = site_url('customers' . $url . 'sort_by=email&order_by=' . $order_by);
     $data['sort_date'] = site_url('customers' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $data['sort_id'] = site_url('customers' . $url . 'sort_by=customer_id&order_by=' . $order_by);
     $data['customers'] = array();
     $results = $this->Customers_model->getList($filter);
     foreach ($results as $result) {
         $data['customers'][] = array('customer_id' => $result['customer_id'], 'first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'email' => $result['email'], 'telephone' => $result['telephone'], 'date_added' => day_elapsed($result['date_added']), 'status' => $result['status'] === '1' ? 'Enabled' : 'Disabled', 'edit' => site_url('customers/edit?id=' . $result['customer_id']));
     }
     $data['questions'] = array();
     $results = $this->Security_questions_model->getQuestions();
     foreach ($results as $result) {
         $data['questions'][] = array('id' => $result['question_id'], 'text' => $result['text']);
     }
     $data['country_id'] = $this->config->item('country_id');
     $data['countries'] = array();
     $results = $this->Countries_model->getCountries();
     // retrieve countries array from getCountries method in locations model
     foreach ($results as $result) {
         // loop through crountries array
         $data['countries'][] = array('country_id' => $result['country_id'], 'name' => $result['country_name']);
     }
     $data['customer_dates'] = array();
     $customer_dates = $this->Customers_model->getCustomerDates();
     foreach ($customer_dates as $customer_date) {
         $month_year = '';
         $month_year = $customer_date['year'] . '-' . $customer_date['month'];
         $data['customer_dates'][$month_year] = mdate('%F %Y', strtotime($customer_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('customers' . $url);
     $config['total_rows'] = $this->Customers_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteCustomer() === TRUE) {
         redirect('customers');
     }
     $this->template->render('customers', $data);
 }
예제 #7
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($data['user_strict_location'] = $this->user->isStrictLocation()) {
         $filter['filter_location'] = $data['filter_location'] = $this->user->getLocationId();
         $url .= 'filter_location=' . $filter['filter_location'] . '&';
     } else {
         if (is_numeric($this->input->get('filter_location'))) {
             $filter['filter_location'] = $data['filter_location'] = $this->input->get('filter_location');
             $url .= 'filter_location=' . $filter['filter_location'] . '&';
         } else {
             $filter['filter_location'] = $data['filter_location'] = '';
         }
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
         $data['filter_status'] = '';
     }
     if (is_numeric($this->input->get('filter_type'))) {
         $filter['filter_type'] = $data['filter_type'] = $this->input->get('filter_type');
         $url .= 'filter_type=' . $filter['filter_type'] . '&';
     } else {
         $filter['filter_type'] = $data['filter_type'] = '';
     }
     if ($this->input->get('filter_payment')) {
         $filter['filter_payment'] = $data['filter_payment'] = $this->input->get('filter_payment');
         $url .= 'filter_payment=' . $filter['filter_payment'] . '&';
     } else {
         $filter['filter_payment'] = $data['filter_payment'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => 'confirmDelete();'));
     if ($this->input->post('delete') and $this->_deleteOrder() === TRUE) {
         redirect('orders');
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_id'] = site_url('orders' . $url . 'sort_by=order_id&order_by=' . $order_by);
     $data['sort_location'] = site_url('orders' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_customer'] = site_url('orders' . $url . 'sort_by=first_name&order_by=' . $order_by);
     $data['sort_status'] = site_url('orders' . $url . 'sort_by=status_name&order_by=' . $order_by);
     $data['sort_type'] = site_url('orders' . $url . 'sort_by=order_type&order_by=' . $order_by);
     $data['sort_payment'] = site_url('orders' . $url . 'sort_by=payment&order_by=' . $order_by);
     $data['sort_total'] = site_url('orders' . $url . 'sort_by=order_total&order_by=' . $order_by);
     $data['sort_time'] = site_url('orders' . $url . 'sort_by=order_time&order_by=' . $order_by);
     $data['sort_date'] = site_url('orders' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $results = $this->Orders_model->getList($filter);
     $data['orders'] = array();
     foreach ($results as $result) {
         $payment_title = '--';
         if ($payment = $this->extension->getPayment($result['payment'])) {
             $payment_title = !empty($payment['ext_data']['title']) ? $payment['ext_data']['title'] : $payment['title'];
         }
         $data['orders'][] = array('order_id' => $result['order_id'], 'location_name' => $result['location_name'], 'first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'order_type' => $result['order_type'] === '1' ? $this->lang->line('text_delivery') : $this->lang->line('text_collection'), 'payment' => $payment_title, 'order_time' => mdate('%H:%i', strtotime($result['order_time'])), 'order_date' => day_elapsed($result['order_date']), 'order_status' => $result['status_name'], 'status_color' => $result['status_color'], 'order_total' => $this->currency->format($result['order_total']), 'date_added' => day_elapsed($result['date_added']), 'edit' => site_url('orders/edit?id=' . $result['order_id']));
     }
     $data['locations'] = array();
     $results = $this->Locations_model->getLocations();
     foreach ($results as $result) {
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']);
     }
     $data['statuses'] = array();
     $statuses = $this->Statuses_model->getStatuses('order');
     foreach ($statuses as $statuses) {
         $data['statuses'][] = array('status_id' => $statuses['status_id'], 'status_name' => $statuses['status_name']);
     }
     $data['payments'] = array();
     $payments = $this->extension->getPayments();
     foreach ($payments as $payment) {
         $data['payments'][] = array('name' => $payment['name'], 'title' => $payment['title']);
     }
     $data['order_dates'] = array();
     $order_dates = $this->Orders_model->getOrderDates();
     foreach ($order_dates as $order_date) {
         $month_year = $order_date['year'] . '-' . $order_date['month'];
         $data['order_dates'][$month_year] = mdate('%F %Y', strtotime($order_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('orders' . $url);
     $config['total_rows'] = $this->Orders_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->render('orders', $data);
 }
예제 #8
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if (is_numeric($this->input->get('show_calendar'))) {
         $filter['show_calendar'] = $data['show_calendar'] = $this->input->get('show_calendar');
         $url .= 'show_calendar=' . $filter['show_calendar'] . '&';
     } else {
         $data['show_calendar'] = '';
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_location'))) {
         $filter['filter_location'] = $data['filter_location'] = $this->input->get('filter_location');
         $url .= 'filter_location=' . $filter['filter_location'] . '&';
     } else {
         $filter['filter_location'] = $data['filter_location'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_year'))) {
         $filter['filter_year'] = $data['filter_year'] = $this->input->get('filter_year');
     } else {
         $filter['filter_year'] = $data['filter_year'] = '';
     }
     if (is_numeric($this->input->get('filter_month'))) {
         $filter['filter_month'] = $data['filter_month'] = $this->input->get('filter_month');
     } else {
         $filter['filter_month'] = $data['filter_month'] = '';
     }
     if (is_numeric($this->input->get('filter_day'))) {
         $filter['filter_day'] = $data['filter_day'] = $this->input->get('filter_day');
     } else {
         $filter['filter_day'] = $data['filter_day'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'reserve_date';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     if ($this->input->get('show_calendar') === '1') {
         $day = $filter['filter_day'] === '' ? date('d', time()) : $filter['filter_day'];
         $month = $filter['filter_month'] === '' ? date('m', time()) : $filter['filter_month'];
         $year = $filter['filter_year'] === '' ? date('Y', time()) : $filter['filter_year'];
         $url .= 'filter_year=' . $filter['filter_year'] . '&filter_month=' . $filter['filter_month'] . '&filter_day=' . $filter['filter_day'] . '&';
         $data['days'] = $this->calendar->get_total_days($month, $year);
         $data['months'] = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
         $data['years'] = array('2011', '2012', '2013', '2014', '2015', '2016', '2017');
         $total_tables = $this->Reservations_model->getTotalCapacityByLocation($filter['filter_location']);
         $calendar_data = array();
         for ($i = 1; $i <= $data['days']; $i++) {
             $date = $year . '-' . $month . '-' . $i;
             $reserve_date = mdate('%Y-%m-%d', strtotime($date));
             $total_guests = $this->Reservations_model->getTotalGuestsByLocation($filter['filter_location'], $reserve_date);
             $state = '';
             if ($total_guests < 1) {
                 $state = 'no_booking';
             } else {
                 if ($total_guests > 0 and $total_guests < $total_tables) {
                     $state = 'half_booked';
                 } else {
                     if ($total_guests >= $total_tables) {
                         $state = 'booked';
                     }
                 }
             }
             $fmt_day = strlen($i) == 1 ? '0' . $i : $i;
             if ($fmt_day == $day) {
                 $calendar_data[$i] = $state . ' selected';
             } else {
                 $calendar_data[$i] = $state;
             }
         }
         $calendar_data['url'] = site_url('reservations');
         $calendar_data['url_suffix'] = $url;
         $this->template->setIcon('<a class="btn btn-default" title="' . $this->lang->line('text_switch_to_list') . '" href="' . site_url('reservations/') . '"><i class="fa fa-list"></i></a>');
         $data['calendar'] = $this->calendar->generate($year, $month, $calendar_data);
     } else {
         $this->template->setIcon('<a class="btn btn-default" title="' . $this->lang->line('text_switch_to_calendar') . '" href="' . site_url('reservations?show_calendar=1') . '"><i class="fa fa-calendar"></i></a>');
         $data['calendar'] = '';
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_id'] = site_url('reservations' . $url . 'sort_by=reservation_id&order_by=' . $order_by);
     $data['sort_location'] = site_url('reservations' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_customer'] = site_url('reservations' . $url . 'sort_by=first_name&order_by=' . $order_by);
     $data['sort_guest'] = site_url('reservations' . $url . 'sort_by=guest_num&order_by=' . $order_by);
     $data['sort_table'] = site_url('reservations' . $url . 'sort_by=table_name&order_by=' . $order_by);
     $data['sort_status'] = site_url('reservations' . $url . 'sort_by=status_name&order_by=' . $order_by);
     $data['sort_staff'] = site_url('reservations' . $url . 'sort_by=staff_name&order_by=' . $order_by);
     $data['sort_date'] = site_url('reservations' . $url . 'sort_by=reserve_date&order_by=' . $order_by);
     $data['reservations'] = array();
     $results = $this->Reservations_model->getList($filter);
     foreach ($results as $result) {
         $data['reservations'][] = array('reservation_id' => $result['reservation_id'], 'location_name' => $result['location_name'], 'first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'guest_num' => $result['guest_num'], 'table_name' => $result['table_name'], 'status_name' => $result['status_name'], 'status_color' => $result['status_color'], 'staff_name' => $result['staff_name'], 'reserve_date' => day_elapsed($result['reserve_date']), 'reserve_time' => mdate('%H:%i', strtotime($result['reserve_time'])), 'edit' => site_url('reservations/edit?id=' . $result['reservation_id']));
     }
     $data['locations'] = array();
     $results = $this->Locations_model->getLocations();
     foreach ($results as $result) {
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']);
     }
     $data['statuses'] = array();
     $statuses = $this->Statuses_model->getStatuses('reserve');
     foreach ($statuses as $status) {
         $data['statuses'][] = array('status_id' => $status['status_id'], 'status_name' => $status['status_name']);
     }
     $data['reserve_dates'] = array();
     $reserve_dates = $this->Reservations_model->getReservationDates();
     foreach ($reserve_dates as $reserve_date) {
         $month_year = $reserve_date['year'] . '-' . $reserve_date['month'];
         $data['reserve_dates'][$month_year] = mdate('%F %Y', strtotime($reserve_date['reserve_date']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('reservations' . $url);
     $config['total_rows'] = $this->Reservations_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteReservation() === TRUE) {
         redirect('reservations');
     }
     $this->template->render('reservations', $data);
 }