You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
377 lines
17 KiB
377 lines
17 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\auth\User as UserAuth;
|
|
use app\core\utils\Response;
|
|
|
|
class Homepage extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
$this->my_parent_controller();
|
|
$this->load->model("event_model");
|
|
$this->load->model("event_video_model");
|
|
}
|
|
|
|
public function filter_events()
|
|
{
|
|
// Response::handleSessionTimeout("fo");
|
|
|
|
/*
|
|
* Check if input is safe from xss attack
|
|
*/
|
|
if (
|
|
!$this->security->xss_clean($this->input->get('month'), TRUE) ||
|
|
!$this->security->xss_clean($this->input->get('type'), TRUE) ||
|
|
!$this->security->xss_clean($this->input->get('city'), TRUE) ||
|
|
!$this->security->xss_clean($this->input->get('page'), TRUE)
|
|
) {
|
|
show_404();
|
|
}
|
|
$event_type = $this->input->get('event_category');
|
|
$month = $this->input->get('month');
|
|
$type = $this->input->get('type');
|
|
$workshop_session = $this->input->get('workshop_session');
|
|
$city = $this->input->get('city');
|
|
$page = (int)$this->input->get('page');
|
|
|
|
$logged_in = UserAuth::isAuth();
|
|
|
|
if($month == 0){
|
|
if($type == 0){
|
|
if($city == 0) $filter = '_default_';
|
|
else $filter = 'city';
|
|
|
|
if(!empty($workshop_session)) $filter = 'workshop_session';
|
|
}
|
|
else {
|
|
if($city == 0) $filter = 'type';
|
|
else $filter = 'type_city';
|
|
|
|
$tst_type = explode(",",$type);
|
|
if(count($tst_type)>=1){
|
|
if(!empty($workshop_session))
|
|
$filter = 'workshop_session_type';
|
|
else
|
|
$filter = 'type_multiple';
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if($type == 0) {
|
|
if($city == 0) $filter = 'month';
|
|
else $filter = 'month_city';
|
|
}
|
|
else {
|
|
if($city == 0) $filter = 'month_type';
|
|
else $filter = 'all';
|
|
}
|
|
}
|
|
//print $filter;
|
|
$query = $this->event_model->filter_events($filter, $page, $month, $type, $city, ($logged_in ? $this->data['logged_in']['user_id']: null), false,$workshop_session);
|
|
|
|
/*
|
|
* Embed event status info in every events
|
|
* The event schedule where you will depend the status to be displayed on the front is in $query['data'][even_index]['bostatus']
|
|
* Split the bostatus, the third index is the event_schedule_id which is 2 [0,1,2]
|
|
*/
|
|
$this->load->model("event_registration_model");
|
|
$eventIndex = 0;
|
|
foreach ($query['data'] as $event ) {
|
|
$videoReserved = false;
|
|
/* Get the event schedule id where bo status will be based */
|
|
$event_schedule_id = (explode('_', $event->bostatus))[2];
|
|
$status_details = $this->getHomeEventStatusDetails($event_schedule_id);
|
|
$event_videos = $this->event_video_model->get_videos_by_event_id($event->event_id);
|
|
$images = $this->event_model->get_file_attachments($event->event_id);
|
|
|
|
/** Check if video workshop and if yes, check if currently subscribed */
|
|
if($logged_in && ($event->workshop_session == 'ENLIGNE')) {
|
|
$re = $this->event_registration_model->is_subscribed($this->data['logged_in']['user_id'], $event->event_id);
|
|
if($re) {
|
|
$videoReserved = true;
|
|
}
|
|
}
|
|
if($event->workshop_session == 'DISTANCE-PRESENTIEL') {
|
|
$event = $this->event_model->format_night_class_prices($event);
|
|
}
|
|
/* Merge status event details and status info*/
|
|
$query['data'][$eventIndex] = array_merge((array) $event, $status_details, ['images'=>$images], ['event_videos'=>$event_videos], ['video_reserved' =>$videoReserved]);
|
|
|
|
$eventIndex++;
|
|
}
|
|
|
|
$result = array(
|
|
"mtype" => "success",
|
|
"mdata" => array(
|
|
'details' => $query['data'],
|
|
'pages' => $query['pagination'],
|
|
'result_count' => $query['result_count'],
|
|
'logged_in' => $query['logged_in']
|
|
)
|
|
);
|
|
|
|
output_to_json($this, $result);
|
|
}
|
|
|
|
protected function getHomeEventStatusDetails($event_schedule_id)
|
|
{
|
|
$query_id = $event_schedule_id;
|
|
$page = 1;
|
|
|
|
$event_status = $this->event_model->check_bo_status($query_id, $page);
|
|
$is_user_active = UserAuth::isAuth();
|
|
|
|
//check weather a user can still register more than one date per event
|
|
$allowed_to_book = ($is_user_active === 1 && isset($event_status[0]->event_id))?$this->event_schedule_model->continue_registration($event_status[0]->event_id, $this->data['logged_in']['user_id'], "register", 1):true;
|
|
//check weather a user can still register for waitinglist more than one date per event
|
|
$allowed_to_book_for_wl = ($is_user_active === 1 && isset($event_status[0]->event_id))?$this->event_schedule_model->continue_registration($event_status[0]->event_id, $this->data['logged_in']['user_id'], "register", 2):true;
|
|
|
|
$checkStats = array('2FULL', '3FULL', '2AVAILABLE', '3AVAILABLE');
|
|
|
|
//get all event schedule statuses
|
|
foreach($event_status as $key=>$value){
|
|
|
|
$book_waiting_list = 0;
|
|
$subscription = array("booking_type" => 0, "seats_reserved" => 0);
|
|
|
|
if ($value->event_category != 'ONLINE_EVENT') {
|
|
|
|
if($value->back_office_status<4 && $value->back_office_status>=1) {
|
|
if(($page == 2 && $is_user_active) || ($page == 1 && $is_user_active)){
|
|
$subscription = $this->check_subscription($value->event_schedule_id, $value->event_id, $page);
|
|
|
|
//display the exact date in the HP
|
|
if($page == 1 && isset($subscription["event_date"]) && !empty($subscription["event_date"])) {
|
|
if($subscription["event_date"]){
|
|
$event_status[$key] = (object) array_merge((array) $value, (array) $subscription["event_date"]);
|
|
$value = $event_status[$key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//if event is not closed
|
|
if($value->back_office_status<4 && $value->back_office_status>=2) {
|
|
|
|
if($value->back_office_status.$value->event_status == '2FULL'){
|
|
if($value->remaining_seat >= 0 && $value->quota_waiting_list_seat > 0) {
|
|
$book_waiting_list = 1;
|
|
} else {
|
|
//complete but bo status is open
|
|
$book_waiting_list = 0;
|
|
$value->back_office_status = 3;
|
|
}
|
|
}
|
|
//to make the button complete when when there's no remaining seats and waiting list seat
|
|
elseif($value->remaining_seat == 0 && $value->quota_waiting_list_seat==0 && $value->back_office_status<4 && $value->back_office_status>1 ){
|
|
|
|
$book_waiting_list = 0;
|
|
$value->back_office_status = 3;
|
|
|
|
}else{
|
|
$book_waiting_list = ( in_array($value->back_office_status.$value->event_status, $checkStats) && $value->remaining_seat <= 0 && $value->quota_waiting_list_seat >0 && $value->back_office_status<3 && $value->back_office_status>1)?1:0;
|
|
}
|
|
}
|
|
|
|
}
|
|
$event_status[$key]->{"book_waiting_list"} = $book_waiting_list;
|
|
$event_status[$key]->{"booking_type"} = $subscription["booking_type"];
|
|
$event_status[$key]->{"seats_reserved"} = $subscription["seats_reserved"];
|
|
$event_status[$key]->{"is_user_active"} = $is_user_active;
|
|
}
|
|
|
|
return array("event_status"=> $event_status, "allowed_to_book"=>$allowed_to_book, "allowed_to_book_for_wl" => $allowed_to_book_for_wl);
|
|
}
|
|
|
|
public function check_bo_status()
|
|
{
|
|
$query_id = $this->input->get('query_id');
|
|
$page = $this->input->get('page');
|
|
|
|
$event_status = $this->event_model->check_bo_status($query_id, $page);
|
|
$is_user_active = UserAuth::isAuth();
|
|
|
|
//check weather a user can still register more than one date per event
|
|
$allowed_to_book = ($is_user_active === 1 && isset($event_status[0]->event_id))?$this->event_schedule_model->continue_registration($event_status[0]->event_id, $this->data['logged_in']['user_id'], "register", 1):true;
|
|
//check weather a user can still register for waitinglist more than one date per event
|
|
$allowed_to_book_for_wl = ($is_user_active === 1 && isset($event_status[0]->event_id))?$this->event_schedule_model->continue_registration($event_status[0]->event_id, $this->data['logged_in']['user_id'], "register", 2):true;
|
|
|
|
$checkStats = array('2FULL', '3FULL', '2AVAILABLE', '3AVAILABLE');
|
|
|
|
//get all event schedule statuses
|
|
foreach((array) $event_status as $key => $value){
|
|
|
|
$book_waiting_list = 0;
|
|
$subscription = array("booking_type" => 0, "seats_reserved" => 0);
|
|
|
|
if(($value->back_office_status < BO_STAT['fer'] && $value->back_office_status >= BO_STAT['pub']) || UserAuth::isLoggedInAsSubscriber()) {
|
|
if(($page == 2 && $is_user_active) || ($page == 1 && $is_user_active)){
|
|
$subscription = $this->check_subscription($value->event_schedule_id, $value->event_id, $page);
|
|
|
|
//display the exact date in the HP
|
|
if($page == 1 && isset($subscription["event_date"]) && !empty($subscription["event_date"])) {
|
|
if($subscription["event_date"]){
|
|
$event_status[$key] = (object) array_merge((array) $value, (array) $subscription["event_date"]);
|
|
$value = $event_status[$key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//if event is not closed
|
|
if(($value->back_office_status < BO_STAT['fer'] && $value->back_office_status >= BO_STAT['ouv']) || UserAuth::isLoggedInAsSubscriber()) {
|
|
|
|
if($value->back_office_status.$value->event_status == '2FULL'){
|
|
if($value->remaining_seat >= 0 && $value->quota_waiting_list_seat > 0) {
|
|
$book_waiting_list = 1;
|
|
} else {
|
|
//complete but bo status is open
|
|
$book_waiting_list = 0;
|
|
$value->back_office_status = 3;
|
|
}
|
|
}
|
|
//to make the button complete when when there's no remaining seats and waiting list seat
|
|
elseif($value->remaining_seat == 0 && $value->quota_waiting_list_seat==0 && $value->back_office_status<4 && $value->back_office_status>1 ){
|
|
|
|
$book_waiting_list = 0;
|
|
$value->back_office_status = 3;
|
|
|
|
}else{
|
|
$book_waiting_list = ( in_array($value->back_office_status.$value->event_status, $checkStats) && $value->remaining_seat <= 0 && $value->quota_waiting_list_seat >0 && $value->back_office_status<3 && $value->back_office_status>1)?1:0;
|
|
}
|
|
}
|
|
|
|
$event_status[$key]->{"book_waiting_list"} = $book_waiting_list;
|
|
$event_status[$key]->{"booking_type"} = $subscription["booking_type"];
|
|
$event_status[$key]->{"seats_reserved"} = $subscription["seats_reserved"];
|
|
$event_status[$key]->{"is_user_active"} = $is_user_active;
|
|
}
|
|
|
|
output_to_json($this, array("event_status"=> $event_status, "allowed_to_book"=>$allowed_to_book, "allowed_to_book_for_wl" => $allowed_to_book_for_wl));
|
|
}
|
|
|
|
public function check_subscription($event_schedule_id, $event_id, $page=2)
|
|
{
|
|
$this->load->model('event_registration_model');
|
|
$this->load->model('event_wait_list_model');
|
|
$this->load->model('event_schedule_model');
|
|
|
|
$user_id = $this->data['logged_in']['user_id'];
|
|
|
|
$subscribed = $this->event_registration_model->count_all_event_subscription($user_id, $event_schedule_id, $event_id, $page);
|
|
if($subscribed) {
|
|
|
|
$event_date = $this->event_schedule_model->get_date_of_reservation($event_id, $user_id, 1, $page);
|
|
return array("booking_type" => 1, "seats_reserved" => (($event_date)?$event_date->seats_reserved:$subscribed), "event_date" => $event_date); //Booked in normal registration
|
|
} else {
|
|
$subscribed_waitlist = $this->event_wait_list_model->count_all_waitlist_subscription($user_id, $event_schedule_id, $event_id, $page);
|
|
if($subscribed_waitlist){
|
|
|
|
//check if event is re-opened and has seats available if yes then, must changed button to reserver
|
|
if($this->event_model->check_seats($event_schedule_id, 1)){
|
|
return array("booking_type" => 0, "seats_reserved" => 0);
|
|
} else {
|
|
$event_date = $this->event_schedule_model->get_date_of_reservation($event_id, $user_id, 2, $page);
|
|
return array("booking_type" => 2, "seats_reserved" => (($event_date)?$event_date->seats_reserved:$subscribed_waitlist), "event_date" => $event_date); //booked in waiting list
|
|
}
|
|
}
|
|
}
|
|
return array("booking_type" => 0, "seats_reserved" => 0);
|
|
}
|
|
|
|
public function get_reservation_start_date($id = null)
|
|
{
|
|
$message['msg'] ="Ouverture des descriptions <br>".$this->event_model->reservation_start_date(true,$id)->reservation_start_date;
|
|
|
|
output_to_json($this,$message);
|
|
}
|
|
|
|
public function check_all_sched(){
|
|
$event_status = $this->event_model->check_all_sched($this->input->get('event_id'), (($this->input->get('isEventOpen') == 'true')? true:false));
|
|
output_to_json($this,$event_status);
|
|
}
|
|
/**
|
|
* Set notif to on once the user has been notified about the new feature moderation
|
|
* @method notif_moderation_feature
|
|
* @return void
|
|
*/
|
|
public function notif_moderation_feature() {
|
|
$this->load->model('user_subscriber_model', '', true);
|
|
$this->load->model("user_activity_log_model");
|
|
if ($this->data['logged_in']['user_id']) {
|
|
$this->user_subscriber_model->notif_moderation_feature($this->data['logged_in']['user_id']);
|
|
$act_log = $this->user_activity_log_model->add_activity_log(array(
|
|
"description" => "ACKNOWLEDGED MODERATION",
|
|
"user_id" => $this->data["logged_in"]["user_id"],
|
|
"action" => "VIEW",
|
|
"table_origin" => "user_subscriber",
|
|
"reference_id" => $this->data["logged_in"]["user_id"]
|
|
));
|
|
}
|
|
}
|
|
|
|
public function get_event_details($event_id){
|
|
$event = $this->event_model->event_details($event_id);
|
|
$this->load->model('event_registration_model');
|
|
$this->load->model('event_author_works_model');
|
|
$this->load->model('event_venue_photos_model');
|
|
$works = $this->event_author_works_model->get_works_by_event_id($event_id);
|
|
$venue_photos = $this->event_venue_photos_model->get_venue_photos_by_event_id($event_id);
|
|
$event_videos = $this->event_video_model->get_videos_by_event_id($event_id);
|
|
|
|
if($event->workshop_session == 'DISTANCE-PRESENTIEL') {
|
|
$event = $this->event_model->format_night_class_prices($event);
|
|
}
|
|
|
|
$event = (array)$event;
|
|
$event['works'] = $works;
|
|
$event['venue_photos'] = $venue_photos;
|
|
$event['event_videos'] = $event_videos;
|
|
$event = (object) $event;
|
|
$registration = $this->event_registration_model->count_total_reserved_seats($event_id);
|
|
$event->remaining_combined_seat = (int)$event->total_available_seat - (int) $registration;
|
|
$event->workshop_author_awards = json_decode($event->workshop_author_awards);
|
|
output_to_json($this, $event);
|
|
}
|
|
|
|
public function get_event_schedules($event_id){
|
|
$this->load->model('event_schedule_model');
|
|
$schedule = $this->event_schedule_model->list_event_schedule($event_id, 1, FALSE);
|
|
output_to_json($this,$schedule);
|
|
}
|
|
|
|
public function proceed_to_payment() {
|
|
delete_cookie($this->config->item('sess_cookie_name').'_event_data');
|
|
$cookie = array(
|
|
'name' => 'event_data',
|
|
'value' => json_encode(array(
|
|
"event_id" => $this->input->post('event_id'),
|
|
"seats_reserved" => $this->input->post('seats_reserved'),
|
|
"booking" => $this->input->post('booking'),
|
|
|
|
)),
|
|
'expire' => 7200, // time() + (86400 * 30),
|
|
'prefix' => $this->config->item('sess_cookie_name').'_'
|
|
);
|
|
|
|
set_cookie($cookie);
|
|
output_to_json($this, true);
|
|
}
|
|
|
|
public function get_event_video(){
|
|
$id = $this->input->get('id');
|
|
$this->load->model('event_video_model');
|
|
$video = $this->event_video_model->get_video_by_id($id);
|
|
if($video) {
|
|
output_to_json($this, array(
|
|
"mtype" => "success",
|
|
"message" => "video",
|
|
"mdata" => $video
|
|
));
|
|
}
|
|
output_to_json($this, array(
|
|
"mtype" => "error",
|
|
"message" => "video not found"
|
|
));
|
|
}
|
|
}
|
|
|