diff --git a/api/application/config/autoload.php b/api/application/config/autoload.php index 24025f75..8e50e9ea 100644 --- a/api/application/config/autoload.php +++ b/api/application/config/autoload.php @@ -89,7 +89,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('url','file','form', 'jwt', 'authorization', 'date','mylog','myocr','mydb','pdalerts','myutil','myhttpclient','pdscore','businessform','otherincomeform','financialform','neighbourreferencecheckform', 'otherfamilyform', 'assetsform','stockform', 'bankingform','sms_gupshup','assessedincome','rentalform','external_dir_check','applicantname_grabber','vendor_form','custom_encryption','readexceldata','loanform'); +$autoload['helper'] = array('url','file','form', 'jwt', 'authorization', 'date','mylog','myocr','mydb','pdalerts','myutil','myhttpclient','pdscore','businessform','otherincomeform','financialform','neighbourreferencecheckform', 'otherfamilyform', 'assetsform','stockform', 'bankingform','sms_gupshup','assessedincome','rentalform','external_dir_check','applicantname_grabber','vendor_form','custom_encryption','readexceldata','loanform','requestdatadump'); /* | ------------------------------------------------------------------- diff --git a/api/application/config/routes.php b/api/application/config/routes.php index b2829701..57a70717 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -324,10 +324,6 @@ $route['getCMUsers'] = 'SMC_Credit_PD_Controller/getCMUsers'; $route['smcCreditPDMisReport'] = 'SMC_Credit_PD_Controller/smcCreditPDMisReport'; $route['getCompanyListForSMCList'] = 'SMC_Credit_PD_Controller/getCompanyListForSMCList'; -$route['getRequestForDataDump'] = 'Request_DataDump_Controller/getRequestForDataDump'; -$route['getMasterForDataDump'] = 'Request_DataDump_Controller/getMasterForDataDump'; -$route['downloadDataDump'] = 'Request_DataDump_Controller/downloadDataDump2'; - $route['getSMCVendorList'] = 'SMC_Credit_PD_Controller/getStateWiseAgency'; $route['getSMCVendorPDOfficersList'] = 'SMC_Credit_PD_Controller/getSMCVendorPDOfficersList'; @@ -357,4 +353,12 @@ $route['verifyOTP'] = 'User_Management_Controller/verifyOTP'; $route['awsrek/(:any)'] = 'Test/testAwsrek'; $route['optimizeImages/(:num)'] = 'PD_Controller/optimizeImages'; $route['downloadSMCExcelFile/(:num)'] = 'PD_Controller/downloadSMCExcelFile'; -$route['compareFaces'] = 'Test/compareFaces'; \ No newline at end of file +$route['compareFaces'] = 'Test/compareFaces'; + +$route['googleSheet'] = 'Data_Dump_Controller/googleSheet'; + +$route['getListPDOfficersForNotification'] = 'PD_Controller/getListPDOfficersForNotification'; +$route['sendNotificationToOfficers'] = 'PD_Controller/sendNotificationToOfficers'; + +$route['getMasterForDataDump'] = 'Request_DataDump_Controller/getMasterForDataDump'; +$route['getRequestForDataDump'] = 'Request_DataDump_Controller/getRequestForDataDump'; \ No newline at end of file diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index 1565e80d..d28f4aab 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -81,4 +81,388 @@ class Data_Dump_Controller extends REST_Controller { } } + + //[true,"IIB","A50397621","Kamal Kumar Garg","9773522518","M/s Bhawani Matel,,,F-3, Kh. No. 105/72, New Mandoli Industrial Area, East Delhi New Delhi, Delhi-110093","Mukund","50 lacs","LAP PD","Tue Jul 06 16:18:00 GMT+05:30 2021","Fix for tomorrow morning 11-12 Pm...08 June",null,null,null,null] + + public function googleSheet_post(){ + // $logger = MYLOG::logFunction(null,"Gsheet"); + log_message('ERROR','#/# G-Sheet Fns Entered - '.date('Y-m-d H:i:s A')); + // $sheetData = $this->post(); + // $sheetData = json_decode($this->post(),true); + $sheetData = $this->post(); + log_message('ERROR','#/# Params Count - '.count($sheetData)); + if(count($sheetData) > 0){ + $pd_id = $this->modificationGsheetData($sheetData); + if($pd_id != null || $pd_id != '') + { + $pd_serial_no = $this->Data_Dump_Model->getPDSerialNO($pd_id); + log_message('ERROR',"#/# G-Sheet For PD ID : ".$pd_id); + // PDALERTS::pdnotification($pd_id); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['pdid'] = $pd_serial_no." / ".$pd_id; + $data['msg'] = "Successfully Inserted PD.NO/ID : ".$pd_serial_no." / ".$pd_id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + log_message("ERROR","#/# G-Sheet SomeThing went Wrong mistake on Gsheet-data PDID not Founded"); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong"; + $this->response($data,REST_Controller::HTTP_OK); + } + }else{ + log_message("ERROR","#/# G-Sheet Data Not Founded"); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong !"; + $this->response($data,REST_Controller::HTTP_OK); + } + // if($reponse){ + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['pdid'] = $reponse; + // $data['sheetData'] = $sheetData; + // $data['modifiedData'] = $modified; + // } + } + + public function modificationGsheetData($GSdata){ + // $logger = MYLOG::logFunction(null,"Gsheet"); + log_message('ERROR',"G-Sheet For PD Step 1 (G-sheet Data)"); + + $pd_details = array(); + $pd_applicant_details = array(); + $addresses = array(); + // pd_details + // {"fk_lender_id":"42","sub_entity_id":"42","lender_applicant_id":"SR201819351","pd_branch_id":null,"lender_sales_person":"376","lender_credit_person":"350","imgc_fin_institute":null,"fk_product_id":"24","fk_subproduct_id":null,"fk_pd_type":"1","is_notify_enabled":null,"fk_customer_segment":"5","loan_amount":"3000000","addressline1":"Third Floor Right Side Bal K 83-84 Udyan Road Uttam Nagar New Delhi","fk_city":"869","fk_state":"5","pincode":"27491","other_pincode":null,"remarks":null,"pd_status":"TRIGGERED","fk_createdby":"397"} + // pd_applicant_details + // [{"applicant_name":"Ranjit Kumar Sharma","applicant_title_name":"5","company_name":"Kr Tourist Services Pvt Ltd","mobile_no":"9717361459","additional_mobile_no":null,"landline":null,"applicant_type":1,"relation":""}] + // addresses + // [{"addressline1":"Third Floor Right Side Bal K 83-84 Udyan Road Uttam Nagar New Delhi","fk_city":"869","fk_state":"5","pincode":"27491","other_pincode":null}] + + log_message('ERROR',"G-Sheet For PD Step 2 (Processing data for-loop)"); + if(isset($GSdata["LenderName"]) && $GSdata["LenderName"] != ""){ + $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 (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; + // $pd_details['lender_sales_person'] = $lender_contact_persons[0]['role_type'] == "SALES" ? $lender_contact_persons[0]['userid'] : null; + // } + } + 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 (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"]) && $GSdata["ApplicantName"] != ""){ + $applicatantParts = explode(',',$GSdata["ApplicantName"]); + if(count($applicatantParts)>1){ + for($j=0;$j1){ + for($j=0;$jData_Dump_Model->getId(5,$splitStateAndPincode[0]); + $pd_details['fk_state'] =$addresses['fk_state']; + $pin = $this->Data_Dump_Model->getId(6,trim($splitStateAndPincode[1])); + $addresses['pincode'] = ($pin != "" ? $pin : 1); + $pd_details['pincode'] = $addresses['pincode']; + $addresses['other_pincode']=($pin == "" ? trim($splitStateAndPincode[1]) : null); + $pd_details['other_pincode'] = $addresses['other_pincode']; + $city = array_slice($NormalParts, -2, 1); + $addresses['fk_city']=$this->Data_Dump_Model->getId(7,$city[0]); + $pd_details['fk_city']=$addresses['fk_city']; + array_splice($NormalParts, -2);//removing city state and pincode. + // $reversedParts = explode('-', strrev($GSdataata[$i]), 2); + // array_push($result_data["Pincode"],strrev($reversedParts[0])); + // print_r($NormalParts); + // print_r(array_filter($NormalParts));// removing Null values + $modifyaddress = implode(",",array_filter($NormalParts)); + $addresses['addressline1'] = implode(",",array_filter($NormalParts)); + $pd_details['addressline1']=$addresses['addressline1']; + // echo "Original Address : ".$GSdataata[$i]; + // echo "Modified Address : ".$address; + 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.7 (Allocated Person) GSheet data : ".$GSdata["PersonDoing"]); + } + if(isset($GSdata["LoanAmount"]) && ($GSdata["LoanAmount"] != "" || $GSdata["LoanAmount"] != 0)){ + // $amount = strtolower($GSdata["LoanAmount"]); + // $amount = explode(' ', $amount); + // 3 zeros in 1,000 - One Thousand + // 4 zeros in 10,000 - Ten Thousand + // 5 zeros in 100,000 - 1 Lakh / 100 Thousand + // 6 zeros in 1,000,000 - 10 Lakh / 1 Million + // 7 zeros in 10,000,000 - 1 Crore / 10 Million + // 8 zeros in 100,000,000 - 10 Crore / 100 Million + // 9 zeros in 1,000,000,000 - 100 Crore / 1 Billion + // 10 zeros in 10,000,000,000 - 1,000 Crore / 10 Billion + // 11 zeros in 100,000,000,000 - 10,000 Crore / 100 Billion + // 12 zeros in 1,000,000,000,000 - 1 Lakh Crore / 1 Trillion + // 13 zeros in 10,000,000,000,000 - 10 Lakh Crore / 10 Trillion + // if(gettype($amount[1]) == 'string'){ + // if($amount[1] == 'cr' || $amount[1] == 'crore'){ + // $amount[1] = "0000000"; + // } + // if($amount[1] == 'lac' || $amount[1] == 'lacs' || $amount[1] == 'lakh'){ + // $amount[1] = "000000"; + // } + // if($amount[1] =='k' ||$amount[1] == 'thousand'){ + // $amount[1] = "000"; + // }} + // $pd_details['loan_amount'] = implode("",$amount); + $pd_details['loan_amount'] = (int)$GSdata["LoanAmount"]; + 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"]) && $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["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; + 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["AdditionalRequirements"]) && $GSdata["AdditionalRequirements"] != ""){ + $requirements = explode(',',$GSdata["AdditionalRequirements"]); + if(count($requirements)>1){ + for($j=0;$jData_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); + // die(); + ## Default Status section; + $pd_details['pd_status'] = TRIGGERED; + $pd_details['pd_date_of_initiation'] = date('Y-m-d H-i-s'); + $pd_details['fk_createdby'] = 379; // default user created for admin. + ## Template ID Section. + $fields = array('fk_template_id'); + $where_condition_array = array('fk_lender_id'=>$fk_lender_id ,'fk_product_id'=> $fk_product_id,'fk_customer_segment'=> $fk_customer_segment,'isactive' => 1); + $table = LENDERTEMPLATE; + $choosed_template_id = $this->Data_Dump_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($choosed_template_id))## CHOOSE FILTERED TEMPLATE + { + $pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id']; + } + else ## CHOOSE GENERIC TEMPLATE + { $customer_segment_abbr = $this->Data_Dump_Model->selectCustomRecords(array('*'),array('customer_segment_id' => $pd_details['fk_customer_segment'],'isactive' => 1),CUSTOMERSEGMENT); + $customer_segment_abbr = $customer_segment_abbr[0]['abbr']; + if( !strcasecmp($customer_segment_abbr,'SAL'))// || !strcasecmp($customer_segment_abbr,'SAL-CHQ')) + {$pd_details['fk_pd_template_id'] = 1;## SAL-(CASH/CHQ) + } + else if( !strcasecmp($customer_segment_abbr,'SE-DI') || !strcasecmp($customer_segment_abbr,'SEP-DI') || !strcasecmp($customer_segment_abbr,'SEP_INDV')) + {$pd_details['fk_pd_template_id'] = 2;## SENP/SEP-(DI) + } + else if( !strcasecmp($customer_segment_abbr,'SE-AI') || !strcasecmp($customer_segment_abbr,'SEP-AI') ) + {$pd_details['fk_pd_template_id'] = 3;## SENP/SEP-(DI) + } + else if( !strcasecmp($customer_segment_abbr,'SE-RI')) + {$pd_details['fk_pd_template_id'] = 4;## SENP/SEP-(RI) + } + } + + + ## Random URL Section. + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 16; $i++) + { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + $pd_details['random_string'] = $randomString; + $url = OFFICER_TRACKING_URL.$randomString; + $pd_details['encrypted_url'] = $url; + $pd_details['is_notify_enabled'] = 1; + log_message('ERROR',"G-Sheet For PD Step 3 (Before Inserting Trigger)"); + try { + $pd_id = $this->Data_Dump_Model->saveRecords($pd_details,PDTRIGGER); + log_message('ERROR',"G-Sheet For PD Step 4 (PDID gotten) PDID : ".$pd_id); + if(empty($pd_id)) { + throw new Exception('Error On Inserting TRIGGER details'); + } + } catch (Exception $e) { + log_message('ERROR',"G-Sheet For PD Step 4 (PDID gotten) ERR : ".$e->getMessage()); + // var_dump($e->getMessage()); + } + // $pd_id = 3149; + + + if($pd_id != null || $pd_id != '') + { + if($pd_applicant_details != "" || $pd_applicant_details != null) + { + log_message('ERROR',"G-Sheet For PD Step 5 (applicant)"); + // Applicant : ".$pd_applicant_details); + foreach($pd_applicant_details as $pd_applicant_detail) + { + $pd_applicant_detail['fk_pd_id'] = $pd_id; + $pd_applicant_detail['applicant_name'] = trim(MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['applicant_name'])); + if(isset($pd_applicant_detail['company_name'])){ $pd_applicant_detail['company_name'] = trim(MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['company_name'])); } + try { + $co_applicant_id = $this->Data_Dump_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); + log_message('ERROR',"G-Sheet For PD Step 5.1 (applicant pkid) Applicant-ID : ".$co_applicant_id); + if(empty($co_applicant_id)) { + throw new Exception('Error On Inserting Applicant details'); + } + } catch (Exception $e) { + //alert the user. + log_message('ERROR',"G-Sheet For PD Step 5.1 (applicant pkid) ERR : ".$e->getMessage()); + // var_dump($e->getMessage()); + } + + } + + } + } + ## Credit Manager’s Specific Queries + if($pd_id != ""){ + if($addi_requirements != "" || $addi_requirements != null) + { + log_message('ERROR',"G-Sheet For PD Step 6 (credit manager queries)"); + foreach($addi_requirements as $pd_addtional_requirement) + { + try { + $pd_addtional_requirement['isactive'] = 1; + $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; + $addresses['is_primary'] = 1 ; + $addresses['assigned_pd'] = $pd_id; + try { + $address_id = $this->Data_Dump_Model->saveRecords($addresses,PDADDRESS); + log_message('ERROR',"G-Sheet For PD Step 6 (Addresses) addressId : ".$address_id); + if(empty($address_id)) { + throw new Exception('Error On Inserting Adresses details'); + } + } catch (Exception $e) { + log_message('ERROR',"G-Sheet For PD Step 6 (Addresses) ERR : ".$e->getMessage()); + // var_dump($e->getMessage()); + } + // $triggertbl_records = array('fk_primary_address_id'=>$address_id,'fk_address_id'=>$address_id); + $triggertbl_records = array('fk_primary_address_id'=>$address_id,'fk_address_id'=>$address_id,'parent_pd_id'=>$pd_id); + + try { + $this->Data_Dump_Model->updateRecords($triggertbl_records,PDTRIGGER,array('pd_id' => $pd_id)); + log_message('ERROR',"G-Sheet For PD Step 7 (updateAddresses in trigger)"); + if(empty($this->Data_Dump_Model->updateRecords($triggertbl_records,PDTRIGGER,array('pd_id' => $pd_id)))) { + throw new Exception('Error On updated Adresses Details in trigger table'); + } + } catch (Exception $e) { + log_message('ERROR',"G-Sheet For PD Step 7 (updateAddresses in trigger) ERR : ".$e->getMessage()); + // var_dump($e->getMessage()); + } + } + + log_message('ERROR',"#/# G-Sheet Final PDID : ".$pd_id); + return $pd_id; + } } \ No newline at end of file diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index e469958b..1c9ca3d5 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -1826,7 +1826,7 @@ public function assignPDTempalate($data) *GET List of PD officers for PD edit/view page for manual allocation *@param pd */ - public function getListPDOfficers_post() + public function getListPDOfficers_post() { $pdid = $this->post('pdid'); @@ -4919,14 +4919,14 @@ public function getPDFormDetailsJSON_post() $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Image ZIP'.', ') : 'Image ZIP, '; } - if($pd_master_details[0]['fk_pd_type'] == 2) - { - $video_status = $this->PD_Model->selectCustomRecords(array('count(*) as count'),array('isactive' => 1,'twilo_status' => 'enqueued','fk_pd_id' => $pdid),VIDEO_ROOM_INFO); - if($video_status[0]['count'] != 0) - { - $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Some videos'.', ') : 'Some videos, '; - } - } + // if($pd_master_details[0]['fk_pd_type'] == 2) + // { + // $video_status = $this->PD_Model->selectCustomRecords(array('count(*) as count'),array('isactive' => 1,'twilo_status' => 'enqueued','fk_pd_id' => $pdid),VIDEO_ROOM_INFO); + // if($video_status[0]['count'] != 0) + // { + // $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Some videos'.', ') : 'Some videos, '; + // } + // } // print_r($data); // echo strrpos($data['msg'], ','); if(isset($data['msg']) && $data['msg'] != '') @@ -11761,9 +11761,107 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $this->response($data,REST_Controller::HTTP_OK); } } - + + public function getListPDOfficersForNotification_get(){ + log_message('ERROR',"getListPDOfficers Function"); + $fields = array('fk_user_id'); + $where_condition_array = array('isactive' => 1); + $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); + if(!empty($list_of_pd_officers)){ + foreach($list_of_pd_officers as $key => $pdofficer) + { + $this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); + $this->db->FROM(USERPROFILE.' as USERPROFILE'); + $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); + $this->db->JOIN(ROLES.' as ROLES','USERPROFILEROLES.user_role = ROLES.role_id'); + $this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']); + $this->db->WHERE_IN("USERPROFILEROLES.user_role",[5]);//pd officer role only + $names = $this->db->GET()->result_array(); + if(count($names)){ + $list_of_pd_officers[$key]['first_name'] = $names[0]['first_name']; + $list_of_pd_officers[$key]['last_name'] = $names[0]['last_name']; + $list_of_pd_officers[$key]['mobile_no'] = $names[0]['mobile_no']; + $list_of_pd_officers[$key]['user_role'] = $names[0]['user_role']; + $list_of_pd_officers[$key]['role_name'] = $names[0]['role_name']; + }else{ + unset($list_of_pd_officers[$key]); + } + } + } + Sort($list_of_pd_officers); + log_message('ERROR',"getListPDOfficers PDofficer list : ".json_encode($list_of_pd_officers)); + // Get Central PD Officers List + $central_pd_officers = array(); + + $this->db->SELECT('USERPROFILE.userid as fk_user_id,USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); + $this->db->FROM(USERPROFILE.' as USERPROFILE'); + $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); + $this->db->JOIN(ROLES.' as ROLES','USERPROFILEROLES.user_role = ROLES.role_id'); + $this->db->WHERE('ROLES.role_id',2); + $central_pd_officers = $this->db->GET()->result_array(); + log_message('ERROR',"getListPDOfficers CentralPDofficer list : ".json_encode($central_pd_officers)); + + if(!empty($list_of_pd_officers) && !empty($central_pd_officers)){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'PD-Officer and Central PD-Officer Records Available!'; + $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); + + }else if(empty($list_of_pd_officers) && !empty($central_pd_officers)){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'PD-Officer Records Not Found!'; + $data['records'] = array('pdofficers' => array(),'centralpdofficers' => $central_pd_officers); + }else if(empty($central_pd_officers) && !empty($list_of_pd_officers)){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Central PD-Officer Records Not Found!'; + $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => array()); + }else{ + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Officers Records Not Found!'; + } + $this->response($data,REST_Controller::HTTP_OK); + } + public function sendNotificationToOfficers_post(){ + log_message('ERROR',"send Notification To Officers "); + $records = $this->post('records'); + $users = $records['user_id']; // alluser,multiuser,particularuser + $msg = $records['msg']; // alluser,multiuser,particularuser + // print_r($this->post());die(); + + if(!empty($msg) && !empty($users)){ + // $fields = array('notification_token_id','mob_token'); + // $where_condition_array = array(); + // $tokens = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,USERNOTIFICATIONTOKENS); + // pd offier's mobile token get form notification table + $resp = PDALERTS::sendNotificationToOfficers($records); + log_message('ERROR',"send Notification To Officers : ".json_encode($resp)); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Notification Sended'; + $data['details'] = $resp; + }else{ + if(empty($msg)){ + log_message('ERROR',"send Notification To Officers : Message Not Found "); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Message Data Not Found!'; + }else if(empty($users)){ + log_message('ERROR',"send Notification To Officers : Officer List Not Found "); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Users Not Found!'; + }else{ + log_message('ERROR',"send Notification To Officers : No Content "); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Records Not Found!'; + } + } + $this->response($data,REST_Controller::HTTP_OK); + } -} - - +} \ No newline at end of file diff --git a/api/application/controllers/Request_DataDump_Controller.php b/api/application/controllers/Request_DataDump_Controller.php index 10e6ad15..e2abc8e0 100755 --- a/api/application/controllers/Request_DataDump_Controller.php +++ b/api/application/controllers/Request_DataDump_Controller.php @@ -12,6 +12,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); /** @noinspection PhpIncludeInspection */ require_once APPPATH . '/libraries/REST_Controller.php'; include_once APPPATH.'/vendor/autoload.php'; +require APPPATH.'/vendor/autoload.php'; /** * This is an example of a few basic user interaction methods you could use @@ -31,33 +32,61 @@ class Request_DataDump_Controller extends REST_Controller { parent::__construct(); $this->load->model('Data_Dump_Model','Data_Dump_Model'); - //$this->load->library('AWS_S3'); - $this->load->library('excel'); - $this->load->helper('download'); + $this->load->library('pdfgenerator'); + // $this->load->library('AWS_S3'); } - + + ### XL-Data-Dump master Details Filter + # PD-TYPE,PRODUCT,CUSTOMER-SEGMENT AND PD-SNO. + public function getMasterForDataDump_get(){ + log_message('ERROR','## XL-datadump Master Details inside Fns - '.date('Y-m-d H:i:s A')); + $result = $this->Data_Dump_Model->filtermasterfordatadumprequest(); + if(count($result) > 0) + { log_message('ERROR',"## XL-datadump Master Details : ".json_encode($result)); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + } + else + { log_message('ERROR',"## XL-datadump Master Details Error "); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + } + $this->response($data,REST_Controller::HTTP_OK); + }//getMasterForDataDump closed here. + + ### Request the Details For XL-Data-Dump. public function getRequestForDataDump_post(){ - // {"type":null,"fd":null,"td":null,"pdid":[]} - // {"type":null,"fd":"2021-07-08","td":null,"pdid":[]} - // {"type":null,"fd":"2021-07-08","td":"2021-07-20","pdid":[]} - // {"product_id":null,"customer_segment_id":null,"pd_type_id":null,"from_date":null,"to_date":null,"pd_id":["2583"]} - // {"type":null,"fd":null,"td":null,"pdid":["6691"]} - // {"type":null,"fd":null,"td":null,"pdid":["6692","6691","6688"]} - // {"product":null"customer_segment":null,"type":null,"fd":null,"td":null,"pdid":["6692","6691","6688"]} + // echo XLPATH;die(); + log_message('ERROR','## Request For XL-datadump inside Fns - '.date('Y-m-d H:i:s A')); + ## Sample Params : {"product_id":1,"customer_segment_id":null,"pd_type_id":null,"from_date":null,"to_date":null,"pd_id":["2583","2606"]} $postarr = $this->post(); - // ### Requested Details - $requested_details = $this->Data_Dump_Model->getRequestForDataDump($postarr); - // echo "i am in controller"; print_r($requested_details); count($requested_details); - $file = APPPATH.'docs/RequestDataDump.xls'; - if (file_exists($file)){ - if (file_exists(APPPATH."docs/DataDump.xls")) { - unlink(APPPATH.'docs/DataDump.xls'); - } + log_message('ERROR','## Request For XL-datadump Parmas - '.json_encode($postarr)); + ## Gathering Data based on params. + $requested_details = $this->Data_Dump_Model->getRequestForDataDump($postarr); + log_message('ERROR','## Request For XL-datadump Requested-data count - '.count($requested_details)); + if (!empty($requested_details)){ + requestdatadump::Fns4($requested_details); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['message'] = "Success"; + }// if closed 68; + else { + log_message('ERROR','## Request For XL-datadump file template Not Founded'); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['message'] = "Fails"; + }//else closed + $this->response($data,REST_Controller::HTTP_OK); + // switch($role_id){} + } + public function getRequestForDataDump2_post(){ + + + // echo "\n The file $file exists"; // $pathinfo = pathinfo($file); print_r($pathinfo); - require_once APPPATH .'third_party/PHPExcel/Classes/PHPExcel/IOFactory.php'; - $reader= PHPExcel_IOFactory::createReaderForFile($file); - $XL = $reader->load($file); + // '3', 'Personal Details', // '15', 'Lender Representative', // '16', 'Assessed Income', @@ -1840,156 +1869,6 @@ class Request_DataDump_Controller extends REST_Controller { // Display the output // echo $encode; // $objWriter->save('php://output'); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - // $data['message'] = "Success ( The file $file exists )"; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['message'] = "Fails ( The file $file does not exists )"; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function check($ths_var){ - if (isset($the_var)) { - if (empty($the_var)) { - return "-"; - } else { return $the_var; } - } else { return "-"; } - - - } - public function getMasterForDataDump_get(){ - - $result = $this->Data_Dump_Model->filtermasterfordatadumprequest(); - - if(count($result) > 0) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); - } - - - } - - public function downloadDataDump_get() - { - - - - - $fp = fopen (APPPATH.'docs/DataDump.xls', 'w+');//This is the file where we save the information - $headers = array('Content-type: application/json'); - $fp = fopen (dirname(__FILE__) . '/localfile.tmp', 'w+');//This is the file where we save the information - $curl = curl_init(DONWLOAD_REPORT); - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_USERPWD, $api_key); - $file = curl_exec($curl); - - if ($file === false) - { - $info = curl_getinfo($curl); - curl_close($curl); - die('error occured during curl exec. Additioanl info: ' . var_export($info)); - } - - curl_close($curl); - - header('Content-type: ' . 'application/octet-stream'); - header('Content-Disposition: ' . 'attachment; filename=DataDump.xls'); - echo $file; - - } - - public function downloadDataDump1_get() - { - $content = trim(file_get_contents(APPPATH.'docs/DataDump.xls')); - return $content; - } - public function downloadDataDump2_post(){ - // $pth = file_get_contents(APPPATH."docs/DataDump.xls"); - // $nme = "sample_file.xls"; - // force_download($nme, $pth); - if (file_exists(APPPATH."docs/DataDump.xls")) { - header("Content-Type: application/x-binary"); - header("Content-Transfer-Encoding: Binary"); - header("Content-Length:".filesize($file)); - header("Content-Disposition: attachment; filename=".$name); - $file = read_file(APPPATH."docs/DataDump.xls"); // Use file helper to read the file's - $name = "DataDump".date('Y-m-d-H-i-s').'.xls'; - force_download($name, $file); - } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['message'] = "The file does not exist"; - $this->response($data,REST_Controller::HTTP_OK); - } - // exit; - } - // public function getXL_get(){ - // $data = read_file(APPPATH."docs/DataDump.xls"); // Use file helper to read the file's - // $name = "DataDump".date('Y-m-d-H-i-s').'.xls'; - // force_download($name, $data); - // } - public function downloadDataDump5_get(){ - $temp_base64_string = "DataDump.xls"; - $title = "Request Data Dump"; - $output_file = APPPATH."docs/DataDump.xls"; - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - $temp_file_name = $randomString.date('Y-m-d-H-i-s').'.xls'; - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - print_r($temp_data); - // fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - // fclose( $ifp ); - // $tempdoc = $output_file; - // prit_r($tempdoc); - } - public function downloadDataDump3_get(){ - $temp_base64_string = "DataDump.xls"; - $title = "Request Data Dump"; - $output_file = APPPATH."docs/DataDump.xls"; - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - $temp_file_name = $randomString.date('Y-m-d-H-i-s').'.xls'; - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $bucketname = LENDER_BUCKET_NAME_PREFIX; - $key = 'docs/'.$tempdocname ; - $sourcefile = $tempdoc; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - - print_r($s3result); - - } - -} \ No newline at end of file + }//closed + +}// Class Closed Here. \ No newline at end of file diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 2cdfbacc..dc14adbb 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -939,6 +939,7 @@ class Template_Management_Controller extends REST_Controller { $records['customer_segment_id'] = $this->get("customer_segment_id");} $result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($records); + // print_r($result_array);die(); if(!empty($result_array)) foreach($result_array as $inx => $arr) { @@ -951,7 +952,8 @@ class Template_Management_Controller extends REST_Controller { }else{ $result_array[$inx]["forms"] = array(); } - array_push($result_array[$inx]["forms"],array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1","pd_form_order"=>"5","is_form_status"=>null,"template_id"=>null)); + $buinessFormAvailable =$this->Template_Management_Model->checkBuinessFormsAvailablity($records); + if($buinessFormAvailable){array_push($result_array[$inx]["forms"],array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1","pd_form_order"=>"5","is_form_status"=>null,"template_id"=>null));} array_push($result_array[$inx]["forms"],array("form_id"=> "18","form_name"=> "General Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"2","is_form_status"=>null,"template_id"=>null)); array_push($result_array[$inx]["forms"],array("form_id"=> "26","form_name"=> "Photograph","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"24","is_form_status"=>null,"template_id"=>null)); // $buiness_arr = array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1"); @@ -1045,26 +1047,54 @@ class Template_Management_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); }else{ $fields = array('id'); + $flag=0; $where_condition_array = $records; $where_condition_array['isactive'] = 1; $map_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_MAP_V2); + // $map_table = array(); if(count($map_table)>0){ // $this->db->where('id',$map_table[0]['id']); // $this->db->set('isactive',0); // $this->db->update(TEMPLATE_MAP_V2); - $map_pk_id = (int)$map_table[0]['id']; - $msg = "Data Already Available For Given Params"; + // $map_pk_id = (int)$map_table[0]['id']; + $msg = "Data Already Available For Given Params / MAPID => ".(int)$map_table[0]['id']; + $STScode = REST_Controller::HTTP_ACCEPTED; + $flag++; }else{ + // form Template is declare as gobally in m_pd_forms table @form_template column using CustomerSegmentID. + // $form_template = array(); + $regular_form_template = $this->Template_Management_Model->getFormTemplate($records['customer_segment_id']); + $buiness_form_template = $this->getBuinessFormTemplate($records); + $key = array_search('13', array_column($regular_form_template, 'form_id')); + if (!empty($key)) { + unset($regular_form_template[$key]);//here 13th form is buiness unset here.id have both regular and buiness. + $form_template = array_merge($regular_form_template,$buiness_form_template); + }else{ + $form_template = $regular_form_template; + } $map_pk_id = $this->Template_Management_Model->saveTemplateMapping($records,TEMPLATE_MAP_V2); + $c = "JSON ID Are =>"; //concate; + for($i=0; $i $form_template[$i]['form_id'],'json' => $template,'map_id'=>$map_pk_id,'is_form_status'=>"DRAFT"); + if($form_template[$i]['form_id'] != 18 ||$form_template[$i]['form_id'] != 26){ + // if($form_template[$i]['form_id'] != 18 ||$form_template[$i]['form_id'] != 26 ||$form_template[$i]['form_id'] != 13){ + $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2); + $c = $c." ".$json_pk_id;} + } + } $msg = "Sucessfully Inserted"; + $flag++; + $STScode = REST_Controller::HTTP_OK; } - - if($map_pk_id) + if($flag>0) { $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['map_id'] = $map_pk_id; + $data['status'] = $STScode; + if(isset($map_pk_id)){$data['map_id'] = $map_pk_id;} + if(isset($c)){$data['json_id'] = $c;} $data['msg'] = $msg; $this->response($data,REST_Controller::HTTP_OK); } @@ -1241,8 +1271,10 @@ class Template_Management_Controller extends REST_Controller { $form_id = $_GET['form_id']; $template_id = isset($_GET['template_id'])?$_GET['template_id']:null; $fields = array('id','json'); - if($template_id){$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","id"=>$template_id);} - else{$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","isactive"=>1);$data['note'] = "Existing JSON..";} + // if($template_id){$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","id"=>$template_id);} + // else{$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","isactive"=>1);$data['note'] = "Existing JSON..";} + if($template_id){$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"id"=>$template_id);} + else{$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);} $json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2); if(count($json_table)>0){ $data['dataStatus'] = true; @@ -1274,7 +1306,8 @@ class Template_Management_Controller extends REST_Controller { $form_id = $record['form_id']; $is_form_disabled = $record['is_form_disabled']; $fields = array('id'); - $where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1,"is_form_status"=>"COMPLETED"); + // $where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1,"is_form_status"=>"COMPLETED"); + $where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1); $json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2); if(count($json_table)>0){ // $data['dataStatus'] = true; @@ -1310,6 +1343,7 @@ class Template_Management_Controller extends REST_Controller { } // analysing public function getBuinessGroupFormsV2_get(){ + // echo $_GET['map_id'];die; // if((!isset($_GET['map_id']))) // { // $data['dataStatus'] = false; @@ -1331,6 +1365,7 @@ class Template_Management_Controller extends REST_Controller { { $records['customer_segment_id'] = $this->get("customer_segment_id");} $result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($records); + // echo "no problem";print_r($result_array);die; if(!empty($result_array)) foreach($result_array as $inx => $arr) { @@ -1395,7 +1430,7 @@ class Template_Management_Controller extends REST_Controller { if(!empty($filter_arr)){ $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['available_question'] = $filter_arr; + // $data['available_question'] = $filter_arr; // $data['json'] = $quest; $this->response($data,REST_Controller::HTTP_OK); }else{ @@ -1552,5 +1587,29 @@ class Template_Management_Controller extends REST_Controller { // $return_arr = array(); // $i = 0 ; // } + // http://localhost/AWSEC2/sparqapi/api/Template_Management_Controller/check + // public function check_get(){ + // $form_template = $this->Template_Management_Model->getFormTemplate(4); + // // print_r($form_template);die(); + // $this->response($form_template,REST_Controller::HTTP_OK); + // } + public function getBuinessFormTemplate($records){ + $fields = array('short_name'); + $where_condition_array = array('entity_id'=>$records['entity_id'],"isactive"=>1); + $lender_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,'m_entity'); + $lender_short_name = $lender_table[0]['short_name']; + $fields = array(' abbr'); + $where_condition_array = array('customer_segment_id'=>$records['customer_segment_id'],"isactive"=>1); + $segment_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,'m_customer_segment'); + $str = substr($segment_table[0]['abbr'],-2); + + $form_id = array(13,22,1,2,11); + //here 14 removed because finacial form calculation are there. + if(strcmp($str,'AI')) { array_push($form_id,16); } + if(!strcasecmp($lender_short_name, 'CLIX')){ array_push($form_id,21); } + if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) { array_push($form_id,23);} + $form_template = $this->Template_Management_Model->getBuinessFormTemplate($form_id); + return $form_template; + } } \ No newline at end of file diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index 65717bef..e38c5dbc 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -567,8 +567,9 @@ else { // SMS_GUPSHUP::sendSMS($msg,$mobile); // $msg = "OTP for starting your personal discussions with the verification officer is ".$OTP.".Pls share this only when the officer has reached your place"; // $msg = "PD for Loan Applicant ".$OTP." ID - ".$OTP." has been triggered."; - $msg = "PDGenie OTP is : ".$OTP; - SMS_GUPSHUP::sendSMS($msg,$mobile,array('id'=>$userid,'msg'=>"Your OTP is ".$OTP." from User Management Controller")); + //$msg = "PDGenie OTP is : ".$OTP; + $msg = "PDGenie Authentication Code is ".$OTP; + SMS_GUPSHUP::sendSMS($msg,$mobile,array('id'=>$userid,'msg'=>"PDGenie Authentication Code is ".$OTP." from User Management Controller")); $this->User_Management_Model->updateRecords(array('OTP'=>$OTP),USERPROFILE,array('userid'=>$userid)); $data['dataStatus'] = true; diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php index 5cb0eef7..b00905fd 100644 --- a/api/application/helpers/pdalerts_helper.php +++ b/api/application/helpers/pdalerts_helper.php @@ -842,6 +842,48 @@ class PDALERTS } $mail->SmtpClose(); } + + public static function sendNotificationToOfficers($records) + { + log_message('ERROR','send Notification To Officers in pd alert'); + $users = $records['user_id']; // alluser,multiuser,particularuser + $msg = $records['msg']; // msg + $CI =&get_instance(); + $CI->load->helper('push_notification'); + // notification_token_id, fk_user_id, web_token, mob_token, createdon, updatedon + $CI->db->SELECT("USERNOTIFICATIONTOKENS.notification_token_id,USERNOTIFICATIONTOKENS.fk_user_id,USERNOTIFICATIONTOKENS.mob_token,concat(USERPROFILE.first_name,' ',USERPROFILE.last_name) as pdofficer_name"); + $CI->db->FROM(USERNOTIFICATIONTOKENS." as USERNOTIFICATIONTOKENS"); + $CI->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERNOTIFICATIONTOKENS.fk_user_id and USERPROFILEROLES.isactive = 1'); + $CI->db->JOIN(USERPROFILE." as USERPROFILE","USERNOTIFICATIONTOKENS.fk_user_id = USERPROFILE.userid",'LEFT'); + // $CI->db->WHERE('ROLES.role_id',2); + if(is_array($users) && count($users)){ + if($users[0] != 0){ + $CI->db->WHERE_IN('USERNOTIFICATIONTOKENS.fk_user_id ',$users); + }else{ + $CI->db->WHERE_IN("USERPROFILEROLES.user_role",[5]);//pd officer roles only + // $CI->db->WHERE_IN("USERPROFILEROLES.user_role",[2,5,22]); + } + } + $CI->db->WHERE('USERNOTIFICATIONTOKENS.mob_token != ""'); + $notification_details = $CI->db->GET()->result_array(); + log_message('ERROR',"send Notification To Officers Records : ".json_encode($notification_details)); + // print_r($CI->db->last_query());die(); + // print_r($notification_details);die(); + + $additional_data_for_logs['to_whom'] = 'PDOFFICERS'; + $web_token = ""; + + // $officers_name = array(); + $officers_name['total_count'] = count($notification_details); + $officers_name['officers'] = array(); + for($i=0;$iinfo("PUSH NOTIFICATION ",array('firebase_result' => $result,'additional_data' => $additional_data,'token_type' => ($type == 1? 'WEB' : 'MOB'),'token' => $token)); + MYLOG::logFunction(null,(isset($additional_data['pd_id'])?$additional_data['pd_id']:""))->info("PUSH NOTIFICATION ",array('firebase_result' => $result,'additional_data' => $additional_data,'token_type' => ($type == 1? 'WEB' : 'MOB'),'token' => $token)); } } diff --git a/api/application/helpers/requestdatadump_helper.php b/api/application/helpers/requestdatadump_helper.php new file mode 100644 index 00000000..4f7b48ee --- /dev/null +++ b/api/application/helpers/requestdatadump_helper.php @@ -0,0 +1,594 @@ +load->library('myspreadsheet'); + $spreadsheet = $CI->myspreadsheet->getMySpreadSheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', 'Second Hello World !'); + $sheet->setTitle('Address Form datas'); + $myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'My Data'); + // Attach the "My Data" worksheet as the first worksheet in the Spreadsheet object + $spreadsheet->addSheet($myWorkSheet, 0); + + $writer = $CI->myspreadsheet->getXlsx($spreadsheet); + $writer->save(XLPATH.'/tmp/SecondTest.xls'); + } + + public static function Fns2($requested_details) + { + log_message('ERROR','####RequestDataDump Helper FNS1'); + log_message('ERROR','####Creating Test Excel'); + $CI =&get_instance(); + $CI->load->library('myspreadsheet'); + SELF::$current_spreadsheet = $CI->myspreadsheet->getMySpreadSheet(); + $sheet = SELF::$current_spreadsheet->getActiveSheet(); + $sheet->setCellValue('A1', 'Second Hello World !'); + $sheet->setTitle('Address Form datas'); + SELF::$current_spreadsheet->setActiveSheetIndex(0)->setTitle('My Data'); + // Attach the "My Data" worksheet as the first worksheet in the Spreadsheet object + SELF::$current_spreadsheet->addSheet($myWorkSheet, 0); + $writer = $CI->myspreadsheet->getXlsx(SELF::$current_spreadsheet); + $writer->save(XLPATH.'/tmp/ThridTest.xls'); + } + + public static function multiple_spreadsheet($r) + { + $CI =&get_instance(); + $CI->load->library('myspreadsheet'); + + // header('Content-Type: application/vnd.ms-excel'); + // header('Content-Disposition: attachment;filename=myexcel.xlsx'); + + $spreadsheet = $CI->myspreadsheet->getMySpreadSheet(); + $spreadsheet->setActiveSheetIndex(0)->setCellValue('A1','service worksheet'); + $spreadsheet->getActiveSheet()->setTitle('Service'); + + $spreadsheet->createSheet(); + $spreadsheet->setActiveSheetIndex(1)->setCellValue('A1','New Worksheet'); + $spreadsheet->getActiveSheet()->setTitle('Product1'); + + $spreadsheet->createSheet(); + $spreadsheet->setActiveSheetIndex(2)->setCellValue('A1','New Worksheeet'); + $spreadsheet->getActiveSheet()->setTitle('Product2'); + + $spreadsheet->createSheet(); + $spreadsheet->setActiveSheetIndex(3)->setCellValue('A1','New Workshet'); + $spreadsheet->getActiveSheet()->setTitle('Product3'); + + $spreadsheet->createSheet(); + $spreadsheet->setActiveSheetIndex(4)->setCellValue('A1','New Workshheet'); + $spreadsheet->getActiveSheet()->setTitle('Product4'); + // $spreadsheet->setActiveSheetIndex(0); + + $writer = $CI->myspreadsheet->getXlsx($spreadsheet); + $writer->save(XLPATH.'/tmp/PDExportXL_f.xls'); + } + + public static function Fns4($requested_details) + { + log_message('ERROR','####RequestDataDump Helper FNS2'); + log_message('ERROR','####Creating Test Excel'); + $CI =&get_instance(); + $CI->load->library('myspreadsheet'); + SELF::$current_spreadsheet = $CI->myspreadsheet->getMySpreadSheet(); + $formid_arr = array(); + for($i=0;$i < count($requested_details);$i++){ + $processedJson = json_decode($requested_details[$i]['processed_json'],TRUE); + $formid = $processedJson['formid']; + // echo " ".$formid." "; + if (!in_array($formid, $formid_arr)){ + array_push($formid_arr,(int)$formid); + } + } + sort($formid_arr); + SELF::formHeadlines($formid_arr); + $writer = $CI->myspreadsheet->getXlsx(SELF::$current_spreadsheet); + $filename = "PDExportXL_".date('Y-m-d H:i:s A').".xls"; + $writer->save(XLPATH.'/tmp/'.$filename); + // $numbers = array(4, 6, 2, 22, 11);sort($numbers); + // print_r($numbers); + // print_r($formid_arr);die(); + + for($i=0;$i < count($requested_details);$i++){ + $processedJson = json_decode($requested_details[$i]['processed_json'],TRUE); + // print_r($processedJson);die(); + // echo "Don't Worry Be happy because i have JSON"; + $formid = $processedJson['formid']; + switch($formid) + { + // case 1: ## '1', 'Supplier Details' + // $details = SELF::gatheringSupplierForm($processedJson); + // // $sheet->setTitle('Supplier Details'); + // $sheet->setActiveSheetIndex(0)->setCellValue('A1','Supplier Details'); + // $sheet->getActiveSheet()->setTitle('Supplier Details'); + + // break; + // case 2: ## '2', 'Client Details' + // $details = SELF::gatheringClientForm($processedJson); + // $sheet->createSheet(); + // $sheet->setActiveSheetIndex(1)->setCellValue('A1', 'Client Details !'); + // $sheet->getActiveSheet()->setTitle('Client Details'); + + // break; + // case 3: ## '3', 'Personal Details' + // $details = SELF::gatheringPersonalForm($processedJson); + // $sheet->createSheet(); + // $sheet->setActiveSheetIndex(2)->setCellValue('A1', 'Personal Details !'); + // $sheet->getActiveSheet()->setTitle('Personal Details'); + // break; + // case 4: ## '4', 'Other Assets' + // $details = SELF::gatheringOtherAssetForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Other Assets'); + + // break; + // case 5: ## '5', 'Address Details' + // $details = SELF::gatheringAddressForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Address Details'); + + // break; + // case 6: ## '6', 'Family Details' + // $details = SELF::gatheringOtherFamilyDetailsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Family Details'); + + // break; + // case 7: ## '7', 'Banking Details' + // $details = SELF::gatheringBankingInfoForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Banking Details'); + + // break; + // case 8: ## '8', 'Existing Loan Obligations' + // $details = SELF::gatheringExistingLoanDetailsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Existing Loan Obligations'); + + // break; + // case 9: ## '9', 'Other Income Details' + // $details = SELF::gatheringOtherIncomeDetailsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Other Income Details'); + + // break; + // case 10: ## '10', 'Loan Details' + // $details = SELF::gatheringLoanDetailsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Loan Details'); + + // break; + // case 11: ## '11', 'Stock Details' + // $details = SELF::gatheringStockDetailsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Stock Details'); + + // break; + // case 12: ## '12', 'Employment Information' + // $details = SELF::gatheringEmploymetForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Employment Information'); + + // break; + // case 13: ## '13', 'Business Information' + // $details = SELF::gatheringBusinessForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Business Information'); + + // break; + // case 14: ## '14', 'Financial Information' + // $details = SELF::gatheringFinancialInfoForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Financial Information'); + + // break; + // case 15: ## '15', 'Lender Representative' + // $details = SELF::gatheringLenderRepresentativeForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Lender Representative'); + + // break; + // case 16: ## '16', 'Assessed Income' + // $details = SELF::gatheringAssessedIncomeForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Assessed Income'); + + // break; + // case 17: ## '17', 'Rental Verification' + // $details = SELF::gatheringRentalIncomeForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Rental Verification'); + + // break; + // case 18: ## '18', 'General Information' + // $details = SELF::gatheringGeneralInfoForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('General Information'); + + // break; + // case 19: ## '19', 'Neighbourhood / Reference Check' + // $details = SELF::gatheringNeighbourForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Neighbourhood and Ref Check'); + + // break; + // case 20: ## '20', 'Final Remarks Form' + // $details = SELF::gatheringFinalRemarksForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Final Remarks Form'); + + // break; + // case 21: ## '21', 'Business Banking' + // $details = SELF::gatheringBusinessBankingFormForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Business Banking'); + + // break; + // case 22: ## '22', 'Business Assets' + // $details = SELF::gatheringBusinessAssetsForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Business Assets'); + + // break; + // case 23: ## '23', 'Future Plan and Business Environment' + // $details = SELF::gatheringFuturePlanandBusinessEnvironmentForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Future Plan'); + + // break; + // case 24: ## '24', 'Credit Manager Queries' + // $details = SELF::gatheringCreditManagerQueriesForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Credit Manager Queries'); + + // break; + // case 25: ## '25', 'Vendor PD Form' + // $details = SELF::gatheringVendorPDForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Vendor PD Form'); + + // break; + // case 26: ## '26', 'Photograph' + // $details = SELF::gatheringPhotographForm($processedJson); + // SELF::$current_spreadsheet->setActiveSheetIndex($formid)->setTitle('Photograph'); + + // break; + // default: ## + // echo "Final - No Form ID";break; + }// Switch ends here + }// for loop ends here + $writer = $CI->myspreadsheet->getXlsx(SELF::$current_spreadsheet); + $filename = "PDExportXL_".date('Y-m-d H:i:s A').".xls"; + $writer->save(XLPATH.'/tmp/'.$filename); + }// fns2 ends here + public static function formHeadlines($formid_arr){ + $i=0; + $arr = sort($formid_arr); + $sheet = SELF::$current_spreadsheet; + foreach($formid_arr as $data) + { + switch($data){ + case 1: ## '1', 'Supplier Details' + $sheet->setActiveSheetIndex($i)->setCellValue('A1','Supplier Details'); + $sheet->getActiveSheet()->setTitle('Supplier Details'); + break; + case 2: ## '2', 'Client Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Client Details'); + break; + case 3: ## '3', 'Personal Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Personal Details !'); + $sheet->getActiveSheet()->setTitle('Personal Details'); + break; + case 4: ## '4', 'Other Assets' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Other Assets'); + + break; + case 5: ## '5', 'Address Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i) + ->setCellValue('A1', 'PDID') + ->setCellValue('B1', 'Address at which PD was initiated') + ->setCellValue('C1', 'City') + ->setCellValue('D1', 'State') + ->setCellValue('E1', 'Pincode') + ->setCellValue('F1', 'Specify other pincode') + ->setCellValue('G1', 'Is this the address where PD is done') + ->setCellValue('H1', 'Enter actual PD address') + ->setCellValue('I1', 'City') + ->setCellValue('J1', 'State') + ->setCellValue('K1', 'Pincode') + ->setCellValue('L1', 'Specify Other Pincode') + ->setCellValue('M1', 'Reason for change in PD visit address') + ->setCellValue('N1', 'Address Type') + ->setCellValue('O1', 'Specify Other Address Type') + ->setCellValue('P1', 'Locality') + ->setCellValue('Q1', 'Specify Other Locality') + ->setCellValue('R1', 'Approach to PD Location') + ->setCellValue('S1', 'Comment on locality') + ->setCellValue('T1', 'Estimated Area') + ->setCellValue('U1', 'Unit Of Measurement') + ->setCellValue('V1', 'Specify Other UOM') + ->setCellValue('W1', 'Remarks'); + $sheet->getActiveSheet()->setTitle('Address Details'); + + break; + case 6: ## '6', 'Family Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Family Details'); + + break; + case 7: ## '7', 'Banking Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Banking Details'); + + break; + case 8: ## '8', 'Existing Loan Obligations' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Existing Loan Obligations'); + + break; + case 9: ## '9', 'Other Income Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Other Income Details'); + + break; + case 10: ## '10', 'Loan Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i) + ->mergeCells('A1:A2')->setCellValue('A1', 'PDID') + ->mergeCells('B1:B2')->setCellValue('B1', 'Loan Amount Applied for ?') + ->mergeCells('C1:C2')->setCellValue('C1', 'Loan Tenure applied for ?') + ->mergeCells('D1:D2')->setCellValue('D1', 'Sub-Product') + ->mergeCells('E1:E2')->setCellValue('E1', 'What is the End Use') + ->mergeCells('F1:F2')->setCellValue('F1', 'Specify End Use') + ->mergeCells('G1:G2')->setCellValue('G1', 'Is there a balance transfer ?') + ->mergeCells('H1:H2')->setCellValue('H1', 'Amount of Own Contribution') + ->mergeCells('I1:I2')->setCellValue('I1', 'Source of Own Contribution') + ->mergeCells('J1:J2')->setCellValue('J1', 'Specify Other Sources') + ->mergeCells('K1:K2')->setCellValue('K1', 'What is the amount for Balance Transfer ?') + ->mergeCells('L1:L2')->setCellValue('L1', 'Lender from where balance transfer done') + ->mergeCells('M1:M2')->setCellValue('M1', 'Specify other Lender') + ->mergeCells('N1:N2')->setCellValue('N1', 'Topup Amount ') + ->mergeCells('O1:O2')->setCellValue('O1', 'What is the End Use of the Top Up ?') + ->mergeCells('P1:P2')->setCellValue('P1', 'Specify End Use Of TopUP') + ->mergeCells('Q1:Q2')->setCellValue('Q1', 'EMI Amount Comfortable Paying') + ->mergeCells('R1:AB1')->setCellValue('R1', 'Details of Property being Mortgaged') + ->setCellValue('R2', 'Type of property') + ->setCellValue('S2', 'Specify type of property') + ->setCellValue('T2', 'Name of the proposed owner') + ->setCellValue('U2', 'Status of Construction') + ->setCellValue('V2', 'Estimate Market Value as Per Customer') + ->setCellValue('W2', 'Name of current owner(s)/ Seller(s) of the property') + ->setCellValue('X2', 'Address of the proposed property') + ->setCellValue('Y2', 'State') + ->setCellValue('Z2', 'City') + ->setCellValue('AA2', 'Pincode') + ->setCellValue('AB2', 'Specify Other pincode') + ->mergeCells('AC1:AC2')->setCellValue('AC1', 'Remarks') + ->mergeCells('AD1:AD2')->setCellValue('AD1', 'Facility Amount Applied For ?') + ->mergeCells('AE1:AE2')->setCellValue('AE1', 'Name of the Anchor') + ->mergeCells('AF1:AI1')->setCellValue('AF1', 'applicant`s association vintage with the Anchor') + ->mergeCells('AJ1:AU1')->setCellValue('AJ1', 'Credit period with the Anchor (Days)') + ->setCellValue('AF2', 'Year') + ->setCellValue('AG2', 'Month') + ->setCellValue('AH2', 'Monthly business (sale/purchase) with the Anchor') + ->setCellValue('AI2', 'Business concentration with Anchor %') + ->setCellValue('AJ2', 'Number of days') + ->setCellValue('AK2', 'Payment Mechanism') + ->setCellValue('AL2', 'Average Invoice Value') + ->setCellValue('AM2', 'Are there peak seasons for the business with Anchor') + ->setCellValue('AN2', 'Months in which sales/service is low?') + ->setCellValue('AO2', 'Comments') + ->setCellValue('AP2', 'Are there debit/credit notes being issued to/by Anchor') + ->setCellValue('AQ2', 'Reason for such debit/credit notes') + ->setCellValue('AR2', 'Value of stock related to Anchor') + ->setCellValue('AS2', 'Observations on Sample Invoices') + ->setCellValue('AT2', 'reason for no sample invoices') + ->setCellValue('AU2', 'Details of invoice and lorry recipts like date, amount, Quantity, Vehicle number, Client and supplier name'); + + + + + + + + $sheet->getActiveSheet()->setTitle('Loan Details'); + + break; + case 11: ## '11', 'Stock Details' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Stock Details'); + + break; + case 12: ## '12', 'Employment Information' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Employment Information'); + + break; + case 13: ## '13', 'Business Information' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Business Information'); + + break; + case 14: ## '14', 'Financial Information' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Financial Information'); + + break; + case 15: ## '15', 'Lender Representative' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Lender Representative'); + + break; + case 16: ## '16', 'Assessed Income' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Assessed Income'); + + break; + case 17: ## '17', 'Rental Verification' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Rental Verification'); + + break; + case 18: ## '18', 'General Information' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i) + ->mergeCells('A1:A2')->setCellValue('A1', 'PDID') + ->mergeCells('B1:G1')->setCellValue('B1', 'Name of Person(s) Met and Individual Loan Applicant(s)') + ->mergeCells('H1:H2')->setCellValue('H1', 'Is the applicant name same as per KYC') + ->mergeCells('I1:I2')->setCellValue('I1', 'Capture the correct name as per the KYC?') + ->mergeCells('J1:O1')->setCellValue('J1', 'Company') + ->mergeCells('P1:R1')->setCellValue('P1', 'Relationship Between Individuals') + ->mergeCells('S1:U1')->setCellValue('S1', 'Relationship of Individuals to Company / Firm') + ->mergeCells('V1:V2')->setCellValue('V1', 'Remarks') + ->setCellValue('B2', 'Name')->setCellValue('C2', 'Person Contacted')->setCellValue('D2', 'Is Loan applicant') + ->setCellValue('E2', 'Age')->setCellValue('F2', 'Qualification')->setCellValue('G2', 'Specify Qualification') + ->setCellValue('J2', 'Company/Firm')->setCellValue('K2', 'Is applicant')->setCellValue('L2', 'Company/Firm Entity Type') + ->setCellValue('M2', 'Month (Number of Years For Which The Company/Firm Has Been Running)') + ->setCellValue('N2', 'Year (Number of Years For Which The Company/Firm Has Been Running)') + ->setCellValue('O2', 'Date of Formation (Number of Years For Which The Company/Firm Has Been Running)') + ->setCellValue('P2', 'Name')->setCellValue('Q2', 'Relation')->setCellValue('R2', 'Relationship To') + ->setCellValue('S2', 'Applicant')->setCellValue('T2', 'Relation')->setCellValue('U2', 'Company') + ->setTitle('General Information'); + // $conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); + // $conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS); + // $conditional1->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN); + // $conditional1->addCondition('0'); + // $conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED); + // $conditional1->getStyle()->getFont()->setBold(true); + + // $conditional2 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); + // $conditional2->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS); + // $conditional2->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL); + // $conditional2->addCondition('0'); + // $conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN); + // $conditional2->getStyle()->getFont()->setBold(true); + + // $conditionalStyles = $sheet->getActiveSheet()->getStyle('B2')->getConditionalStyles(); + // $conditionalStyles[] = $conditional1; + // $conditionalStyles[] = $conditional2; + + // $sheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles); + + + break; + case 19: ## '19', 'Neighbourhood / Reference Check' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Neighbourhood and Ref Check'); + + break; + case 20: ## '20', 'Final Remarks Form' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Final Remarks Form'); + + break; + case 21: ## '21', 'Business Banking' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Business Banking'); + + break; + case 22: ## '22', 'Business Assets' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Business Assets'); + + break; + case 23: ## '23', 'Future Plan and Business Environment' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Future Plan'); + + break; + case 24: ## '24', 'Credit Manager Queries' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Credit Manager Queries'); + + break; + case 25: ## '25', 'Vendor PD Form' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Vendor PD Form'); + + break; + case 26: ## '26', 'Photograph' + $sheet->createSheet(); + $sheet->setActiveSheetIndex($i)->setCellValue('A1', 'Client Details !'); + $sheet->getActiveSheet()->setTitle('Photograph'); + + break; + default: ## + echo "Final - No Form ID";break; + }// Switch ends here + // $spreadsheet->setActiveSheetIndex(0) + // ->setCellValue('A'.$i, ) + // ->setCellValue('B'.$i, ) + // ->setCellValue('C'.$i, ) + // ->setCellValue('D'.$i, ); + $i++; + } + return $sheet; + + } + ## '1', 'Supplier Details' + static function gatheringSupplierForm($processedJson){ + + }// supplier ends here + ## '2', 'Client Details' + static function gatheringClientForm($processedJson){ } //client ends here + ## '3', 'Personal Details' + static function gatheringPersonalForm($processedJson){ }//personal ends here + ## '4', 'Other Assets' + static function gatheringOtherAssetForm($processedJson){ }// other asset ends here + ## '5', 'Address Details' + static function gatheringAddressForm($processedJson){ }//address ends here + ## '6', 'Family Details' + static function gatheringOtherFamilyDetailsForm($processedJson){ }// family ends here + ## '7', 'Banking Details' + static function gatheringBankingInfoForm($processedJson){}// banking ends here + ## '8', 'Existing Loan Obligations' + static function gatheringExistingLoanDetailsForm($processedJson){} //exist loan ends here + ## '9', 'Other Income Details' + static function gatheringOtherIncomeDetailsForm($processedJson){}// other Income ends here + ## '10', 'Loan Details' + static function gatheringLoanDetailsForm($processedJson){}// loan ends here + ## '11', 'Stock Details' + static function gatheringStockDetailsForm($processedJson){}// stock ends here + ## '12', 'Employment Information' + static function gatheringEmploymetForm($processedJson){}// employment INfoo ends here + ## '13', 'Business Information' + static function gatheringBusinessForm($processedJson){ }// buiness ends here + ## '14', 'Financial Information' + static function gatheringFinancialInfoForm($processedJson){ }//financial ends here + ## '15', 'Lender Representative' + static function gatheringLenderRepresentativeForm($processedJson){}//lender rep ends here + ## '16', 'Assessed Income' + static function gatheringAssessedIncomeForm($processedJson){ }// assess info ends here + ## '17', 'Rental Verification' + static function gatheringRentalIncomeForm($processedJson){ } //rental info ends here + ## '18', 'General Information' + static function gatheringGeneralInfoForm($processedJson){ }//general ends here + ## '19', 'Neighbourhood / Reference Check' + static function gatheringNeighbourForm($processedJson){ }// refer ends here + ## '20', 'Final Remarks Form' + static function gatheringFinalRemarksForm($processedJson){ }// final remarks ends here + ## '21', 'Business Banking' + static function gatheringBusinessBankingForm($processedJson){ }// buiness bank ends here + ## '22', 'Business Assets' + static function gatheringBusinessAssetsForm($processedJson){} //buiness asset ends here + ## '23', 'Future Plan and Business Environment' + static function gatheringFuturePlanandBusinessEnvironmentForm($processedJson){}//future plan ends here + ## '24', 'Credit Manager Queries' + static function gatheringCreditManagerQueriesForm($processedJson){}// CM quries ends here + ## '25', 'Vendor PD Form' + static function gatheringVendorPDForm($processedJson){} // pd vendor info ends here + ## '26', 'Photograph' + static function gatheringPhotographForm($processedJson){} //photograph ends here +} +?> \ No newline at end of file diff --git a/api/application/models/Data_Dump_Model.php b/api/application/models/Data_Dump_Model.php index beaaee5a..c7fffaa7 100755 --- a/api/application/models/Data_Dump_Model.php +++ b/api/application/models/Data_Dump_Model.php @@ -120,4 +120,50 @@ class Data_Dump_Model extends SPARQ_Model { $result['pdid'] = $this->db->select('PDTRIGGER.pd_sno,PDTRIGGER.pd_id')->from(PDTRIGGER.' as PDTRIGGER')->WHERE('PDTRIGGER.pd_status !=',"TRUNCATED")->GET()->result_array(); return $result; } + + public function getId($flag,$keyword){ + // echo "flag".$flag; + if($flag == 1){ $value = trim($keyword); $value = strtolower($value); + $select = "entity_id";$table = "m_entity";$where = "short_name";} + if($flag == 2){ $value = rtrim($keyword," ");$value = ltrim($value," "); $value = strtolower($value); + $select = "product_id"; $table = "m_products"; $where = "abbr";} + if($flag == 3){ $value = rtrim($keyword," ");$value = ltrim($value," "); $value = strtolower($value); + $select = "subproduct_id"; $table = "m_subproducts"; $where = "abbr";} + if($flag == 4){ $value = trim($keyword);$value = strtolower($value); + $select = "customer_segment_id"; $table = "m_customer_segment"; $where = "abbr";} + if($flag == 5){ $value = rtrim($keyword," ");$value = ltrim($value," "); $value = strtolower($value); + $select = "state_id"; $table = "m_states"; $where = "name";} + if($flag == 6){ $value = trim($keyword); $value = strtolower($value); + $select = "pincode_id";$where = "pincode";$table = "m_pincode";} + if($flag == 7){ $value = rtrim($keyword," ");$value = ltrim($value," "); $value = strtolower($value); + $select = "city_id";$where = "name";$table = "m_city";} + if($flag == 8){ $value = rtrim($keyword," ");$value = ltrim($value," ");$value = strtolower($value); + $select = "userid";$where = "concat(m_user_profile.first_name, ' ', m_user_profile.last_name)";$table = "m_user_profile";} + if($flag == 9){ $value = trim($keyword);$value = strtolower($value); + $select = "userid";$where = "first_name";$table = "m_user_profile";} + + $this->db->select($select); + $this->db->from($table); + $this->db->where($where." LIKE '%$value%'"); + $this->db->where("isactive",1); + // print_r($this->db->last_query());die(); + $row = $this->db->get()->row(); + if (isset($row)) { + $id = $row->$select; + } else { + $id = ""; + } + return $id; + } + + public function getPDSerialNO($pd_id){ + $this->db->select('pd_sno'); + $this->db->from(PDTRIGGER); + $this->db->where('pd_id',$pd_id); + $row = $this->db->get()->row(); + $sno = (isset($row)) ? $row->pd_sno : ""; + return $sno; + } + // public function GsheetData($GSdata){ + // } } \ No newline at end of file diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 2b7576b0..9e8ae855 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -2362,6 +2362,8 @@ class PD_Model extends SPARQ_Model { $map_id = $row->id; } else { $map_id = ""; + return []; + // msg = 'There is no Template Registered With Us Please check With TemplateV2 Screen'; } } $this->db->SELECT('TEMPLATE_JSON_V2.id as template_id,TEMPLATE_JSON_V2.map_id,TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_order,PDFORMS.pd_form_level_order,PDFORMS.pd_form_name as form_name,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form'); diff --git a/api/application/models/Template_Management_Model.php b/api/application/models/Template_Management_Model.php index 571e5cd6..6062cf92 100644 --- a/api/application/models/Template_Management_Model.php +++ b/api/application/models/Template_Management_Model.php @@ -310,6 +310,7 @@ class Template_Management_Model extends SPARQ_Model { } } $result = $this->db->GET()->result_array(); + // print_r($this->db->last_query());die(); return $result; } @@ -326,7 +327,7 @@ class Template_Management_Model extends SPARQ_Model { // $this->db->ORDER_BY('PDFORMS.pd_form_order'); // $result = $this->db->GET()->result_array(); // return $result; - $sql_query = "SELECT `TEMPLATE_JSON_V2`.`id` as `template_id`, `TEMPLATE_JSON_V2`.`form_id`, `PDFORMS`.`pd_form_name` as `form_name`, + $sql_query = "SELECT `TEMPLATE_JSON_V2`.`map_id`,`TEMPLATE_JSON_V2`.`id` as `template_id`, `TEMPLATE_JSON_V2`.`form_id`, `PDFORMS`.`pd_form_name` as `form_name`, `TEMPLATE_JSON_V2`.`json`, `TEMPLATE_JSON_V2`.`is_form_disabled`, `PDFORMS`.`is_business_form`, `TEMPLATE_JSON_V2`.`is_group_form`, `PDFORMS`.`pd_form_order`, `TEMPLATE_JSON_V2`.`is_form_status` FROM `m_template_json_v2` as `TEMPLATE_JSON_V2` @@ -334,15 +335,37 @@ class Template_Management_Model extends SPARQ_Model { WHERE `TEMPLATE_JSON_V2`.`isactive` = 1 AND `TEMPLATE_JSON_V2`.`map_id` = ".$value." AND `PDFORMS`.`is_business_form` = 0 - AND + AND ( `TEMPLATE_JSON_V2`.`is_form_status` = 'COMPLETED' or `TEMPLATE_JSON_V2`.`is_form_status` = 'APPROVED' or - `TEMPLATE_JSON_V2`.`is_form_status` = 'DRAFT' + `TEMPLATE_JSON_V2`.`is_form_status` = 'DRAFT' ) ORDER BY `PDFORMS`.`pd_form_order`"; return $this->db->query($sql_query)->result_array(); } + + public function checkBuinessFormsAvailablity($records){ + $Availablity = false; + if(!empty($records['customer_segment_id'])){ + $cs_id = $cs_id; + }else{ + $this->db->select('customer_segment_id'); + $this->db->from(TEMPLATE_MAP_V2); + $this->db->where('id',$records['map_id']); + $this->db->where('isactive',1); + $query = $this->db->get(); + if ($query->num_rows() > 0) { + $cs_id = $query->row()->customer_segment_id; + } + } + if($cs_id){ + $arr = $this->getFormTemplate($cs_id); + $key = array_search('13', array_column($arr, 'form_id')); + $Availablity = (!empty($key)) ? true : false; + } + return $Availablity; + } public function saveTemplateMapping($records,$table){ $this->db->insert($table, $records); @@ -390,9 +413,9 @@ class Template_Management_Model extends SPARQ_Model { WHERE `TEMPLATE_JSON_V2`.`map_id` = ".$map_id." AND `PDFORMS`.`is_business_form` = 1 AND `TEMPLATE_JSON_V2`.`isactive` = 1 - AND `TEMPLATE_JSON_V2`.`is_form_status` = 'COMPLETED' + AND (`TEMPLATE_JSON_V2`.`is_form_status` = 'COMPLETED' OR `TEMPLATE_JSON_V2`.`is_form_status` = 'APPROVED' - OR `TEMPLATE_JSON_V2`.`is_form_status` = 'DRAFT'"; + OR `TEMPLATE_JSON_V2`.`is_form_status` = 'DRAFT')"; $result = $this->db->query($sql_query)->result_array(); }else{ $this->db->SELECT('TEMPLATE_JSON_V2.id as template_id,TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_order,PDFORMS.pd_form_level_order,PDFORMS.pd_form_name as form_name,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form,TEMPLATE_JSON_V2.is_form_status'); @@ -407,4 +430,62 @@ class Template_Management_Model extends SPARQ_Model { } + public function getFormTemplate($csID){ + // $sql_query = "'DRAFT'"; + $sql_query = "SELECT m_template_forms.form_id,m_pd_forms.form_template + FROM m_template_forms + JOIN m_template + on m_template_forms.fk_template_id = m_template.template_id and m_template_forms.isactive = 1 + JOIN m_pd_forms + on m_pd_forms.pd_form_id = m_template_forms.form_id and m_pd_forms.isactive = 1 + WHERE fk_customer_segment like '%`".$csID."`%' and m_template.isactive = 1 "; + // and form_template != ''"; + $result = $this->db->query($sql_query)->result_array(); + // print_r($result); + // print_r($sql_query);die(); + return $result; + } + +// public function getFormTemplate($csID){ +// // $sql_query = "'DRAFT'"; +// $sql_query_old = "SELECT m_template_forms.form_id,m_pd_forms.form_template +// FROM m_template_forms +// JOIN m_template +// on m_template_forms.fk_template_id = m_template.template_id and m_template_forms.isactive = 1 +// JOIN m_pd_forms +// on m_pd_forms.pd_form_id = m_template_forms.form_id and m_pd_forms.isactive = 1 +// WHERE fk_customer_segment like '%`".$csID."`%' and m_template.isactive = 1 "; +// // and form_template != ''"; +// // $result = $this->db->query($sql_query)->result_array(); +// // print_r($result); +// // print_r($sql_query);die(); +// // return $result; + +// $get_template_id = "SELECT m_template.template_id +// FROM m_template +// WHERE m_template.isactive = 1 and fk_customer_segment like '%`".$csID."`%' "; +// $row = $this->db->query($get_template_id)->row(); +// // print_r($this->db->last_query());die(); +// // print_r($row);die(); +// if(isset($row->template_id)){ +// $template_id = $row->template_id; +// $sql_query = "SELECT m_pd_forms.pd_form_id as form_id,m_pd_forms.form_template +// FROM m_pd_forms +// LEFT JOIN m_template_forms +// ON m_template_forms.form_id = m_pd_forms.form_id AND m_template_forms.isactive = 1 +// WHERE m_template_forms.fk_template_id = ".$template_id; +// $result = $this->db->query($sql_query)->result_array(); +// // print_r($this->db->last_query());die(); +// return $result; +// }else{ +// return array(); +// } +// } + public function getBuinessFormTemplate($form_id){ + $this->db->select('m_pd_forms.pd_form_id as form_id,m_pd_forms.form_template'); + $this->db->from(PDFORMS.' as m_pd_forms'); + $this->db->where_in('m_pd_forms.pd_form_id',$form_id); // Must be id + $this->db->where('m_pd_forms.is_business_form',1); + return $this->db->get()->result_array();; + } } \ No newline at end of file