Mail Enabled - REG & disabled - ONLINE

This commit is contained in:
Velz2020 2019-10-18 20:15:43 +05:30
parent 78bb9c3bd0
commit 1f54c9dc92
6 changed files with 63 additions and 15 deletions

View File

@ -130,6 +130,7 @@ defined('CSR_CONTRIBUTION_DETAILS') OR define('CSR_CONTRIBUTION_DETAILS','csr_co
defined('CSR_CONTRIBUTIONS') OR define('CSR_CONTRIBUTIONS','csr_contributions');
defined('CSR_TXN_DETAILS') OR define('CSR_TXN_DETAILS','csr_txn_details');
defined('SCHOOLNEW_INFRA_DETAIL') OR define('SCHOOLNEW_INFRA_DETAIL','schoolnew_infra_detail');
defined('CSR_MAIL_CONTENTS') OR define('CSR_MAIL_CONTENTS','csr_mail_contents');
// APP SPECIFIC CONSTANTS

View File

@ -160,10 +160,12 @@ class iobpay extends REST_Controller
$log_message = '### Server error ! Please contact your website Administrator! Error Code : '. $errorcd;
log_message('ERROR',$log_message);
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
$data['msg'] = 'Server error ! Please contact your website Administrator! Error Code : '. $errorcd;
$this->response($data,REST_Controller::HTTP_OK);
// $data['dataStatus'] = false;
// $data['status'] = REST_Controller::HTTP_NOT_FOUND;
// $data['msg'] = 'Server error ! Please contact your website Administrator! Error Code : '. $errorcd;
echo $log_message;
header('Location: '.$this->config->item('failure_url'));
// $this->response($data,REST_Controller::HTTP_OK);
}
else
{
@ -186,6 +188,8 @@ class iobpay extends REST_Controller
//update child
$updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTION_DETAILS,array('cont_id' => $contribution_id[0]['con_id']));
//trigger mail
//$this->sendMail('SUCCESS',$merchanttxnid);
header('Location: '.$this->config->item('success_url'));
exit;
@ -193,6 +197,7 @@ class iobpay extends REST_Controller
else if($txnstatus=="FAILURE")
{
$temp_array['msg'] = 'Txn Failed!';
// $this->sendMail('FAILURE',$merchanttxnid);
header('Location: '.$this->config->item('failure_url'));
exit;
}
@ -383,6 +388,25 @@ class iobpay extends REST_Controller
return "Rupees ". $result . " Only";
}
function sendMail($status,$merchanttxnid)
{
$mail_content = $this->user_management_model->getMailContentForOnlineTransaction($merchanttxnid);
$mail_configs = $this->user_management_model->selectCustomRecords(array('*'),array('mail_code' => $status),CSR_MAIL_CONTENTS);
$fromMail = $mail_configs[0]['from_mail'];
$display_name = $mail_configs[0]['display_name'];
$subject = $mail_configs[0]['subject'];
$tomail = $mail_content['email'];
$content = $mail_configs[0]['content'];
$content = str_replace('{{user}}',$mail_content['name'],$content);
$content = str_replace('{{amount}}',$mail_content['amount'],$content);
$content = str_replace('{{txnstatus}}',$mail_content['txnstatus'],$content);
$content = str_replace('{{refid}}',$mail_content['ref_id'],$content);
$content = str_replace('{{trackid}}',$mail_content['trackid'],$content);
$this->load->helper('mymail');
MYMAIL::sendmyMail($fromMail,$display_name, $tomail,$subject,$content);
}
}

View File

@ -52,7 +52,7 @@ class user_management extends REST_Controller
if($org_info['id'] != "" || $org_info['id'] != null)
{
$org_info['updated_by'] = $user_data['updated_by'] ;
// $org_info['updated_by'] = $user_data['updated_by'] ;
$org_id = $this->user_management_model->updateRecords($org_info,CSR_USER_ORG,array('id' => $org_info['id']));
}
else
@ -73,6 +73,19 @@ class user_management extends REST_Controller
$org_info['created_by'] = $user_data['created_by'];
$org_id = $this->user_management_model->saveRecords($org_info,CSR_USER_ORG);
//trigger Reg sucessfull Mail
$mail_configs = $this->user_management_model->selectCustomRecords(array('*'),array('mail_code' => 'REG'),CSR_MAIL_CONTENTS);
$fromMail = $mail_configs[0]['from_mail'];
$display_name = $mail_configs[0]['display_name'];
$subject = $mail_configs[0]['subject'];
$tomail = $user_data['email'];
$content = $mail_configs[0]['content'];
$content = str_replace('{{user}}',$user_data['name'],$content);
$this->load->helper('mymail');
MYMAIL::sendmyMail($fromMail,$display_name, $tomail,$subject,$content);
}
}

View File

@ -4,14 +4,12 @@ class myMail
{
public static function sendmyMail($from,$fromDisplayName,$toWhom,$cc,$bcc,$subject,$mailContent)
public static function sendmyMail($from,$fromDisplayName,$toWhom,$subject,$mailContent)
{
$CI =&get_instance();
$CI->load->library('myMaillib');
$myMail = $CI->myMaillib->load();
$CI->load->library('mymaillib');
$myMail = $CI->mymaillib->load();
$myMail->IsSMTP(); // Telling the class to use SMTP
$myMail->SMTPAuth = true;
@ -24,20 +22,22 @@ class myMail
$myMail->addAddress($toWhom); // Name is optional
$myMail->From = $from;
$myMail->FromName = $fromDisplayName;
$myMail->isHTML($isHTM); // Set emyMail format to HTML
$myMail->isHTML(1); // Set emyMail format to HTML
$myMail->Subject = $subject;
$myMail->Body = $mailContent;
$myMail->AltBody = $mailContent;
$logger = MYLOG::logFunction();
//$logger = MYLOG::logFunction();
if(!$myMail->send()) {
log_message("ERROR",($myMail->ErrorInfo));
//echo $myMail->ErrorInfo;
} else {
log_message("ERROR",("myMailer Send:".$toWhom));
//$logger->info("myMailer Send:" ,array('myMail_ID' => $toWhom,'Status' => 'SEND'));
//echo 'done..!';
}

View File

@ -5,7 +5,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
//include_once APPPATH.'/vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class maillib
class mymaillib
{
public function __construct()
{

View File

@ -48,12 +48,22 @@ class user_management_model extends Custom_Model {
function getProfileData($userid)
{
$this->db->SELECT('CSR_USER.id, CSR_USER.name, CSR_USER.email, CSR_USER.mobile, CSR_USER.user_type, CSR_USER.isactive, CSR_USER.profile_share, CSR_USER.notify_pref,CSR_USER_ORG.orgname,CSR_USER_ORG.org_address,CSR_USER_ORG.org_pan');
$this->db->SELECT('CSR_USER.id, CSR_USER.name, CSR_USER.email, CSR_USER.mobile, CSR_USER.user_type, CSR_USER.isactive, CSR_USER.profile_share, CSR_USER.notify_pref,CSR_USER_ORG.orgname,CSR_USER_ORG.org_address,CSR_USER_ORG.org_pan,CSR_USER_ORG.id as org_id');
$this->db->FROM(CSR_USER.' as CSR_USER');
$this->db->JOIN(CSR_USER_ORG.' as CSR_USER_ORG','CSR_USER.id = CSR_USER_ORG.user_id','LEFT');
$this->db->WHERE('CSR_USER.id',$userid);
return $this->db->GET()->result_array();
}
function getMailContentForOnlineTransaction($merchanttxnid)
{
$this->db->SELECT('CSR_TXN_DETAILS.merchant_txn_id,CSR_TXN_DETAILS.amount,CSR_TXN_DETAILS.trackid,CSR_TXN_DETAILS.con_id,CSR_TXN_DETAILS.user_id,concat(DATE_FORMAT(convert_tz(CSR_CONTRIBUTIONS.timestamp,"+00:00","+05:30"),"%Y%m%d"),CSR_TXN_DETAILS.merchant_txn_id) as ref_id,CSR_USER.id, CSR_USER.name,CSR_USER.email,CSR_TXN_DETAILS.txnstatus');
$this->db->FROM(CSR_TXN_DETAILS.' as CSR_TXN_DETAILS');
$this->db->JOIN(CSR_CONTRIBUTIONS.' as CSR_CONTRIBUTIONS','CSR_TXN_DETAILS.con_id = CSR_CONTRIBUTIONS.id');
$this->db->JOIN(CSR_USER.' as CSR_USER','CSR_TXN_DETAILS.user_id = CSR_USER.id');
$this->db->WHERE('CSR_TXN_DETAILS.merchant_txn_id',$merchanttxnid);
return $this->db->GET()->result_array();
}
}