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.
331 lines
11 KiB
331 lines
11 KiB
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\utils\Response;
|
|
|
|
class Noshow extends MY_Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
//parent::__construct();
|
|
$this->my_parent_controller();
|
|
Response::handleSessionTimeout("bo");
|
|
|
|
//load language files
|
|
$this->load_language_backoffice();
|
|
// $this->lang->load('backoffice/no_show', 'fr');
|
|
|
|
$this->load->model('noshow_model');
|
|
$this->load->model('Event_schedule_model');
|
|
|
|
// $this->lang->load('backoffice/reports', 'fr');
|
|
// $this->lang->load('backoffice/events', 'fr');
|
|
|
|
$config['upload_path'] = './resources/images/backoffice/noshow_imports/';
|
|
$config['allowed_types'] = '*';
|
|
$config['max_size'] = 0;
|
|
|
|
//$this->noshow_folder = noshow_bundle();
|
|
$this->load->library('upload', $config);
|
|
|
|
//load nshow_model
|
|
$this->load->model('nshow_model');
|
|
}
|
|
|
|
public function post_noshow($event_schedule_id)
|
|
{
|
|
$this->noshow_model->update_noshows($this->data["logged_in"]["user_id"]);
|
|
output_to_json($this, array( 'mtype' => 'success', 'message' => $this->lang->line("message_success") ));
|
|
}
|
|
public function export_no_shows_lists($event_schedule_id)
|
|
{
|
|
$tab1 = array("registration_id", "email_address", "users_name", "type", "no_of_place" , "no_show_type" , "comment");
|
|
$tab2 = array("walk_in_id" ,"first_name", "last_name", "email_address", "note");
|
|
|
|
$confirmed = $this->noshow_model->confirmed($event_schedule_id);
|
|
$waitlist = $this->noshow_model->waitlist($event_schedule_id);
|
|
$extra_people = $this->noshow_model->extra_people($event_schedule_id);
|
|
|
|
return array(
|
|
"tab1" => $tab1,
|
|
"tab2" => $tab2,
|
|
"data" => array_merge($confirmed, $waitlist),
|
|
"invitee" => $confirmed,
|
|
"extra_people" => $extra_people
|
|
);
|
|
}
|
|
public function check_remaining_seats($event_schedule_id)
|
|
{
|
|
$msg = "";
|
|
|
|
if ($this->noshow_model->check_has_remaining_seats($event_schedule_id) > 0) {
|
|
$msg = array("export" => "true" , "message" => "L'événement est toujours ouvert à la réservation, êtes vous sûr de vouloir exporter la liste des participants ?");
|
|
} else {
|
|
$msg = array("export" => "false" , "message" => "L'événement est toujours ouvert à la réservation, êtes vous sûr de vouloir exporter la liste des participants ?");
|
|
}
|
|
output_to_json($this, $msg);
|
|
}
|
|
|
|
public function get_datatable($event_schedule_id, $type)
|
|
{
|
|
if ($this->input->post() && isset($this->data["logged_in"]["user_id"]) && !empty($event_schedule_id)) {
|
|
$list = $this->noshow_model->get_datatables($this->input->post(), $event_schedule_id, $type);
|
|
|
|
$data = array();
|
|
$row = array();
|
|
$x = $this->input->post("start");
|
|
|
|
foreach ($list as $noshow_list) {
|
|
$row["no"] = ++$x;
|
|
$row["event_name"] = $noshow_list->event_name;
|
|
$row["registration_id"] = $noshow_list->registration_id;
|
|
$row["users_name"] = $noshow_list->users_name;
|
|
$row["type"] = $noshow_list->type;
|
|
$row["reservation_date"] = $noshow_list->reservation_date;
|
|
$row["no_of_place"] = $noshow_list->no_of_place;
|
|
$row["no_show_type"] = $noshow_list->no_show_type;
|
|
$row["comment"] = $noshow_list->comment;
|
|
array_push($data, $row);
|
|
}
|
|
$output = array(
|
|
"draw" => $_POST['draw'],
|
|
"recordsTotal" => $this->noshow_model->count_all($this->input->post(), $event_schedule_id, $type),
|
|
"recordsFiltered" => $this->noshow_model->count_filtered($this->input->post(), $event_schedule_id, $type),
|
|
"data" => $data,
|
|
);
|
|
//output to json format
|
|
output_to_json($this, $output);
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
|
|
// get noshow data
|
|
public function get_noshow_data(int $event_schedule_id, $type)
|
|
{
|
|
switch ($type) {
|
|
// waitlist
|
|
case 0:
|
|
$data = $this->nshow_model->waitList($event_schedule_id);
|
|
break;
|
|
// normal reservation
|
|
case 1:
|
|
$data = $this->nshow_model->bookList($event_schedule_id);
|
|
break;
|
|
// extra people/walk in
|
|
case 2:
|
|
$data = $this->nshow_model->extraPeople($event_schedule_id);
|
|
break;
|
|
|
|
default:
|
|
$data = array_merge(
|
|
$this->nshow_model->bookList($event_schedule_id),
|
|
$this->nshow_model->waitList($event_schedule_id),
|
|
$this->nshow_model->extraPeople($event_schedule_id)
|
|
);
|
|
// code...
|
|
break;
|
|
}
|
|
// $confirmed = $this->nshow_model->bookList($event_schedule_id);
|
|
// $extra = $this->nshow_model->extraPeople($event_schedule_id);
|
|
|
|
// return array_merge($confirmed, $waitlist, $extra);
|
|
// return $confirmed;
|
|
output_to_json($this, $data);
|
|
}
|
|
|
|
// save noshow data
|
|
public function save_noshow_data()
|
|
{
|
|
$this->nshow_model->save_noshow_data($this->input->post());
|
|
output_to_json($this, $this->input->post());
|
|
}
|
|
|
|
|
|
/**
|
|
* Save new extra people in database table
|
|
* @return stdclass
|
|
*
|
|
* access public member
|
|
*/
|
|
public function save_walk_in()
|
|
{
|
|
/**
|
|
* Email not exist save to database
|
|
*/
|
|
$this->nshow_model->save_walk_in($this->input->post());
|
|
output_to_json($this, [
|
|
'hasError' => false,
|
|
'postValues' => $this->input->post()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Check if emails are exist in database
|
|
* @return string [description]
|
|
* access public member
|
|
*/
|
|
public function validateExtraPeopleIfEmailsExists() : void
|
|
{
|
|
/**
|
|
* Get post email address
|
|
* @var string
|
|
*/
|
|
$email = $this->input->post('email_address');
|
|
|
|
if (notSet($email)) {
|
|
output_to_json($this, [
|
|
'commandValidate' => false
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display 'invalid email address' message
|
|
*/
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
output_to_json($this, [
|
|
'commandValidate' => true,
|
|
'color' => 'red',
|
|
'sucessEmailValidation' => false,
|
|
'highlightError' => true,
|
|
'message' => 'Enter a valid email address!',
|
|
'postValues' => $this->input->post()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display details message for registered email subscriber
|
|
*/
|
|
if ($this->checkEmailsExistInDb($email) > 0) {
|
|
output_to_json($this, [
|
|
'commandValidate' => true,
|
|
'color' => 'green',
|
|
'sucessEmailValidation' => true,
|
|
'highlightError' => false,
|
|
'message' => 'Cette adresse email est bien enregistrée dans la liste des abonnés de la plateforme Evénement.',
|
|
'postValues' => $this->input->post()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display details message for unregistered email subscriber
|
|
*/
|
|
if ($this->checkEmailsExistInDb($email) == 0) {
|
|
output_to_json($this, [
|
|
'commandValidate' => true,
|
|
'color' => 'red',
|
|
'sucessEmailValidation' => true,
|
|
'highlightError' => false,
|
|
'message' => 'Cette adresse email n\'est pas enregistrée dans la liste des abonnés de la plateforme Evénement.
|
|
',
|
|
'postValues' => $this->input->post()
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get remaining seat information
|
|
* @param int $eventScheduleId = event schedule id
|
|
* @return [type] [description]
|
|
* access public function
|
|
*/
|
|
public function getSeatInfo(int $eventScheduleId, int $event_id = 0)
|
|
{
|
|
$data = $this->nshow_model->getSeatInfo($eventScheduleId, $event_id);
|
|
output_to_json($this, $data);
|
|
}
|
|
|
|
/**
|
|
* Search for emails in tables if exits
|
|
*
|
|
* @param string $keySearch = email address
|
|
* @return object
|
|
* access public member function
|
|
*/
|
|
public function checkEmailsExistInDb(string $keySearch) : int
|
|
{
|
|
$keySearch = trim(strtolower($keySearch));
|
|
|
|
$inList = array();
|
|
|
|
if (notSet($keySearch)) {
|
|
return 0;
|
|
}
|
|
|
|
$tablePropertiesForEmailSearch = array(
|
|
[ 'tableName' => 'user' , 'field' => 'user.email_address' ],
|
|
[ 'tableName' => 'user_subscriber' , 'field' => 'user_subscriber.email_address' ],
|
|
[ 'tableName' => 'event_attendance_walk_in' , 'field' => 'event_attendance_walk_in.email_address' ],
|
|
[ 'tableName' => 'event_subscriber_guest' , 'field' => 'event_subscriber_guest.email_address' ]
|
|
);
|
|
|
|
foreach ($tablePropertiesForEmailSearch as $key => $value) {
|
|
array_push($inList, $this->nshow_model->checkEmailsExistInDb($value['tableName'], $value['field'], $keySearch));
|
|
}
|
|
|
|
return count(array_filter($inList));
|
|
}
|
|
|
|
|
|
/**
|
|
* Get all noshow info or noshow for specified event schedule
|
|
* @param int $eventScheduleId = event schedule id
|
|
* @return [type] [description]
|
|
* access public function
|
|
*/
|
|
public function getNoshowInfo(int $eventScheduleId)
|
|
{
|
|
$data = $this->nshow_model->getNoshowInfo($eventScheduleId);
|
|
output_to_json($this, $data);
|
|
}
|
|
|
|
/**
|
|
* total_available_seat, remaining_seat in Event_schedule table
|
|
*
|
|
* @param integer $eventScheduleId
|
|
* @return void
|
|
* access public member
|
|
*/
|
|
public function toggleNoshowStatus(int $event_schedule_id)
|
|
{
|
|
$success = $this->nshow_model->toggleNoshowStatus($this->input->post()['no_show_stat'], $event_schedule_id);
|
|
if ($success) {
|
|
$msg = array(
|
|
"message" => "Les paramètres de Noshow mis à jour.",
|
|
"mtype" => "success"
|
|
);
|
|
} else {
|
|
$msg = array(
|
|
"message" => "Noshow settings could not be updated",
|
|
"mtype" => "error"
|
|
);
|
|
}
|
|
output_to_json($this, $msg);
|
|
}
|
|
/**
|
|
* gets the current noshow_status
|
|
*
|
|
* @param integer $eventScheduleId
|
|
* @return void
|
|
* access public member
|
|
*/
|
|
public function getNoshowStatus(int $event_schedule_id)
|
|
{
|
|
/*
|
|
* Get event schedule info
|
|
*/
|
|
$evsched_info = $this->nshow_model->getEventScheduleDetails($event_schedule_id);
|
|
|
|
$nshow_stat = $this->nshow_model->getNoshowStatus($event_schedule_id);
|
|
if ($nshow_stat) {
|
|
$msg = array(
|
|
"noshow_stat" => $nshow_stat['no_show_stat'],
|
|
"is_passed_start_date" => $evsched_info['is_passed_start_date']
|
|
);
|
|
} else {
|
|
$msg = array(
|
|
"noshow_stat" => 0
|
|
);
|
|
}
|
|
output_to_json($this, $msg);
|
|
}
|
|
}
|
|
|