diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 22b879e7..d3b55142 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -1102,6 +1102,19 @@ class PD_Controller extends REST_Controller { // echo 'after'; // print_r($pd_details); // die(); + + $temp_data = $this->PD_Model->selectCustomRecords(array('pd_agency_id','fk_lender_id'),array('pd_id' => $pd_details['pd_id']),PDTRIGGER); + $agency_id = isset($pd_details['pd_agency_id']) ? $pd_details['pd_agency_id'] : $temp_data[0]['pd_agency_id']; + $mwise_lender_id = (ENVIRONMENT == 'production' ? 7 : 35); + $current_lender_id = (isset($pd_details['fk_lender_id']) && $pd_details['fk_lender_id'] != '' ? $pd_details['fk_lender_id'] : $temp_data[0]['fk_lender_id']); + $is_mwise_lender = ( $current_lender_id == $mwise_lender_id ? true : false); + + if($is_mwise_lender && (!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0) && ($pd_details['pd_status'] != "TRIGGERED" || $pd_details['pd_status'] != "QC_COMPLETED")) + { + $pd_details['vendor_status'] = $pd_details['pd_status']; + $pd_details['pd_status'] = ALLOCATED_TO_FIA; + } + $where_condition_array = array('pd_id' => $pd_details['pd_id'],'random_string' => $pd_details['random_string']); $pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array); // print_r($this->db->last_query()); @@ -1654,8 +1667,6 @@ public function assignPDTempalate($data) $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,1); - PDALERTS::sendMWcreditPDMail($this,$records,2); $records['pd_status'] = ALLOCATED_TO_FIA; } } @@ -1694,6 +1705,10 @@ public function assignPDTempalate($data) $logger = MYLOG::logFunction(null,$records['pd_id']); $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'TRIGGERED','Current_status' => isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED)); PDALERTS::pdnotification($records['pd_id']); + if(isset($records['pd_agency_id']) && $records['vendor_status'] == ALLOCATED){ + PDALERTS::sendMWcreditPDMail($this,$records,1); + PDALERTS::sendMWcreditPDMail($this,$records,2); + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true;