コード例 #1
0
 /**
  * Listing all tables of shift
  * url: http://localhost/shift/<number_of_shift>/tables?[for_vegans=]
  * Method: GET
  * @param       int  $shift_id
  * @param       int  $for_vegans
  * @return      json
  */
 function tables_of_shift_get($shift_id)
 {
     $this->authenticate();
     $messages_lang = $this->common->set_language_for_server_api('tables_api', array('get_tables_of_shift_success', 'get_tables_of_shift_failure', 'variables_not_valid'));
     $for_vegans = NULL;
     $day = NULL;
     if (NULL != $this->input->get('for_vegans')) {
         $for_vegans = strtolower($this->input->get('for_vegans'));
     }
     if ($for_vegans == 'true') {
         $day = $for_vegans = VEGAN_DAY;
     } else {
         if ($for_vegans == 'false') {
             $day = $for_vegans = NORMAL_DAY;
         }
     }
     $result = Tables_model::get_tables_by_shift($shift_id, $for_vegans, $day);
     $tables = array();
     $response = array();
     if ($result != NULL) {
         foreach ($result as $key => $temp) {
             $table = array();
             $table['id'] = (int) $temp->id;
             $table['name'] = $temp->name;
             $table['for_vegans'] = (bool) $temp->for_vegans;
             $table['description'] = $temp->description;
             $table['seats'] = (int) $temp->seats;
             $table['available_seats'] = (int) $temp->seats - (int) $temp->occupied_seats;
             $table['shift_id'] = (int) $temp->shift_id;
             $table['shift'] = $temp->shift;
             $table['start_time'] = $temp->start_time;
             $table['end_time'] = $temp->end_time;
             $users = array();
             $result = Tables_model::get_users_in_table($temp->id, $day);
             if ($result != NULL) {
                 foreach ($result as $key => $temp) {
                     $user = array();
                     $user['id'] = (int) $temp->id;
                     $user['email'] = $temp->email;
                     $user['first_name'] = $temp->first_name;
                     $user['last_name'] = $temp->last_name;
                     $user['want_vegan_meal'] = (bool) $temp->want_vegan_meal;
                     $user['avatar_content_file'] = $temp->avatar_content_file;
                     array_push($users, $user);
                 }
                 $table['users'] = $users;
             }
             array_push($tables, $table);
         }
         $response['status'] = $messages_lang['success'];
         $response['message'] = $messages_lang['get_tables_of_shift_success'];
         $response['data'] = $tables;
     } else {
         $response['status'] = $messages_lang['failure'];
         $response['message'] = $messages_lang['get_tables_of_shift_failure'];
     }
     $this->response($response, 200);
 }
コード例 #2
0
 function get_tables_from_shift()
 {
     $this->common->authenticate();
     $shift_id = $this->input->post('shift_id');
     $day = $this->input->post('day');
     $for_vegans = $day == NORMAL_DAY ? 0 : NULL;
     $this->load->model('tables_model');
     $this->load->model('shifts_model');
     $tables = Tables_model::get_tables_by_shift($shift_id, $for_vegans, $day);
     $data['tables'] = $tables;
     $data['shift'] = Shifts_model::get_shift_by_id($shift_id);
     echo json_encode($data);
 }
コード例 #3
0
 public function load_arrange_table_view($shift_id = NULL, $day)
 {
     $message = array('title', 'shift', 'search', 'normal_day', 'vegan_day', 'list_tables', 'table', 'arrange', 'for_vegan', 'for_normal', 'add_user', 'list_of_users', 'avatar', 'name', 'floor', 'vegan', 'move_to', 'leave', 'are_you_sure', 'yes', 'cancel');
     $data = $this->common->set_language_and_data('arrange_tables', $message);
     $this->load->model('shifts_model');
     $data['shifts'] = Shifts_model::get_all_shifts();
     $for_vegans = $day == NORMAL_DAY ? 0 : NULL;
     $tables = array();
     if (!is_null($shift_id)) {
         $tables = Tables_model::get_tables_by_shift($shift_id, $for_vegans, $day);
     } else {
         if (!empty($data['shifts'])) {
             $shift_id = $data['shifts'][0]->id;
             $tables = Tables_model::get_tables_by_shift($shift_id, $for_vegans, $day);
         }
     }
     $data['tables'] = $tables;
     $data['users'] = Shifts_model::get_users_by_shift($shift_id);
     $data['day'] = $day;
     $this->common->load_view('admin/tables/arrange_tables', $data);
 }