103 lines
2.8 KiB
PHP
103 lines
2.8 KiB
PHP
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||
|
|
/**
|
||
|
|
* Cronjob Abstract Controller
|
||
|
|
* @copyright 2019 Manaknightdigital Inc.
|
||
|
|
* @link https://manaknightdigital.com
|
||
|
|
* @license Proprietary Software licensing
|
||
|
|
* @author Ryan Wong
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
class Cronjob_controller extends CI_Controller
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Debug Controller to error_log and turn off in production
|
||
|
|
*
|
||
|
|
* @param mixed $data
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function dl($key, $data)
|
||
|
|
{
|
||
|
|
if (ENVIRONMENT == 'development')
|
||
|
|
{
|
||
|
|
error_log($key . ' CONTROLLER : <pre>' . print_r($data, TRUE) . '</pre>');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Debug json Controller to error_log and turn off in production
|
||
|
|
*
|
||
|
|
* @param mixed $data
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function dj($key, $data)
|
||
|
|
{
|
||
|
|
if (ENVIRONMENT == 'development')
|
||
|
|
{
|
||
|
|
error_log($key . ' CONTROLLER : ' . json_encode($data));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Function to send Emails given slug, payload and email
|
||
|
|
*
|
||
|
|
* @param string $slug
|
||
|
|
* @param mixed $payload
|
||
|
|
* @param string $email
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
protected function _send_email_notification($slug, $payload, $email)
|
||
|
|
{
|
||
|
|
$this->load->model('email_model');
|
||
|
|
$this->load->library('mail_service');
|
||
|
|
$this->mail_service->set_adapter('smtp');
|
||
|
|
$email_template = $this->email_model->get_template($slug, $payload);
|
||
|
|
|
||
|
|
if ($email_template)
|
||
|
|
{
|
||
|
|
$from = $this->config->item('from_email');
|
||
|
|
return $this->mail_service->send($from, $email, $email_template->subject, $email_template->html);
|
||
|
|
}
|
||
|
|
|
||
|
|
return FALSE;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Function to send Sms given slug, payload and phone #
|
||
|
|
*
|
||
|
|
* @param string $slug
|
||
|
|
* @param mixed $payload
|
||
|
|
* @param string $to
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
protected function _send_sms_notification($slug, $payload, $to)
|
||
|
|
{
|
||
|
|
$this->load->model('sms_model');
|
||
|
|
$this->load->library('sms_service');
|
||
|
|
$this->sms_service->set_adapter('sms');
|
||
|
|
$sms_template = $this->sms_model->get_template($slug, $payload);
|
||
|
|
|
||
|
|
if ($sms_template)
|
||
|
|
{
|
||
|
|
return $this->sms_service->send($to, $sms_template->content);
|
||
|
|
}
|
||
|
|
|
||
|
|
return FALSE;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Function to send Push notification
|
||
|
|
*
|
||
|
|
* @param string $slug
|
||
|
|
* @param mixed $payload
|
||
|
|
* @param string $to
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
protected function _send_push_notification($device_type, $device_id, $title, $message, $image)
|
||
|
|
{
|
||
|
|
$this->load->library('push_notification_service');
|
||
|
|
$this->push_notification_service->init();
|
||
|
|
return $this->push_notification_service->send($device_type, $device_id, $title, $message, $image);
|
||
|
|
}
|
||
|
|
}
|