545 lines
22 KiB
PHP
545 lines
22 KiB
PHP
<?php
|
|
|
|
|
|
class PDALERTS
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
This function plays role of sending sms/email while PD status changing.
|
|
@param pdid
|
|
get current status, lender, created by, allocated_to, etc by using pdid.
|
|
then get pd notification config's using current pd status.
|
|
based on that pd config's send sms/email to endpoints
|
|
|
|
*/
|
|
|
|
public static function pdnotification($pdid)
|
|
{
|
|
|
|
|
|
if($pdid != "" || $pdid != null)
|
|
{
|
|
//echo $pdid;
|
|
$CI =&get_instance();
|
|
//$CI->load->library('AWS_SNS');
|
|
$CI->load->helper('push_notification');
|
|
$pd_notification_configs = array();
|
|
//die();
|
|
$additional_data_for_logs = array('pd_id' =>$pdid);
|
|
|
|
/*********************************************/
|
|
/*******Get PD Master Details*****************/
|
|
/*********************************************/
|
|
$CI->db->SELECT("PDTRIGGER.pd_id,PDTRIGGER.fk_lender_id,ENTITY.short_name,PDTRIGGER.lender_applicant_id,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.pd_date_of_initiation,PDTRIGGER.scheduled_on,PDTRIGGER.updatedon,PDTRIGGER.fk_pd_allocated_to,ALLOCATED.email as allocated_email,ALLOCATED.mobile_no as allocated_mobile_no,concat(ALLOCATED.first_name,' ',ALLOCATED.last_name) as pdofficer_name,PDTRIGGER.executive_id,EXECUTIVE.email as executive_email,EXECUTIVE.mobile_no as executive_mobile_no,PDTRIGGER.central_pd_officer_id,CENTRALPDOFFICER.mobile_no as centralpdofficer_mobile_no,CENTRALPDOFFICER.email as centralpdofficer_mail,PDTRIGGER.pd_agency_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,CREATED.fk_entity_type_id,CREATED.email as created_email,PDTRIGGER.pd_contact_person_mail,PDAPPLICANTSDETAILS.applicant_name,PDAPPLICANTSDETAILS.mobile_no as customer_mobile_no,PDTRIGGER.encrypted_url,PDOFFICER.web_token as pdofficer_webtoken,PDOFFICER.mob_token as pdofficer_mobtoken,PDEXECUTIVE.web_token as pdexecutive_webtoken,PDEXECUTIVE.mob_token as pdexecutive_mobtoken,CENTRALPDOFFICERTOKEN.web_token as centralpdofficer_webtoken,CENTRALPDOFFICERTOKEN.mob_token as centralpdofficer_mobtoken,concat(LENDERSALESPERSON.first_name,' ',LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,concat(LENDERCREDITPERSON.first_name,' ',LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,LENDERSALESPERSONTOKEN.web_token as lender_sales_web_token,LENDERSALESPERSONTOKEN.mob_token as lender_sales_mob_token,LENDERCREDITPERSONTOKEN.web_token as lender_credit_web_token,LENDERCREDITPERSONTOKEN.mob_token as lender_credit_mob_token,ENTITYFININSTITUTION.institute_email,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,PDTRIGGER.is_notify_enabled");
|
|
$CI->db->FROM(PDTRIGGER." as PDTRIGGER");
|
|
$CI->db->JOIN(USERPROFILE." as CREATED","PDTRIGGER.fk_createdby = CREATED.userid",'LEFT');
|
|
$CI->db->JOIN(ENTITY." as ENTITY","PDTRIGGER.fk_lender_id = ENTITY.entity_id",'LEFT');
|
|
$CI->db->JOIN(ENTITYFININSTITUTION." as ENTITYFININSTITUTION","PDTRIGGER.imgc_fin_institute = ENTITYFININSTITUTION.entity_fin_institution_id",'LEFT');
|
|
$CI->db->JOIN(USERPROFILE." as ALLOCATED","PDTRIGGER.fk_pd_allocated_to = ALLOCATED.userid",'LEFT');
|
|
$CI->db->JOIN(USERPROFILE." as EXECUTIVE","PDTRIGGER.executive_id = EXECUTIVE.userid",'LEFT');
|
|
$CI->db->JOIN(USERPROFILE." as CENTRALPDOFFICER","PDTRIGGER.central_pd_officer_id = CENTRALPDOFFICER.userid",'LEFT');
|
|
$CI->db->JOIN(USERPROFILE.' as LENDERSALESPERSON','PDTRIGGER.lender_sales_person = LENDERSALESPERSON.userid','LEFT');
|
|
$CI->db->JOIN(USERPROFILE.' as LENDERCREDITPERSON','PDTRIGGER.lender_credit_person = LENDERCREDITPERSON.userid','LEFT');
|
|
$CI->db->JOIN(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS","PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1",'LEFT');
|
|
$CI->db->JOIN(USERNOTIFICATIONTOKENS." as PDOFFICER","PDTRIGGER.fk_pd_allocated_to = PDOFFICER.fk_user_id",'LEFT');
|
|
$CI->db->JOIN(USERNOTIFICATIONTOKENS." as PDEXECUTIVE","PDTRIGGER.executive_id = PDEXECUTIVE.fk_user_id",'LEFT');
|
|
$CI->db->JOIN(USERNOTIFICATIONTOKENS." as CENTRALPDOFFICERTOKEN","PDTRIGGER.central_pd_officer_id = CENTRALPDOFFICERTOKEN.fk_user_id",'LEFT');
|
|
$CI->db->JOIN(USERNOTIFICATIONTOKENS." as LENDERSALESPERSONTOKEN","PDTRIGGER.lender_sales_person = LENDERSALESPERSONTOKEN.fk_user_id",'LEFT');
|
|
$CI->db->JOIN(USERNOTIFICATIONTOKENS." as LENDERCREDITPERSONTOKEN","PDTRIGGER.lender_credit_person = LENDERCREDITPERSONTOKEN.fk_user_id",'LEFT');
|
|
$CI->db->WHERE("PDTRIGGER.pd_id",$pdid);
|
|
$core_details = $CI->db->GET()->result_array();
|
|
//print_r($core_details);
|
|
|
|
|
|
// die();
|
|
if(count($core_details))
|
|
{
|
|
$is_pd_notify_enabled = $core_details[0]['is_notify_enabled'];
|
|
$is_sms_enabled = $core_details[0]['is_sms_enabled'];
|
|
$is_mail_enabled = $core_details[0]['is_mail_enabled'];
|
|
$is_app_notify_enabled = $core_details[0]['is_app_notify_enabled'];
|
|
|
|
if(!$is_pd_notify_enabled)
|
|
{
|
|
$is_sms_enabled = 0;
|
|
$is_mail_enabled = 0;
|
|
$is_app_notify_enabled = 0;
|
|
}
|
|
|
|
|
|
|
|
$additional_data_for_logs['pd_status'] = $core_details[0]['pd_status'];
|
|
/*********************************************/
|
|
/*******Get Notification Config Details*****/
|
|
/*********************************************/
|
|
$CI->db->SELECT("*");
|
|
$CI->db->FROM(PDNOTIFICATION." as PDNOTIFICATION");
|
|
$CI->db->WHERE("PDNOTIFICATION.pd_status",$core_details[0]['pd_status']);
|
|
$CI->db->WHERE("PDNOTIFICATION.isactive",1);
|
|
$pd_notification_configs = $CI->db->GET()->result_array();
|
|
//print_r($CI->db->last_query());
|
|
//print_r($pd_notification_configs);
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
|
/*******Get Previous PD status from History Table*****/
|
|
/*********************************************/
|
|
$CI->db->SELECT("*");
|
|
$CI->db->FROM(COMMONMASTER." as COMMONMASTER");
|
|
$CI->db->WHERE("COMMONMASTER.primary_key",$pdid);
|
|
$CI->db->WHERE("COMMONMASTER.field_name",'pd_status');
|
|
$CI->db->WHERE("COMMONMASTER.table_name",PDTRIGGER);
|
|
$pd_previous_status = $CI->db->GET()->result_array();
|
|
|
|
$is_flag = 0;
|
|
//print_r($pd_previous_status);
|
|
if($core_details[0]['pd_status'] != 'ALLOCATED' || $core_details[0]['pd_status'] != 'SCHEDULED')
|
|
{
|
|
if(count($pd_previous_status))
|
|
{
|
|
foreach($pd_previous_status as $previous_status)
|
|
{
|
|
if($previous_status['old_value'] == $core_details[0]['pd_status'])
|
|
{
|
|
$is_flag = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//echo $is_flag;
|
|
if($is_flag == 0)
|
|
{
|
|
|
|
/*********************************************/
|
|
/*******Get SMS Notifications From Master*****/
|
|
/*********************************************/
|
|
$CI->db->SELECT("*");
|
|
$CI->db->FROM(PDNOTIFICATIONMSG." as PDNOTIFICATIONMSG");
|
|
$CI->db->WHERE("PDNOTIFICATIONMSG.pd_status",$core_details[0]['pd_status']);
|
|
$CI->db->WHERE("PDNOTIFICATIONMSG.isactive",1);
|
|
$pd_notification_msg = $CI->db->GET()->result_array();
|
|
|
|
|
|
if(count($pd_notification_configs))
|
|
{
|
|
/*********************************************/
|
|
/*******Send SMS Notification to Lender*****/
|
|
/*********************************************/
|
|
|
|
if($pd_notification_configs[0]['sms_lender'] == 1 && $is_sms_enabled)
|
|
{
|
|
$lender_sms = (string)$core_details[0]['pd_contact_mobileno'];
|
|
$lender_sales_contact_mobileno = (string)$core_details[0]['lender_sales_contact_mobileno'];
|
|
$lender_credit_person_contact_mobileno = (string)$core_details[0]['lender_credit_person_contact_mobileno'];
|
|
|
|
if($pd_notification_msg[0]['lender'] != null)
|
|
{
|
|
$msg = $pd_notification_msg[0]['lender'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
//echo $msg;
|
|
$msg = str_replace('<br>','',$msg);
|
|
|
|
$additional_data_for_logs['to_whom'] = 'LEDNER';
|
|
SMS_GUPSHUP::sendSMS($msg,$lender_sms,$additional_data_for_logs);
|
|
|
|
$additional_data_for_logs['to_whom'] = 'LEDNERSALES';
|
|
SMS_GUPSHUP::sendSMS($msg,$lender_sales_contact_mobileno,$additional_data_for_logs);
|
|
|
|
$additional_data_for_logs['to_whom'] = 'LEDNERCREDIT';
|
|
SMS_GUPSHUP::sendSMS($msg,$lender_credit_person_contact_mobileno,$additional_data_for_logs);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/*******Send Mail Notification to Lender*****/ // currently Mail disabled
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['mail_lender'] == 1 && $is_mail_enabled)
|
|
{
|
|
$lender_email = null;
|
|
$lender_sales_person_email = $core_details[0]['lender_sales_person_email'];
|
|
$lender_credit_person_email = $core_details[0]['lender_credit_person_email'];
|
|
$financial_institude_email = $core_details[0]['institute_email'];
|
|
|
|
if($core_details[0]['fk_entity_type_id'] == 2 )
|
|
{
|
|
$lender_email = $core_details[0]['created_email'];
|
|
}
|
|
else if($core_details[0]['pd_contact_person_mail'] != null)
|
|
{
|
|
$lender_email = $core_details[0]['pd_contact_person_mail'];
|
|
}
|
|
|
|
$msg = $pd_notification_msg[0]['lender'];
|
|
$msg = self::stringReplace($msg,$core_details,'MAIL');
|
|
if($lender_email != null)
|
|
{
|
|
// self::sendMail($CI,$lender_email,$msg,$core_details); // currently Mail disabled
|
|
}
|
|
|
|
|
|
if($lender_sales_person_email != null){ self::sendMail($CI,$lender_sales_person_email,$msg,$core_details); }
|
|
if($lender_credit_person_email != null){ self::sendMail($CI,$lender_credit_person_email,$msg,$core_details); }
|
|
if($financial_institude_email != null)
|
|
{
|
|
self::sendMail($CI,$financial_institude_email,$msg,$core_details);
|
|
self::sendMail($CI,'velmurugan.s@venbainfotech.com',$msg,$core_details);
|
|
if(ENVIRONMENT == 'testing')
|
|
{
|
|
self::sendMail($CI,'vitvelz@gmail.com',$msg,$core_details);
|
|
}
|
|
}
|
|
|
|
self::sendMail($CI,'komalmittal@sinemanagement.com',$msg,$core_details);
|
|
|
|
self::sendMail($CI,'sinepd@sinemanagement.com',$msg,$core_details);
|
|
|
|
}
|
|
// echo 'afer len mail';
|
|
// die();
|
|
|
|
|
|
/*********************************************/
|
|
/*******Send Push Notification to Lender(WEB/MOB)*****
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['app_lender'] == 1 && $is_app_notify_enabled)
|
|
{
|
|
//$lender_web_token = (string)$core_details[0]['pd_contact_mobileno'];
|
|
//$lender_mob_token = (string)$core_details[0]['pd_contact_mobileno'];
|
|
$msg = $pd_notification_msg[0]['lender'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
|
|
$lender_sales_web_token = (string)$core_details[0]['lender_sales_web_token'];
|
|
$lender_sales_mob_token = (string)$core_details[0]['lender_sales_mob_token'];
|
|
|
|
$additional_data_for_logs['to_whom'] = 'LEDNERSALES';
|
|
PUSH_NOTIFICATION::sendNotification($lender_sales_web_token,$lender_sales_mob_token,$msg,$additional_data_for_logs);
|
|
|
|
|
|
$lender_credit_web_token = (string)$core_details[0]['lender_credit_web_token'];
|
|
$lender_credit_mob_token = (string)$core_details[0]['lender_credit_mob_token'];
|
|
|
|
$additional_data_for_logs['to_whom'] = 'LEDNERCREDIT';
|
|
PUSH_NOTIFICATION::sendNotification($lender_credit_web_token,$lender_credit_mob_token,$msg,$additional_data_for_logs);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************/
|
|
/*******Send SMS Notification to PD Officer*****/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['sms_pdofficer'] == 1 && $is_sms_enabled)
|
|
{
|
|
$mobile_nos_to_send_notification = array();
|
|
array_push($mobile_nos_to_send_notification,$core_details[0]['allocated_mobile_no']);
|
|
|
|
if($core_details[0]['executive_mobile_no'] != "" || $core_details[0]['executive_mobile_no'] != null)
|
|
{
|
|
array_push($mobile_nos_to_send_notification,$core_details[0]['executive_mobile_no']);
|
|
}
|
|
|
|
|
|
if($pd_notification_msg[0]['pdofficer'] != null)
|
|
{
|
|
$msg = $pd_notification_msg[0]['pdofficer'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
$additional_data_for_logs['to_whom'] = 'PD_OFFICER';
|
|
foreach($mobile_nos_to_send_notification as $mobile){ SMS_GUPSHUP::sendSMS($msg,(string)$mobile,$additional_data_for_logs); };
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/*********************************************/
|
|
/*******Send Push Notification to PD Officer*****/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['app_pdofficer'] == 1 && $is_app_notify_enabled)
|
|
{
|
|
|
|
$pd_offcier_web_token = $core_details[0]['pdofficer_webtoken'];
|
|
$pd_offcier_mob_token = $core_details[0]['pdofficer_mobtoken'];
|
|
$pd_executive_mob_token = $core_details[0]['pdexecutive_mobtoken'];
|
|
$pd_executive_web_token = $core_details[0]['pdexecutive_webtoken'];
|
|
$msg = $pd_notification_msg[0]['pdofficer'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
|
|
PUSH_NOTIFICATION::sendNotification($pd_offcier_web_token,$pd_offcier_mob_token,$msg,$additional_data_for_logs);
|
|
PUSH_NOTIFICATION::sendNotification($pd_executive_web_token,$pd_executive_mob_token,$msg,$additional_data_for_logs);
|
|
|
|
}
|
|
|
|
/*********************************************/
|
|
/*******Send SMS Notification to Customer*****/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['sms_customer'] == 1 && $is_sms_enabled)
|
|
{
|
|
if($core_details[0]['customer_mobile_no'] != "" || $core_details[0]['customer_mobile_no'] != null)
|
|
{
|
|
if($pd_notification_msg[0]['customer'] != null)
|
|
{
|
|
$msg = $pd_notification_msg[0]['customer'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
$additional_data_for_logs['to_whom'] = 'CUSTOMER';
|
|
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['customer_mobile_no'],$additional_data_for_logs);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/**Send SMS Notification to Central PD Officer**/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['sms_pdincharge'] == 1 && $is_sms_enabled)
|
|
{
|
|
if($core_details[0]['centralpdofficer_mobile_no'] != "" || $core_details[0]['centralpdofficer_mobile_no'] != null)
|
|
{
|
|
if($pd_notification_msg[0]['pdincharge'] != null)
|
|
{
|
|
$msg = $pd_notification_msg[0]['pdincharge'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
$additional_data_for_logs['to_whom'] = 'PDMANAGER/PDINCHARGE';
|
|
SMS_GUPSHUP::sendSMS($msg,(string)$core_details[0]['centralpdofficer_mobile_no'],$additional_data_for_logs);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/**Send Push Notification to Central PD Officer**/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['app_pdincharge'] == 1 && $is_app_notify_enabled)
|
|
{
|
|
|
|
$central_offcier_web_token = $core_details[0]['centralpdofficer_webtoken'];
|
|
$central_offcier_mob_token = $core_details[0]['centralpdofficer_mobtoken'];
|
|
$msg = $pd_notification_msg[0]['pdincharge'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
PUSH_NOTIFICATION::sendNotification($central_offcier_web_token,$central_offcier_mob_token,$msg,$additional_data_for_logs);
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/**Send SMS Notification to QC Team*****/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['sms_qcteam'] == 1 && $is_sms_enabled)
|
|
{
|
|
$CI->db->DISTINCT();
|
|
$CI->db->SELECT("mobile_no");
|
|
$CI->db->FROM(USERPROFILE." as USERPROFILE");
|
|
$CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1 AND USERPROFILE.isactive = 1");
|
|
$CI->db->WHERE("USERPROFILEROLES.user_role",6);//QC Manager
|
|
$CI->db->OR_WHERE("USERPROFILEROLES.user_role",7);//QC Officer
|
|
$qcteam_mobile_nos = $CI->db->GET()->result_array();
|
|
|
|
if(count($qcteam_mobile_nos))
|
|
{
|
|
$mobile_nos_to_send_notification = array();
|
|
foreach($qcteam_mobile_nos as $mobile)
|
|
{
|
|
array_push($mobile_nos_to_send_notification,$mobile);
|
|
}
|
|
|
|
if($pd_notification_msg[0]['qc_team'] != null)
|
|
{
|
|
$msg = $pd_notification_msg[0]['qc_team'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
$additional_data_for_logs['to_whom'] = 'QC_TEAM';
|
|
foreach($mobile_nos_to_send_notification as $mobile){
|
|
SMS_GUPSHUP::sendSMS($msg,(string)$mobile['mobile_no'],$additional_data_for_logs);
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/**Send PUSH Notification to QC Team*****/
|
|
/*********************************************/
|
|
if($pd_notification_configs[0]['app_qcteam'] == 1 && $is_app_notify_enabled)
|
|
{
|
|
$CI->db->DISTINCT();
|
|
$CI->db->SELECT("web_token,mob_token");
|
|
$CI->db->FROM(USERNOTIFICATIONTOKENS." as USERNOTIFICATIONTOKENS");
|
|
//$CI->db->FROM(USERPROFILE." as USERPROFILE");
|
|
$CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILEROLES.fk_userid = USERNOTIFICATIONTOKENS.fk_user_id AND USERPROFILEROLES.isactive = 1",'LEFT');
|
|
$CI->db->WHERE("USERPROFILEROLES.user_role",6);//QC Manager
|
|
$CI->db->OR_WHERE("USERPROFILEROLES.user_role",7);//QC Officer
|
|
$qcteam_push_tokens = $CI->db->GET()->result_array();
|
|
|
|
if(count($qcteam_push_tokens))
|
|
{
|
|
$qc_team_web_token = array();
|
|
$qc_team_mob_token = array();
|
|
|
|
foreach($qcteam_push_tokens as $token)
|
|
{
|
|
if(isset($token['web_token']) && ($token['web_token'] != "" || $token['web_token'] != null))
|
|
{
|
|
array_push($qc_team_web_token,$token['web_token']);
|
|
}
|
|
if(isset($token['mob_token']) && ($token['mob_token'] != "" || $token['mob_token'] != null))
|
|
{
|
|
array_push($qc_team_mob_token,$token['mob_token']);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$msg = $pd_notification_msg[0]['qc_team'];
|
|
$msg = self::stringReplace($msg,$core_details);
|
|
|
|
$additional_data_for_logs['to_whom'] = 'QC_TEAM';
|
|
foreach ($qc_team_web_token as $key => $value) {
|
|
PUSH_NOTIFICATION::sendNotification($value,null,$msg,$additional_data_for_logs);
|
|
}
|
|
|
|
foreach ($qc_team_mob_token as $key => $value) {
|
|
PUSH_NOTIFICATION::sendNotification(null,$value,$msg,$additional_data_for_logs);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*********************************************/
|
|
/**REPLACE PLACEHOLDERS****/
|
|
/*********************************************/
|
|
public static function stringReplace($msg,$core_details,$for = 'SMS')
|
|
{
|
|
|
|
$msg = str_replace('{{applicant_name}}',$core_details[0]['applicant_name'],$msg);
|
|
$msg = str_replace('{{applicant_id}}',$core_details[0]['lender_applicant_id'],$msg);
|
|
$msg = str_replace('{{schedule_time}}',$core_details[0]['scheduled_on'],$msg);
|
|
$msg = str_replace('{{initiate_time}}',$core_details[0]['pd_date_of_initiation'],$msg);
|
|
$msg = str_replace('{{pdofficer_name}}',$core_details[0]['pdofficer_name'],$msg);
|
|
$msg = str_replace('{{start_time}}',$core_details[0]['updatedon'],$msg);
|
|
$msg = str_replace('{{pdofficer_name}}',$core_details[0]['pdofficer_name'],$msg);
|
|
$msg = str_replace('{{lender_name}}',$core_details[0]['short_name'],$msg);
|
|
$msg = str_replace('{{link}}',$core_details[0]['encrypted_url'],$msg);
|
|
//$msg = str_replace('{{\n\n}}','\n\n',$msg);
|
|
// $msg = nl2br($msg);
|
|
if($for == 'SMS')
|
|
{
|
|
$msg = str_replace('\n','',$msg);
|
|
$msg = str_replace('\\','',$msg);
|
|
}
|
|
else if($for == 'MAIL')
|
|
{
|
|
$msg = str_replace('\n','<br>',$msg);
|
|
$msg = str_replace('\\','',$msg);
|
|
}
|
|
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function sendMail($CI,$lender_email,$msg,$core_details)
|
|
{
|
|
//echo "Mail called";
|
|
|
|
$mail = $CI->phpmailer_library->load();
|
|
//echo "$msg";
|
|
|
|
$mail->IsSMTP(); // Telling the class to use SMTP
|
|
$mail->SMTPAuth = true;
|
|
$mail->SMTPDebug = 0;
|
|
$mail->SMTPSecure = "ssl";
|
|
$mail->Host = 'bh-in-16.webhostbox.net'; // SMTP server
|
|
$mail->Username = "noreply@ssa.sineedge.com"; // "The account"
|
|
$mail->Password = "noreply@ssa"; // "The password"
|
|
$mail->Port = 465; // "The port"
|
|
$mail->addAddress($lender_email); // Name is optional
|
|
$mail->From = 'noreply@pdgenie.com';
|
|
$fromName = 'PD Genie'; if(ENVIRONMENT == 'testing' || ENVIRONMENT == 'development') { $fromName .= ' ( TEST ENV ) '; }
|
|
$mail->FromName = $fromName;
|
|
$mail->isHTML(true); // Set email format to HTML
|
|
$mail->Subject = SELF::subGenerator($core_details);
|
|
$mail->Body = $msg;
|
|
$mail->AltBody = $msg;
|
|
|
|
|
|
$logger = MYLOG::logFunction(null,$core_details[0]['pd_id']);
|
|
if(!$mail->send()) {
|
|
$logger->error("Mailer Error:" ,array($mail->ErrorInfo));
|
|
|
|
} else {
|
|
$logger->info("Mailer Send:" ,array('mail_ID' => $lender_email,'Status' => 'SEND'));
|
|
}
|
|
}
|
|
|
|
|
|
public static function subGenerator($core_details)
|
|
{
|
|
$status = $core_details[0]['pd_status'];
|
|
$dynamic = '';
|
|
|
|
switch($status)
|
|
{
|
|
case 'TRIGGERED':
|
|
$dynamic = 'Triggered';
|
|
break;
|
|
|
|
case 'ACCEPTED':$dynamic = 'Accepted';
|
|
break;
|
|
|
|
case 'BOUNCED':$dynamic = 'Bounced';
|
|
break;
|
|
|
|
case 'ALLOCATED':$dynamic = 'Allocated';
|
|
break;
|
|
|
|
case 'SCHEDULED':$dynamic = 'Scheduled';
|
|
break;
|
|
|
|
case 'STARTED':$dynamic = 'Started';
|
|
break;
|
|
|
|
case 'COMPLETED':$dynamic = 'Completed';
|
|
break;
|
|
|
|
case 'QC_COMPLETED':$dynamic = 'QC Completed';
|
|
break;
|
|
|
|
case 'CANCELLED':$dynamic = 'Cancelled';
|
|
break;
|
|
|
|
default: $dynamic = 'Status Update';
|
|
}
|
|
$subject = 'PD '.$dynamic .' For Application ID -'.$core_details[0]['lender_applicant_id'];
|
|
return ENVIRONMENT == 'testing' || ENVIRONMENT == 'development' ? $subject .= ' ( TEST ENV ) ' : $subject;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|