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.
931 lines
40 KiB
931 lines
40 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
use app\core\auth\Sso;
|
|
use app\controllers\events\Event_workshop_informer;
|
|
|
|
class Background_service extends \MY_Controller {
|
|
protected $_servers_;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->my_parent_controller();
|
|
$this->load->library("mailjet_libr");
|
|
$this->load->model("GAnalytics_model");
|
|
$this->load->model("event_email_recipient_model");
|
|
$this->load->model("event_email_template_model");
|
|
|
|
// $this->eventWorkshop = new Event_workshop_informer();
|
|
}
|
|
|
|
public function run_service_011($limit, $service_type, $server){
|
|
if ((isset($service_type) && !empty($service_type)) || (isset($this->_servers_[$server]) && !empty($this->_servers_[$server]))) {
|
|
if (isset($limit) && !empty($limit)) {
|
|
$maildata = $this->get_mail_recipes($limit, $service_type);
|
|
if ($maildata["status"]) {
|
|
$maildata["addVars"] = $this->definedVars(strtoupper($server));
|
|
$mjmailer_response = $this->mailjet_libr->send($maildata, $service_type);
|
|
|
|
if (isset($mjmailer_response["success"]) && !empty($mjmailer_response["success"])) {
|
|
if(countVal($mjmailer_response["sent_emails"]) > 0 || countVal($mjmailer_response["failed_emails"]) > 0) {
|
|
$response = $this->event_email_recipient_model->update_recipient_email_status($mjmailer_response, $service_type);
|
|
if ($response) {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") - ".$mjmailer_response["logs"] . PHP_EOL;
|
|
} else {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : Server connection error." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : Err code : ".$mjmailer_response["logs"]." Message : Cannot send emails." . PHP_EOL;
|
|
}
|
|
} else {
|
|
if (isset($mjmailer_response["logs"]) && !empty($mjmailer_response["logs"])) {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : " . print_r($mjmailer_response["logs"]) . PHP_EOL;
|
|
} else {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : Unknown error occurred" . PHP_EOL;
|
|
}
|
|
}
|
|
} else {
|
|
if(isset($maildata["message"]) && !empty($maildata["message"])){
|
|
echo $maildata["message"];
|
|
}
|
|
}
|
|
} else {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : Specify the number of items to process." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "Log (" . date("Y-m-d H:i:s A") . ") : Undefined service type." . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
private function get_mail_recipes($limit, $type){
|
|
switch($type){
|
|
case 1:
|
|
return $this->get_reminder_emails($limit);
|
|
break;
|
|
case 2:
|
|
return $this->get_waitlist_emails($limit);
|
|
break;
|
|
case 3:
|
|
return $this->get_push_event_emails($limit);
|
|
break;
|
|
case 4:
|
|
// Resend email or Send Paid event emails in the Background
|
|
return $this->get_fo_emails_to_send($limit);
|
|
break;
|
|
case 5:
|
|
// Send workshop informer emails
|
|
return $this->sendEmailToWorkshopInformer($limit);
|
|
break;
|
|
default :
|
|
echo "No action has been specified.";
|
|
exit(0);
|
|
break;
|
|
};
|
|
}
|
|
|
|
public function auto_close_and_open_event($service_code){
|
|
if (isset($service_code) && !empty($service_code)) {
|
|
if($service_code == "lemodeFRWlogx0d@2016") {
|
|
//open events
|
|
$this->load->model("event_model");
|
|
$this->load->model("user_subscriber_model");
|
|
$open_events_for_res_feedback = $this->event_model->open_events_for_reservations();
|
|
$terminate_events_feedback = $this->event_model->terminate_events();
|
|
$close_events_feedback = $this->event_model->close_events();
|
|
// $close_events_feedback = $this->user_subscriber_model->automatic_disable_moderation_events();
|
|
|
|
// Delete outdated files in FO
|
|
deleteOutdatedTmpFiles();
|
|
|
|
if($open_events_for_res_feedback){
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Events Open for Reservation : " . $open_events_for_res_feedback .PHP_EOL;
|
|
}
|
|
if($terminate_events_feedback){
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Events Terminated : " . $terminate_events_feedback .PHP_EOL;
|
|
}
|
|
if($close_events_feedback){
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Events Closed : " . $close_events_feedback . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unknown service code." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Undefined service. Please specify a valid service code." . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
public function auto_unlock_fo_actions($service_code){
|
|
if (isset($service_code) && !empty($service_code)) {
|
|
if($service_code == "lemodeFRWlogx0d@2016") {
|
|
$this->load->model("event_concurrent_process_model");
|
|
$this->load->model("user_model");
|
|
$this->load->model("event_email_schedule_model");
|
|
$unlock_processes = $this->event_concurrent_process_model->cron_unlock_fo_actions();
|
|
/*This approach will log out all users who closes the browser and not logged in properly after 24hrs.*/
|
|
$logout_users = $this->user_model->logout_users();
|
|
/* we need to set to passe all the reminder custom schedule */
|
|
$set_reminder_sched_topass = $this->event_email_schedule_model->set_reminder_sched_to_pass();
|
|
$expired_access_token = $this->user_model->access_token_has_expired();
|
|
if($unlock_processes) {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unlock_processes : " . $unlock_processes .PHP_EOL;
|
|
}
|
|
// if($logout_users){
|
|
// echo "System (" . date("Y-m-d H:i:s A") . ") : Logout_Users : " . $logout_users . PHP_EOL;
|
|
// }
|
|
// if($set_reminder_sched_topass){
|
|
// echo "System (" . date("Y-m-d H:i:s A") . ") : Reminder_sched_passed : " . $set_reminder_sched_topass. PHP_EOL;
|
|
// }
|
|
// if($expired_access_token){
|
|
// echo "System (" . date("Y-m-d H:i:s A") . ") : Expired_token : " . $expired_access_token . PHP_EOL;
|
|
// }
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unknown service code." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Undefined service. Please specify a valid service code." . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
public function get_reminder_emails($limit=1){
|
|
if($limit>0) {
|
|
$this->load->model("event_registration_model");
|
|
$published_events = $this->event_registration_model->get_data_reminder_email_list();
|
|
|
|
if ($published_events) {
|
|
$mj_mailer_data = array();
|
|
foreach ($published_events as $value) {
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($value->event_id, 3, 1);
|
|
if(countVal($event_email_tpl) > 0) {
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
|
|
$subscribers = $this->event_registration_model->get_event_subscribers_list($value->event_start_date_time, $value->event_id, $limit);
|
|
|
|
if ($subscribers) {
|
|
$total_result = countVal($subscribers);
|
|
if ($total_result < $limit) {
|
|
$limit = $limit - $total_result;
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
} else {
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(countVal($mj_mailer_data) > 0){
|
|
return array("status" => true, "maildata" => $mj_mailer_data);
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => "Log (" . date("Y-m-d H:i:s A") . ") : Please specify the number of mails to send per process.".PHP_EOL
|
|
);
|
|
}
|
|
}
|
|
|
|
public function get_waitlist_emails($limit=1){
|
|
if($limit>0) {
|
|
$this->load->model("event_wait_list_model");
|
|
$published_events = $this->event_wait_list_model->get_data_waitlists();
|
|
if ($published_events) {
|
|
$swift_mailer_data = array();
|
|
foreach ($published_events as $value) {
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($value->event_id, $value->event_schedule_id, 2, true);
|
|
if(countVal($event_email_tpl) > 0) {
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
|
|
$subscribers = $this->event_wait_list_model->get_waitlists_subscribers($value->event_schedule_id, $limit);
|
|
|
|
if ($subscribers) {
|
|
$total_result = countVal($subscribers);
|
|
if ($total_result < $limit) {
|
|
$limit = $limit - $total_result;
|
|
array_push($swift_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
} else {
|
|
array_push($swift_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(countVal($swift_mailer_data) > 0){
|
|
return array("status" => true, "maildata" => $swift_mailer_data);
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => "Log (" . date("Y-m-d H:i:s A") . ") : Please specify the number of mails to send per process.".PHP_EOL
|
|
);
|
|
}
|
|
}
|
|
|
|
public function get_push_event_emails($limit=1){
|
|
if($limit>0) {
|
|
$this->load->model("event_email_custom_model");
|
|
$published_events = $this->event_email_custom_model->get_data_push_event_email();
|
|
if ($published_events) {
|
|
$mj_mailer_data = array();
|
|
foreach ($published_events as $value) {
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($value->event_id, $value->event_schedule_id, 4, true);
|
|
if(countVal($event_email_tpl) > 0) {
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
|
|
$subscribers = $this->event_email_custom_model->get_push_event_recipients($value->email_custom_id, $limit);
|
|
$total_result = countVal($subscribers);
|
|
if ($total_result > 0) {
|
|
if ($total_result < $limit) {
|
|
$limit = $limit - $total_result;
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
} else {
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(countVal($mj_mailer_data) > 0){
|
|
return array("status" => true, "maildata" => $mj_mailer_data);
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => "Log (" . date("Y-m-d H:i:s A") . ") : Please specify the number of mails to send per process.".PHP_EOL
|
|
);
|
|
}
|
|
}
|
|
|
|
public function get_fo_emails_to_send($limit=1){
|
|
if($limit>0) {
|
|
$this->load->model("event_email_recipient_model");
|
|
$published_events = $this->event_email_recipient_model->get_data_resend_email_list();
|
|
|
|
if (!$published_events) {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
|
|
$mj_mailer_data = array();
|
|
/* Get resend emails for published events*/
|
|
foreach ($published_events as $value) {
|
|
// Remove duplicate email_type_id
|
|
$email_type_ids = array_values(array_unique(explode("_", $value->email_type_id)));
|
|
|
|
if(countVal($email_type_ids) <= 0){
|
|
continue;
|
|
}
|
|
foreach ($email_type_ids as $email_type_id) {
|
|
$event_cancel_tpl = (($value->event_status === 'CANCEL') ? 7 : null);
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($value->event_id, $value->event_schedule_id, $email_type_id, true, $event_cancel_tpl);
|
|
|
|
if(countVal($event_email_tpl) <= 0) {
|
|
continue;
|
|
}
|
|
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
|
|
$subscribers = $this->event_email_recipient_model->get_event_subscribers_list($value->event_schedule_id, $email_type_id, $limit);
|
|
|
|
if (!$subscribers) {
|
|
continue;
|
|
}
|
|
|
|
$total_result = countVal($subscribers);
|
|
if ($total_result < $limit) {
|
|
$limit = $limit - $total_result;
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
} else {
|
|
array_push($mj_mailer_data, array(
|
|
"event" => $value,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscribers" => $subscribers
|
|
));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(countVal($mj_mailer_data) > 0){
|
|
return array("status" => true, "maildata" => $mj_mailer_data);
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => ""
|
|
);
|
|
}
|
|
|
|
} else {
|
|
return array(
|
|
"status" => false,
|
|
"message" => "Log (" . date("Y-m-d H:i:s A") . ") : Please specify the number of mails to send per process.".PHP_EOL
|
|
);
|
|
}
|
|
}
|
|
|
|
public function reminder_email_management_service($service_code){
|
|
if (isset($service_code) && !empty($service_code)) {
|
|
if($service_code == "lemodeFRWlogx0d@2016") {
|
|
$this->load->model("event_model");
|
|
$this->load->model("event_email_schedule_model");
|
|
$result = $this->event_model->get_events_for_reminder_email();
|
|
$msg_log = "";
|
|
if(countVal($result) > 0) {
|
|
foreach ($result as $row) {
|
|
$email_schedule = $this->event_email_schedule_model->get_email_sending_schedule($row);
|
|
if(countVal($email_schedule) > 0){
|
|
$msg_log .=$this->reminder_subscribers($email_schedule, $row);
|
|
}
|
|
}
|
|
}
|
|
echo $msg_log. PHP_EOL;
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unknown service code." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Undefined service. Please specify a valid service code." . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
private function reminder_subscribers($email_schedule, $event){
|
|
$count = 0; $events="";
|
|
$this->load->model("event_registration_model");
|
|
if(countVal($email_schedule) > 0)
|
|
{
|
|
foreach($email_schedule as $row){
|
|
$events .="Event_id : ".$event->event_id.", Event_schedule_id : ".$row->email_schedule_id.", Email sched. type : ".$row->email_sched_reference." \n";
|
|
$count += $this->event_registration_model->prepare_list_for_reimnder_email($row, $event);
|
|
}
|
|
} else{
|
|
$events .="Event_id : ".$event->event_id.", Event_schedule_id : ".$email_schedule->email_schedule_id.", Email sched. type : ".$email_schedule->email_sched_reference." \n";
|
|
$count += $this->event_registration_model->prepare_list_for_reimnder_email($email_schedule, $event);
|
|
}
|
|
|
|
if($count > 0) {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Count : ".$count.", Record : \n".$events. PHP_EOL;
|
|
}
|
|
}
|
|
|
|
public function waitlist_management_service($service_code){
|
|
if (!isset($service_code) && empty($service_code)) {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Undefined service. Please specify a valid service code.";
|
|
}
|
|
|
|
if($service_code != "lemodeFRWlogx0d@2016") {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unknown service code.";
|
|
return false;
|
|
}
|
|
$this->load->model("event_model");
|
|
$this->load->model("event_wait_list_model");
|
|
$this->load->model("event_email_schedule_model");
|
|
$this->load->model("event_email_default_setting_model");
|
|
$result = $this->event_model->get_events_for_waitinglist_email();
|
|
|
|
// $parameters = $this->event_email_default_setting_model->get_default_email_schedule(2);
|
|
$msg_log = "";
|
|
//only process data when parameters are all set
|
|
// if(sizeof($parameters) > 0) {
|
|
//only process events with waitlisted
|
|
if (countVal($result) <= 0) {
|
|
return false;
|
|
}
|
|
|
|
foreach ($result as $row) {
|
|
//check the date to reset, check from table "event_template_email"
|
|
if($row->email_schedule_id <= 0) {
|
|
//if there are parameters already, immediately add them to "event_email_template"
|
|
$msg_log .= $this->prepare_waitlist_tobe_emailed($row);
|
|
continue;
|
|
}
|
|
$check_reset_date = $this->event_email_template_model->check_reset_time($row->email_schedule_id);
|
|
//reset date is now
|
|
if(!$check_reset_date) {
|
|
continue;
|
|
}
|
|
//if there are parameters already, immediately add them to "event_email_template"
|
|
$msg_log .= $this->prepare_waitlist_tobe_emailed($row);
|
|
}
|
|
echo $msg_log;
|
|
}
|
|
|
|
private function prepare_waitlist_tobe_emailed($event){
|
|
$result = $this->event_email_schedule_model->add_email_schedule_for_waitlist($event->event_id, $event->event_schedule_id);
|
|
if($result["success"]) {
|
|
$this->event_wait_list_model->prepare_list_for_reinvitation_email($result["email_schedule_id"], $event->event_schedule_id, $result["schedule"]->email_tpl_number_of_recipients);
|
|
} else {
|
|
return "Log (" . date("Y-m-d H:i:s A") . ") : " ."Cannot add email_template";
|
|
}
|
|
}
|
|
|
|
private function add_to_waitlist_for_email($event_id){
|
|
$this->load->model("event_deregistration_model");
|
|
|
|
$this->event_deregistration_model->add_to_waitlist_for_email($event_id);
|
|
}
|
|
|
|
public function email_waiting_list_reinvitation() {
|
|
$this->mailjet_libr->email_waiting_list_reinvitation();
|
|
}
|
|
|
|
public function sendEmailToWorkshopInformer($limit = 1){
|
|
return Event_workshop_informer::sendEmailToWorkshopInformer($limit);
|
|
}
|
|
|
|
public function prepareWorkshopInformerList($service_code) {
|
|
Event_workshop_informer::prepareWorkshopInformerList($service_code);
|
|
}
|
|
|
|
/** Set status of reservation when year of subscription is more than 1 year */
|
|
public function video_workshop_reservation_validation() {
|
|
$this->load->model("event_registration_model");
|
|
$result = $this->event_registration_model->update_expiring_video_reservation();
|
|
}
|
|
|
|
/** Sets event registration workshop session value */
|
|
public function update_event_registration() {
|
|
$this->load->model("event_model");
|
|
$this->load->model("event_registration_model");
|
|
$events = $this->event_model->get_online_video();
|
|
foreach($events as $event) {
|
|
$this->event_registration_model->update_reservation_workshop_session($event->workshop_session, $event->event_id);
|
|
}
|
|
}
|
|
public function definedVars($server){
|
|
switch($server) {
|
|
case "LOCAL":
|
|
return array(
|
|
"base_url" => "https://univ.c4m.mg/",
|
|
"lemonde_logo" => "/home/stephane/public_html/img/logo_white.png",
|
|
"event_picture" => "resources/images/frontoffice/events/",
|
|
"event_url" => "event_details?event_id="
|
|
);
|
|
case "PREPROD":
|
|
return array(
|
|
"base_url" => "https://univ.c4m.mg/",
|
|
"lemonde_logo" => "/home/stephane/public_html/img/logo_white.png",
|
|
"event_picture" => "resources/images/frontoffice/events/",
|
|
"event_url" => "event_details?event_id="
|
|
);
|
|
case "DEV":
|
|
return array(
|
|
"base_url" => "https://univ.c4m.mg/",
|
|
"lemonde_logo" => "/home/stephane/public_html/img/logo_white.png",
|
|
"event_picture" => "resources/images/frontoffice/events/",
|
|
"event_url" => "event_details?event_id="
|
|
);
|
|
default: // PROD
|
|
return array(
|
|
"base_url" => "https://univ.c4m.mg/",
|
|
"lemonde_logo" => "/home/stephane/public_html/img/logo_white.png",
|
|
"event_picture" => "resources/images/frontoffice/events/",
|
|
"event_url" => "event_details?event_id="
|
|
);
|
|
}
|
|
}
|
|
|
|
public function get_server_time(){
|
|
|
|
echo "PHP : ".date('Y-m-d H:i:s');
|
|
echo "<br/>";
|
|
print_r($this->db->query("SELECT @@global.time_zone, @@session.time_zone, NOW();")->row());
|
|
if (date_default_timezone_get()) {
|
|
echo '<br/>date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
|
|
}
|
|
if (ini_get('date.timezone')) {
|
|
echo '<br/>date.timezone: ' . ini_get('date.timezone');
|
|
}
|
|
}
|
|
|
|
public function update_email_status(){
|
|
$this->load->model("event_schedule_model");
|
|
|
|
$scheds = $this->event_schedule_model->get_scheds();
|
|
|
|
foreach($scheds as $row){
|
|
$this->event_schedule_model->add_event_email_schedule_status($row->event_schedule_id);
|
|
}
|
|
}
|
|
|
|
/**
|
|
** @method get Google analytics data and store it locally
|
|
*/
|
|
public function fetch_and_store_analytics_data($start ='', $end ='', $limit ='', $order ='', $report_category = 'all_garep'){
|
|
$report = new GAnalytics_model();
|
|
$data = $report->getStoreGAData($this->db, $start, $end);
|
|
$data = $report->getStoreConnectedUsers($start, $end);
|
|
|
|
output_to_json($this, array(
|
|
"message" => 'successful'
|
|
));
|
|
// output_to_json($this, $data);
|
|
}
|
|
|
|
/**
|
|
* CRON
|
|
* Way to automatically sets by event schedule flexible moderation setting to TRUE
|
|
* once it matches the scheduled set
|
|
*
|
|
* @param $service_code passcode
|
|
* @return void
|
|
*
|
|
* access public member
|
|
*/
|
|
public function moderation(string $service_code) : void
|
|
{
|
|
/**
|
|
* Total seats = 100
|
|
* Remaining = 40
|
|
* A = 100 * .50
|
|
* B = 100 – A,
|
|
* B > Remaining , enable flexible
|
|
* B < Remaining, disable flexible
|
|
*/
|
|
// function model that checks and update per event flexible moderation to TRUE once it satisfies the schedule
|
|
if (isset($service_code) && !empty($service_code)) {
|
|
if($service_code == "lemodeFRWlogx0d@2016") {
|
|
$this->load->model('event_moderation_model');
|
|
$this->event_moderation_model->querySetPerEventFlexibleModerationToActive();
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Unknown service code." . PHP_EOL;
|
|
}
|
|
} else {
|
|
echo "System (" . date("Y-m-d H:i:s A") . ") : Undefined service. Please specify a valid service code." . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
//TODO: Remove this part before updating Prod server!!!
|
|
public function bypass_coockie_creation() {
|
|
|
|
$WHITELIST = [
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]',
|
|
'[email protected]'
|
|
];
|
|
|
|
$data = array(
|
|
'csrfname' => $this->security->get_csrf_token_name(),
|
|
'csrfhash' => $this->security->get_csrf_hash(),
|
|
'error' => "",
|
|
"whitelisted" => $WHITELIST
|
|
);
|
|
|
|
if ($this->input->post('email_address') && !in_array($this->input->post('email_address'), $WHITELIST)) {
|
|
$data["error"] = "Subscriber not found!";
|
|
} else if ($this->input->post('email_address')) {
|
|
$extractName = explode("@", $this->input->post('email_address'));
|
|
Sso::set_mock_cookies([
|
|
'mail' => $this->input->post('email_address'),
|
|
'firstname' => $extractName[0],
|
|
'name' => 'Test',
|
|
'premium' => !!$this->input->post('premium'),
|
|
'sso' => [
|
|
'product_code' => ""//$this->input->post('product_code')
|
|
]
|
|
// 'stay_connected' => 1
|
|
]);
|
|
|
|
redirect('authenticate');
|
|
}
|
|
|
|
$this->load->view('cookie_view', $data);
|
|
}
|
|
|
|
/**
|
|
* send reminder email for distance workshop per video
|
|
*/
|
|
public function atelier_distance_reminder() {
|
|
$this->load->model("event_registration_model");
|
|
$result = $this->event_registration_model->get_atelier_distance_subscribers();
|
|
$response = array();
|
|
if($result) {
|
|
//$this->load->library("mailjet_libr");
|
|
foreach($result as $row) {
|
|
//unset($row->night_class_prices);
|
|
$email_data = $this->get_distance_reminder_email((array)$row);
|
|
if($email_data) {
|
|
$val = $this->mailjet_libr->send($email_data, 7);
|
|
array_push($response, $val);
|
|
}
|
|
}
|
|
}
|
|
|
|
output_to_json($this, array(
|
|
"datetime" => date('Y-m-d H:i:s'),
|
|
"data" => $response
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Caution: do not call this method
|
|
* This was use on the static event reminder email
|
|
* Send reminder email
|
|
*/
|
|
public function atelier_event_47_53_reminder() {
|
|
$this->load->model("event_registration_model");
|
|
$result = $this->event_registration_model->get_subscribers_by_event_id(REMINDER_EVENT_IDS);
|
|
$response = array();
|
|
if($result) {
|
|
//$this->load->library("mailjet_libr");
|
|
$copy = false;
|
|
$tmp = false;
|
|
foreach($result as $row) {
|
|
//unset($row->night_class_prices);
|
|
if(!$copy) {
|
|
$tmp = (array) $row;
|
|
$copy = true;
|
|
break;
|
|
}
|
|
// $email_data = $this->get_distance_reminder_email_47_53((array)$row);
|
|
// if($email_data) {
|
|
// $val = $this->mailjet_libr->send($email_data, 7);
|
|
// array_push($response, $val);
|
|
// }
|
|
}
|
|
if($tmp) {
|
|
$emails = $this->subscribers_email();
|
|
foreach($emails as $email) {
|
|
$tmp['email_address'] = $email;
|
|
$email_data = $this->get_distance_reminder_email_47_53((array)$tmp);
|
|
if($email_data) {
|
|
$val = $this->mailjet_libr->send($email_data, 7);
|
|
array_push($response, $val);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
output_to_json($this, array(
|
|
"datetime" => date('Y-m-d H:i:s'),
|
|
"data" => $response
|
|
));
|
|
}
|
|
|
|
private function get_distance_reminder_email(array $data) {
|
|
$mj_mailer_data = array();
|
|
$this->load->model("event_email_template_model");
|
|
$data = array_merge($data, ['video_link' => 'atelier-a-distance/'.$data['event_id']]);
|
|
$event_email_tpl = $this->event_email_template_model->get_current_event_email_template($data['event_id'], 8, 1);
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
array_push($mj_mailer_data, array(
|
|
"event" => (object)$data,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscriber" => (object)$data
|
|
));
|
|
//return $event_email_tpl;
|
|
return $mj_mailer_data[0];
|
|
|
|
}
|
|
|
|
private function get_distance_reminder_email_47_53(array $data) {
|
|
$mj_mailer_data = array();
|
|
$this->load->model("event_email_template_model");
|
|
$data = array_merge($data, ['video_link' => 'atelier-a-distance/'.$data['event_id']]);
|
|
// $event_email_tpl = $this->event_email_template_model->get_customized_template_by_email_type_id(8);
|
|
$event_email_tpl = $this->event_email_template_model->get_default_template_by_email_type_id(8);
|
|
$event_email_tpl->email_tpl_detail = urldecode($event_email_tpl->email_tpl_detail);
|
|
array_push($mj_mailer_data, array(
|
|
"event" => (object)$data,
|
|
"event_email_tpl" => $event_email_tpl,
|
|
"subscriber" => (object)$data
|
|
));
|
|
//return $event_email_tpl;
|
|
return $mj_mailer_data[0];
|
|
|
|
}
|
|
|
|
private function subscribers_email() {
|
|
return array('[email protected]', '[email protected]');
|
|
// return array(
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// 'é[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
// '[email protected]',
|
|
|
|
// );
|
|
}
|
|
}
|
|
|