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.
125 lines
5.1 KiB
125 lines
5.1 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\utils\Response;
|
|
|
|
class Event_registration extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
$this->my_parent_controller();
|
|
$this->load_language_backoffice();
|
|
$this->lang->load('backoffice/events', 'fr');
|
|
//load model
|
|
$this->load->model("event_registration_model");
|
|
$this->load->model("event_model");
|
|
$this->load->model('event_email_template_model');
|
|
$this->load->library("mailjet_libr");
|
|
|
|
}
|
|
|
|
public function event_subscribers_list($event_id=0) {
|
|
|
|
if($event_id) {
|
|
$formattedResult = array();
|
|
$result = $this->event_registration_model->get_subscribers_by_event($event_id);
|
|
if(!$result) {
|
|
output_to_json($this, array(
|
|
"mtype" => "error",
|
|
"message" => 'No subscribers'
|
|
));
|
|
}
|
|
foreach($result as $row) {
|
|
$total_seats_reserved = $this->event_registration_model->count_total_reserved_seats_by_subscriber($row->subscriber, $event_id);
|
|
$row = array_merge((array)$row, ['total_seats_reserved' => $total_seats_reserved]);
|
|
array_push($formattedResult, $row);
|
|
}
|
|
output_to_json($this, array(
|
|
"mtype" => "success",
|
|
"message" => $this->lang->line("subscribers_list"),
|
|
"mdata" => $formattedResult
|
|
));
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
/**
|
|
* Cancel subscriber reservation
|
|
*/
|
|
public function cancel_event_registration($registration_id=0) {
|
|
if($registration_id) {
|
|
$eventRegistration = $this->input->post();
|
|
$event = $this->event_registration_model->can_cancel_reservation($eventRegistration['event_id']);
|
|
if(!empty($event)) {
|
|
$result = $this->event_registration_model->cancel_event_registration($registration_id);
|
|
|
|
if($result) {
|
|
// $this->event_registration_model->update_remaining_seat($eventRegistration);
|
|
$emaildata = $this->get_cancelation_email($eventRegistration, $event);
|
|
$val = $this->mailjet_libr->send($emaildata, 6);
|
|
output_to_json($this, array(
|
|
"mtype" => "success",
|
|
"message" => $this->lang->line("subscriber_registration_canceled"),
|
|
"mdata" => $val
|
|
));
|
|
} else {
|
|
output_to_json($this, array(
|
|
"mtype" => "error",
|
|
"message" => $this->lang->line("cancel_registration_failed"),
|
|
"mdata" => ''
|
|
));
|
|
}
|
|
} else {
|
|
output_to_json($this, array(
|
|
"mtype" => "error",
|
|
"message" => $this->lang->line("not_allowed_to_cancel_registration"),
|
|
"mdata" => ''
|
|
));
|
|
}
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
private function get_cancelation_email($eventRegistration, $event) {
|
|
$mj_mailer_data = array();
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($eventRegistration['event_id'], 2, 1);
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
array_push($mj_mailer_data, array(
|
|
"event" => (object)array_merge((array)$event, ['seats_reserved' => $eventRegistration['seats_reserved']]),
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => [(object)$eventRegistration]
|
|
));
|
|
|
|
return array("status" => true, "maildata" => $mj_mailer_data);
|
|
|
|
}
|
|
|
|
/**
|
|
* This function used to update event payment table. to add registration id to it.
|
|
* Do not use this function to any part of your codes.
|
|
*/
|
|
public function update_event_payment_add_registration_id() {
|
|
$this->load->model("event_payment_model");
|
|
|
|
$registrations = $this->event_registration_model->get_subscribers();
|
|
foreach($registrations as $row) {
|
|
$payment = $this->event_payment_model->update_payment($row->subscriber, $row->event_id, $row->date_time, $row->registration_id);
|
|
print_r($payment);
|
|
echo "<br/><br/>";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is use to update event payment table. to add created_at column to it.
|
|
* Do not use this function to any part of your codes.
|
|
*/
|
|
public function update_event_payment_add_created_at() {
|
|
$this->load->model("event_payment_model");
|
|
|
|
$registrations = $this->event_registration_model->get_subscribers();
|
|
foreach($registrations as $row) {
|
|
$payment = $this->event_payment_model->add_payment_created_at($row->subscriber, $row->event_id, $row->registration_id, $row->date_time);
|
|
print_r($payment);
|
|
echo "<br/><br/>";
|
|
}
|
|
}
|
|
}
|