my_parent_controller(); Response::handleSessionTimeout("bo"); //load language files $this->load_language_backoffice(); $this->lang->load('backoffice/events', 'fr'); //load models $this->load->model("user_activity_log_model"); $this->load->model("event_schedule_model"); $this->load->model("event_registration_paid_event_model"); $this->load->model("nshow_model"); } public function list_event_schedule($event_id=0){ if(isset($this->data["logged_in"]["user_id"])){ $list = $this->event_schedule_model->get_all_event_schedule($event_id); $data = array(); $row = array(); foreach ($list as $event_sched) { $row["event_schedule_id"] = $event_sched->event_schedule_id; $row["start_date_time"] = $event_sched->start_date_time; $row["end_date_time"] = $event_sched->end_date_time; $row["reservation_start_date"] = $event_sched->reservation_start_date; $row["reservation_end_date"] = $event_sched->reservation_end_date; $row["event_status"] = $event_sched->event_status; $row["back_office_status"] = $event_sched->back_office_status; $row["total_available_remaining_seat"] = (empty($event_sched->rem_seats)?0:$event_sched->rem_seats).' / '.(empty($event_sched->avl_seats)?0:$event_sched->avl_seats); /* * Get noshow data for each event schedule */ $row["noshow"] = 'Désactivé'; $noshow_data = $this->nshow_model->getNoshowInfo($event_sched->event_schedule_id); if (!empty($noshow_data)>0) { if ($noshow_data['no_show_stat']) { $row["noshow"] = "{$noshow_data['total_noshow']}/{$noshow_data['total_bookings']}"; } } $row["total_available_seat"] = $event_sched->total_available_seat; $row["total_quota_waiting_list_seat"] = $event_sched->total_quota_waiting_list_seat; $row["seats_per_subscriber"] = $event_sched->seats_per_subscriber; $row["city_name"] = $event_sched->city_name; $row["location"] = $event_sched->location; $row["city_location"] = $event_sched->city_location; $row["address"] = $event_sched->address; $row["code_postal"] = $event_sched->code_postal; $row["event_url"] = $event_sched->event_url; $row["item_code"] = $event_sched->item_code; $row["action"] = array( "event_id" => $event_sched->event_id, "event_schedule" => array( "avl_seats" => $event_sched->avl_seats, "rem_seats" => $event_sched->rem_seats, "avl_wl_seats" => $event_sched->total_quota_waiting_list_seat, "rem_wl_seats" => $event_sched->quota_waiting_list_seat, "seat_feature" => $event_sched->seat_feature, "seat_feature" => $event_sched->seat_feature ) ); array_push($data, $row); } $output = array( "draw" => (isset($_POST['draw']))?$_POST['draw']:0, "data" => $data, ); //output to json format output_to_json($this, $output); } else { show_404(); } } public function event_schedule_information($event_sched_id){ if(isset($this->data["logged_in"]["user_id"])){ $ev_sched_info = $this->event_schedule_model->event_schedule_information($event_sched_id); output_to_json($this, array( "mtype" => "success", "mdata" => $ev_sched_info )); } else { show_404(); } } public function change_seat_feature($event_id=0){ if($this->input->post() && isset($this->data["logged_in"]["user_id"]) && $event_id){ $update_e_schedule = $this->event_schedule_model->change_seat_feature($this->data["logged_in"]["user_id"], $this->input->post("seat_feature"), $event_id); output_to_json($this, array( "mtype" => "success", "message" => "updated" )); } else { show_404(); } } public function add_event_schedule($event_id=0) { if($this->input->post() && isset($this->data["logged_in"]["user_id"]) && $event_id){ if($this->input->post()){ $event_schedule = array($this->input->post()); // Get event category $event_category = $this->event_registration_paid_event_model->get_event_category($event_schedule[0]['event_id']); // Check Code selection duplicate if (isset($event_schedule[0]['event_id'])) { if ($event_category && $event_category == 'PAID_EVENT') { $this->unique_code_selection($event_schedule[0]); } // Set event_category $this->data['event_category'] = $event_category; // Remove unecessary key unset($event_schedule[0]['event_id']); } if(sizeof($event_schedule) > 0){ $result = $this->event_schedule_model->add_event_schedule($this->data["logged_in"]["user_id"], $event_id, $event_schedule, $this->data); if(!$result){ output_to_json($this, array( "mtype" => "warning", "message" => $this->lang->line("unknown_error") )); exit(); } else { output_to_json($this, array( "mtype" => "success", "message" => $this->lang->line("added_new_event") )); } } else { output_to_json($this, array( "mtype" => "warning", "message" => $this->lang->line("unknown_error") )); exit(); } } } else { show_404(); } } public function update_event_schedule($event_schedule_id=0) { if($this->input->post() && isset($this->data["logged_in"]["user_id"]) && $event_schedule_id){ // Check Code selection duplicate if ($this->input->post('event_id')) { if ($this->event_registration_paid_event_model->is_paid_event($this->input->post('event_id'))) { $this->unique_code_selection($_POST, $event_schedule_id); } // Remove unecessary key unset($_POST['event_id']); } // store moderation settings data in a separate variable and remove them from main var $ev_mod_settings = $this->extractEvSchedModData(); //check if total_avl_seat is undefined $_POST['total_available_seat'] = (!isset($_POST['total_available_seat']) && empty($_POST['total_available_seat']))?0:$_POST['total_available_seat']; //check if places dispondible is valid $check_avl_places = $this->event_schedule_model->check_available_places($event_schedule_id, $this->input->post('total_available_seat'), $_POST['seat_feature']); if($check_avl_places){ //check if valid wl quota $check_wl_seats = $this->event_schedule_model->check_quota_wl($event_schedule_id, $this->input->post('total_quota_waiting_list_seat')); if($check_wl_seats){ $update_e_schedule = $this->event_schedule_model->update_event_schedule($this->data["logged_in"]["user_id"], $this->input->post(), $event_schedule_id, $ev_mod_settings); if($update_e_schedule) { if ($this->input->post('event_status') == 'CANCEL' || $this->input->post('seat_feature') == 2) { // if an event is cancelled on a combined seat event re add the available seats consumed $update_combined_seats = $this->event_schedule_model->retrieve_combined_event_seats_from_cancelled($event_schedule_id); } output_to_json($this, array( "mtype" => "success", "message" => $this->lang->line("updated_event") )); } else { output_to_json($this, array( "mtype" => "error", "message" => $this->lang->line("unknown_error_on_saving") )); } } else { output_to_json($this, array( "mtype" => "warning", "message" => "Invalid input, value is less than the total quota waiting list seats reserved.", "mdetail" => array(array("field" => "total_quota_waiting_list_seat", "message" => "Invalid input, value is less than the total quota waiting list seats reserved.")) )); } } else { output_to_json($this, array( "mtype" => "error", "message" => "Invalid input, value is less than the total number of seats reserved.", "mdetail" => array(array("field" => "total_available_seat", "message" => "Invalid input, value is less than the total number of seats reserved.")) )); } } else { show_404(); } } // multiple edit event schedule bo statuses public function multi_update_evsched_status() { if($this->input->post() && count($this->input->post('alL_status_ids')) > 0 && is_numeric($this->input->post('target_status'))){ $update_e_schedules = $this->event_schedule_model->multi_update_evsched_status($this->data["logged_in"]["user_id"], $this->input->post('target_status'), $this->input->post('alL_status_ids')); if($update_e_schedules) { foreach ($this->input->post('alL_status_ids') as $key => $id) { $act_log = $this->user_activity_log_model->add_activity_log(array( "description" => $this->lang->line("updated_event")." - event_schedule_id : ".$id, "user_id" => $this->data["logged_in"]["user_id"], "action" => "EDIT", "table_origin" => "event_schedule", "reference_id" => $id )); } if($act_log){ output_to_json($this, array( "mtype" => "success", "message" => $this->lang->line("updated_event") )); } else { output_to_json($this, array( "mtype" => "warning", "message" => $this->lang->line("unknown_error") )); } } else { output_to_json($this, array( "mtype" => "error", "message" => $this->lang->line("unknown_error_on_saving") )); } } else { show_404(); } } public function delete_event_schedule($event_schedule_id=0){ if($event_schedule_id && isset($this->data["logged_in"]["user_id"])){ //update also all event schedule status to deleted $delete_e_schedule = $this->event_schedule_model->delete_event_schedule($event_schedule_id); if($delete_e_schedule){ output_to_json($this, array( "mtype" => "success", "message" => $this->lang->line("event_deleted") )); } else { output_to_json($this, array( "mtype" => "warning", "message" => $this->lang->line("unknown_error") )); } } else { show_404(); } } /** * Save event moderation settings * * @param string $action = INSERT/UPDATE command * @param integer $event_schedule_id = event schedule id * @return void * access private member */ private function extractEvSchedModData() { $moderationVariables = array(); /** * Extract moderation settings from post */ //Unset 'Activer la Modération' if (isAvailablePostKey($_POST, 'adapt_cur_mod_settings')) { $moderationVariables['adapt_cur_mod_settings'] = ($_POST['adapt_cur_mod_settings'] == 'on' ? 1: 0); unset($_POST['adapt_cur_mod_settings']); } if (isAvailablePostKey($_POST, 'moderationSwitchBtn')) { $moderationVariables['mod_stat'] = ($_POST['moderationSwitchBtn'] == 'on' ? 1: 0); unset($_POST['moderationSwitchBtn']); } //Unset 'Modération Flexible' if (isAvailablePostKey($_POST, 'moderationSwitchFlexibleBtn')) { $moderationVariables['flex_mod_stat'] = ($_POST['moderationSwitchFlexibleBtn'] == 'on' ? 1: 0); unset($_POST['moderationSwitchFlexibleBtn']); } //Unset 'Désactivation de la modération [] heures ' if (isAvailablePostKey($_POST, 'flex_no_of_hours')) { $moderationVariables['hrs_bef_event_closes'] = ($_POST['flex_no_of_hours']?:0); unset($_POST['flex_no_of_hours']); } //Unset 'avant la date de fin de la réservation S'il reste % de places vacantes.' if (isAvailablePostKey($_POST, 'flex_places_to_lift_moderation')) { $moderationVariables['places_volume'] = ($_POST['flex_places_to_lift_moderation']?:0); unset($_POST['flex_places_to_lift_moderation']); } /** * End of collection for event_moderation_settings */ return $moderationVariables; } /** * Check if item_code || code_selection is unique for every event_schedule * Item code is only applicable to PAID EVENT * * @param $action add || edit */ private function unique_code_selection($data, $event_schedule_id = 0) { if (!isset($data['item_code']) || empty($data['item_code'])) { output_to_json($this, array( "mtype" => "error", "message" => "Code selection is required for PAID EVENT.", "mdetail" => array(array("field" => "item_code", "message" => "Code selection is required")) )); } $result = $this->event_schedule_model->validate_code_selection($data['item_code'], $event_schedule_id); if ($result) { output_to_json($this, array( "mtype" => "error", "message" => "Code selection '".$data['item_code']."' already used by another event.", "mdetail" => array(array("field" => "item_code", "message" => "Code selection already used by another event.")) )); } } public function has_duplicate_code_selection() { if ($this->input->post('item_code')) { $this->unique_code_selection($this->input->post(), 0); } output_to_json($this, array( "mtype" => "success", "message" => "No duplicate" )); } }