From 69da7583b1fdc2339f578c028722e8586c855b71 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 20 Apr 2022 21:37:25 +0530 Subject: [PATCH] Gsheet client queries 1 : ps --- .../controllers/Data_Dump_Controller.php | 142 +++++++++++------- 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index 03044fb2..16584395 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -147,7 +147,7 @@ class Data_Dump_Controller extends REST_Controller { $fk_lender_id = $this->Data_Dump_Model->getId(1,trim($GSdata["LenderName"])); $pd_details['fk_lender_id']=$fk_lender_id; $pd_details['sub_entity_id']=$fk_lender_id; - log_message('ERROR',"G-Sheet For PD Step 2.1 (First Cell lender/casebookedin) GSheet data : ".$GSdata["LenderName"]." PD :".$pd_details['fk_lender_id']." ".$pd_details['sub_entity_id']); + log_message('ERROR',"G-Sheet For PD Step 2.1 (lender/casebookedin) GSheet data : ".$GSdata["LenderName"]." PD :".$pd_details['fk_lender_id']." ".$pd_details['sub_entity_id']); $lender_contact_persons = $this->PD_Model->getLenderContactPersons($fk_lender_id,null); if(!empty($lender_contact_persons)){ $pd_details['lender_credit_person'] = $lender_contact_persons[0]['role_type'] == "CREDIT" ? $lender_contact_persons[0]['userid'] : null; @@ -157,33 +157,52 @@ class Data_Dump_Controller extends REST_Controller { if(isset($GSdata["LAN"]) && $GSdata["LAN"] != ""){ $LAN = trim(str_replace(" ", "", $GSdata["LAN"])); $pd_details['lender_applicant_id'] =$LAN; - log_message('ERROR',"G-Sheet For PD Step 2.2 (Second Cell - loan applicantid)GSheet data : ".$LAN." PD :".$pd_details['lender_applicant_id']); + log_message('ERROR',"G-Sheet For PD Step 2.2 (loan applicantid) GSheet data : ".$LAN." PD :".$pd_details['lender_applicant_id']); } + // $applicatantParts =""; + // if(isset($GSdata["ApplicantName_CompanyName"]) && $GSdata["ApplicantName_CompanyName"] != ""){ + // $applicatantParts = explode(',',$GSdata["ApplicantName_CompanyName"]); + // if(count($applicatantParts)>1){ + // for($j=0;$j1){ + // $pd_applicant_details[0]['applicant_name'] = $splitCompanyandApplicant[0]; + // $pd_applicant_details[0]['company_name'] = isset($splitCompanyandApplicant[1]) ? $splitCompanyandApplicant[1] : null; + // } + // else{ + // $pd_applicant_details[0]['applicant_name'] = $splitCompanyandApplicant[0]; + // $pd_applicant_details[0]['company_name'] = null; + // } + // } + // $pd_applicant_details[0]['mobile_no'] = isset($GSdata['ContactNumber']) ? $GSdata['ContactNumber'] : null; + // $pd_applicant_details[0]['applicant_type'] = 1; + // log_message('ERROR',"G-Sheet For PD Step 2.3 (Third Cell applicantdetails) GSheet data : ".$GSdata['ContactNumber']); + // log_message('ERROR',"G-Sheet For PD Step 2.4 (Fourth Cell mobilenumber) GSheet data : ".$GSdata['ContactNumber']); + // } $applicatantParts =""; - if(isset($GSdata["ApplicantName_CompanyName"]) && $GSdata["ApplicantName_CompanyName"] != ""){ - $applicatantParts = explode(',',$GSdata["ApplicantName_CompanyName"]); + if(isset($GSdata["ApplicantName"]) && $GSdata["ApplicantName"] != ""){ + $applicatantParts = explode(',',$GSdata["ApplicantName"]); if(count($applicatantParts)>1){ for($j=0;$j1){ - $pd_applicant_details[0]['applicant_name'] = $splitCompanyandApplicant[0]; - $pd_applicant_details[0]['company_name'] = isset($splitCompanyandApplicant[1]) ? $splitCompanyandApplicant[1] : null; - } - else{ - $pd_applicant_details[0]['applicant_name'] = $splitCompanyandApplicant[0]; - $pd_applicant_details[0]['company_name'] = null; - } + $pd_applicant_details[0]['applicant_name'] = $applicatantParts[0]; + } + $pd_applicant_details[0]['company_name'] = isset($GSdata["CompanyName"]) ? $GSdata["CompanyName"] : null ; $pd_applicant_details[0]['mobile_no'] = isset($GSdata['ContactNumber']) ? $GSdata['ContactNumber'] : null; $pd_applicant_details[0]['applicant_type'] = 1; - log_message('ERROR',"G-Sheet For PD Step 2.3 (Third Cell applicantdetails) GSheet data : ".$GSdata['ContactNumber']); - log_message('ERROR',"G-Sheet For PD Step 2.4 (Fourth Cell mobilenumber) GSheet data : ".$GSdata['ContactNumber']); + log_message('ERROR',"G-Sheet For PD Step 2.3 (applicant details) GSheet data : ".json_encode($pd_applicant_details)); + log_message('ERROR',"G-Sheet For PD Step 2.4 (mobile number) GSheet data : ".$GSdata['ContactNumber']); + log_message('ERROR',"G-Sheet For PD Step 2.5 (company) GSheet data : ".$GSdata["CompanyName"]); } + //address section. if(isset($GSdata["PDLocation"]) && $GSdata["PDLocation"] != ""){ $NormalParts = explode(',', $GSdata["PDLocation"]); @@ -209,11 +228,11 @@ class Data_Dump_Controller extends REST_Controller { $pd_details['addressline1']=$addresses['addressline1']; // echo "Original Address : ".$GSdataata[$i]; // echo "Modified Address : ".$address; - log_message('ERROR',"G-Sheet For PD Step 2.5 (Fifth Cell address) GSheet data : ".$GSdata["PDLocation"]); + log_message('ERROR',"G-Sheet For PD Step 2.6 (address) GSheet data : ".$GSdata["PDLocation"]); } if(isset($GSdata["PersonDoing"]) && $GSdata["PersonDoing"] != ""){ $pd_details['fk_createdby'] = $this->Data_Dump_Model->getId(8,$GSdata["PersonDoing"]); - log_message('ERROR',"G-Sheet For PD Step 2.6 (Sixth Cell createdPerson) GSheet data : ".$GSdata["PersonDoing"]); + log_message('ERROR',"G-Sheet For PD Step 2.7 (Allocated Person) GSheet data : ".$GSdata["PersonDoing"]); } if(isset($GSdata["LoanAmount"]) && ($GSdata["LoanAmount"] != "" || $GSdata["LoanAmount"] != 0)){ // $amount = strtolower($GSdata["LoanAmount"]); @@ -241,50 +260,50 @@ class Data_Dump_Controller extends REST_Controller { // }} // $pd_details['loan_amount'] = implode("",$amount); $pd_details['loan_amount'] = (int)$GSdata["LoanAmount"]; - log_message('ERROR',"G-Sheet For PD Step 2.7 (Seventh Cell Amount) GSheet data : ".$GSdata["LoanAmount"]." PD :".$pd_details['loan_amount']); + log_message('ERROR',"G-Sheet For PD Step 2.8 (Amount) GSheet data : ".$GSdata["LoanAmount"]." PD details :".$pd_details['loan_amount']); } $fk_product_id =""; - if(isset($GSdata["Product_SubProduct"]) && $GSdata["Product_SubProduct"] != ""){ - $product = explode('/', $GSdata["Product_SubProduct"]); - if(count($product)>1){ - $fk_product_id = $this->Data_Dump_Model->getId(2,trim($product[0])); - $pd_details['fk_product_id'] = $fk_product_id; - $pd_details['fk_subproduct_id'] = $this->Data_Dump_Model->getId(3,$product[1]); - } - else{ - $fk_product_id = $this->Data_Dump_Model->getId(2,trim($product[0])); - $pd_details['fk_product_id'] = $product[0] ? $fk_product_id : null ; - } - log_message('ERROR',"G-Sheet For PD Step 2.8 (eighth Cell Product/SubProduct) GSheet data : ".$GSdata["Product_SubProduct"]); + if(isset($GSdata["Product"]) && $GSdata["Product"] != ""){ + $fk_product_id = $this->Data_Dump_Model->getId(2,trim($GSdata["Product"])); + $pd_details['fk_product_id'] = $GSdata["Product"] ? $fk_product_id : null ; + log_message('ERROR',"G-Sheet For PD Step 2.9 (Product) GSheet data : ".$GSdata["Product"]." pd details : ".$fk_product_id); + } + if(isset($GSdata["SubProduct"]) && $GSdata["SubProduct"] != ""){ + $pd_details['fk_subproduct_id'] = $this->Data_Dump_Model->getId(3,$GSdata["SubProduct"]); + log_message('ERROR',"G-Sheet For PD Step 2.10 (SubProduct) GSheet data : ".$GSdata["SubProduct"]." pd details : ".$pd_details['fk_subproduct_id']); + } + if(isset($GSdata["Type"]) && $GSdata["Type"] != ""){ + $type = $GSdata["Type"]; + $modifytype = ($type != "") ? strtoupper(str_replace(' ', '', $type)) : "FULLPD"; + $pd_details['fk_pd_type'] = $modifytype == "FULLPD" ? 1 : ($modifytype == "SMARTPD" ? 2 :($modifytype == "TELEPD" ? 3 : 0) ) ; + log_message('ERROR',"G-Sheet For PD Step 2.11 (pd-type) GSheet data : ".$GSdata["Type"]." PD details :".$pd_details['fk_pd_type']); } $fk_customer_segment = ""; - if(isset($GSdata["Type_CustomerSegment"]) && $GSdata["Type_CustomerSegment"] != ""){ - $type = explode('/', $GSdata["Type_CustomerSegment"]); - $modifytype = ($type[0] != "") ? strtoupper(str_replace(' ', '', $type[0])) : "FULLPD"; - if(count($type)>1){ - $pd_details['fk_pd_type'] = $modifytype == "FULLPD" ? 1 : ($modifytype == "SMARTPD" ? 2 :($modifytype == "TELEPD" ? 3 : 0) ) ; - $modifycustomerSegment = ($type[1] != "") ? $type[1] : null; + if(isset($GSdata["CustomerSegment"]) && $GSdata["CustomerSegment"] != ""){ + $modifycustomerSegment = ($GSdata["CustomerSegment"] != "") ? $GSdata["CustomerSegment"] : null; $fk_customer_segment = $this->Data_Dump_Model->getId(4,trim($modifycustomerSegment)); $pd_details['fk_customer_segment'] = $fk_customer_segment; - }else{ - $pd_details['fk_pd_type'] = $modifytype == "FULLPD" ? 1 : ($modifytype == "SMARTPD" ? 2 :($modifytype == "TELEPD" ? 3 : 0) ) ; - } - log_message('ERROR',"G-Sheet For PD Step 2.9 (ninth Cell type/cs) GSheet data : ".$GSdata["Type_CustomerSegment"]." Modify : ".$modifytype." PD :".$pd_details['fk_pd_type']); + log_message('ERROR',"G-Sheet For PD Step 2.12 (customer segment) GSheet data : ".$GSdata["CustomerSegment"]." PD details :".$fk_customer_segment); } - // if(isset($GSdata["DateofReceivingPDRequest"]) && $GSdata["DateofReceivingPDRequest"] != ""){ // $new_date_format = date('Y-m-d H:i:s', strtotime($GSdata["DateofReceivingPDRequest"])); // $pd_details['pd_date_of_initiation'] = $new_date_format; // log_message('ERROR',"G-Sheet For PD Step 2.10 (tenth Cell initiationdate) GSheet data : ".$GSdata["DateofReceivingPDRequest"]." PD :".$pd_details['pd_date_of_initiation']); // } - if(isset($GSdata["RemarksonCurrentStatus"]) && $GSdata["RemarksonCurrentStatus"] != ""){ - $pd_details['remarks'] = "`Remarks on Current Status` : ".$GSdata["RemarksonCurrentStatus"]; - log_message('ERROR',"G-Sheet For PD Step 2.11 (eleventh Cell Remarks) GSheet data : ".$GSdata["RemarksonCurrentStatus"]." PD :".$pd_details['remarks']); + if(isset($GSdata["AdditionalRequirements"]) && $GSdata["AdditionalRequirements"] != ""){ + // $pd_details['remarks'] = "`Remarks on Current Status` : ".$GSdata["RemarksonCurrentStatus"]; + $pd_addtional_requirements = explode(',',$GSdata["AdditionalRequirements"]); + log_message('ERROR',"G-Sheet For PD Step 2.13 ( additional requirements) GSheet data : ".$GSdata["AdditionalRequirements"]." PD details :".json_encode($pd_addtional_requirements)); } - if(isset($GSdata["PreviousRemarks"]) && $GSdata["PreviousRemarks"] != ""){ - $pd_details['remarks'] = $pd_details['remarks']."\r\n `Previous Remarks` : ".$GSdata["PreviousRemarks"]; - log_message('ERROR',"G-Sheet For PD Step 2.11 (eleventh Cell Remarks) GSheet data : ".$GSdata["RemarksonCurrentStatus"]." PD :".$pd_details['remarks']); + if(isset($GSdata["Remarks"]) && $GSdata["Remarks"] != ""){ + // $pd_details['remarks'] = $pd_details['remarks']."\r\n `Previous Remarks` : ".$GSdata["PreviousRemarks"]; + $pd_details['remarks'] = $GSdata["Remarks"]; + log_message('ERROR',"G-Sheet For PD Step 2.14 (Remarks) : ".$pd_details['remarks']); + } + if(isset($GSdata["LenderCreditName"]) && $GSdata["LenderCreditName"] != ""){ + $pd_details['lender_credit_person'] = $this->Data_Dump_Model->getId(8,$GSdata["LenderCreditName"]); + log_message('ERROR',"G-Sheet For PD Step 2.15 (Lender Credit Person) GSheet data : ".$GSdata["LenderCreditName"]); } // print_r($pd_applicant_details); @@ -372,7 +391,28 @@ class Data_Dump_Controller extends REST_Controller { } } - + ## Credit Manager’s Specific Queries + if($pd_id != ""){ + if($pd_addtional_requirements != "" || $pd_addtional_requirements != null) + { + log_message('ERROR',"G-Sheet For PD Step 6 (credit manager queries)"); + foreach($pd_addtional_requirements as $pd_addtional_requirement) + { + try { + $pd_addtional_requirement['fk_pd_id'] = $pd_id; + $requirement_id = $this->Data_Dump_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); + log_message('ERROR',"G-Sheet For PD Step 6.1 (credit manager queries/additional requirements pkid) REQUIREMENTS-ID : ".$requirement_id); + if(empty($requirement_id)) { + throw new Exception('Error On Inserting Additional Requirements'); + } + } catch (Exception $e) { + //alert the user. + log_message('ERROR',"G-Sheet For PD Step 6.1 (credit manager queries/additional requirements pkid) ERR : ".$e->getMessage()); + // var_dump($e->getMessage()); + } + } + } + } ## Address Section. if($pd_id != ""){ $addresses['fk_pd_id'] = $pd_id;