From 1cbce13e1add143b312f9f20e1d8e351964a6a9d Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Fri, 12 Feb 2021 00:40:38 +0530 Subject: [PATCH] SMC CHGS 1 --- api/application/config/constants.php | 1 + api/application/config/routes.php | 1 + .../controllers/Common_Masters_Controller.php | 59 +++++++++++-- api/application/controllers/PD_Controller.php | 30 +++---- .../controllers/SMC_Credit_PD_Controller.php | 4 +- api/application/helpers/pdalerts_helper.php | 1 + .../helpers/readexceldata_helper.php | 82 +++++++++++++++---- .../models/Common_Masters_Model.php | 27 ++++++ api/application/models/PD_Model.php | 6 +- 9 files changed, 173 insertions(+), 38 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 0684791c..3762a14e 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -665,6 +665,7 @@ defined('SMC_CREDITPD_IMGS') OR define('SMC_CREDITPD_IMGS','m_smc_creditpd_imgs' defined('SALESVENDORLIST') OR define('SALESVENDORLIST','m_smcvendorlist'); defined('SALESEQUIPMENTLIST') OR define('SALESEQUIPMENTLIST','m_smc_equipmentlist'); defined('USERCONFIG') OR define('USERCONFIG','m_user_config'); +defined('SMC_TEMP_ADDRESS') OR define('SMC_TEMP_ADDRESS','t_smc_temp_address'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 270c473f..784a6621 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -88,6 +88,7 @@ $route['getCommonConfig'] = 'Common_Masters_Controller/getCommonConfig'; $route['getServerInfo'] = 'Common_Masters_Controller/getServerInfo'; $route['getVideoChatAccessKey'] = 'Common_Masters_Controller/getVideoChatAccessKey'; $route['uploadSMCDataFile'] = 'Common_Masters_Controller/uploadSMCDataFile'; +$route['getSMCTempAddresses'] = 'Common_Masters_Controller/getSMCTempAddresses'; diff --git a/api/application/controllers/Common_Masters_Controller.php b/api/application/controllers/Common_Masters_Controller.php index 39eef175..e54dd2d9 100644 --- a/api/application/controllers/Common_Masters_Controller.php +++ b/api/application/controllers/Common_Masters_Controller.php @@ -18,6 +18,7 @@ class Common_Masters_Controller extends REST_Controller { // Construct the parent class parent::__construct(); $this->load->model('Common_Masters_Model'); + $this->load->model('PD_Model'); $this->load->library('AWS_S3'); } @@ -1295,16 +1296,20 @@ class Common_Masters_Controller extends REST_Controller { public function uploadSMCDataFile_post() { $records = json_decode($this->post('records'),true); - //print_r($records); + // print_r($records); $is_bucket_upload_sucess = false; $id = null; - //die(); + // echo date('Y-m-d_h:i:s'); + // die(); if(!empty($_FILES['pd_excel_data'])) { $folder_to_check = XLPATH.'/tmp'; // $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name'])); $modified_fname = str_replace(' ','_',($_FILES['pd_excel_data']['name'])); - + $modified_fname = (explode('.',$_FILES['pd_excel_data']['name'])); + $modified_fname = $modified_fname[0].'_'.date('Y-m-d_h-i-s').'.'.$modified_fname[1]; + // echo $modified_fname; + // die(); // #TEMP // $sourcefile = $folder_to_check.'/'.$modified_fname; // $result_data = readexceldata::getExcelSectionData($sourcefile); @@ -1340,18 +1345,29 @@ class Common_Masters_Controller extends REST_Controller { $fields_to_insert['fk_pd_id'] = $records['fk_pd_id']; } $is_bucket_upload_sucess = 1; + // disable old entries + $this->Common_Masters_Model->updateRecords(array('isactive' => 0),SMC_EXCEL_FILELIST,array('fk_pd_id' => $records['fk_pd_id'])); + + //have to do disable key 'is_reupload_data_fetched' to 0 in section data table + $this->Common_Masters_Model->updateRecords(array('is_reupload_data_fetched' => 0),SMC_CREDIT_PD_SECTION_DATA,array('fk_pd_id' => $records['fk_pd_id'])); + + //insert new records $id = $this->Common_Masters_Model->saveRecords($fields_to_insert,SMC_EXCEL_FILELIST); if(!isset($records['fk_pd_id'])) { //read excel file get trigger data - $result_data = readexceldata::getExcelSectionData($sourcefile); + $result_data = readexceldata::getExcelSectionData($sourcefile,null,null,$id); } unlink($sourcefile); } } + else + { + log_message('ERROR','###File Upload Failed'.$modified_fname); + } if($is_bucket_upload_sucess && $id) @@ -1380,5 +1396,38 @@ class Common_Masters_Controller extends REST_Controller { } } + public function getSMCTempAddresses_get() + { + $pdid = $this->get('pdid'); + if($pdid) + { + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + // print_r($pd_master_details);die(); + $addresses = $this->Common_Masters_Model->getSMCTempAddresses($pd_master_details[0]['excel_file_id']); + if(count($addresses)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $addresses; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Data Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } - } \ No newline at end of file + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Data Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } +} +?> \ No newline at end of file diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index c8c525cc..d5a8f3d4 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -2065,24 +2065,24 @@ public function assignPDTempalate($data) if($this->get('createdby')) { $createdby = $this->get('createdby'); } if($this->get('lenderid')) { - $lenderid = $this->get('lenderid'); - $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo - if($lenderid == $smc_lender_id) - { + // $lenderid = $this->get('lenderid'); + // $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo + // if($lenderid == $smc_lender_id) + // { - $this->load->model('User_Management_Model'); - $user_details = $this->User_Management_Model->getUserDetails($createdby); - if($user_details['data'][0]['user_role'] == 26)//Credit Manager - { - $pdofficerid = $createdby; + // $this->load->model('User_Management_Model'); + // $user_details = $this->User_Management_Model->getUserDetails($createdby); + // if($user_details['data'][0]['user_role'] == 26)//Credit Manager + // { + // $pdofficerid = $createdby; - } - else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager - { - $lender_details = array('city' => $user_details['data'][0]['fk_city']); + // } + // else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager + // { + // $lender_details = array('city' => $user_details['data'][0]['fk_city']); - } - $createdby = ''; + // } + // $createdby = ''; } diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index 02af19c7..973d84f4 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1308,7 +1308,7 @@ public function filterSalesPDList_post() { $records = $this->post('records'); $pd_master_data = $this->PD_Model->getPDMasterDetails($records['pd_id'],$records['random_string']); $cur_section_data = array(); - // print_r($pd_master_data);die(); + // print_r($pd_master_data);die(); // echo $records['form_id'];die(); //check excel file in local, otherwise get it from s3 and store locallly $filename = ($pd_master_data[0]['re_uploaded'] ? XLPATH.'/tmp/'.$pd_master_data[0]['re_uploaded_file_name'] : XLPATH.'/tmp/'.$pd_master_data[0]['modified_fname']); @@ -1553,7 +1553,7 @@ public function filterSalesPDList_post() { $score_card_questions['pd_officer_recommendation'] = array('answer_id' => $view_data['pd_section_data'][19]['pd_officer_recommendation'],'answer' => $over_all[ $view_data['pd_section_data'][19]['pd_officer_recommendation'] ]); - $score_card_questions['neighbourhood_status'] = array('answer_id' => $view_data['pd_section_data'][17]['neighbourhood_status'],'answer' => $view_data['pd_section_data'][17]['neighbourhood_status']); + //$score_card_questions['neighbourhood_status'] = array('answer_id' => $view_data['pd_section_data'][17]['neighbourhood_status'],'answer' => $view_data['pd_section_data'][17]['neighbourhood_status']); $score_card_questions['business_seasonality'] = array('answer_id' => $view_data['pd_section_data'][4]['seasonality'],'answer' => $view_data['pd_section_data'][4]['seasonality']); diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php index 6a3f6ffc..26e0bc6d 100644 --- a/api/application/helpers/pdalerts_helper.php +++ b/api/application/helpers/pdalerts_helper.php @@ -546,6 +546,7 @@ class PDALERTS $mail_id = 'cpa@smcfinance.com'; $mail->addBCC("neville@sinemanagement.com"); $mail->addBCC("ssa@venbainfotech.com"); + $mail->addAddress('cpumumbai@smcfinance.com'); //$mail->addBCC("vitvelz@gmail.com"); } // Name is optional } $mail->addAddress($mail_id); diff --git a/api/application/helpers/readexceldata_helper.php b/api/application/helpers/readexceldata_helper.php index b396c0d4..bcbfbab5 100644 --- a/api/application/helpers/readexceldata_helper.php +++ b/api/application/helpers/readexceldata_helper.php @@ -3,11 +3,13 @@ class readexceldata { private static $current_section_id = null; - public static function getExcelSectionData($file_path_withname,$section_id = null,$pd_id = null) + private static $current_excel_file_id = 9999; + public static function getExcelSectionData($file_path_withname,$section_id = null,$pd_id = null,$excel_file_id = null) { $CI =&get_instance(); $CI->load->library('myspreadsheet'); SELF::$current_section_id = $section_id; + SELF::$current_excel_file_id = $excel_file_id; // echo is_numeric($section_id); @@ -98,6 +100,35 @@ class readexceldata else { $return_data = SELF::getTriggerData($sheetData,$section_ref_data); + //store address details in temp table SMC_TEMP_ADDRESS + if(array_key_exists('address_details', $return_data)) + { + foreach ($return_data['address_details'] as $key => $address) + { + $display = $address['address'].', '.$address['city'].', '.$address['state'].', '.$address['pincode']; + + $pincode = $CI->PD_Model->selectCustomRecords(array('*'),array('pincode' => $address['pincode']),PINCODE); + $city = $CI->PD_Model->selectCustomRecords(array('*'),array('lower(name)' => strtolower($address['city'])),CITY); + // print_r($CI->db->last_query()); + // $state = $CI->PD_Model->selectCustomRecords(array('*'),array('pincode' => $address['pincode']),PINCODE,1); + $fields_to_insert = array('file_id' => SELF::$current_excel_file_id,'addressline' => $address['address']); + if(is_array($pincode) && count($pincode)) + { + $fields_to_insert['pincode'] = $pincode[0]['pincode_id']; + } + if(is_array($city) && count($city)) + { + $fields_to_insert['city'] = $city[0]['city_id']; + $fields_to_insert['state'] = $city[0]['fk_state_id']; + } + + // print_r($fields_to_insert); + $temp_add_id = $CI->PD_Model->saveRecords($fields_to_insert,SMC_TEMP_ADDRESS); + $fields_to_insert['address_id'] = $temp_add_id; + $return_data['address_details'][ $key ]['display'] = $display; + $return_data['address_details'][ $key ]['id'] = $fields_to_insert; + } + } } return ($return_data); @@ -155,11 +186,15 @@ class readexceldata return ($return_data); } + static function getTriggerData($sheetData,$section_ref_data) { - // echo 'worked';die(); + // echo 'worked'; + $return_data = array(); unset($sheetData[1]); + // print_r($sheetData); + // die(); $main_applicant_column_name = ''; foreach ($sheetData as $key => $value) { @@ -167,16 +202,30 @@ class readexceldata $value = SELF::trimExcelEmptyCells($value); //print_r($value);//die(); $tmp = SELF::returnMatchedData($section_ref_data,$value); + // print_r($tmp); + // $temp = array(); if(is_array($tmp) && isset($tmp['key_name'])) { - $temp[$tmp['key_name']] = $value['C']; - //$temp['value'] = $value['C']; - $return_data = $temp; - } - if($key == 8) + // $return_data[$tmp['key_name']] = $value['C']; + //$temp['value'] = $value['C']; + // print_r($return_data); + // echo '################'; + if(isset($tmp['parent_key']))// & !array_key_exists($tmp['parent_key'], $return_data)) + { + if($tmp['parent_key'] == 'address_details') + { $return_data[$tmp['parent_key']][] = array('city' => $value['C'],'address' =>$value['B'],'state' => $value['D'],'pincode' => $value['E']); } + } + else{ $return_data[$tmp['key_name']] = $value['C']; } + // print_r($temp); + // echo '@@@@@@@@@@@@@'; + // $return_data = $temp; + + if($key == 8) { - //print_r($value); + // print_r($value); + //getting co applicants only $value = (array_splice(($value),3));$value = array_reverse($value); + // print_r($value); foreach ($value as $val) { $return_data['co_applicants'][] = array('applicant_name' => $val); @@ -184,22 +233,27 @@ class readexceldata } - if($key == 9) - {break;} + + } + + // if($key == 9) + // {break;} + + } - + // print_r($return_data);die(); return ($return_data); } - static function returnMatchedData($arr,$val) + static function returnMatchedData($arr,$val)//$arr is sheetdata where $val is section column ref's { foreach ($arr as $key => $value) { - if(!$value['parent_key'] && ($val['A'] == $value['ref'])) + if(!$value['parent_key'] && (isset($val['A'])) && ($val['A'] == $value['ref'])) { return array('key_name' => $value['key_name']); } - else if($value['parent_key'] && ($val['A'] == $value['ref'])) + else if($value['parent_key'] && (isset($val['A'])) && ($val['A'] == $value['ref'])) { return array('key_name' => $value['key_name'],'parent_key' => $value['parent_key']); } diff --git a/api/application/models/Common_Masters_Model.php b/api/application/models/Common_Masters_Model.php index 610346fa..1c72f81c 100644 --- a/api/application/models/Common_Masters_Model.php +++ b/api/application/models/Common_Masters_Model.php @@ -163,4 +163,31 @@ class Common_Masters_Model extends SPARQ_Model { } + function getSMCTempAddresses($excel_file_id) + { + $columns = array('SMC_TEMP_ADDRESS.*',"concat(SMC_TEMP_ADDRESS.addressline,', ',CITY.name,', ',STATE.name,', ',PINCODE.pincode) as display",'CITY.name as city_name','STATE.name as state_name','PINCODE.pincode'); + $table = SMC_TEMP_ADDRESS.' as SMC_TEMP_ADDRESS'; + $where_condition_array = array('SMC_TEMP_ADDRESS.file_id' => $excel_file_id); + $joins = array( + array( + 'table' => CITY. ' as CITY', + 'condition' => 'SMC_TEMP_ADDRESS.city = CITY.city_id ', + 'jointype' => 'INNER' + ), + array( + 'table' => STATE. ' as STATE', + 'condition' => 'SMC_TEMP_ADDRESS.state = STATE.state_id ', + 'jointype' => 'INNER' + ), + array( + 'table' => PINCODE. ' as PINCODE', + 'condition' => 'SMC_TEMP_ADDRESS.pincode = PINCODE.pincode_id ', + 'jointype' => 'INNER' + ) + ); + + return $result = $this->getJoinRecords($columns,$table,$joins,$where_condition_array); + } + + } \ No newline at end of file diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 2e1fb4c0..7f8280c5 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1001,7 +1001,7 @@ class PD_Model extends SPARQ_Model { */ public function getPDMasterDetails($pdid,$random_string = null) { - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled,ENTITY.is_otp_enabled, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %h:%i:%s %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby,DESIGNATION.designation as updatedby_designation,PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.is_qc_enabled,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,PDTRIGGER.vendor_pdofficer,concat(VENDORPDOFFICER.first_name," ",VENDORPDOFFICER.last_name) as vendor_pdofficer_name,PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.lender_sales_person,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,PDTRIGGER.lender_credit_person,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,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,AGENCY.is_vendor_visit_disabled,PDTRIGGER.is_notify_enabled,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_img_pdf_created,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,PDTRIGGER.vendor_scheduled_on as vendor_scheduled_on_validation,DATE_FORMAT(PDTRIGGER.vendor_scheduled_on,"%d/%m/%Y %h:%i %p") as vendor_scheduled_on,PDTRIGGER.complete_override_data,PDTRIGGER.excel_file_id,SMC_EXCEL_FILELIST.file_name,SMC_EXCEL_FILELIST.modified_fname,PDTRIGGER.mwise_sales_person,PDTRIGGER.is_field_visit_done,PDTRIGGER.cancel_pd_remark,if(SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id is not null,"1","0") as re_uploaded,SMC_EXCEL_FILELIST_RE_UPLOAD.modified_fname as re_uploaded_file_name'); + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled,ENTITY.is_otp_enabled, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation,PDTRIGGER.pd_date_of_initiation as pd_date_of_initiation_sqlformat, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %h:%i:%s %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby,DESIGNATION.designation as updatedby_designation,PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.is_qc_enabled,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,PDTRIGGER.vendor_pdofficer,concat(VENDORPDOFFICER.first_name," ",VENDORPDOFFICER.last_name) as vendor_pdofficer_name,PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.lender_sales_person,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,PDTRIGGER.lender_credit_person,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,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,AGENCY.is_vendor_visit_disabled,PDTRIGGER.is_notify_enabled,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_img_pdf_created,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,PDTRIGGER.vendor_scheduled_on as vendor_scheduled_on_validation,DATE_FORMAT(PDTRIGGER.vendor_scheduled_on,"%d/%m/%Y %h:%i %p") as vendor_scheduled_on,PDTRIGGER.complete_override_data,PDTRIGGER.excel_file_id,SMC_EXCEL_FILELIST.file_name,SMC_EXCEL_FILELIST.modified_fname,PDTRIGGER.mwise_sales_person,PDTRIGGER.is_field_visit_done,PDTRIGGER.cancel_pd_remark,if(SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id is not null,"1","0") as re_uploaded,SMC_EXCEL_FILELIST_RE_UPLOAD.modified_fname as re_uploaded_file_name,ROLES.role_id as pd_allocated_to_role_id'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT'); $this->db->JOIN(ENTITY.' as SUBENTITY','PDTRIGGER.sub_entity_id = SUBENTITY.entity_id ','LEFT'); @@ -1033,8 +1033,10 @@ class PD_Model extends SPARQ_Model { $this->db->JOIN(TITLES.' as TITLES','PDAPPLICANTSDETAILS.applicant_title_name = TITLES.title_id','LEFT'); $this->db->JOIN(OTPREJECTION.' as OTPREJECTION','PDTRIGGER.otp_reject_reason = OTPREJECTION.otp_rejection_id','LEFT'); $this->db->JOIN(SMC_EXCEL_FILELIST.' as SMC_EXCEL_FILELIST','SMC_EXCEL_FILELIST.id = PDTRIGGER.excel_file_id','LEFT'); - $this->db->JOIN(SMC_EXCEL_FILELIST.' as SMC_EXCEL_FILELIST_RE_UPLOAD','PDTRIGGER.pd_id = SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id','LEFT'); + $this->db->JOIN(SMC_EXCEL_FILELIST.' as SMC_EXCEL_FILELIST_RE_UPLOAD','PDTRIGGER.pd_id = SMC_EXCEL_FILELIST_RE_UPLOAD.fk_pd_id AND SMC_EXCEL_FILELIST_RE_UPLOAD.isactive = 1','LEFT'); $this->db->JOIN(DESIGNATION.' as DESIGNATION','USERPROFILE1.designation = DESIGNATION.designation_id','LEFT'); + $this->db->JOIN(USERPROFILEROLES.' as ALLOCATED_PERSION_ROLE','PDTRIGGER.fk_pd_allocated_to = ALLOCATED_PERSION_ROLE.fk_userid AND ALLOCATED_PERSION_ROLE.isactive = 1','LEFT'); + $this->db->JOIN(ROLES.' as ROLES','ALLOCATED_PERSION_ROLE.user_role = ROLES.role_id','LEFT'); $this->db->WHERE('PDTRIGGER.pd_id',$pdid); if($random_string != null) {