diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php
index 6609bdc9..d628ad5f 100644
--- a/api/application/controllers/PD_Controller.php
+++ b/api/application/controllers/PD_Controller.php
@@ -1638,8 +1638,11 @@ public function assignPDTempalate($data)
// IF Condition - PD AGENCY ID means SMC VENDOR FLOW
if(isset($records['pd_agency_id'])){
// IF Condition - using PDID get the lender and mapped with SMC_lender_id macthed means Vendor status dynamically assigned
+ // {"records":{"pd_id":"2795","fk_pd_allocated_to":"383","pd_agency_id":"2","fk_updatedby":"395"}}
if($smc_lender_id == $lender_id[0]['fk_lender_id'] && isset($records['pd_agency_id']) && $records['pd_agency_id'] != null){
$records['vendor_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED ; //Here vendor_status is dynamic (ALLOCATED,SCHEDULED,COMPLETED like that)
+ //Mail - SMC Vendor.
+ if($records['vendor_status'] == ALLOCATED){PDALERTS::sendMWcreditPDMail($this,$records['pd_id']);}
}
}
else{
diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php
index 6591e0ff..af69fd26 100644
--- a/api/application/helpers/pdalerts_helper.php
+++ b/api/application/helpers/pdalerts_helper.php
@@ -690,7 +690,67 @@ class PDALERTS
//print_r($CI->db->last_query);
//echo $d;
}
-
+
+ public static function sendMWcreditPDMail($CI,$pd_id)
+ {
+ // $pd_id = $arr['pd_id'];
+ if($pd_id != "" || $pd_id != null)
+ {
+ // $CI->db->SELECT("PDTRIGGER.pd_id,PDTRIGGER.pd_sno,ENTITY.short_name,PRODUCT.abbr,'concat(USERPROFILE.first_name,' ',USERPROFILE.last_name)' as officer_name,AGENCYLIST.agency_name,USERPROFILE.vendor_status,AGENCYLIST.mail_id,USERPROFILE.email");
+ $CI->db->SELECT("PDTRIGGER.pd_id,PDTRIGGER.pd_sno,concat(USERPROFILE.first_name,'',USERPROFILE.last_name) as officer_name,AGENCYLIST.agency_name,PDTRIGGER.vendor_status,AGENCYLIST.mail_id,USERPROFILE.email");
+ $CI->db->FROM(PDTRIGGER.' as PDTRIGGER');
+ $CI->db->JOIN(AGENCYLIST. ' as AGENCYLIST','PDTRIGGER.pd_agency_id = AGENCYLIST.agency_id');
+ $CI->db->JOIN(USERPROFILE. ' as USERPROFILE','PDTRIGGER.fk_pd_allocated_to = USERPROFILE.userid');
+ $CI->db->WHERE('PDTRIGGER.pd_id',$pd_id);
+ $pd_data = $CI->db->GET()->result_array();
+
+ if(count($pd_data))
+ {
+ $mail = $CI->phpmailer_library->load();
+ $content = "Hi ".$pd_data[0]['officer_name'].",
MW-credit PD (".$pd_data[0]['pd_sno'].") is Allocated to You";
+ $mail->IsSMTP(); // Telling the class to use SMTP
+ $mail_id1 = $pd_data[0]['email'];
+ $mail_id2 = $pd_data[0]['mail_id'];
+ $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"
+ if(ENVIRONMENT == 'testing'){ $mail->addBCC("venkiraj0@gmail.com");$mail->addBCC("venbalap08@gmail.com");}
+ $mail->addAddress($mail_id1); //
+ $mail->addBCC($mail_id2); //
+ $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 = "Mwise-credit PD Allocation";
+ $mail->Body = $content;
+ $mail->AltBody = $content;
+
+ // $try = 1;
+ // sendMailAgain:
+ // if(!$mail->send()) {
+ // //$logger->error("Mailer Error:" ,array($mail->ErrorInfo));
+ // //echo 'not send';
+ // log_message('ERROR','###MWISE-CREDITPD MAIL NOT SEND'.$content[1].'- mail Error - '.$mail->ErrorInfo);
+ // if($try == 4)
+ // {
+ // goto stopSendAttempt;
+ // }
+ // $try++;
+ // log_message('ERROR','###MWISE-CREDITPD MAIL attempt'.$try.' '.$content[1].'- mail Error - '.$mail->ErrorInfo);
+ // goto sendMailAgain;
+
+ // } else {
+ // //$logger->info("Mailer Send:" ,array('mail_ID' => $lender_email,'Status' => 'SEND'));
+ // log_message('ERROR','####MWISE-CREDITPD MAIL SEND'.$content[1]);
+ // }
+ // stopSendAttempt:
+ }
+ }
+ }
}
diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php
index 3c1b6bf6..d3e0cf1e 100644
--- a/api/application/models/PD_Model.php
+++ b/api/application/models/PD_Model.php
@@ -2299,7 +2299,7 @@ class PD_Model extends SPARQ_Model {
//Get SMC CityWise Agency
function getCityWiseSMCAgency($city){
- $this->db->select('AGENCYLIST.agency_id as entity_id, AGENCYLIST.agency_name as full_name, AGENCYLIST.agency_abbr as short_name,AGENCYLIST.fk_city_id');
+ $this->db->select('AGENCYLIST.agency_id as entity_id, AGENCYLIST.agency_name as full_name, AGENCYLIST.agency_abbr as short_name,AGENCYLIST.fk_city_id,AGENCYLIST.mail_id');
$this->db->from(AGENCYLIST.' as AGENCYLIST');
$this->db->where('AGENCYLIST.isactive',1);
if($city!=""){