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.
149 lines
6.3 KiB
149 lines
6.3 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\utils\Response;
|
|
|
|
class Event_resend_email extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
//parent::__construct();
|
|
$this->my_parent_controller();
|
|
Response::handleSessionTimeout("bo");
|
|
|
|
//load language file
|
|
$this->load_language_backoffice();
|
|
$this->lang->load('backoffice/event_resend_email', 'fr');
|
|
|
|
//load model
|
|
$this->load->model("event_email_recipient_model");
|
|
}
|
|
|
|
/*
|
|
* Method for generationg list of
|
|
* Last Name, First name Email datatable for front end
|
|
*/
|
|
public function list_resend_email($email_type_id = null, $event_schedule_id = null){
|
|
|
|
if($this->input->post() && isset($this->data["logged_in"]["user_id"]) && !empty($email_type_id) && !empty($event_schedule_id)) {
|
|
|
|
$list = $this->event_email_recipient_model->get_datatables($this->input->post(), $email_type_id, $event_schedule_id);
|
|
|
|
$data = array();
|
|
$row = array();
|
|
$x = $this->input->post("start");
|
|
|
|
foreach ($list as $resend_email) {
|
|
$email_status = ""; $email_recipient_id = "";
|
|
$email_description = "";
|
|
if(($resend_email->email_status != null && $resend_email->email_status !="")){
|
|
$exp = explode("_",$resend_email->email_status);
|
|
if(count($exp) > 1){
|
|
$email_status = $exp[0];
|
|
$email_recipient_id = $exp[1];
|
|
$email_description = (isset($exp[2]) && !empty($exp[2]))?$exp[2]:"";
|
|
}
|
|
}
|
|
$row["no"] = ++$x;
|
|
$row["first_name"] = $resend_email->first_name;
|
|
$row["last_name"] = $resend_email->last_name;
|
|
$row["reference_id"] = $resend_email->reference_id;
|
|
$row["email"] = $resend_email->email;
|
|
$row["email_status"] = $email_status;
|
|
$row["email_description"] = $email_description;
|
|
$row["email_recipient_id"] = $email_recipient_id;
|
|
$row["event_schedule_id"] = $event_schedule_id;
|
|
array_push($data, $row);
|
|
}
|
|
$output = array(
|
|
"draw" => $_POST['draw'],
|
|
"recordsTotal" => $this->event_email_recipient_model->count_all($this->input->post(), $email_type_id, $event_schedule_id),
|
|
"recordsFiltered" => $this->event_email_recipient_model->count_filtered($this->input->post(), $email_type_id, $event_schedule_id),
|
|
"data" => $data,
|
|
);
|
|
//output to json format
|
|
output_to_json($this, $output);
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
|
|
public function resend_email_to_subscribers($email_type_id, $event_schedule_id)
|
|
{
|
|
if((isset($_GET)) && isset($this->data["logged_in"]["user_id"]) && !empty($email_type_id) && !empty($event_schedule_id)) {
|
|
$list = $this->event_email_recipient_model->resend_email($email_type_id, $event_schedule_id);
|
|
//output to json format
|
|
|
|
output_to_json($this, array(
|
|
'status' => 'SUCCESS',
|
|
'message' => 'Email sent to subscribers.'
|
|
));
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
/**
|
|
* generate select box for datable
|
|
*/
|
|
public function get_email_template_type()
|
|
{
|
|
output_to_json($this, $this->event_email_recipient_model->get_email_template_types([3,5,6]));
|
|
}
|
|
/*
|
|
* insert new refence ids for resend
|
|
*/
|
|
public function insert_reference_id()
|
|
{
|
|
if($this->input->post() && isset($this->data["logged_in"]["user_id"])) {
|
|
//check if email template is activated
|
|
if($this->event_email_recipient_model->check_emailing_status() > 0){
|
|
|
|
if( $this->event_email_recipient_model->insert_reference_ids() ){
|
|
output_to_json($this, array( 'mtype' => 'success' , 'message' => $this->lang->line("resend_email_success")));
|
|
}
|
|
else {
|
|
output_to_json($this, array( 'mtype' => 'error' , 'message' => $this->lang->line("resend_email_error")));
|
|
}
|
|
} else{
|
|
output_to_json($this, array( 'mtype' => 'warning' , 'message' => "Email sending is currently disabled for this email type!"));
|
|
}
|
|
} else {
|
|
show_404();
|
|
}
|
|
}
|
|
|
|
public function cancel_resend_email(){
|
|
|
|
if($this->input->post() && isset($this->data["logged_in"]["user_id"]) && !empty($_POST['email_recipient_id']) && isset($_POST['email_recipient_id'])) {
|
|
$result = $this->event_email_recipient_model->cancel_resend_email($this->input->post('email_recipient_id'));
|
|
if($result){
|
|
output_to_json($this, array( 'mtype' => 'success' , 'message' => "Email has been cancelled."));
|
|
} else {
|
|
output_to_json($this, array( 'mtype' => 'warning' , 'message' => "Unable to cancel email. Email status is not updated."));
|
|
}
|
|
}else{
|
|
show_404();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Onqueue cancellation emails for registered subscribers to an event
|
|
* whenever an event has been cancelled by the Admin in the Backoffice
|
|
*/
|
|
public function onqueue_cancellation_emails_upon_event_cancellation($event_schedule_id) {
|
|
|
|
if (!$this->event_email_recipient_model->check_emailing_status($event_schedule_id, 7)) {
|
|
output_to_json($this, array( 'mtype' => 'warning' , 'message' => "Email sending is currently disabled for this email type!"));
|
|
}
|
|
|
|
$this->load->model("event_email_template_model");
|
|
$email_tpl = $this->event_email_template_model->get_current_event_email_template(null, $event_schedule_id, 7, false);
|
|
|
|
if(!countVal($email_tpl)) {
|
|
output_to_json($this, array( 'mtype' => 'warning' , 'message' => "No current email template used for this email type!"));
|
|
}
|
|
|
|
$count = $this->event_email_recipient_model->onqueue_cancellation_emails_upon_event_cancellation($event_schedule_id, 7);
|
|
|
|
output_to_json($this, array( 'mtype' => 'success' , 'message' => $count." registered subscriber".($count > 1 ? "s" : "")." will be emailed about event cancellation shortly!"));
|
|
}
|
|
}
|
|
|