From 9e81d25666f9a499fb394c9a226d0e22f223c1c4 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Sat, 11 Jun 2022 06:27:41 +0000 Subject: [PATCH 001/132] Flyhi_Controller.php edited online with Bitbucket --- api/application/controllers/Flyhi_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a79f6ad7..29ff1ad6 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -20,7 +20,7 @@ class Flyhi_Controller extends REST_Controller { $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', 'SALES_PD_DATA.lender_sales_person','concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name','LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno','LENDERSALESPERSON.email as lender_sales_person_email', 'SALES_PD_DATA.lender_credit_person','concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name','LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno','LENDERCREDITPERSON.email as lender_credit_person_email', - 'SALES_PD_DATA.pd_branch_id,ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount', + 'SALES_PD_DATA.pd_branch_id','ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount', '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; From 6ab786d646dfd821d86f4d09098e591ed8407dce Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 14 Jun 2022 09:51:45 +0530 Subject: [PATCH 002/132] FlyHI report Design : ps --- api/application/config/routes.php | 3 +- .../controllers/Flyhi_Controller.php | 294 ++++++++++++++- .../views/sale_pd_templates/FHFSL.php | 345 ++++++++++++++++++ 3 files changed, 640 insertions(+), 2 deletions(-) create mode 100644 api/application/views/sale_pd_templates/FHFSL.php diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 18e306aa..caf8937d 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -377,7 +377,8 @@ $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; $route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD'; $route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; -$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiPD'; $route['getFlyhiPD'] = 'Flyhi_Controller/getFlyhiPD'; +$route['loadFlyhiPDTemplate'] = 'Flyhi_Controller/loadFlyhiPDTemplate'; +$route['(downloadFlyhiPDReport/:any)'] = 'Flyhi_Controller/getFlyhiPDReport'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 29ff1ad6..a27fa0fa 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -11,6 +11,12 @@ class Flyhi_Controller extends REST_Controller { parent::__construct(); $this->load->model('Flyhi_Model','Flyhi_Model'); $this->load->model('Sales_PD_Model','Sales_PD_Model'); + $this->load->library('AWS_S3'); + $this->load->library('pdfgenerator'); + $this->load->helper('satellite_image'); + $this->load->helper('camunda'); + + } public function listFlyhiPD_get(){ @@ -268,7 +274,7 @@ class Flyhi_Controller extends REST_Controller { $section_data = array(); if(isset($Flyhi_pdid) || $Flyhi_pdid != "" || $Flyhi_pdid != null) { - $section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => 1),SALESPD_SECTION_DATA); + $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => 1),SALESPD_SECTION_DATA); } if($section_data) { @@ -285,4 +291,290 @@ class Flyhi_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } } + + public function loadFlyhiPDTemplate_post() + { + $records = $this->post('records'); + $lender_id = $records['lender_id']; + $sales_pd_type = $records['sales_pd_type']; + $product = $records['product_id']; + $pd_type = 2; + if(isset($records['pd_type'])){ $pd_type = $records['pd_type'];} + $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); + if(is_array($template) && count($template)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template[0]; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Tempate Found!'; + $this->response($data,REST_Controller::HTTP_OK); + + } + } + + public function getFlyhiPDReport_get() + { + $pd_id = $this->uri->segment(2); + $this->prepareFlyhiPDReport($pd_id); + } + + function prepareFlyhiPDReport($pd_id,$api = true) + { + log_message('ERROR','####PREPARE Flyhi PD REPORT CALLED'.$pd_id); + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','USERPROFILE.smc_emp_code'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + array('table' => USERPROFILE. ' as USERPROFILE', + 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', + 'jointype' => 'LEFT') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pd_id); + $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + $pd_type = ""; + if($sales_pd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($sales_pd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} + + if($sales_pd_data) + { + ini_set('max_execution_time', 0); + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id']; + // 1st Type Key name. (name,abbr and date). + $pdf_name = strtolower(trim($sales_pd_data[0]['applicant_name'])); + $pdf_name .= '-'.$pd_type; + $pdf_name .= '-'.(date('dmY',strtotime($sales_pd_data[0]['completed_date']))); + $key = 'sales_pd/'.$pd_id.'/'.$pdf_name.'.pdf'; + //$this->Sales_PD_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); + + if(!file_exists($this->external_path.'/sales_pd/'.$pd_id)) + { + mkdir($this->external_path.'/sales_pd/'.$pd_id,0777); + } + + if(!$sales_pd_data[0]['is_pdf'] || $sales_pd_data[0]['is_edited']) + { + + $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); + // print_r(json_decode($all_section_data[0]['section_data'],true));die(); + $view_data['master'] = $sales_pd_data; + $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], + 'caseno'=>$sales_pd_data[0]['sales_pd_sno']); + foreach ($all_section_data as $sec_key => $section) + { + // print_r($section['section_id']);die(); + // log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$pd_id); + $view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);//die(); + $section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); + } + $view_data['geo_location'] = $sales_pd_data[0]['geo_location']; + // die(); + //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; + $view_name = $sales_pd_data[0]['short_name']; + $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); + // echo $html_content;die(); + $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file = $this->external_path ."/sales_pd/" . $pd_id . "/temp.pdf"; + $bytes = file_put_contents($output_file, $pdf_doc); + //echo $bytes; + //die(); + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$this->external_path.'/sales_pd/'.$pd_id.'/temp.pdf'); + log_message('ERROR','####FLYHIPD REPORT UPLOAD TO S3'.$pd_id); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + + $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); + if($api) + { + $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); + $headers = @get_headers($_uri); + if($headers && strpos( $headers[0], '200')) { + // $singed_uri = $_uri; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $_uri; + }else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Report URI Not Found'; + } + + $this->response($data,REST_Controller::HTTP_OK); + } + } + } + else + { + if($api) + { + ## NEW KEY BECAUSE TITLE-RENAME + $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); + $headers = @get_headers($_uri); + if($headers && strpos( $headers[0], '200')) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $_uri; + }else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Report URI Not Found'; + } + + $this->response($data,REST_Controller::HTTP_OK); + } + } + } + } + + function processSalesPDJSON($section_array) + { + // + //print_r($section_array);die(); + //echo '###'.$section_array['section_id'].'####'; + if($section_array['section_id'] == 6) + { + // print_r(json_decode($section_array['section_data'],true)); + // die(); + } + if($section_array['section_id']) + { + //print_r($section_array);//die(); + $questions = json_decode($section_array['section_data'],true); + return $this->processSalesPDQuestions($questions['questions'],$section_array['section_id']); + + } + // die(); + // $general_section_dta = array(); + // foreach ($section_array as $sec_key => $section) + // { + + //} + } + + function processSalesPDQuestions($questions,$section_id) + { + //print_r($questions);die(); + $temp_array = array(); + foreach ($questions as $ques_key => $question) + { + //if($question['section_id']){} + if($question['is_repeatable'] == null && ($question['type'] == 1 || $question['type'] == 2 || $question['type'] == 3 || $question['type'] == 4 || $question['type'] == 6 || $question['type'] == 7 || $question['type'] == 8))//text,radio,SDD,MDD,camera,txt area, searchable dd + { + + $temp_array[ $question['question_key'] ] = isset($question['answer_value']) ? $question['answer_value'] : null; + if($question['question_key'] == 'state' || $question['question_key'] == 'city' || $question['question_key'] == 'pincode' || $question['question_key'] == 'loan_purpose' || $question['question_key'] == 'constitution' || $question['question_key'] == 'about_locality' || $question['question_key'] == 'equipment_list' || $question['question_key'] == 'vendor_list' || $question['question_key'] == 'person_met_designation') + { + //if($question['type'] == 4) { print_r($question['answer_value']); } + $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); + // if($question['type'] == 4) { print_r($temp_array[ $question['question_key'] ]); } + } + if(isset($question['subfield_key'])) + { + + $temp_array[ $question['question_key'] ] .= $question['subfield_value'].','; + + } +// echo 'FIRST';print_r($temp_array[ $question['question_key'] ]); + if(substr_count($temp_array[ $question['question_key'] ], ',')) + { + $temp_array[ $question['question_key'] ] = substr_replace($temp_array[ $question['question_key'] ],'', strrpos($temp_array[ $question['question_key'] ],','),1); + } + //echo 'SECOND'; print_r($temp_array[ $question['question_key'] ]); + if(substr_count($temp_array[ $question['question_key'] ], ',')) + { + + $temp_array[ $question['question_key'] ] = substr_replace($temp_array[ $question['question_key'] ],' and ', strrpos($temp_array[ $question['question_key'] ],','),1); + + } + } + else if($question['is_repeatable'] == 1 ) + { + //print_r($question['questions_group']);die(); + if($section_id != 9) + { + foreach ($question['questions_group'] as $group_key => $group_value) + { + //print_r($group_value['questions']);//die(); + $group_temp = array(); + foreach ($group_value['questions'] as $q_key => $q_value) + { + //print_r($q_value);die(); + //echo $group_key; + $group_temp[ $q_value['question_key'] ] = $q_value['answer_value']; + + if(isset($q_value['subfield_key'])){ $group_temp[ $q_value['question_key'] ] = $q_value['subfield_value']; } + //print_r($group_temp); + } + //print_r($group_temp); + $temp_array[ $group_key ] = $group_temp; + + } + } + else + { +//echo "SDKJHKSJ**"; + $group_temp = array(); + foreach ($question['questions_group'] as $group_key => $group_value) + { + + $temp_array[ $group_value['questions'][0]['question_key'] ][] = isset($group_value['questions'][0]['subfield_key']) ? $group_value['questions'][0]['subfield_value'] : $group_value['questions'][0]['answer_value']; + + } + } + } + } + // //print_r($temp_array);die(); + // if($section_id == 2) + // { + // //print_r(json_decode($section_array['section_data'],true)); die(); + // die(); + // } + return $temp_array; + } + + function getMasterData($id,$array) + { + + // print_r($id);echo '***'; + if(!is_array($id)) + { + foreach($array as $value) + { + if($id == $value['answer_id']) + { + return ($value['answer']); + break; + } + } + } + else + { + $final_string = ''; + + foreach($id as $value) + { + //echo $value.'****'.strcasecmp($value,'Others').'#'; + foreach($array as $mas_value) + { + if( !strcasecmp($value,$mas_value['answer_id']) && (!substr_count($mas_value['answer'],'Others')) ) + { + $final_string .= $mas_value['answer'] . ','; + } + } + } + // print_r($final_string);//die(); + return $final_string; + } + + } }// Class Ends diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php new file mode 100644 index 00000000..f390c9ff --- /dev/null +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -0,0 +1,345 @@ +↑'; + $downarrow = ''; + $dash = ' '; + // $product_name = $master[0]['abbr']; + $product_name = ""; + $rupee_symbol = ""; + $title = ""; + if($master[0]['sales_pd_type'] == 3){$title = "Office FI PD "; }else if($master[0]['sales_pd_type'] == 4){$title = "Residence FI PD ";} + $smc_emp_code = $master[0]['smc_emp_code']; +?> + + + + + + + + + + + + +
+
+ Powered By PD Genie (FLYHI Team) +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Personal Discussion by FlyHI Team -
Lender Name
Branch
Application ID
Lender sales Person
Lender credit Person
Product Name
Loan Amount Applied for (Rs)
Verification Type
CityStatePIN
Residence Ownership
Years at current Residence
Same as current residence address
Permanent Address
CityStatePIN
Number of earning family member
Number of Dependents
Occupation of the loan applicant
Employer/Business Name
Employer/Business Address
Address
CityStatePIN
Constitution of Employer /Business applicant
Years at Current employment/Business
Total Work Experience
Net Monthly Salary/ Net Income
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Additional Questions
Name of Student
Relationship with Applicant
Educational Institute Name
Educational Institute Address
CityStatePIN
Class /Section/ Course Name
Educational Institute Fee
Duration of the course
Loan Amount Applied for (Rs)Total Fund Requirement (Rs)
Loan Tenure (Months)Loan Purpose (End-Use)
+ + + + + \ No newline at end of file From d092634876c03a0650efb441ddd3095a1794443c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 14 Jun 2022 15:23:04 +0530 Subject: [PATCH 003/132] FLYHI Report key changed : ps --- .../controllers/Flyhi_Controller.php | 41 +++++++--- .../views/sale_pd_templates/FHFSL.php | 80 +++++++++++-------- 2 files changed, 77 insertions(+), 44 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a27fa0fa..32b4005a 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -34,6 +34,9 @@ class Flyhi_Controller extends REST_Controller { array('table' => ENTITY. ' as ENTITY', 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', 'jointype' => 'INNER'), + // array('table' => PRODUCTS. ' as PRODUCT', + // 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + // 'jointype' => 'INNER'), array('table' => CITY. ' as CITY', 'condition' =>'SALES_PD_DATA.city_id = CITY.city_id', 'jointype' => 'LEFT'), @@ -101,6 +104,7 @@ class Flyhi_Controller extends REST_Controller { $pd_branch_id = null; $lender_sales_person = null; $lender_credit_person = null; + // $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); log_message('ERROR','####FLYHI-PD SAVE CALLED'); @@ -133,11 +137,11 @@ class Flyhi_Controller extends REST_Controller { { $applicant_name = $g_value['answer_value']; } - if($g_value['question_key'] == 'city') + if($g_value['question_key'] == 'residence_address_city') { $city = $g_value['answer_value']; } - if($g_value['question_key'] == 'lender_id') + if($g_value['question_key'] == 'lender_name') { $lender_id = $g_value['answer_value']; } @@ -145,7 +149,7 @@ class Flyhi_Controller extends REST_Controller { { $loan_amount = $g_value['answer_value']; } - if($g_value['question_key'] == 'pd_branch_id') + if($g_value['question_key'] == 'branch') { $pd_branch_id = $g_value['answer_value']; } @@ -192,6 +196,9 @@ class Flyhi_Controller extends REST_Controller { $records['completed_date'] = date('Y-m-d H:i:s'); $flyhi_pd_id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + $this->prepareFlyhiPDReport($records['sales_pd_id'],false); + sleep(10); + log_message('ERROR','####FLYHI-PD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); } else { @@ -211,11 +218,11 @@ class Flyhi_Controller extends REST_Controller { { $applicant_name = $g_value['answer_value']; } - if($g_value['question_key'] == 'city') + if($g_value['question_key'] == 'residence_address_city') { $city = $g_value['answer_value']; } - if($g_value['question_key'] == 'lender_id') + if($g_value['question_key'] == 'lender_name') { $lender_id = $g_value['answer_value']; } @@ -223,7 +230,7 @@ class Flyhi_Controller extends REST_Controller { { $loan_amount = $g_value['answer_value']; } - if($g_value['question_key'] == 'pd_branch_id') + if($g_value['question_key'] == 'branch') { $pd_branch_id = $g_value['answer_value']; } @@ -296,11 +303,13 @@ class Flyhi_Controller extends REST_Controller { { $records = $this->post('records'); $lender_id = $records['lender_id']; - $sales_pd_type = $records['sales_pd_type']; + // $product = $records['product_id']; + $sales_pd_type = $records['sales_pd_type'] ? $records['sales_pd_type'] : null; $product = $records['product_id']; $pd_type = 2; if(isset($records['pd_type'])){ $pd_type = $records['pd_type'];} $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); + // $template = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); if(is_array($template) && count($template)) { $data['dataStatus'] = true; @@ -327,18 +336,23 @@ class Flyhi_Controller extends REST_Controller { function prepareFlyhiPDReport($pd_id,$api = true) { log_message('ERROR','####PREPARE Flyhi PD REPORT CALLED'.$pd_id); - $columns = array('SALES_PD_DATA.*','ENTITY.short_name','USERPROFILE.smc_emp_code'); + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr','USERPROFILE.smc_emp_code'); + // $columns = array('SALES_PD_DATA.*','ENTITY.short_name','USERPROFILE.smc_emp_code'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; $joins = array( array('table' => ENTITY. ' as ENTITY', 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', 'jointype' => 'INNER'), + // array('table' => PRODUCTS. ' as PRODUCT', + // 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + // 'jointype' => 'INNER'), array('table' => USERPROFILE. ' as USERPROFILE', 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', 'jointype' => 'LEFT') ); $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pd_id); + // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); $pd_type = ""; if($sales_pd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($sales_pd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} @@ -349,7 +363,8 @@ class Flyhi_Controller extends REST_Controller { $bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id']; // 1st Type Key name. (name,abbr and date). $pdf_name = strtolower(trim($sales_pd_data[0]['applicant_name'])); - $pdf_name .= '-'.$pd_type; + // $pdf_name .= '-'.$pd_type; + $pdf_name .= '-'.$pd_type.$sales_pd_data[0]['abbr']; $pdf_name .= '-'.(date('dmY',strtotime($sales_pd_data[0]['completed_date']))); $key = 'sales_pd/'.$pd_id.'/'.$pdf_name.'.pdf'; //$this->Sales_PD_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); @@ -366,6 +381,7 @@ class Flyhi_Controller extends REST_Controller { // print_r(json_decode($all_section_data[0]['section_data'],true));die(); $view_data['master'] = $sales_pd_data; $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], + // 'product'=>$sales_pd_data[0]['abbr'], 'caseno'=>$sales_pd_data[0]['sales_pd_sno']); foreach ($all_section_data as $sec_key => $section) { @@ -472,7 +488,12 @@ class Flyhi_Controller extends REST_Controller { { $temp_array[ $question['question_key'] ] = isset($question['answer_value']) ? $question['answer_value'] : null; - if($question['question_key'] == 'state' || $question['question_key'] == 'city' || $question['question_key'] == 'pincode' || $question['question_key'] == 'loan_purpose' || $question['question_key'] == 'constitution' || $question['question_key'] == 'about_locality' || $question['question_key'] == 'equipment_list' || $question['question_key'] == 'vendor_list' || $question['question_key'] == 'person_met_designation') + if($question['question_key'] == 'residence_state' || $question['question_key'] == 'residence_address_city' || $question['question_key'] == 'residence_pincode' || + $question['question_key'] == 'business_state'|| $question['question_key'] == 'business_city'|| $question['question_key'] == 'business_city' || + $question['question_key'] == 'permanent_state' || $question['question_key'] == 'permanent_address_city' || $question['question_key'] == 'permanent_pincode' || + $question['question_key'] == 'employer_business_state' || $question['question_key'] == 'employer_business_address_city' || $question['question_key'] == 'employer_business_pincode' || + $question['question_key'] == 'educational_institute_state' || $question['question_key'] == 'educational_institute_address_city' || $question['question_key'] == 'educational_institute_pincode' + ) { //if($question['type'] == 4) { print_r($question['answer_value']); } $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index f390c9ff..1d4b24e4 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -8,8 +8,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $product_name = ""; $rupee_symbol = ""; $title = ""; - if($master[0]['sales_pd_type'] == 3){$title = "Office FI PD "; }else if($master[0]['sales_pd_type'] == 4){$title = "Residence FI PD ";} + if($section1['verification_type'] == "Office verification"){$title = "Office FI PD "; }else if($section1['verification_type'] == "Residence verification"){$title = "Residence FI PD ";} $smc_emp_code = $master[0]['smc_emp_code']; + $residence_ownership_arr = array("self_owned" => "Self-Owned","parental"=>"Parental","family_owned"=>"Family Owned","rented"=>"Rented"); + $residence_yr_arr = array("0"=>"< 1 yr","1"=>"1-2 yrs","2"=>"2 to 5 yrs","3"=>"> 5 yrs"); + $occupation_arr = array("0"=>"Salaried","1"=>"SENP","2"=>"SEP"); + $constitution_arr = array("0"=>"Ltd","1"=>"Pvt","2"=>"Ltd","3"=>"Trust/Society","4"=>"Partnership/LLP","5"=>"Proprietorship"); + ?> @@ -186,43 +191,42 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - - - + + + + City - + State - + PIN - + - - Residence Ownership - + Years at current Residence - + Same as current residence address - + Permanent Address City - + State - + PIN - + @@ -234,10 +238,18 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + + + City + + State + + PIN + + Occupation of the loan applicant - + Employer/Business Name @@ -245,25 +257,25 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Employer/Business Address - + - - + + City - + State - + PIN - + - + Constitution of Employer /Business applicant - + Years at Current employment/Business @@ -303,14 +315,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Educational Institute Address - + Class /Section/ Course Name @@ -332,8 +344,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Loan Tenure (Months) - Loan Purpose (End-Use) - + From cbf401e4833f795caa845db8467e2d1889c2d88c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 14 Jun 2022 22:17:13 +0530 Subject: [PATCH 004/132] FlyHI : ps --- .../controllers/Flyhi_Controller.php | 222 +++++++++++------- .../views/sale_pd_templates/FHFSL.php | 152 ++++++------ 2 files changed, 208 insertions(+), 166 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 32b4005a..a67ba436 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -15,6 +15,7 @@ class Flyhi_Controller extends REST_Controller { $this->load->library('pdfgenerator'); $this->load->helper('satellite_image'); $this->load->helper('camunda'); + $this->external_path = $this->config->item('external_data_path'); } @@ -63,7 +64,7 @@ class Flyhi_Controller extends REST_Controller { $where_condition_array[$key_date] = $condition_value; // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- - $FHFSL_lender = (ENVIRONMENT == 'production' ? 0 : 49); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); if($user_id && is_numeric($user_id)) { $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; } @@ -95,7 +96,7 @@ class Flyhi_Controller extends REST_Controller { $is_entry_done = null; $flyhi_pd_id = null; $section_data = json_encode($records); - $fk_createdby = $records['fk_createdby']; + $fk_createdby = isset($records['fk_createdby']) ? $records['fk_createdby'] : ""; $applicant_id = null; $applicant_name = null; $city = null; @@ -103,7 +104,8 @@ class Flyhi_Controller extends REST_Controller { $loan_amount = null; $pd_branch_id = null; $lender_sales_person = null; - $lender_credit_person = null; + $lender_credit_person = null; + $product_id = null; // $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); log_message('ERROR','####FLYHI-PD SAVE CALLED'); @@ -129,44 +131,68 @@ class Flyhi_Controller extends REST_Controller { { foreach ($records['questions'] as $g_key => $g_value) { - if($g_value['question_key'] == 'application_id') + if(isset($g_value['question_key']) && $g_value['question_key'] === 'loan_application_id') { $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; - } - if($g_value['question_key'] == 'company_name') - { - $applicant_name = $g_value['answer_value']; - } - if($g_value['question_key'] == 'residence_address_city') - { - $city = $g_value['answer_value']; - } - if($g_value['question_key'] == 'lender_name') + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_name') { $lender_id = $g_value['answer_value']; } - if($g_value['question_key'] == 'loan_amount') + if(isset($g_value['question_key']) && $g_value['question_key'] == 'loan_amount') { $loan_amount = $g_value['answer_value']; } - if($g_value['question_key'] == 'branch') + if(isset($g_value['question_key']) && $g_value['question_key'] == 'branch') { $pd_branch_id = $g_value['answer_value']; } - if($g_value['question_key'] == 'lender_sales_person') + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_sales_person') { $lender_sales_person = $g_value['answer_value']; } - if($g_value['question_key'] == 'lender_credit_person') + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_credit_person') { $lender_credit_person = $g_value['answer_value']; } - + if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') + { + $product_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') + { + if(isset($g_value['onchange_properties'])) + { + foreach ($g_value['onchange_properties'] as $h_key => $h_value) + { + foreach ($h_value['form_controls'] as $i_key => $i_value) + { + foreach ($i_value['questions'] as $j_key => $j_value) + { + if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ + $city = $j_value['answer_value']; + $sales_pd_type = 4; + } + if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ + $city = $j_value['answer_value']; + $sales_pd_type = 3; + } + if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') + { + $applicant_name = $j_value['answer_value']; + } + } + } + } + } + } + } + } $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender_id,'isactive' => 1),SALES_PD_DATA); $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender_id),ENTITY); - $flyhipd_serial_no = $lender_short_name.'-'.(++$count[0]['count']); + $flyhipd_serial_no = $lender_short_name[0]['short_name'].'-'.(++$count[0]['count']); $FLYHI_PD['applicant_name'] = $applicant_name; $FLYHI_PD['applicant_id'] = $applicant_id; $FLYHI_PD['city_id']=$city; @@ -178,6 +204,8 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['lender_id'] = $lender_id; $FLYHI_PD['createdby'] = $fk_createdby; $FLYHI_PD['rand_string'] = $randomString; + $FLYHI_PD['sales_pd_type'] = $sales_pd_type; + $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); $section_data = json_encode($records); $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); @@ -210,48 +238,80 @@ class Flyhi_Controller extends REST_Controller { if($records['questions']){ foreach ($records['questions'] as $g_key => $g_value) { - if($g_value['question_key'] == 'application_id') - { - $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; - } - if($g_value['question_key'] == 'company_name') - { - $applicant_name = $g_value['answer_value']; + if(isset($g_value['question_key']) && $g_value['question_key'] === 'loan_application_id') + { + $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + } + + + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_name') + { + $lender_id = $g_value['answer_value']; + } + + + if(isset($g_value['question_key']) && $g_value['question_key'] == 'loan_amount') + { + $loan_amount = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'branch') + { + $pd_branch_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_sales_person') + { + $lender_sales_person = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_credit_person') + { + $lender_credit_person = $g_value['answer_value']; + } + + if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') + { + $product_id = $g_value['answer_value']; + } + + if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') + { + if(isset($g_value['onchange_properties'])) + { + foreach ($g_value['onchange_properties'] as $h_key => $h_value) + { + foreach ($h_value['form_controls'] as $i_key => $i_value) + { + foreach ($i_value['questions'] as $j_key => $j_value) + { + if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ + $city = $j_value['answer_value']; + $sales_pd_type = 4; + } + if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ + $city = $j_value['answer_value']; + $sales_pd_type = 3; + } + if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') + { + $applicant_name = $j_value['answer_value']; + } + } + } + } + } + } + } - if($g_value['question_key'] == 'residence_address_city') - { - $city = $g_value['answer_value']; - } - if($g_value['question_key'] == 'lender_name') - { - $lender_id = $g_value['answer_value']; - } - if($g_value['question_key'] == 'loan_amount') - { - $loan_amount = $g_value['answer_value']; - } - if($g_value['question_key'] == 'branch') - { - $pd_branch_id = $g_value['answer_value']; - } - if($g_value['question_key'] == 'lender_sales_person') - { - $lender_sales_person = $g_value['answer_value']; - } - if($g_value['question_key'] == 'lender_credit_person') - { - $lender_credit_person = $g_value['answer_value']; - } + } - } - $FLYHI_PD['applicant_name'] = $applicant_name; - $FLYHI_PD['applicant_id'] = $applicant_id; - $FLYHI_PD['city_id']=$city; - $FLYHI_PD['loan_amount'] = $loan_amount; - $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; - $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; - $FLYHI_PD['pd_branch_id'] = $pd_branch_id; - $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['applicant_name'] = int($applicant_name); + $FLYHI_PD['applicant_id'] = int($applicant_id); + $FLYHI_PD['city_id']=int($city); + $FLYHI_PD['loan_amount'] = int($loan_amount); + $FLYHI_PD['lender_sales_person'] = int($lender_sales_person) ; + $FLYHI_PD['lender_credit_person'] = int($lender_credit_person) ; + $FLYHI_PD['pd_branch_id'] = int($pd_branch_id); + $FLYHI_PD['lender_id'] = int($lender_id); + $FLYHI_PD['product_id'] = int($product_id); $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); $status = $records['is_complete']; $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); @@ -273,7 +333,7 @@ class Flyhi_Controller extends REST_Controller { $data['msg'] = 'Something went wrong! Try Later'; $this->response($data,REST_Controller::HTTP_OK); } - } + } public function getFlyhiPD_get() { @@ -336,16 +396,16 @@ class Flyhi_Controller extends REST_Controller { function prepareFlyhiPDReport($pd_id,$api = true) { log_message('ERROR','####PREPARE Flyhi PD REPORT CALLED'.$pd_id); - $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr','USERPROFILE.smc_emp_code'); + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.name','PRODUCT.abbr','USERPROFILE.smc_emp_code'); // $columns = array('SALES_PD_DATA.*','ENTITY.short_name','USERPROFILE.smc_emp_code'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; $joins = array( array('table' => ENTITY. ' as ENTITY', 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', 'jointype' => 'INNER'), - // array('table' => PRODUCTS. ' as PRODUCT', - // 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', - // 'jointype' => 'INNER'), + array('table' => PRODUCTS. ' as PRODUCT', + 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + 'jointype' => 'INNER'), array('table' => USERPROFILE. ' as USERPROFILE', 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', 'jointype' => 'LEFT') @@ -378,6 +438,7 @@ class Flyhi_Controller extends REST_Controller { { $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); + // print_r(json_decode($all_section_data[0]['section_data'],true));die(); $view_data['master'] = $sales_pd_data; $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], @@ -395,10 +456,9 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; $view_name = $sales_pd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - // echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF - $output_file = $this->external_path ."/sales_pd/" . $pd_id . "/temp.pdf"; + $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; $bytes = file_put_contents($output_file, $pdf_doc); //echo $bytes; //die(); @@ -454,27 +514,12 @@ class Flyhi_Controller extends REST_Controller { function processSalesPDJSON($section_array) { - // - //print_r($section_array);die(); - //echo '###'.$section_array['section_id'].'####'; - if($section_array['section_id'] == 6) - { - // print_r(json_decode($section_array['section_data'],true)); - // die(); - } if($section_array['section_id']) { - //print_r($section_array);//die(); $questions = json_decode($section_array['section_data'],true); return $this->processSalesPDQuestions($questions['questions'],$section_array['section_id']); } - // die(); - // $general_section_dta = array(); - // foreach ($section_array as $sec_key => $section) - // { - - //} } function processSalesPDQuestions($questions,$section_id) @@ -488,12 +533,13 @@ class Flyhi_Controller extends REST_Controller { { $temp_array[ $question['question_key'] ] = isset($question['answer_value']) ? $question['answer_value'] : null; - if($question['question_key'] == 'residence_state' || $question['question_key'] == 'residence_address_city' || $question['question_key'] == 'residence_pincode' || - $question['question_key'] == 'business_state'|| $question['question_key'] == 'business_city'|| $question['question_key'] == 'business_city' || - $question['question_key'] == 'permanent_state' || $question['question_key'] == 'permanent_address_city' || $question['question_key'] == 'permanent_pincode' || - $question['question_key'] == 'employer_business_state' || $question['question_key'] == 'employer_business_address_city' || $question['question_key'] == 'employer_business_pincode' || - $question['question_key'] == 'educational_institute_state' || $question['question_key'] == 'educational_institute_address_city' || $question['question_key'] == 'educational_institute_pincode' - ) + if($question['question_key'] == 'residence_state' || $question['question_key'] == 'residence_city' || $question['question_key'] == 'residence_pincode' || + $question['question_key'] == 'business_state'|| $question['question_key'] == 'business_city'|| $question['question_key'] == 'business_pincode' || + $question['question_key'] == 'permanent_state' || $question['question_key'] == 'permanent_city' || $question['question_key'] == 'permanent_pincode' || + $question['question_key'] == 'officer_state' || $question['question_key'] == 'officer_city' || $question['question_key'] == 'officer_pincode') + // $question['question_key'] == 'employer_business_state' || $question['question_key'] == 'employer_business_address_city' || $question['question_key'] == 'employer_business_pincode' || + // $question['question_key'] == 'educational_institute_state' || $question['question_key'] == 'educational_institute_address_city' || $question['question_key'] == 'educational_institute_pincode' + // ) { //if($question['type'] == 4) { print_r($question['answer_value']); } $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 1d4b24e4..4f212a45 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -1,14 +1,13 @@ ↑'; $downarrow = ''; $dash = ' '; - // $product_name = $master[0]['abbr']; - $product_name = ""; + $product_name = $master[0]['abbr']; $rupee_symbol = ""; $title = ""; - if($section1['verification_type'] == "Office verification"){$title = "Office FI PD "; }else if($section1['verification_type'] == "Residence verification"){$title = "Residence FI PD ";} + if($section1['verification_type'] == "Office verification"){$title = "Office FI "; }else if($section1['verification_type'] == "Residence verification"){$title = "Residence FI ";} $smc_emp_code = $master[0]['smc_emp_code']; $residence_ownership_arr = array("self_owned" => "Self-Owned","parental"=>"Parental","family_owned"=>"Family Owned","rented"=>"Rented"); $residence_yr_arr = array("0"=>"< 1 yr","1"=>"1-2 yrs","2"=>"2 to 5 yrs","3"=>"> 5 yrs"); @@ -146,9 +145,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Powered By PD Genie (FLYHI Team)
- +
+ +

@@ -180,84 +179,85 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Product Name - + Loan Amount Applied for (Rs) - + Verification Type - + + - - - + + + - City - - State - - PIN - + City + + State + + PIN + Residence Ownership - + Years at current Residence - + Same as current residence address - + - + Permanent Address - + - City - - State - - PIN - + City + + State + + PIN + Number of earning family member - + Number of Dependents - + - + - City - - State - - PIN - + City + + State + + PIN + Occupation of the loan applicant - + Employer/Business Name - + Employer/Business Address - + - City - - State - - PIN - + City + + State + + PIN + Constitution of Employer /Business applicant - + Years at Current employment/Business - + Total Work Experience - + Net Monthly Salary/ Net Income - + @@ -301,57 +301,53 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Name of Student - + Relationship with Applicant - + Educational Institute Name - + - Educational Institute Address - + Educational Institute Address + - + + City + + State + + PIN + + Class /Section/ Course Name - + Educational Institute Fee - + Duration of the course - + Loan Amount Applied for (Rs) - + Total Fund Requirement (Rs) - + Loan Tenure (Months) - - + + Loan Purpose (End-Use) + - - - - + \ No newline at end of file From 7450c29b798a7c9a5e9408d9866a9dda348d0cd2 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 15 Jun 2022 04:41:50 +0000 Subject: [PATCH 005/132] Flyhi_Controller.php edited online with Bitbucket --- .../controllers/Flyhi_Controller.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a67ba436..1cc9c64e 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -303,15 +303,15 @@ class Flyhi_Controller extends REST_Controller { } } - $FLYHI_PD['applicant_name'] = int($applicant_name); - $FLYHI_PD['applicant_id'] = int($applicant_id); - $FLYHI_PD['city_id']=int($city); - $FLYHI_PD['loan_amount'] = int($loan_amount); - $FLYHI_PD['lender_sales_person'] = int($lender_sales_person) ; - $FLYHI_PD['lender_credit_person'] = int($lender_credit_person) ; - $FLYHI_PD['pd_branch_id'] = int($pd_branch_id); - $FLYHI_PD['lender_id'] = int($lender_id); - $FLYHI_PD['product_id'] = int($product_id); + $FLYHI_PD['applicant_name'] = $applicant_name; + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); $status = $records['is_complete']; $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); From 269c0441e3762500a954cb67f42606e299dee74a Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 15 Jun 2022 13:15:27 +0530 Subject: [PATCH 006/132] FLYHI master : ps --- api/application/config/routes.php | 1 + .../controllers/Flyhi_Controller.php | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index caf8937d..10a2ce05 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -380,5 +380,6 @@ $route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; $route['getFlyhiPD'] = 'Flyhi_Controller/getFlyhiPD'; $route['loadFlyhiPDTemplate'] = 'Flyhi_Controller/loadFlyhiPDTemplate'; $route['(downloadFlyhiPDReport/:any)'] = 'Flyhi_Controller/getFlyhiPDReport'; +$route['getMasterForFlyhiPD'] = 'Flyhi_Controller/getMasterForFlyhiPD'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a67ba436..7ac733bb 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -19,6 +19,52 @@ class Flyhi_Controller extends REST_Controller { } + public function getMasterForFlyhiPD_get(){ + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $default_product = $FHFSL_product; + $default_lender = $FHFSL_lender; + + $lender_fields = array('entity_id','full_name','short_name'); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); + if(count($result_data)) + { + + foreach($result_data as $key => $value) + { + $fields = array('*'); + $where_condition_array = array('isactive' => 1,'fk_entity_id' => $value['entity_id']); + $result_data[$key]['billing_address'] = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,ENTITYBILLING); + + $branch_fields = array('entity_lender_branch_id', 'branch_name'); + $branch_where_condition_array = array('fk_entity_id' => $value['entity_id'],'isactive'=>1); + $result_data[$key]['branches'] = $this->Flyhi_Model->selectCustomRecords($branch_fields,$branch_where_condition_array,ENTITYLENDERBRANCH); + + } + } + + $product = $this->Flyhi_Model->selectCustomRecords(array('product_id','name as product_name','abbr as product_abbr','prod_catagory'),array('product_id' => $FHFSL_product),PRODUCTS); + $product = count($product)>0 ? $product : 'product was not found?. Create Product in Lender profile'; + + $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); + $table = USERPROFILE.' as USERPROFILE'; + $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', + 'condition' =>'USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1', + 'jointype' => 'INNER'), + array('table' => ROLES.' as ROLES', + 'condition' =>'ROLES.role_id = USERPROFILEROLES.user_role', + 'jointype' => 'INNER')); + $order_by = 'USERPROFILE.userid'; + $or_where = array(); + $lender_contact_persons = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,array('USERPROFILE.fk_entity_id' => $FHFSL_lender),$order_by,'DESC','',$or_where); + $lender_contact_persons = count($lender_contact_persons)>0 ? $lender_contact_persons : 'Credit Person Lender Profile was not found?. Create Credit Person Lender profile'; + // isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('lender'=> $result_data,'products' =>$product,'lender_contact_persons'=>$lender_contact_persons,'default_lender' =>$FHFSL_lender,'default_product' =>$FHFSL_product); + $this->response($data,REST_Controller::HTTP_OK); + } public function listFlyhiPD_get(){ From aa39a9084522a134cd5c9dbd083736a711a13b96 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 15 Jun 2022 14:47:46 +0530 Subject: [PATCH 007/132] FLYHI Report : ps --- .../controllers/Flyhi_Controller.php | 18 +++---- .../views/sale_pd_templates/FHFSL.php | 50 +++++++++++++------ 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 7ac733bb..c2f7ff95 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -349,15 +349,15 @@ class Flyhi_Controller extends REST_Controller { } } - $FLYHI_PD['applicant_name'] = int($applicant_name); - $FLYHI_PD['applicant_id'] = int($applicant_id); - $FLYHI_PD['city_id']=int($city); - $FLYHI_PD['loan_amount'] = int($loan_amount); - $FLYHI_PD['lender_sales_person'] = int($lender_sales_person) ; - $FLYHI_PD['lender_credit_person'] = int($lender_credit_person) ; - $FLYHI_PD['pd_branch_id'] = int($pd_branch_id); - $FLYHI_PD['lender_id'] = int($lender_id); - $FLYHI_PD['product_id'] = int($product_id); + $FLYHI_PD['applicant_name'] = $applicant_name; + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['product_id'] = $product_id; $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); $status = $records['is_complete']; $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 4f212a45..777c65e8 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -188,20 +188,26 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Verification Type + + + +
+ + + + - - - + + - - + @@ -226,7 +232,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + @@ -237,15 +243,27 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - - - + + +
Residence Details
Address Details
City State PIN
Residence OwnershipState PIN
Number of Dependents
+ + + + + + + + + + + + - + @@ -270,7 +288,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + @@ -289,9 +307,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); -
Office Details
Address Details
City State PIN
Occupation of the loan applicantState PIN
Net Monthly Salary/ Net Income
+
@@ -315,14 +333,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + @@ -344,8 +362,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - - + +
Educational Institute Address
Class /Section/ Course Name
Loan Tenure (Months) Loan Purpose (End-Use)
From 8da58136c58f5a4fded8d5cdb4354232a863546b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 15 Jun 2022 19:11:30 +0530 Subject: [PATCH 008/132] FlyHI Master api Splitted : ps --- api/application/config/routes.php | 5 + .../controllers/Flyhi_Controller.php | 134 ++++++++++++++++-- 2 files changed, 127 insertions(+), 12 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 10a2ce05..158fbfd1 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -381,5 +381,10 @@ $route['getFlyhiPD'] = 'Flyhi_Controller/getFlyhiPD'; $route['loadFlyhiPDTemplate'] = 'Flyhi_Controller/loadFlyhiPDTemplate'; $route['(downloadFlyhiPDReport/:any)'] = 'Flyhi_Controller/getFlyhiPDReport'; $route['getMasterForFlyhiPD'] = 'Flyhi_Controller/getMasterForFlyhiPD'; +$route['getFlyhiSalesPersonList'] = 'Flyhi_Controller/lenderSalesPersonForFlyhiPD'; +$route['getFlyhiCreditPersonList'] = 'Flyhi_Controller/lenderCreditPersonForFlyhiPD'; +$route['getFlyhiBranchList'] = 'Flyhi_Controller/branchMasterForFlyhiPD'; +$route['getFlyhiProductList'] = 'Flyhi_Controller/productMasterForFlyhiPD'; +$route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index ae9a2f87..d2c11f32 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -10,7 +10,6 @@ class Flyhi_Controller extends REST_Controller { { parent::__construct(); $this->load->model('Flyhi_Model','Flyhi_Model'); - $this->load->model('Sales_PD_Model','Sales_PD_Model'); $this->load->library('AWS_S3'); $this->load->library('pdfgenerator'); $this->load->helper('satellite_image'); @@ -66,6 +65,114 @@ class Flyhi_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } + public function lenderMasterForFlyhiPD_get(){ + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $default_lender = $FHFSL_lender; + + $lender_fields = array('entity_id','full_name','short_name'); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); + $result_data = count($result_data)>0 ? $result_data : 'Lender was not found'; + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + + public function productMasterForFlyhiPD_get(){ + + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $default_product = $FHFSL_product; + + $product = $this->Flyhi_Model->selectCustomRecords(array('product_id','name as product_name','abbr as product_abbr','prod_catagory'),array('product_id' => $FHFSL_product),PRODUCTS); + $product = count($product)>0 ? $product : 'product was not found'; + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $product; + $this->response($data,REST_Controller::HTTP_OK); + } + + public function branchMasterForFlyhiPD_get(){ + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $branches = array(); + $lender_fields = array('entity_id','full_name','short_name'); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); + if(count($result_data)) + { + + foreach($result_data as $key => $value) + { + $branch_fields = array('entity_lender_branch_id', 'branch_name'); + $branch_where_condition_array = array('fk_entity_id' => $value['entity_id'],'isactive'=>1); + $result_data[$key]['branches'] = $this->Flyhi_Model->selectCustomRecords($branch_fields,$branch_where_condition_array,ENTITYLENDERBRANCH); + $branches = $this->Flyhi_Model->selectCustomRecords($branch_fields,$branch_where_condition_array,ENTITYLENDERBRANCH); + + } + } + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = count($branches)>0?$branches:"Branches Not Found"; + $this->response($data,REST_Controller::HTTP_OK); + } + + public function lenderCreditPersonForFlyhiPD_get(){ + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + + $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); + $table = USERPROFILE.' as USERPROFILE'; + $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', + 'condition' =>'USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1', + 'jointype' => 'INNER'), + array('table' => ROLES.' as ROLES', + 'condition' =>'ROLES.role_id = USERPROFILEROLES.user_role', + 'jointype' => 'INNER')); + $order_by = 'USERPROFILE.userid'; + $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; + $key_date="ROLES.role_name LIKE '%credit%'"; + $condition_value=null; + $where_condition_array[$key_date] = $condition_value; + $or_where = array(); + $lender_contact_persons = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); + $lender_contact_persons = count($lender_contact_persons)>0 ? $lender_contact_persons : 'Credit Person Lender Profile was not found?. Create Credit Person Lender profile'; + // isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $lender_contact_persons; + $this->response($data,REST_Controller::HTTP_OK); + } + public function lenderSalesPersonForFlyhiPD_get(){ + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + + $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); + $table = USERPROFILE.' as USERPROFILE'; + $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', + 'condition' =>'USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive =1', + 'jointype' => 'INNER'), + array('table' => ROLES.' as ROLES', + 'condition' =>'ROLES.role_id = USERPROFILEROLES.user_role', + 'jointype' => 'INNER')); + $order_by = 'USERPROFILE.userid'; + $or_where = array(); + $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; + $key_date="ROLES.role_name LIKE '%sale%'"; + $condition_value=null; + $where_condition_array[$key_date] = $condition_value; + + $lender_contact_persons = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); + $lender_contact_persons = count($lender_contact_persons)>0 ? $lender_contact_persons : 'Sales Person Lender Profile was not found?. Create Sales Person Lender profile'; + // isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $lender_contact_persons; + $this->response($data,REST_Controller::HTTP_OK); + } + public function listFlyhiPD_get(){ $user_id = $this->uri->segment(1); @@ -152,7 +259,7 @@ class Flyhi_Controller extends REST_Controller { $lender_sales_person = null; $lender_credit_person = null; $product_id = null; - // $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); + // $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); log_message('ERROR','####FLYHI-PD SAVE CALLED'); @@ -254,10 +361,10 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); $section_data = json_encode($records); - $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); $status = $records['is_complete']; $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); - $is_entry_done = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); + $is_entry_done = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); } else @@ -279,7 +386,7 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); // $gen_form = json_decode($form[0]['section_data'],true); - $flyhi_pd_id = $records['sales_pd_id']; + $flyhi_pd_id = (int)$records['sales_pd_id']; if($records['questions']){ foreach ($records['questions'] as $g_key => $g_value) @@ -358,10 +465,12 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['pd_branch_id'] = $pd_branch_id; $FLYHI_PD['lender_id'] = $lender_id; $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); - $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); $status = $records['is_complete']; + $section_data = json_encode($records); + $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1)); $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); - $is_entry_done = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); + $is_entry_done = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); } // else 179 } // else 167 if($flyhi_pd_id) @@ -415,7 +524,7 @@ class Flyhi_Controller extends REST_Controller { $pd_type = 2; if(isset($records['pd_type'])){ $pd_type = $records['pd_type'];} $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); - // $template = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); + // $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); if(is_array($template) && count($template)) { $data['dataStatus'] = true; @@ -459,7 +568,7 @@ class Flyhi_Controller extends REST_Controller { $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pd_id); // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); - $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + $sales_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); $pd_type = ""; if($sales_pd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($sales_pd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} @@ -473,7 +582,7 @@ class Flyhi_Controller extends REST_Controller { $pdf_name .= '-'.$pd_type.$sales_pd_data[0]['abbr']; $pdf_name .= '-'.(date('dmY',strtotime($sales_pd_data[0]['completed_date']))); $key = 'sales_pd/'.$pd_id.'/'.$pdf_name.'.pdf'; - //$this->Sales_PD_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); + //$this->Flyhi_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); if(!file_exists($this->external_path.'/sales_pd/'.$pd_id)) { @@ -483,7 +592,7 @@ class Flyhi_Controller extends REST_Controller { if(!$sales_pd_data[0]['is_pdf'] || $sales_pd_data[0]['is_edited']) { - $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); + $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); // print_r(json_decode($all_section_data[0]['section_data'],true));die(); $view_data['master'] = $sales_pd_data; @@ -502,6 +611,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; $view_name = $sales_pd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); + echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; @@ -515,7 +625,7 @@ class Flyhi_Controller extends REST_Controller { if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); + $this->Flyhi_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); if($api) { $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes'); From 830589b612cd56983b0eb363ae225af03334c020 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 15 Jun 2022 23:02:57 +0530 Subject: [PATCH 009/132] Flyhi Fixes 1 : ps --- .../controllers/Flyhi_Controller.php | 29 ++++++++++++------- .../views/sale_pd_templates/FHFSL.php | 14 ++++----- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index d2c11f32..fe507e63 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -611,7 +611,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; $view_name = $sales_pd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - echo $html_content;die(); + // echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; @@ -674,17 +674,15 @@ class Flyhi_Controller extends REST_Controller { { $questions = json_decode($section_array['section_data'],true); return $this->processSalesPDQuestions($questions['questions'],$section_array['section_id']); - } } function processSalesPDQuestions($questions,$section_id) { - //print_r($questions);die(); $temp_array = array(); foreach ($questions as $ques_key => $question) { - //if($question['section_id']){} + if($question['is_repeatable'] == null && ($question['type'] == 1 || $question['type'] == 2 || $question['type'] == 3 || $question['type'] == 4 || $question['type'] == 6 || $question['type'] == 7 || $question['type'] == 8))//text,radio,SDD,MDD,camera,txt area, searchable dd { @@ -692,20 +690,30 @@ class Flyhi_Controller extends REST_Controller { if($question['question_key'] == 'residence_state' || $question['question_key'] == 'residence_city' || $question['question_key'] == 'residence_pincode' || $question['question_key'] == 'business_state'|| $question['question_key'] == 'business_city'|| $question['question_key'] == 'business_pincode' || $question['question_key'] == 'permanent_state' || $question['question_key'] == 'permanent_city' || $question['question_key'] == 'permanent_pincode' || - $question['question_key'] == 'officer_state' || $question['question_key'] == 'officer_city' || $question['question_key'] == 'officer_pincode') + $question['question_key'] == 'officer_state' || $question['question_key'] == 'officer_city' || $question['question_key'] == 'officer_pincode' || + $question['question_key'] == 'lender_name' || $question['question_key'] == 'branch' || $question['question_key'] == 'lender_sales_person' || $question['question_key'] == 'lender_credit_person') // $question['question_key'] == 'employer_business_state' || $question['question_key'] == 'employer_business_address_city' || $question['question_key'] == 'employer_business_pincode' || // $question['question_key'] == 'educational_institute_state' || $question['question_key'] == 'educational_institute_address_city' || $question['question_key'] == 'educational_institute_pincode' // ) { - //if($question['type'] == 4) { print_r($question['answer_value']); } - $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); - // if($question['type'] == 4) { print_r($temp_array[ $question['question_key'] ]); } + $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); } if(isset($question['subfield_key'])) { - $temp_array[ $question['question_key'] ] .= $question['subfield_value'].','; + } + if(isset($question['onchange_properties'])){ + for ($a = 0; $a < count($question['onchange_properties']); $a++){ + if(isset($question['onchange_properties'][$a]['form_controls'])){ + $onchange_array = $question['onchange_properties'][$a]['form_controls']; + $singleArray = []; + for ($i = 0; $i < count($onchange_array); $i++){ + $value = $this->processSalesPDQuestions($onchange_array[$i]['questions'],$section_id); + foreach ($value as $key => $val){ $temp_array[$key] = $val; } + } + } + } } // echo 'FIRST';print_r($temp_array[ $question['question_key'] ]); if(substr_count($temp_array[ $question['question_key'] ], ',')) @@ -745,7 +753,6 @@ class Flyhi_Controller extends REST_Controller { } else { -//echo "SDKJHKSJ**"; $group_temp = array(); foreach ($question['questions_group'] as $group_key => $group_value) { @@ -756,12 +763,12 @@ class Flyhi_Controller extends REST_Controller { } } } - // //print_r($temp_array);die(); // if($section_id == 2) // { // //print_r(json_decode($section_array['section_data'],true)); die(); // die(); // } + return $temp_array; } diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 777c65e8..abd003f2 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -356,15 +356,15 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Loan Amount Applied for (Rs) - Total Fund Requirement (Rs) - - - - Loan Tenure (Months) - + Loan Tenure (Months) + + + From 455cfca65882d8c54b0598bb7b5054f72652d1d5 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 17 Jun 2022 11:28:05 +0530 Subject: [PATCH 010/132] FlyHI Photograph : ps --- api/application/config/routes.php | 2 + .../controllers/Flyhi_Controller.php | 314 +++++++++++++++--- .../views/sale_pd_templates/FHFSL.php | 43 +++ 3 files changed, 319 insertions(+), 40 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 158fbfd1..867fd9f9 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -386,5 +386,7 @@ $route['getFlyhiCreditPersonList'] = 'Flyhi_Controller/lenderCreditPersonForFlyh $route['getFlyhiBranchList'] = 'Flyhi_Controller/branchMasterForFlyhiPD'; $route['getFlyhiProductList'] = 'Flyhi_Controller/productMasterForFlyhiPD'; $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; +$route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; +$route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index fe507e63..2bdf1fbd 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -263,8 +263,8 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','####FLYHI-PD SAVE CALLED'); - // $section_names = array('1' => 'General Section','2' => 'Photography'); - $section_names = array('1' => 'General Section'); + $section_names = array('1' => 'General Section','2' => 'Photography'); + // $section_names = array('1' => 'General Section'); if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) { @@ -324,11 +324,11 @@ class Flyhi_Controller extends REST_Controller { { if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ $city = $j_value['answer_value']; - $sales_pd_type = 4; + $flyhi_pd_type = 4; } if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ $city = $j_value['answer_value']; - $sales_pd_type = 3; + $flyhi_pd_type = 3; } if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') { @@ -357,7 +357,7 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['lender_id'] = $lender_id; $FLYHI_PD['createdby'] = $fk_createdby; $FLYHI_PD['rand_string'] = $randomString; - $FLYHI_PD['sales_pd_type'] = $sales_pd_type; + $FLYHI_PD['sales_pd_type'] = $flyhi_pd_type; $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); $section_data = json_encode($records); @@ -372,14 +372,54 @@ class Flyhi_Controller extends REST_Controller { if(isset($records['status']) && $records['status'] == 'COMPLETED') { log_message('ERROR','####COMPLETE FLYHI-PD'.$records['sales_pd_id']); - $records['status'] = 'COMPLETED'; - $records['is_cus_link_disabled'] = 1; - $records['completed_date'] = date('Y-m-d H:i:s'); - $flyhi_pd_id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $drafted_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); - $this->prepareFlyhiPDReport($records['sales_pd_id'],false); - sleep(10); - log_message('ERROR','####FLYHI-PD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); + $dup_of_section_names = $section_names; + foreach ($completed_sections as $completed_section_key => $completed_section_value) + { + if($dup_of_section_names [ $completed_section_value['section_id'] ] ) + { + unset($dup_of_section_names [ $completed_section_value['section_id'] ]); + } + } + unset($dup_of_section_names[2]);//unset photograph always + $img_satellite_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'satellite','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); + $img_selfile_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); + + if(count($drafted_sections) ) + { + + $drafted_sections = array_map(function($single) use ($section_names) + { + return array('section_id' => $single['section_id'],'sectin_name' => $section_names [ $single['section_id'] ]); + },$drafted_sections); + + unset($records['status']); + $data['dataStatus'] = true; + $data['records'] = $drafted_sections; + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + else if($img_satellite_check[0]['count'] == 0 || $img_selfile_check[0]['count'] == 0) + { + unset($records['status']); + $data['dataStatus'] = true; + $data['records'][] = ($img_selfile_check[0]['count'] == 0) ? array('section_id' => 2,'section_name' => 'selfie image') : ( $img_satellite_check[0]['count'] == 0 ? array('section_id' => 2,'section_name' => 'satellite image') :('selfie image and satellite image ar not available')); + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $records['status'] = 'COMPLETED'; + $records['is_cus_link_disabled'] = 1; + $records['completed_date'] = date('Y-m-d H:i:s'); + $flyhi_pd_id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $this->prepareFlyhiPDReport($records['sales_pd_id'],false); + sleep(10); + log_message('ERROR','####FLYHI-PD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); + } } else { @@ -437,11 +477,11 @@ class Flyhi_Controller extends REST_Controller { { if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ $city = $j_value['answer_value']; - $sales_pd_type = 4; + $flyhi_pd_type = 4; } if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ $city = $j_value['answer_value']; - $sales_pd_type = 3; + $flyhi_pd_type = 3; } if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') { @@ -493,10 +533,54 @@ class Flyhi_Controller extends REST_Controller { public function getFlyhiPD_get() { $Flyhi_pdid = $this->get('pd_id'); + $section_id = $this->get('section_id'); $section_data = array(); if(isset($Flyhi_pdid) || $Flyhi_pdid != "" || $Flyhi_pdid != null) { - $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => 1),SALESPD_SECTION_DATA); + if(isset($section_id) || $section_id != "" || $section_id != null){ + $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => $section_id),SALESPD_SECTION_DATA); + if($section_id == 2 && count($section_data)) + { + $all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); + $photo_questions = (json_decode(($section_data[0]['section_data']),true)); + foreach ($photo_questions['questions'] as $key => $value) + { + if(isset($value['answer_value']) && $value['answer_value'] && !$value['is_repeatable']) + { + $selfie = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name' => 'selfie_with_person_met','isactive' => 1),SALEPD_DOCS); + if(count($selfie)) + { + $photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img']; + } + } + else + { + + foreach ($value['questions_group'] as $v_key => $individual_value) + { + if(isset($individual_value['questions'][0]['answer_value'])) + { + foreach ($all_sales_pd_images as $img_key => $img_value) + { + if($individual_value['questions'][0]['question_key'] == $img_value['img_name']) + { + $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img']; + unset($all_sales_pd_images[$img_key]); + break; + } + } + } + } + } + } + $photo_questions = json_encode($photo_questions); + $section_data[0]['section_data'] = $photo_questions; + } + + }else{ + $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1),SALESPD_SECTION_DATA); + } + } if($section_data) { @@ -519,12 +603,12 @@ class Flyhi_Controller extends REST_Controller { $records = $this->post('records'); $lender_id = $records['lender_id']; // $product = $records['product_id']; - $sales_pd_type = $records['sales_pd_type'] ? $records['sales_pd_type'] : null; + $flyhi_pd_type = $records['sales_pd_type'] ? $records['sales_pd_type'] : null; $product = $records['product_id']; $pd_type = 2; if(isset($records['pd_type'])){ $pd_type = $records['pd_type'];} - $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); - // $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'pd_type' => $pd_type,'sales_pd_type' => $sales_pd_type,'isactive' => 1),SALESPDTEMPLATE); + $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'pd_type' => $pd_type,'sales_pd_type' => $flyhi_pd_type,'isactive' => 1),SALESPDTEMPLATE); + // $template = $this->Flyhi_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'pd_type' => $pd_type,'sales_pd_type' => $flyhi_pd_type,'isactive' => 1),SALESPDTEMPLATE); if(is_array($template) && count($template)) { $data['dataStatus'] = true; @@ -567,20 +651,20 @@ class Flyhi_Controller extends REST_Controller { ); $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pd_id); - // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); - $sales_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $flyhipd_id); + $flyhipd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); $pd_type = ""; - if($sales_pd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($sales_pd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} + if($flyhipd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($flyhipd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} - if($sales_pd_data) + if($flyhipd_data) { ini_set('max_execution_time', 0); - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id']; + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$flyhipd_data[0]['lender_id']; // 1st Type Key name. (name,abbr and date). - $pdf_name = strtolower(trim($sales_pd_data[0]['applicant_name'])); + $pdf_name = strtolower(trim($flyhipd_data[0]['applicant_name'])); // $pdf_name .= '-'.$pd_type; - $pdf_name .= '-'.$pd_type.$sales_pd_data[0]['abbr']; - $pdf_name .= '-'.(date('dmY',strtotime($sales_pd_data[0]['completed_date']))); + $pdf_name .= '-'.$pd_type.$flyhipd_data[0]['abbr']; + $pdf_name .= '-'.(date('dmY',strtotime($flyhipd_data[0]['completed_date']))); $key = 'sales_pd/'.$pd_id.'/'.$pdf_name.'.pdf'; //$this->Flyhi_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); @@ -589,27 +673,30 @@ class Flyhi_Controller extends REST_Controller { mkdir($this->external_path.'/sales_pd/'.$pd_id,0777); } - if(!$sales_pd_data[0]['is_pdf'] || $sales_pd_data[0]['is_edited']) + if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); // print_r(json_decode($all_section_data[0]['section_data'],true));die(); - $view_data['master'] = $sales_pd_data; - $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], - // 'product'=>$sales_pd_data[0]['abbr'], - 'caseno'=>$sales_pd_data[0]['sales_pd_sno']); + $view_data['master'] = $flyhipd_data; + $common_fields = array('pdid'=>$flyhipd_data[0]['sales_pd_id'], + // 'product'=>$flyhipd_data[0]['abbr'], + 'caseno'=>$flyhipd_data[0]['sales_pd_sno']); foreach ($all_section_data as $sec_key => $section) { // print_r($section['section_id']);die(); // log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$pd_id); - $view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);//die(); - $section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); + $view_data['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section);//die(); + $section_fields['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section); } - $view_data['geo_location'] = $sales_pd_data[0]['geo_location']; + $view_data['section2'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); + $view_data['product_id'] = $flyhipd_data[0]['product_id']; + $view_data['geo_location'] = $flyhipd_data[0]['geo_location']; + $view_data['satellite_image'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS); // die(); - //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; - $view_name = $sales_pd_data[0]['short_name']; + //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; + $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); // echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); @@ -668,16 +755,16 @@ class Flyhi_Controller extends REST_Controller { } } - function processSalesPDJSON($section_array) + function processFlyhiPDJSON($section_array) { if($section_array['section_id']) { $questions = json_decode($section_array['section_data'],true); - return $this->processSalesPDQuestions($questions['questions'],$section_array['section_id']); + return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); } } - function processSalesPDQuestions($questions,$section_id) + function processFlyhiPDQuestions($questions,$section_id) { $temp_array = array(); foreach ($questions as $ques_key => $question) @@ -709,7 +796,7 @@ class Flyhi_Controller extends REST_Controller { $onchange_array = $question['onchange_properties'][$a]['form_controls']; $singleArray = []; for ($i = 0; $i < count($onchange_array); $i++){ - $value = $this->processSalesPDQuestions($onchange_array[$i]['questions'],$section_id); + $value = $this->processFlyhiPDQuestions($onchange_array[$i]['questions'],$section_id); foreach ($value as $key => $val){ $temp_array[$key] = $val; } } } @@ -807,4 +894,151 @@ class Flyhi_Controller extends REST_Controller { } } + + public function saveFlyhiPDImage_post() + { + $records = $this->post('records'); + $is_customer_app = isset($records['is_customer_app']) ? $records['is_customer_app'] : null; + unset($records['is_customer_app']); + + if($records['img_name'] == 'selfie_with_person_met') + { + + $update_fields2 = array('isactive' => 0); + $this->Flyhi_Model->updateRecords($update_fields2,SALEPD_DOCS,array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['fk_sales_pd_id'])); + if($is_customer_app) + { + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 2,'sales_pd_id' => $records['fk_sales_pd_id'])); + } + + } + + $id = $this->Flyhi_Model->saveRecords($records,SALEPD_DOCS); + if($id) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = "Image Updated at ".$id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + public function getFlyhiPDImgDataCusLink_post() + { + $rand_string = $this->post('rand_string'); + + $sales_pd_master_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('rand_string' => $rand_string),SALES_PD_DATA); + $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $sales_pd_master_data[0]['product_id']),PRODUCTS); + $sales_pd_img_data = $this->Flyhi_Model->selectCustomRecords(array('doc_id', 'fk_sales_pd_id','img','img_name','isactive'),array('fk_sales_pd_id' => $sales_pd_master_data[0]['sales_pd_id'],'isactive' => 1,'img_name!=' => 'satellite'),SALEPD_DOCS); + + // print_r($product_short_name);die(); + //sales tele pd img structure array + $imgs = array('selfie_with_person_met' => array('is_multiple' => 0,'img_name' => 'Selfie of the person contacted')); + + + $img_data = array(); + if(count($sales_pd_img_data)) + { + + foreach ($imgs as $key => $value) + { + //echo "FISRT LOOP****$key"; + foreach ($sales_pd_img_data as $sales_pd_img_data_key => $sales_pd_img_data_value) + { + //echo "SEC LOOP****"; + if($key == $sales_pd_img_data_value['img_name']) + { + if($value['is_multiple']) + { + if(!array_key_exists($key,$img_data)) + { + $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => [array('img_url' => $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : '')],'is_multiple' => 1,'section_heading' => $value['img_name']); + } + else + { + $img_data[$key]['img_data'][] = array('img_url' => $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : ''); + } + + } + else + { + $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_url' => $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : '','is_multiple' => 0,'section_heading' => $value['img_name']);//$sales_pd_img_data_value['img'] + } + + unset($sales_pd_img_data[$sales_pd_img_data_key]); + //break; + } + // else + // { + + // if(!$value['is_multiple']) + // { + + // $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_url' => $value['is_multiple'] == 0 ? '' : array(),'is_multiple' => $value['is_multiple'],'section_heading' => $value['img_name']); + // } + // else + // { + // if(!array_key_exists($key,$img_data)) + // { + // $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => [array('img_url' => $sales_pd_img_data_value['img'] ? 'Y' : 'N')],'is_multiple' => 1,'section_heading' => $value['img_name']); + // } + // else + // { + // $img_data[$key]['img_data'][] = array('img_url' => $sales_pd_img_data_value['img'] ? 'yes' : 'No'); + // } + // } + + // } + } + + //IF current img key is not exist in existing img arry + + if(!array_key_exists($key,$img_data)) + { + + if(!$value['is_multiple']) + { + $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_url' => '','is_multiple' => $value['is_multiple'],'section_heading' => $value['img_name']); + } + else + { + $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => array(),'is_multiple' => $value['is_multiple'],'section_heading' => $value['img_name']); + } + } + } + $img_data = array_values($img_data); + + } + else + { + + foreach ($imgs as $key => $value) + { + if($value['is_multiple']) + { + $img_data[] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => array(),'is_multiple' => 1,'section_heading' => $value['img_name']); + + } + else + { + $img_data[] = array('img_key' => $key,'img_name' => $value['img_name'],'img_url' => '','is_multiple' => 0,'section_heading' => $value['img_name']); + } + } + } + + //print_r($img_data); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('sales_pd_id' => $sales_pd_master_data[0]['sales_pd_id'],'img_data' => $img_data,'is_cus_link_disabled' => $sales_pd_master_data[0]['is_cus_link_disabled']); + $this->response($data,REST_Controller::HTTP_OK); + } + + }// Class Ends diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index abd003f2..28aacf90 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -367,5 +367,48 @@ defined('BASEPATH') OR exit('No direct script access allowed'); --> +
+
Satellite Image of PD Location

+

GPS Coordinates of location where PD Visit was done :

+ + PD Visted Location Satellite Image + Due to location access not provided by loan applicant Geo coordinates on photographs and Satellite image of PD location is not shown

';} + ?> + 'Selfie with person met','satellite1' => 'satellite'); + + $tot_rows = ceil(count($section2) / 3); + + if(count($section2)) + { + echo '
'; + echo '
Photograph`s

'; + + $add_factor = 0; + for($row = 0;$row < $tot_rows; $row++) + { + echo ''; + + $from = $row == 0 ? $row : ($row+$add_factor); + $to = ($from + 2); + $add_factor = $add_factor + 2; + for($i = $from ; $i <= $to; $i++) + { + + if(isset($section2[$i])) + { + + echo ''; + } + + //unset($p_key); + } + echo ''; + } + echo '
'.$section2[$i]['img_name'].'
'.$photo_names [ $section2[$i]['img_name'] ].'
'; + } + ?> \ No newline at end of file From 13a1891dda9131e298898e93b28cdb5839ba816b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 17 Jun 2022 14:49:04 +0530 Subject: [PATCH 011/132] flyhi getflyhi api : ps --- api/application/config/routes.php | 2 +- .../controllers/Flyhi_Controller.php | 57 +++++++++++-------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 867fd9f9..0d0721bd 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -377,7 +377,7 @@ $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; $route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD'; $route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; -$route['getFlyhiPD'] = 'Flyhi_Controller/getFlyhiPD'; +$route['getFlyhiPDSectionData'] = 'Flyhi_Controller/getFlyhiPD'; $route['loadFlyhiPDTemplate'] = 'Flyhi_Controller/loadFlyhiPDTemplate'; $route['(downloadFlyhiPDReport/:any)'] = 'Flyhi_Controller/getFlyhiPDReport'; $route['getMasterForFlyhiPD'] = 'Flyhi_Controller/getMasterForFlyhiPD'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 2bdf1fbd..264352f1 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -530,19 +530,25 @@ class Flyhi_Controller extends REST_Controller { } } - public function getFlyhiPD_get() + + public function getFlyhiPD_post() { - $Flyhi_pdid = $this->get('pd_id'); - $section_id = $this->get('section_id'); + $records = $this->post('records'); $section_data = array(); - if(isset($Flyhi_pdid) || $Flyhi_pdid != "" || $Flyhi_pdid != null) - { - if(isset($section_id) || $section_id != "" || $section_id != null){ - $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => $section_id),SALESPD_SECTION_DATA); - if($section_id == 2 && count($section_data)) + if(!is_numeric($records['section_id'])){ + $fields=array('id','sales_pd_id','section_id','status','createdby','createdon'); + if($records['section_id'] == 'data'){ $fields[] = 'section_data'; } + $section_data=$this->Flyhi_Model->selectCustomRecords($fields,array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + } + else{ + $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1,'section_id' => $records['section_id']),SALESPD_SECTION_DATA); + //print_r( json_decode($section_data[0]['section_data'],true));die(); + if($records['section_id'] == 2 && count($section_data)) { $all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); - $photo_questions = (json_decode(($section_data[0]['section_data']),true)); + //print_r($all_sales_pd_images);die(); + $photo_questions = (json_decode(($section_data[0]['section_data']),true)); + // print_r($photo_questions); foreach ($photo_questions['questions'] as $key => $value) { if(isset($value['answer_value']) && $value['answer_value'] && !$value['is_repeatable']) @@ -551,20 +557,24 @@ class Flyhi_Controller extends REST_Controller { if(count($selfie)) { $photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img']; + //$photo_questions['questions'][$key]['answer_value'] = "CHNAGED"; } } else - { - + { foreach ($value['questions_group'] as $v_key => $individual_value) { + //print_r($individual_value);die(); + //if($individual_value['questions'][0]['answer_value']) if(isset($individual_value['questions'][0]['answer_value'])) { + //iterate all_sales_pd_images to get one foreach ($all_sales_pd_images as $img_key => $img_value) { if($individual_value['questions'][0]['question_key'] == $img_value['img_name']) { $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img']; + //$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = "CHANGED"; unset($all_sales_pd_images[$img_key]); break; } @@ -573,29 +583,26 @@ class Flyhi_Controller extends REST_Controller { } } } + //die(); $photo_questions = json_encode($photo_questions); $section_data[0]['section_data'] = $photo_questions; } - - }else{ - $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1),SALESPD_SECTION_DATA); - } - } - if($section_data) - { + if($section_data) + { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $section_data; $this->response($data,REST_Controller::HTTP_OK); - } - else - { + } + else + { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Data Found'; - $this->response($data,REST_Controller::HTTP_OK); - } + $this->response($data,REST_Controller::HTTP_OK); + + } } public function loadFlyhiPDTemplate_post() @@ -818,7 +825,7 @@ class Flyhi_Controller extends REST_Controller { else if($question['is_repeatable'] == 1 ) { //print_r($question['questions_group']);die(); - if($section_id != 9) + if($section_id != 2) { foreach ($question['questions_group'] as $group_key => $group_value) { @@ -910,6 +917,8 @@ class Flyhi_Controller extends REST_Controller { { $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 2,'sales_pd_id' => $records['fk_sales_pd_id'])); } + // $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 2,'sales_pd_id' => $records['fk_sales_pd_id']));// temporary + } From 38474870aa952515e4d5b82e9efb25c26ff49509 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 17 Jun 2022 15:55:45 +0530 Subject: [PATCH 012/132] Saveflyhi pd api is changed as per savesales pd --- api/application/config/routes.php | 1 + .../controllers/Flyhi_Controller.php | 323 +++++++++++++++++- 2 files changed, 323 insertions(+), 1 deletion(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 0d0721bd..a27daeb8 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -388,5 +388,6 @@ $route['getFlyhiProductList'] = 'Flyhi_Controller/productMasterForFlyhiPD'; $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; +$route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 264352f1..e0b3b292 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -243,7 +243,7 @@ class Flyhi_Controller extends REST_Controller { } } - public function saveFlyhiPD_post() + public function saveFlyhiPDOLD_post() { $records = $this->post('records'); $is_entry_done = null; @@ -1049,5 +1049,326 @@ class Flyhi_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } + public function saveFlyhiPD_post() + { + $records = $this->post('records'); + + $applicant_id = null; + $applicant_name = null; + $city = null; + $lender_id = null; + $loan_amount = null; + $pd_branch_id = null; + $lender_sales_person = null; + $lender_credit_person = null; + $product_id = null; + $is_entry_done = null; + $id = null; + // print_r($records);//die(); + log_message('ERROR','####FLYHIPD SAVE CALLED'); + $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); + + $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); + + $section_names = array('1' => 'General Section','2' => 'Photography'); + + $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id'],'isactive' => 1),SALES_PD_DATA); + + if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) + { + /************ASSIGN Random URL******************/ + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 16; $i++) + { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + $records['rand_string'] = $randomString; + log_message('ERROR','####INSERT NEW FLYHIPD'); + $salepd_serial_no = count($lender_short_name)? $lender_short_name[0]['short_name']:'UNKNOWN'; + $salepd_serial_no .= count($product_short_name)? '-'.$product_short_name[0]['abbr']:'-UNKNOWN'; + $salepd_serial_no .= '-'.(++$count[0]['count']); + + $records['sales_pd_sno'] = $salepd_serial_no; + + $id = $this->Flyhi_Model->saveRecords($records,SALES_PD_DATA); + + } + else + { + //echo $product_short_name[0]['abbr']; + if(isset($records['status']) && $records['status'] == 'COMPLETED') + { + log_message('ERROR','####COMPLETE FLYHIPD'.$records['sales_pd_id']); + $drafted_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + + $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + + $img_satellite_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'satellite','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); + + $img_selfile_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); + + + $dup_of_section_names = $section_names; + // print_r($dup_of_section_names); + foreach ($completed_sections as $completed_section_key => $completed_section_value) + { + if($dup_of_section_names [ $completed_section_value['section_id'] ] ) + { + unset($dup_of_section_names [ $completed_section_value['section_id'] ]); + } + } + + // print_r($dup_of_section_names); + unset($dup_of_section_names[2]);//unset photograph always + + + if(count($dup_of_section_names)) + { + $res_data = array(); + foreach ($dup_of_section_names as $key => $value) + { + $res_data[] = array('section_id' => $key,'sectin_name' => $section_names[$key]); + } + $data['dataStatus'] = true; + $data['records'] = $res_data; + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + + + + if(count($drafted_sections) ) + { + + + + $drafted_sections = array_map(function($single) use ($section_names) + { + return array('section_id' => $single['section_id'],'sectin_name' => $section_names [ $single['section_id'] ]); + }, + $drafted_sections); + + //print_r($drafted_sections);die(); + + unset($records['status']); + $data['dataStatus'] = true; + $data['records'] = $drafted_sections; + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + else if($img_satellite_check[0]['count'] == 0 || $img_selfile_check[0]['count'] == 0) + { + unset($records['status']); + $data['dataStatus'] = true; + $data['records'][] = array('section_id' => 2,'section_name' => 'selfie image'); + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + + + else + { + $records['status'] = 'COMPLETED'; + $records['is_cus_link_disabled'] = 1; + $records['completed_date'] = date('Y-m-d H:i:s'); + //echo 'final';die(); + $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + + //CAMUNDA::completeSalesPDTask($records['sales_pd_id']); + + $this->prepareFlyhiPDReport($records['sales_pd_id'],false); + sleep(10); + log_message('ERROR','####FlyHiPD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); + + // $city = ''; + // $form = $this->Flyhi_Model->selectCustomRecords(array(),array('isactive' => 1,'sales_pd_id' => $records['sales_pd_id'],'section_id' => 1,'status' => 1),SALESPD_SECTION_DATA); + // $gen_form = json_decode($form[0]['section_data'],true); + // if(!empty($gen_form)){ + // foreach ($gen_form['questions'] as $g_key => $g_value) + // { + // // if($g_value['question_key'] == 'state') + // // { + // // $ids_to_send_mail['state'] = $g_value['answer_value']; + // // } + // if($g_value['question_key'] == 'city') + // { + // $city = $g_value['answer_value']; + // } + // } + // }//gen_form closed here. + // PDALERTS::sendSalesPDMail($this,$records['sales_pd_id'],$city); + } + + } + else + { + log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); + $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + + } + + } + + if($id) + { + $data['dataStatus'] = true; + $data['records'] = $id; + $data['status'] = REST_Controller::HTTP_OK; + if(isset($records['rand_string'])){ $data['rand_string'] = $records['rand_string']; } + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + + public function saveFlyhiPDsection_post() + { + $records = $this->post('records'); + $sales_pd_id = $records['sales_pd_id']; + $section_id = $records['section_id']; + $fk_createdby = $records['fk_createdby']; + $status = $records['is_complete']; + $section_data = json_encode($records); + + //Get Sales PD master Data + + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + array('table' => PRODUCTS. ' as PRODUCT', + 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + 'jointype' => 'INNER') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); + $sales_pd_master_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + + //pre process works + switch($section_id) + { + case 1: //General section + //update Applicant ID and applicant Name to sales pD master Table + $city = ''; + if($records['questions']) + { + foreach ($records['questions'] as $g_key => $g_value) + { + if(isset($g_value['question_key']) && $g_value['question_key'] === 'loan_application_id') + { + $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_name') + { + $lender_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'loan_amount') + { + $loan_amount = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'branch') + { + $pd_branch_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_sales_person') + { + $lender_sales_person = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_credit_person') + { + $lender_credit_person = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') + { + $product_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') + { + if(isset($g_value['onchange_properties'])) + { + foreach ($g_value['onchange_properties'] as $h_key => $h_value) + { + foreach ($h_value['form_controls'] as $i_key => $i_value) + { + foreach ($i_value['questions'] as $j_key => $j_value) + { + if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ + $city = $j_value['answer_value']; + $flyhi_pd_type = 4; + } + if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ + $city = $j_value['answer_value']; + $flyhi_pd_type = 3; + } + // if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') + // { + // $applicant_name = $j_value['answer_value']; + // } + } + } + } + } + } + + } + + } + + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['sales_pd_sno'] = $flyhipd_serial_no; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['sales_pd_type'] = $flyhi_pd_type; + $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); + $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + + + break; + + case 2: //photosection + break; + + default: + } + + //make inactive previous records + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$sales_pd_id,'section_id' => $section_id )); + + //insert new record + $fields = array('sales_pd_id' => $sales_pd_id, 'section_id' => $section_id, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); + $is_entry_created = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); + if($is_entry_created) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $is_entry_created; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + }// Class Ends From 74ba7ffb05f840bfda3bbeb0b8fcd2e5c68e34bb Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 17 Jun 2022 18:35:39 +0530 Subject: [PATCH 013/132] flyhi serial no removed : ps --- api/application/controllers/Flyhi_Controller.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index e0b3b292..0eb48fc0 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -345,11 +345,9 @@ class Flyhi_Controller extends REST_Controller { } $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender_id,'isactive' => 1),SALES_PD_DATA); $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender_id),ENTITY); - $flyhipd_serial_no = $lender_short_name[0]['short_name'].'-'.(++$count[0]['count']); $FLYHI_PD['applicant_name'] = $applicant_name; $FLYHI_PD['applicant_id'] = $applicant_id; $FLYHI_PD['city_id']=$city; - $FLYHI_PD['sales_pd_sno'] = $flyhipd_serial_no; $FLYHI_PD['loan_amount'] = $loan_amount; $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; @@ -1329,7 +1327,6 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['applicant_id'] = $applicant_id; $FLYHI_PD['city_id']=$city; - $FLYHI_PD['sales_pd_sno'] = $flyhipd_serial_no; $FLYHI_PD['loan_amount'] = $loan_amount; $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; From b83bf0f3ee33d0c3ec11f981546784330f497943 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 10:26:37 +0530 Subject: [PATCH 014/132] COde committed : ps --- .../controllers/Flyhi_Controller.php | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 0eb48fc0..bb5dcc56 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1050,27 +1050,20 @@ class Flyhi_Controller extends REST_Controller { public function saveFlyhiPD_post() { $records = $this->post('records'); - - $applicant_id = null; - $applicant_name = null; - $city = null; - $lender_id = null; - $loan_amount = null; - $pd_branch_id = null; - $lender_sales_person = null; - $lender_credit_person = null; - $product_id = null; - $is_entry_done = null; + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $lender = $records['lender_id'] ? $records['lender_id'] : $FHFSL_lender; + $product = $records['product_id'] ? $records['product_id'] : $FHFSL_product; $id = null; // print_r($records);//die(); log_message('ERROR','####FLYHIPD SAVE CALLED'); - $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); + $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender ),ENTITY); - $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); + $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $product ),PRODUCTS); $section_names = array('1' => 'General Section','2' => 'Photography'); - $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id'],'isactive' => 1),SALES_PD_DATA); + $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender,'product_id' => $product,'isactive' => 1),SALES_PD_DATA); if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) { From fccaa144ed2dd1f4691e3d02b6b4e0501e21ebc1 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 13:11:17 +0530 Subject: [PATCH 015/132] Section 2 into 9 in flhiphots : ps --- .../controllers/Flyhi_Controller.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index bb5dcc56..e32a7865 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -263,7 +263,7 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','####FLYHI-PD SAVE CALLED'); - $section_names = array('1' => 'General Section','2' => 'Photography'); + $section_names = array('1' => 'General Section','9' => 'Photography'); // $section_names = array('1' => 'General Section'); if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) @@ -380,7 +380,7 @@ class Flyhi_Controller extends REST_Controller { unset($dup_of_section_names [ $completed_section_value['section_id'] ]); } } - unset($dup_of_section_names[2]);//unset photograph always + unset($dup_of_section_names[9]);//unset photograph always $img_satellite_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'satellite','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); $img_selfile_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); @@ -403,7 +403,7 @@ class Flyhi_Controller extends REST_Controller { { unset($records['status']); $data['dataStatus'] = true; - $data['records'][] = ($img_selfile_check[0]['count'] == 0) ? array('section_id' => 2,'section_name' => 'selfie image') : ( $img_satellite_check[0]['count'] == 0 ? array('section_id' => 2,'section_name' => 'satellite image') :('selfie image and satellite image ar not available')); + $data['records'][] = ($img_selfile_check[0]['count'] == 0) ? array('section_id' => 9,'section_name' => 'selfie image') : ( $img_satellite_check[0]['count'] == 0 ? array('section_id' => 9,'section_name' => 'satellite image') :('selfie image and satellite image ar not available')); $data['pd_status'] = 'DRAFT'; $data['status'] = REST_Controller::HTTP_OK; $this->response($data,REST_Controller::HTTP_OK); @@ -541,7 +541,7 @@ class Flyhi_Controller extends REST_Controller { else{ $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1,'section_id' => $records['section_id']),SALESPD_SECTION_DATA); //print_r( json_decode($section_data[0]['section_data'],true));die(); - if($records['section_id'] == 2 && count($section_data)) + if($records['section_id'] == 9 && count($section_data)) { $all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); //print_r($all_sales_pd_images);die(); @@ -695,7 +695,7 @@ class Flyhi_Controller extends REST_Controller { $view_data['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section);//die(); $section_fields['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section); } - $view_data['section2'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); + $view_data['section9'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); $view_data['product_id'] = $flyhipd_data[0]['product_id']; $view_data['geo_location'] = $flyhipd_data[0]['geo_location']; $view_data['satellite_image'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS); @@ -823,7 +823,7 @@ class Flyhi_Controller extends REST_Controller { else if($question['is_repeatable'] == 1 ) { //print_r($question['questions_group']);die(); - if($section_id != 2) + if($section_id != 9) { foreach ($question['questions_group'] as $group_key => $group_value) { @@ -913,9 +913,9 @@ class Flyhi_Controller extends REST_Controller { $this->Flyhi_Model->updateRecords($update_fields2,SALEPD_DOCS,array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['fk_sales_pd_id'])); if($is_customer_app) { - $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 2,'sales_pd_id' => $records['fk_sales_pd_id'])); + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 9,'sales_pd_id' => $records['fk_sales_pd_id'])); } - // $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 2,'sales_pd_id' => $records['fk_sales_pd_id']));// temporary + // $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 9,'sales_pd_id' => $records['fk_sales_pd_id']));// temporary } @@ -1061,7 +1061,7 @@ class Flyhi_Controller extends REST_Controller { $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $product ),PRODUCTS); - $section_names = array('1' => 'General Section','2' => 'Photography'); + $section_names = array('1' => 'General Section','9' => 'Photography'); $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender,'product_id' => $product,'isactive' => 1),SALES_PD_DATA); @@ -1112,7 +1112,7 @@ class Flyhi_Controller extends REST_Controller { } // print_r($dup_of_section_names); - unset($dup_of_section_names[2]);//unset photograph always + unset($dup_of_section_names[9]);//unset photograph always if(count($dup_of_section_names)) @@ -1155,7 +1155,7 @@ class Flyhi_Controller extends REST_Controller { { unset($records['status']); $data['dataStatus'] = true; - $data['records'][] = array('section_id' => 2,'section_name' => 'selfie image'); + $data['records'][] = array('section_id' => 9,'section_name' => 'selfie image'); $data['pd_status'] = 'DRAFT'; $data['status'] = REST_Controller::HTTP_OK; $this->response($data,REST_Controller::HTTP_OK); @@ -1332,7 +1332,7 @@ class Flyhi_Controller extends REST_Controller { break; - case 2: //photosection + case 9: //photosection break; default: From db065fab4445dc80da0770a8615a22c130f01beb Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 13:21:10 +0530 Subject: [PATCH 016/132] view file : ps --- api/application/views/sale_pd_templates/FHFSL.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 28aacf90..c1049904 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -379,9 +379,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $iter = 0; $photo_names = array('selfie_with_person_met' => 'Selfie with person met','satellite1' => 'satellite'); - $tot_rows = ceil(count($section2) / 3); + $tot_rows = ceil(count($section9) / 3); - if(count($section2)) + if(count($section9)) { echo '
'; echo '
Photograph`s

'; @@ -397,10 +397,10 @@ defined('BASEPATH') OR exit('No direct script access allowed'); for($i = $from ; $i <= $to; $i++) { - if(isset($section2[$i])) + if(isset($section9[$i])) { - echo ''; + echo ''; } //unset($p_key); From 26a96278aaa8a2701288b16a2b2d0bc772cb6b62 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 14:06:11 +0530 Subject: [PATCH 017/132] constant : ps --- api/application/config/constants.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 16396452..f1cf3277 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,6 +95,7 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); +defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors defined('ROUTE_LOGIN_C') OR define('ROUTE_LOGIN_C', 'getCreditPDReportforCETApp'); defined('ROUTE_LOGIN_B') OR define('ROUTE_LOGIN_B', 'getSalesPDReportforCETApp'); defined('ROUTE_LOGIN_A') OR define('ROUTE_LOGIN_A', 'getAuditedImages'); // no errors From e2af91b3fe86335ff9620b664de0c605a9204104 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 15:52:25 +0530 Subject: [PATCH 018/132] applicant name in flyhi : ps --- api/application/controllers/Flyhi_Controller.php | 10 +++++----- api/application/views/sale_pd_templates/FHFSL.php | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index e32a7865..a5223cda 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1285,6 +1285,10 @@ class Flyhi_Controller extends REST_Controller { if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') { $product_id = $g_value['answer_value']; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') + { + $applicant_name = $g_value['applicant_name']; } if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') { @@ -1304,10 +1308,6 @@ class Flyhi_Controller extends REST_Controller { $city = $j_value['answer_value']; $flyhi_pd_type = 3; } - // if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') - // { - // $applicant_name = $j_value['answer_value']; - // } } } } @@ -1317,7 +1317,7 @@ class Flyhi_Controller extends REST_Controller { } } - + $FLYHI_PD['applicant_name'] = $applicant_name; $FLYHI_PD['applicant_id'] = $applicant_id; $FLYHI_PD['city_id']=$city; $FLYHI_PD['loan_amount'] = $loan_amount; diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index c1049904..ba5de205 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -185,6 +185,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); + + + + + + + + From 225574e1c10ae69e27909f8ff2fb1b2221713160 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 17:03:13 +0530 Subject: [PATCH 019/132] type : ps --- api/application/controllers/Flyhi_Controller.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a5223cda..5db3ce3d 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -225,7 +225,7 @@ class Flyhi_Controller extends REST_Controller { $order_by = 'SALES_PD_DATA.sales_pd_id'; $Flyhi_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); - //print_r($this->db->last_query());die(); + // print_r($this->db->last_query());die(); if(count($Flyhi_pd_data)) { @@ -312,6 +312,13 @@ class Flyhi_Controller extends REST_Controller { { $product_id = $g_value['answer_value']; } + if($g_value['answer_value'] == 'Residence verification'){ + $flyhi_pd_type = 4; + } + if($g_value['answer_value'] == 'Office verification'){ + $flyhi_pd_type = 3; + } + if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') { if(isset($g_value['onchange_properties'])) From 57e797ede00efcfee6272ea5b91dfdee60f00f2b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 18 Jun 2022 17:25:49 +0530 Subject: [PATCH 020/132] type : 2 --- .../controllers/Flyhi_Controller.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 5db3ce3d..3f16c3ca 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -312,12 +312,6 @@ class Flyhi_Controller extends REST_Controller { { $product_id = $g_value['answer_value']; } - if($g_value['answer_value'] == 'Residence verification'){ - $flyhi_pd_type = 4; - } - if($g_value['answer_value'] == 'Office verification'){ - $flyhi_pd_type = 3; - } if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') { @@ -337,10 +331,7 @@ class Flyhi_Controller extends REST_Controller { $city = $j_value['answer_value']; $flyhi_pd_type = 3; } - if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') - { - $applicant_name = $j_value['answer_value']; - } + } } } @@ -1297,6 +1288,12 @@ class Flyhi_Controller extends REST_Controller { { $applicant_name = $g_value['applicant_name']; } + if($g_value['answer_value'] == 'Residence verification'){ + $flyhi_pd_type = 4; + } + if($g_value['answer_value'] == 'Office verification'){ + $flyhi_pd_type = 3; + } if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') { if(isset($g_value['onchange_properties'])) @@ -1309,11 +1306,9 @@ class Flyhi_Controller extends REST_Controller { { if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ $city = $j_value['answer_value']; - $flyhi_pd_type = 4; } if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ $city = $j_value['answer_value']; - $flyhi_pd_type = 3; } } } From b6754ed404655730a4ee324a575cd750325ad109 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 23 Jun 2022 22:30:33 +0530 Subject: [PATCH 021/132] Code Committed : ps --- api/application/config/routes.php | 5 + .../controllers/Flyhi_Controller.php | 440 +++++++++++++++++- 2 files changed, 443 insertions(+), 2 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index a27daeb8..c39f11f8 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -389,5 +389,10 @@ $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; +$route['saveCusFlyhiVideo'] = 'Flyhi_Controller/saveCusFlyhiVideo'; +$route['getFlyhiVideoURL'] = 'Flyhi_Controller/getFlyhiVideoURL'; +$route['deleteFlyhiVideo'] = 'Flyhi_Controller/deleteFlyhiVideo'; +$route['uploadFlyhiVideoFile'] = 'Flyhi_Controller/uploadFlyhiVideoFile'; +$route['updateTwlioFlyhiVideoStatus'] = 'Flyhi_Controller/updateTwlioFlyhiVideoStatus'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 3f16c3ca..ceb52c54 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -11,12 +11,15 @@ class Flyhi_Controller extends REST_Controller { parent::__construct(); $this->load->model('Flyhi_Model','Flyhi_Model'); $this->load->library('AWS_S3'); + $this->load->library('AWS_COGNITO'); + $this->load->library('AWS_SNS'); $this->load->library('pdfgenerator'); $this->load->helper('satellite_image'); $this->load->helper('camunda'); $this->external_path = $this->config->item('external_data_path'); - - + $this->load->helper('MYUTIL'); + $this->load->helper('faceapi'); + $this->load->library('phpmailer_library'); } public function getMasterForFlyhiPD_get(){ $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); @@ -1362,5 +1365,438 @@ class Flyhi_Controller extends REST_Controller { } } + public function saveCusFlyhiVideo_post() + { + + $records = json_decode($this->post('records'),true); + $id = null; + //log_message('ERROR','hi'); + // print_r($records); + // print_r($_FILES); + // die(); + + + if(!empty($_FILES['video_file'])) + { + $pd_master_details = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['pd_id']),SALES_PD_DATA); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['lender_id']; + $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; + $file_name_wo_extension = explode('.', ($records['filename']))[0]; + $file_type = explode('/', ($_FILES['video_file']['type']))[1]; + $folder_to_check = XLPATH.'/sales_pd/'.$records['pd_id'].'/videos'; + //echo $folder_to_check;//die(); + if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/sales_pd/'.$records['pd_id'],0777); mkdir($folder_to_check,0777); } + //die(); + $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $file_name_wo_extension.'.'.$file_type); + $this->load->library('upload', $config); + if($this->upload->do_upload('video_file')) + { + $upload_data = $this->upload->data(); + //$this->load->view('upload_success',$data); + //print_r($upload_data); + + $command_to_execute = FFMPEG_PATH.' -i '.$folder_to_check.'/'.$file_name_wo_extension.'.'.$file_type.' '.$folder_to_check.'/'.$file_name_wo_extension.'.mp4'.' 2>&1' ; + //print_r($command_to_execute);die(); + exec($command_to_execute,$o,$v); + // print_r($o); + // echo $command_to_execute;die(); + if($o) + { + $sourcefile = $folder_to_check.'/'.$file_name_wo_extension.'.mp4'; + + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + // print_r($s3result); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); + $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key'],'flyhi_pd_flag'=>$records['flyhi_pd_flag']); + $id = $this->Flyhi_Model->saveRecords($record_data,CUS_VIDEO); + unlink($folder_to_check.'/'.$file_name_wo_extension.'.webm'); + unlink($folder_to_check.'/'.$file_name_wo_extension.'.mp4'); + + } + + // if it is last part of a video call, then call video merge functionality + if(isset($records['is_call_ended']) && $records['is_call_ended'] == 1) + { + $final_video_name = $records['pd_id'].'-'.$records['video_key']; + sleep(10); + $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key']); + } + + + if($id != null || $id != "") + { + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Video Saved Successfully'; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data,REST_Controller::HTTP_OK); + } + + + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Image found to upload'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + + //merge all splitted videos + public function getFlyhiVideoURL_post() + { + $pd_id = $this->post('pd_id'); + $random_string = $this->post('random_string'); + $this->load->helper('video_grabber_helper'); + $pd_master_details = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA); + + $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['sales_pd_id'],$pd_master_details[0]['rand_string'],$pd_master_details); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + + + } + + // To Inactive Video Recorded. + public function deleteFlyhiVideo_get(){ + $id = $this->get('id'); + // $id = (int) $id; + // if(!empty($id)){ + // // $multipleWhere['fk_pd_id'] = $multipleWhere['pd_id']; + // // unset($multipleWhere['pd_id']); + $this->load->helper('video_grabber_helper'); + $result_data = (new video_grabber_helper)->deleteVideo($id); + // }else{ + // $result_data = "ID Not Available. Unable to Delete"; + // } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = $result_data ; + $this->response($data,REST_Controller::HTTP_OK); + } + + function updateTwlioFlyhiVideoStatus_post() + { + $pd_id = $this->post('pd_id'); + $random_string = $this->post('random_string'); + $room_id = $this->post('room_id'); + + $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + + + } + + function getTwiloVideoStatus($pd_id,$random_string,$room_id = '') + { + $this->load->library('twlio'); + $result_data = 0; + // $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;"; + $pd_master_details = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA); + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0";// and twilo_status = 'enqueued' and composition_id is not null;"; + if($room_id) + { + $query .=" and room_id = '$room_id'"; + } + $video_info = $this->db->query($query); + if($video_info->num_rows()) + { + $video_info = $video_info->result_array(); + //print_r($video_info);die(); + foreach ($video_info as $key => $value) + { + + if($value['composition_id'] && $value['vps'] != 'google') + { + $res = $this->twlio->getCompositionStatus($value['composition_id']); + //echo $res['status']; + if(count($res) && $res['status'] == 'completed') + { + + $is_copied = $this->copyMediaFromTwiloToS3($pd_master_details,$value);// copy media from twlio s3 to our s3 + $fields_to_update = array('twilo_status' => 'completed'); + if($is_copied) { $fields_to_update['s3_copied'] = 1; } + $id = $this->Flyhi_Model->updateRecords($fields_to_update,VIDEO_ROOM_INFO,array('video_room_info_id' => $value['video_room_info_id'])); + + if($id){ if($room_id) {$result_data = $is_copied;}else{$result_data++ ;}} + + } + } + else + { + $room_status = $this->twlio->getRoomDataByRoomID($value['room_id']); + if($room_status == 'completed') + { + $composition_result_data = $this->twlio->startComposistion($value['room_id']); + // $composition_result_data = $this->twlio->startComposistion('RM23b8d502434e46e696d1fbd5d64c59c8'); + // print_r($composition_result_data); + $composition_result_data_json = json_encode($composition_result_data); + // print_r($composition_result_data_json); + $records['res_json'] = $composition_result_data_json; + $records['twilo_status'] = $composition_result_data['status']; + $records['composition_id'] = $composition_result_data['compositionId']; + $records['is_call_ended'] = 1; + $records['flyhi_pd_flag'] = 1; + $where_condition_array = array('fk_pd_id' => $pd_id); + if($value['room_id']){ $where_condition_array['room_id'] = $value['room_id']; } + $id = $this->Flyhi_Model->updateRecords($records,VIDEO_ROOM_INFO,$where_condition_array); + } + } + + } + + } + return $result_data; + } + + function copyMediaFromTwiloToS3($pd_master_details,$value)// copy media from twlio s3 to our s3 + { + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['sales_pd_id']); + //get media uri from twlio + $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); + //echo $singed_uri; + $internal_server_tmp_location = XLPATH.'/sales_pd/'.$pd_master_details[0]['sales_pd_id'].'/videos'; + $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); + //echo $internal_server_tmp_location; + if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location); }; + $is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri)); + //upload it to aws s3 + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['lender_id']; + $final_key = 'pd'.$pd_master_details[0]['sales_pd_id'].'/video/'.$value['composition_id'].'.mp4'; + + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($internal_server_tmp_location_filename)); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + log_message('ERROR','###TWLIO TO S3 STARTED'.$value['composition_id']); + + unlink($internal_server_tmp_location_filename); + return $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+7 days'); + //unlink($folder_to_check.'/'.$final_video_name.'.mp4'); + } + return null; + + + } + + function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key) + { + // $pd_id = $this->post('pd_id'); + // $random_string = $this->post('random_string'); + //$final_video_name = $pd_id.'-'.$random_string; + + //echo $final_video_name;die(); + //Get PD master DEtails + //$pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + //$is_video_merged = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'video_part_name' => $final_video_name),CUS_VIDEO); + //prit_r($pd_master_details);die(); + // if(count($pd_master_details) && isset($pd_master_details[0]['pd_id'])) + // { + + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['lender_id']; + $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$final_video_name.'.mp4'; + + //Get all video info + $qu = "SELECT *,convert(substr(substring_index(video_part_name,'-',1),6),UNSIGNED INTEGER) as sno FROM t_cus_video + where fk_pd_id = $pd_id and video_key = '$video_key' and is_active = 1 and flyhi_pd_flag = 1 order by sno"; + + $video_info = $this->db->query($qu)->result_array(); + $folder_to_check = XLPATH.'/sales_pd/'.$pd_id.'/videos'; + $file_list = $folder_to_check.'/filelist.txt'; + + //Get All video and temp store it in xlpath + $file_pointer = fopen($file_list, 'w+'); + $all_input_files_names_with_path = ''; + foreach ($video_info as $video_info_key => $video_info_value) + { + $key = 'pd'.$pd_id.'/video/'.$video_info_value['video_part_name']; + $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+10 minutes'); + $file_to_create = $folder_to_check.'/'.$video_info_value['video_part_name']; + $output = file_put_contents($file_to_create,file_get_contents($temp_uri)); + if($output) + { + + $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; + + //fwrite($file_pointer,"file "."'".$file_name_wo_extension.".mp4"."'\n"); + fwrite($file_pointer,"file "."'".$file_name_wo_extension."'\n"); + } + } + fclose($file_pointer); + // echo '***************************************';//die(); + + $merge_cmd = FFMPEG_PATH.' -f concat -safe 0 -i '.$folder_to_check.'/'.'filelist.txt -c copy '.$folder_to_check.'/'.$final_video_name.'.mp4 2>&1'; + //echo '#########################################'; + //echo $merge_cmd;//die(); + exec($merge_cmd,$ou,$v); + //print_r($ou);//die(); + if($ou && file_exists($folder_to_check.'/'.$final_video_name.'.mp4')) + { + //echo 'upload to s3'; + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($folder_to_check.'/'.$final_video_name.'.mp4')); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + log_message('ERROR','###PDVIDEO merged video stored in S3'.$pd_id); + $record_data = array('is_video_merged' => 1); + //$id = $this->PD_Model->updateRecords($record_data,PDTRIGGER,array('pd_id' => $pd_id)); + $id = 1; + unlink($folder_to_check.'/'.$final_video_name.'.mp4'); + + } + + foreach($video_info as $video_info_key => $video_info_value) + { + $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; + //unlink($folder_to_check.'/'.$file_name_wo_extension.'.ts'); + unlink($folder_to_check.'/'.$file_name_wo_extension); + } + + + // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['url'] = $singed_uri; + // $this->response($data,REST_Controller::HTTP_OK); + + + } + else + { + log_message('ERROR','###PDVIDEO merged video not stored in S3'.$pd_id); + } + + + + + + + } + + public function uploadFlyhiVideoFile_post() + { + $records = json_decode($this->post('records'),true); + // $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); + $pd_master_details = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['fk_pd_id'],'rand_string'=>$records['random_string']),SALES_PD_DATA); + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['lender_id']; + // echo XLPATH; + // print_r($records);die(); + // print_r($pd_master_details);die(); + $is_bucket_upload_sucess = false; + $id = null; + //die(); + if(!empty($_FILES['video_file'])) + { + $folder_to_check = XLPATH.'/sales_pd/'.$records['fk_pd_id'].'/videos'; + + if(!file_exists($folder_to_check)) + { + mkdir($folder_to_check,0777); + } + // die(); + // $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name'])); + $modified_fname = str_replace(' ','_',($_FILES['video_file']['name'])); + // echo file_exists($folder_to_check);die(); + + $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $modified_fname); + + $this->load->library('upload', $config); + $this->upload->initialize($config); + + + try { + + + if($this->upload->do_upload('video_file')) + { + log_message('ERROR','video uplaod done :' . $folder_to_check); + $sourcefile = $folder_to_check.'/'.$modified_fname; + // echo $sourcefile; + $key = 'pd'.$records['fk_pd_id'].'/video/'.$modified_fname; + + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$sourcefile); + // print_r($bucket_data);die(); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result);die(); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $is_bucket_upload_sucess = 1; + $id = $this->PD_Model->saveRecords(array('fk_pd_id' =>$records['fk_pd_id'],'room_id' => $modified_fname,'composition_id' => $modified_fname,'twilo_status' => 'completed','is_call_ended' => 1,'s3_copied' => 1,'is_uploaded' => 1,'flyhi_pd_flag'=>1),VIDEO_ROOM_INFO); + unlink($sourcefile); + } + } + else + { + log_message('ERROR','video uplaod failed :' . $folder_to_check); + } + + } catch (Exception $e) { + log_message('ERROR','video uplaod failed exception:' . $folder_to_check.' - '.$e->getMessage()); + } + // die(); + + if($is_bucket_upload_sucess && $id) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'File Uploaded Successfully'; + // $data['excel_file_id'] = $id; + // $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Data File Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + }// Class Ends From 4c56e8e182810f916807026ea647e9cb7045dd4c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 25 Jun 2022 12:56:10 +0530 Subject: [PATCH 022/132] FLYHI Save Api Chnaged to new format :ps --- .../controllers/Flyhi_Controller.php | 128 +++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index ceb52c54..8ac18465 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1224,7 +1224,7 @@ class Flyhi_Controller extends REST_Controller { } - public function saveFlyhiPDsection_post() + public function saveFlyhiPDsection_Aspersalespdtype_post() { $records = $this->post('records'); $sales_pd_id = $records['sales_pd_id']; @@ -1365,6 +1365,132 @@ class Flyhi_Controller extends REST_Controller { } } + public function saveFlyhiPDsection_post() + { + $records = $this->post('records'); + $sales_pd_id = $records['sales_pd_id']; + $section_id = $records['section_id']; + $fk_createdby = $records['fk_createdby']; + $status = $records['is_complete']; + $section_data = json_encode($records); + + //Get Sales PD master Data + + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + array('table' => PRODUCTS. ' as PRODUCT', + 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + 'jointype' => 'INNER') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); + $sales_pd_master_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); +// print_r($records['json']); + //pre process works + switch($section_id) + { + case 1: //General section + //update Applicant ID and applicant Name to sales pD master Table + $applicant_id = null ; $city = null; $lender_id= null;$loan_amount = null; + $pd_branch_id = null ; $lender_sales_person =null; $lender_credit_person =null; + $flyhi_pd_type = null; $applicant_name =null;$current_resd_addr_check = 0 ; + if($records['json']) + { + foreach ($records['json'] as $g_key => $g_value) + { + + if($g_key == 'loan_application_id'){ + $applicant_id = (!empty($g_value)) ? $g_value : 'Not Provided'; + } + if($g_key == 'lender_name'){ + $lender_id = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'loan_amount'){ + $loan_amount = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'branch'){ + $pd_branch_id = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'lender_sales_person'){ + $lender_sales_person = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'lender_credit_person'){ + $lender_credit_person = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'product_name'){ + $product_id = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'applicant_name'){ + $applicant_name = (!empty($g_value)) ? $g_value : null ; + } + if($g_key == 'verification_type' && $g_value == 'Residence verification'){ + $flyhi_pd_type = 4; + } + if($g_key == 'verification_type' && $g_value == 'Office verification'){ + $flyhi_pd_type = 3; + } + if($g_key == 'Same_as_current_residence_address' && $g_value == 'NO'){ + $current_resd_addr_check = 1; + } + if($current_resd_addr_check && $g_key == 'permanent_city'){ + $city = $g_value; + }else if($g_key == 'residence_details'){ + $city = $g_value[0]['residence_city']; + } + if($g_key == 'officer_city'){ + $city = $g_value; + } + + } + + } + $FLYHI_PD['applicant_name'] = $applicant_name; + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['sales_pd_type'] = $flyhi_pd_type; + $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); + $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + + + break; + + case 9: //photosection + break; + + default: + } + + //make inactive previous records + $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$sales_pd_id,'section_id' => $section_id )); + + //insert new record + $fields = array('sales_pd_id' => $sales_pd_id, 'section_id' => $section_id, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); + $is_entry_created = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); + if($is_entry_created) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $is_entry_created; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + public function saveCusFlyhiVideo_post() { From 1249f11e5cf851d0f37f19e51704deb3fe165b15 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 25 Jun 2022 18:53:19 +0530 Subject: [PATCH 023/132] code moved : ps --- .../controllers/Flyhi_Controller.php | 187 +++++++++++++++++- 1 file changed, 183 insertions(+), 4 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 8ac18465..230ce979 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -704,7 +704,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - // echo $html_content;die(); + echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; @@ -766,9 +766,188 @@ class Flyhi_Controller extends REST_Controller { if($section_array['section_id']) { $questions = json_decode($section_array['section_data'],true); - return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); + return $this->processFlyhiPDData($questions['json'],$section_array['section_id']); + // return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); } } + function processFlyhiPDData($questions,$section_id){ + $temp_array = array(); + foreach ($questions as $ques_key => $ques_value) { + if($ques_key == 'permanent_state' && !empty($ques_value)){ + + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + }if($ques_key == 'business_state' && !empty($ques_value)){ + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + }if($ques_key == 'officer_state' && !empty($ques_value)){ + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'permanent_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + }if($ques_key == 'business_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + }if($ques_key == 'officer_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'business_pincode' && $ques_value != "1"){ + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + + }if($ques_key == 'business_pincode_others' && $ques_value == "1"){ + $new_key = 'business_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'permanent_pincode' && $ques_value != "1"){ + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + }if($ques_key == 'permanent_pincode_others' && $ques_value == "1"){ + $new_key = $ques_key . 'permanent_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'officer_pincode' && $ques_value != "1"){ + // residence_pincode: "1" + // residence_pincode_others: "600016" + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + }if($ques_key == 'officer_pincode_others'){ + $new_key = 'officer_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'lender_name'){ + $table = ENTITY; + $fields = array('full_name','short_name'); + $where_condition_array = array('entity_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['full_name']; + $questions["lender_abbr"] = $result_data[0]['short_name']; + } + } + if($ques_key == 'branch'){ + + $table = ENTITYLENDERBRANCH; + $fields = array('branch_name as name'); + $where_condition_array = array('entity_lender_branch_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'lender_sales_person'){ + $table = USERPROFILE; + $fields = array('concat(first_name," ",last_name) as name'); + $where_condition_array = array('userid'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + } + if($ques_key == 'lender_credit_person'){ + $table = USERPROFILE; + $fields = array('concat(first_name," ",last_name) as name'); + $where_condition_array = array('userid'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'product_name'){ + $table = PRODUCTS; + $fields = array('name'); + $where_condition_array = array('product_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'residence_details'){ + + } + + } + print_r($questions);die(); + } function processFlyhiPDQuestions($questions,$section_id) { @@ -1053,8 +1232,8 @@ class Flyhi_Controller extends REST_Controller { $records = $this->post('records'); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $lender = $records['lender_id'] ? $records['lender_id'] : $FHFSL_lender; - $product = $records['product_id'] ? $records['product_id'] : $FHFSL_product; + $lender = isset($records['lender_id']) ? $records['lender_id'] : $FHFSL_lender; + $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; $id = null; // print_r($records);//die(); log_message('ERROR','####FLYHIPD SAVE CALLED'); From 7e5be8746e4b5b99035c7f6a18c827d6e4505223 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 25 Jun 2022 20:28:41 +0530 Subject: [PATCH 024/132] Flyhi Report Completed : ps --- .../controllers/Flyhi_Controller.php | 53 ++++++++++++++-- .../views/sale_pd_templates/FHFSL.php | 61 ++++++++++--------- 2 files changed, 80 insertions(+), 34 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 230ce979..8bf371ee 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -694,6 +694,7 @@ class Flyhi_Controller extends REST_Controller { // print_r($section['section_id']);die(); // log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$pd_id); $view_data['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section);//die(); + // print_r($view_data['section'.$section['section_id'] ]);die; $section_fields['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section); } $view_data['section9'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); @@ -704,7 +705,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - echo $html_content;die(); + // echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; @@ -846,7 +847,7 @@ class Flyhi_Controller extends REST_Controller { if(count($result_data)) { $new_key = $ques_key . '_master'; - $questions[$new_key] = $result_data[0]['pincode']; + $questions[$new_key] = $ques_value; } }if($ques_key == 'business_pincode_others' && $ques_value == "1"){ @@ -865,7 +866,7 @@ class Flyhi_Controller extends REST_Controller { } }if($ques_key == 'permanent_pincode_others' && $ques_value == "1"){ $new_key = $ques_key . 'permanent_pincode_master'; - $questions[$new_key] = $result_data[0]['pincode']; + $questions[$new_key] = $ques_value; } if($ques_key == 'officer_pincode' && $ques_value != "1"){ // residence_pincode: "1" @@ -881,7 +882,7 @@ class Flyhi_Controller extends REST_Controller { } }if($ques_key == 'officer_pincode_others'){ $new_key = 'officer_pincode_master'; - $questions[$new_key] = $result_data[0]['pincode']; + $questions[$new_key] = $ques_value; } if($ques_key == 'lender_name'){ $table = ENTITY; @@ -942,11 +943,51 @@ class Flyhi_Controller extends REST_Controller { } } if($ques_key == 'residence_details'){ - + for($i=0;$i 1,'state_id'=>$ques_value[$i]['residence_state']); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + $new_key = 'residence_state_master'; + if(count($result_data)) + { + $questions[$ques_key][$i][$new_key] = $result_data[0]['name']; + }else{ + $questions[$ques_key][$i][$new_key] = 'name'; + } + } + if(isset($ques_value[$i]['residence_city'])){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value[$i]['residence_city']); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + $new_key = 'residence_city_master'; + if(count($result_data)) + { + $questions[$ques_key][$i][$new_key] = $result_data[0]['name']; + } + } + if(isset($ques_value[$i]['residence_pincode'])){ + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value[$i]['residence_pincode']); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + $new_key = 'residence_pincode_master'; + if(count($result_data)) + { + $questions[$ques_key][$i][$new_key] = $result_data[0]['pincode']; + } + } + if(isset($ques_value[$i]['residence_pincode_others'])){ + $new_key = 'residence_pincode_master'; + $questions[$ques_key][$i][$new_key] = $ques_value[$i]['residence_pincode_others']; + } + } } } - print_r($questions);die(); + return $questions; } function processFlyhiPDQuestions($questions,$section_id) diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index ba5de205..f3c5866d 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -159,43 +159,43 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + - + - + - + - + - + - + - + - + - +
'.$section2[$i]['img_name'].'
'.$photo_names [ $section2[$i]['img_name'] ].'
'.$section9[$i]['img_name'].'
'.$photo_names [ $section9[$i]['img_name'] ].'
Loan Amount Applied for (Rs)
Application Name
Application Mobile Number
Verification Type
Lender Name
Branch
Application ID
Lender sales Person
Lender credit Person
Product Name
Loan Amount Applied for (Rs)
Application Name
Application Mobile Number
Verification Type
@@ -205,25 +205,30 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Residence Details + - Address Details - + Address Details + City - + State - + PIN - + + + Residence Ownership - + Years at current Residence - + Same as current residence address @@ -236,11 +241,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); City - + State - + PIN - + @@ -267,15 +272,15 @@ defined('BASEPATH') OR exit('No direct script access allowed'); City - + State - + PIN - + Occupation of the loan applicant - + Employer/Business Name @@ -292,16 +297,16 @@ defined('BASEPATH') OR exit('No direct script access allowed'); --> City - + State - + PIN - + Constitution of Employer /Business applicant - + Years at Current employment/Business From 623163da664155555b3ba84e29b353ca9cba828b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 25 Jun 2022 22:37:17 +0530 Subject: [PATCH 025/132] Video API for FLyhi : ps --- api/application/controllers/PD_Controller.php | 57 +++++++++++++------ .../helpers/video_grabber_helper.php | 9 ++- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 224505e1..5a53f62f 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -10085,17 +10085,24 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // print_r($_FILES); // die(); - + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $lender_id = $records['pd_category'] == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $file_folder = $records['pd_category'] == "2" ? "sales_pd" : "pd_reports" ; if(!empty($_FILES['video_file'])) { - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); + + if($pd_category == '2'){ + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + if($pd_category == '1'){ + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']);} + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; $file_name_wo_extension = explode('.', ($records['filename']))[0]; $file_type = explode('/', ($_FILES['video_file']['type']))[1]; - $folder_to_check = XLPATH.'/pd_reports/'.$records['pd_id'].'/videos'; + $folder_to_check = XLPATH.'/'.$file_folder.'/'.$records['pd_id'].'/videos'; //echo $folder_to_check;//die(); - if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/pd_reports/'.$records['pd_id'],0777); mkdir($folder_to_check,0777); } + if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/'.$file_folder.'/'.$records['pd_id'],0777); mkdir($folder_to_check,0777); } //die(); $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $file_name_wo_extension.'.'.$file_type); $this->load->library('upload', $config); @@ -10120,7 +10127,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); - $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key']); + $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key'],'pd_category'=>$pd_category); $id = $this->PD_Model->saveRecords($record_data,CUS_VIDEO); unlink($folder_to_check.'/'.$file_name_wo_extension.'.webm'); unlink($folder_to_check.'/'.$file_name_wo_extension.'.mp4'); @@ -10132,7 +10139,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $final_video_name = $records['pd_id'].'-'.$records['video_key']; sleep(10); - $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key']); + $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key'],$pd_category); } @@ -10187,9 +10194,13 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $pd_id = $this->post('pd_id'); $random_string = $this->post('random_string'); + $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; $this->load->helper('video_grabber_helper'); + if($pd_category == '1'){//normal Credit PD; $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details); + }if($pd_category == '2'){//Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details,$pd_category); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; @@ -10222,8 +10233,9 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $pd_id = $this->post('pd_id'); $random_string = $this->post('random_string'); $room_id = $this->post('room_id'); + $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; - $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id); + $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id,$pd_category); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; @@ -10233,13 +10245,13 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } - function getTwiloVideoStatus($pd_id,$random_string,$room_id = '') + function getTwiloVideoStatus($pd_id,$random_string,$room_id = '',$pd_category) { $this->load->library('twlio'); $result_data = 0; // $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;"; $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0";// and twilo_status = 'enqueued' and composition_id is not null;"; + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0 and pd_category = $pd_category";// and twilo_status = 'enqueued' and composition_id is not null;"; if($room_id) { $query .=" and room_id = '$room_id'"; @@ -10294,19 +10306,21 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() return $result_data; } - function copyMediaFromTwiloToS3($pd_master_details,$value)// copy media from twlio s3 to our s3 + function copyMediaFromTwiloToS3($pd_master_details,$value,$pd_catgory)// copy media from twlio s3 to our s3 { EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id']); //get media uri from twlio $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); //echo $singed_uri; - $internal_server_tmp_location = XLPATH.'/pd_reports/'.$pd_master_details[0]['pd_id'].'/videos'; + $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ; + $lender_id = $pd_catgory == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); //echo $internal_server_tmp_location; if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location); }; $is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri)); //upload it to aws s3 - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$value['composition_id'].'.mp4'; $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($internal_server_tmp_location_filename)); @@ -10324,8 +10338,10 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } - function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key) + function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key,$pd_category) { + $pd_category = $pd_category ? $pd_category : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; // $pd_id = $this->post('pd_id'); // $random_string = $this->post('random_string'); //$final_video_name = $pd_id.'-'.$random_string; @@ -10346,7 +10362,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() where fk_pd_id = $pd_id and video_key = '$video_key' and is_active = 1 order by sno"; $video_info = $this->db->query($qu)->result_array(); - $folder_to_check = XLPATH.'/pd_reports/'.$pd_id.'/videos'; + $folder_to_check = XLPATH.'/'.$file_folder.'/'.$pd_id.'/videos'; $file_list = $folder_to_check.'/filelist.txt'; //Get All video and temp store it in xlpath @@ -11485,7 +11501,14 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function uploadVideoFile_post() { $records = json_decode($this->post('records'),true); - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; + if($pd_category == '1'){//normal Credit PD; + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); + }if($pd_category == '2'){//Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $records['fk_pd_id'],'rand_string'=>$records['random_string']),SALES_PD_DATA); + } + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; // echo XLPATH; // print_r($records);die(); @@ -11495,7 +11518,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() //die(); if(!empty($_FILES['video_file'])) { - $folder_to_check = XLPATH.'/pd_reports/'.$records['fk_pd_id'].'/videos'; + $folder_to_check = XLPATH.'/'.$file_folder.'/'.$records['fk_pd_id'].'/videos'; if(!file_exists($folder_to_check)) { diff --git a/api/application/helpers/video_grabber_helper.php b/api/application/helpers/video_grabber_helper.php index 58d8ca72..beca56e4 100644 --- a/api/application/helpers/video_grabber_helper.php +++ b/api/application/helpers/video_grabber_helper.php @@ -9,19 +9,22 @@ class video_grabber_helper } - public function grabAllVideo($pdid,$random_string,$pd_master_details = array()) + public function grabAllVideo($pdid,$random_string,$pd_master_details = array(),$pd_category) { $CI =&get_instance(); // $CI->load->helper('url_shortener'); if(!count($pd_master_details)) { - $pd_master_details = $CI->PD_Model->getPDMasterDetails($pd_id,$random_string); + if($pd_category == '2'){ + $pd_master_details = $CI->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} + if($pd_category == '1'){ + $pd_master_details = $CI->PD_Model->getPDMasterDetails($pd_id,$random_string);} } $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; $result_data = array(); - $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1"; + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1 and pd_category = $pd_category"; $video_info = $CI->db->query($query); // print_r($video_info->result_array());die(); if($video_info->num_rows()) From 473082cd8bcb6b83942e11c6a2a95845d17c3bb2 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 27 Jun 2022 04:46:44 +0000 Subject: [PATCH 026/132] Flyhi_Controller : ps --- api/application/controllers/Flyhi_Controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 8bf371ee..94d689a1 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1275,6 +1275,9 @@ class Flyhi_Controller extends REST_Controller { $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); $lender = isset($records['lender_id']) ? $records['lender_id'] : $FHFSL_lender; $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; + $records['lender_id'] = $lender; + $records['product_id'] = $product; + $records['sales_pd_type'] = null; $id = null; // print_r($records);//die(); log_message('ERROR','####FLYHIPD SAVE CALLED'); From de4045a55ef2763941295e0211dc4da7a6f11fd5 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 27 Jun 2022 05:02:59 +0000 Subject: [PATCH 027/132] Flyhi_Controller : ps --- api/application/controllers/Flyhi_Controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 94d689a1..83febb0e 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1277,7 +1277,6 @@ class Flyhi_Controller extends REST_Controller { $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; $records['lender_id'] = $lender; $records['product_id'] = $product; - $records['sales_pd_type'] = null; $id = null; // print_r($records);//die(); log_message('ERROR','####FLYHIPD SAVE CALLED'); From 98d9ea4a1dc349ab5f6654b45ed3905aa01b65e8 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 27 Jun 2022 22:03:05 +0530 Subject: [PATCH 028/132] Review Changes DOn e: ps --- api/application/config/routes.php | 7 ---- .../controllers/Flyhi_Controller.php | 40 ++++++++++++------- .../views/sale_pd_templates/FHFSL.php | 30 ++++++++------ 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index c39f11f8..1fee1767 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -389,10 +389,3 @@ $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; -$route['saveCusFlyhiVideo'] = 'Flyhi_Controller/saveCusFlyhiVideo'; -$route['getFlyhiVideoURL'] = 'Flyhi_Controller/getFlyhiVideoURL'; -$route['deleteFlyhiVideo'] = 'Flyhi_Controller/deleteFlyhiVideo'; -$route['uploadFlyhiVideoFile'] = 'Flyhi_Controller/uploadFlyhiVideoFile'; -$route['updateTwlioFlyhiVideoStatus'] = 'Flyhi_Controller/updateTwlioFlyhiVideoStatus'; - - diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 83febb0e..7344d13e 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -684,7 +684,7 @@ class Flyhi_Controller extends REST_Controller { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); - // print_r(json_decode($all_section_data[0]['section_data'],true));die(); + // print_r(json_decode($all_section_data[0]['json'],true));die(); $view_data['master'] = $flyhipd_data; $common_fields = array('pdid'=>$flyhipd_data[0]['sales_pd_id'], // 'product'=>$flyhipd_data[0]['abbr'], @@ -767,12 +767,16 @@ class Flyhi_Controller extends REST_Controller { if($section_array['section_id']) { $questions = json_decode($section_array['section_data'],true); + // echo "770"; + // print_r($questions['json']);die; return $this->processFlyhiPDData($questions['json'],$section_array['section_id']); // return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); } } function processFlyhiPDData($questions,$section_id){ + // print_r($questions);die(); $temp_array = array(); + if(!empty($questions)){ foreach ($questions as $ques_key => $ques_value) { if($ques_key == 'permanent_state' && !empty($ques_value)){ @@ -808,7 +812,7 @@ class Flyhi_Controller extends REST_Controller { $questions[$new_key] = $result_data[0]['name']; } } - if($ques_key == 'permanent_city'){ + if($ques_key == 'permanent_city' && !empty($ques_value)){ $table = CITY; $fields = array('name'); $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); @@ -818,7 +822,7 @@ class Flyhi_Controller extends REST_Controller { $new_key = $ques_key . '_master'; $questions[$new_key] = $result_data[0]['name']; } - }if($ques_key == 'business_city'){ + }if($ques_key == 'business_city' && !empty($ques_value)){ $table = CITY; $fields = array('name'); $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); @@ -828,7 +832,7 @@ class Flyhi_Controller extends REST_Controller { $new_key = $ques_key . '_master'; $questions[$new_key] = $result_data[0]['name']; } - }if($ques_key == 'officer_city'){ + }if($ques_key == 'officer_city' && !empty($ques_value)){ $table = CITY; $fields = array('name'); $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); @@ -884,7 +888,7 @@ class Flyhi_Controller extends REST_Controller { $new_key = 'officer_pincode_master'; $questions[$new_key] = $ques_value; } - if($ques_key == 'lender_name'){ + if($ques_key == 'lender_name' && !empty($ques_value)){ $table = ENTITY; $fields = array('full_name','short_name'); $where_condition_array = array('entity_id'=>$ques_value); @@ -896,7 +900,7 @@ class Flyhi_Controller extends REST_Controller { $questions["lender_abbr"] = $result_data[0]['short_name']; } } - if($ques_key == 'branch'){ + if($ques_key == 'branch' && !empty($ques_value)){ $table = ENTITYLENDERBRANCH; $fields = array('branch_name as name'); @@ -908,7 +912,7 @@ class Flyhi_Controller extends REST_Controller { $questions[$new_key] = $result_data[0]['name']; } } - if($ques_key == 'lender_sales_person'){ + if($ques_key == 'lender_sales_person' && !empty($ques_value)){ $table = USERPROFILE; $fields = array('concat(first_name," ",last_name) as name'); $where_condition_array = array('userid'=>$ques_value); @@ -920,7 +924,7 @@ class Flyhi_Controller extends REST_Controller { } } - if($ques_key == 'lender_credit_person'){ + if($ques_key == 'lender_credit_person' && !empty($ques_value)){ $table = USERPROFILE; $fields = array('concat(first_name," ",last_name) as name'); $where_condition_array = array('userid'=>$ques_value); @@ -931,7 +935,7 @@ class Flyhi_Controller extends REST_Controller { $questions[$new_key] = $result_data[0]['name']; } } - if($ques_key == 'product_name'){ + if($ques_key == 'product_name' && !empty($ques_value)){ $table = PRODUCTS; $fields = array('name'); $where_condition_array = array('product_id'=>$ques_value); @@ -942,7 +946,7 @@ class Flyhi_Controller extends REST_Controller { $questions[$new_key] = $result_data[0]['name']; } } - if($ques_key == 'residence_details'){ + if($ques_key == 'residence_details' && !empty($ques_value)){ for($i=0;$i array('is_multiple' => 0,'img_name' => 'Selfie of the person contacted')); + // $imgs = array('selfie_with_person_met' => array('is_multiple' => 0,'img_name' => 'Selfie of the person contacted')); + $imgs = array('selfie_with_person_met' => array('is_multiple' => 0,'img_name' => 'Selfie of the person contacted'),'name_board_seen' => array('is_multiple' => 1,'img_name' => 'Business Name Board'),'stock_image' => array('is_multiple' => 1,'img_name' => 'Stock Images'),'workplace_interior_image' => array('is_multiple' => 1,'img_name' => 'Work Place Interior')); $img_data = array(); @@ -1396,6 +1401,7 @@ class Flyhi_Controller extends REST_Controller { //CAMUNDA::completeSalesPDTask($records['sales_pd_id']); $this->prepareFlyhiPDReport($records['sales_pd_id'],false); + // die(); sleep(10); log_message('ERROR','####FlyHiPD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); @@ -1619,7 +1625,7 @@ class Flyhi_Controller extends REST_Controller { //update Applicant ID and applicant Name to sales pD master Table $applicant_id = null ; $city = null; $lender_id= null;$loan_amount = null; $pd_branch_id = null ; $lender_sales_person =null; $lender_credit_person =null; - $flyhi_pd_type = null; $applicant_name =null;$current_resd_addr_check = 0 ; + $flyhi_pd_type = null; $applicant_name =null;$current_resd_addr_check = 0 ; $current_office_addr_check = 0 ; if($records['json']) { foreach ($records['json'] as $g_key => $g_value) @@ -1663,8 +1669,14 @@ class Flyhi_Controller extends REST_Controller { }else if($g_key == 'residence_details'){ $city = $g_value[0]['residence_city']; } - if($g_key == 'officer_city'){ + + if($g_key == 'Same_as_current_business_address' && $g_value == 'NO'){ + $current_office_addr_check = 1; + } + if($current_office_addr_check && $g_key == 'business_city'){ $city = $g_value; + }else if($g_key == 'officer_city'){ + $city = $g_value; } } diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index f3c5866d..6644bcd7 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -170,11 +170,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Lender sales Person + Lender Sales Person - Lender credit Person + Lender Credit Person @@ -227,11 +227,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Years at current Residence - + Years at Current Residence + - Same as current residence address + Same as Current Residence Address @@ -249,7 +249,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Number of earning family member + Number of Earning Family Member @@ -279,18 +279,23 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Occupation of the loan applicant + Occupation of the Loan Applicant Employer/Business Name + + Same as Current Business Address + + + Employer/Business Address - + + - Constitution of Employer /Business applicant + Constitution of Employer /Business Applicant @@ -363,7 +368,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Duration of the course + Duration of the Course @@ -390,7 +395,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); ?> 'Selfie with person met','satellite1' => 'satellite'); + // $photo_names = array('selfie_with_person_met' => 'Selfie with person met','satellite1' => 'satellite'); + $photo_names = array('selfie_with_person_met' => 'Selfie with person met','approach_to_pd_location' => 'Approach to pd location','name_board_seen' => 'Name board seen', 'stock_image' => 'Stock image','workplace_interior_image' => 'Workplace interior image','satellite1' => 'satellite'); $tot_rows = ceil(count($section9) / 3); From f35d0bfe1a0364d972a2f845d4415e77577e2f6a Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 28 Jun 2022 21:02:11 +0530 Subject: [PATCH 029/132] color changes in report : ps --- api/application/controllers/Flyhi_Controller.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 7344d13e..606036c7 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -679,7 +679,8 @@ class Flyhi_Controller extends REST_Controller { mkdir($this->external_path.'/sales_pd/'.$pd_id,0777); } - if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) + // if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) + if(1) { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); @@ -705,7 +706,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - // echo $html_content;die(); + echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; From 2a94049647b48486579e1c26e36d674b44d6be2d Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 29 Jun 2022 11:12:43 +0530 Subject: [PATCH 030/132] Report Color Flyhi : ps --- api/application/views/sale_pd_templates/FHFSL.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 6644bcd7..a5db735a 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -88,7 +88,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); padding-top: 8px; padding-bottom: 8px; text-align: center; - background-color: #0191ed; + background-color: #0d93a9; color: white;page-break-inside: inline; } @@ -123,7 +123,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); padding-top: 8px; padding-bottom: 8px; text-align: center; - background-color: #0191ed; + background-color: #0d93a9; color: white;page-break-inside: avoid; } @@ -389,7 +389,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
Satellite Image of PD Location

GPS Coordinates of location where PD Visit was done :

- PD Visted Location Satellite Image + PD Visted Location Satellite Image Due to location access not provided by loan applicant Geo coordinates on photographs and Satellite image of PD location is not shown

';} ?> From 4452678bdc3594334f63b302827d576e1cb9f063 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 29 Jun 2022 10:49:34 +0000 Subject: [PATCH 031/132] html content : ps --- api/application/controllers/Flyhi_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 606036c7..3b0d0acf 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -706,7 +706,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - echo $html_content;die(); + //echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; From b0cd0ce7e0856e98af92e4a33020ee0c3aa50b5f Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 1 Jul 2022 10:38:06 +0530 Subject: [PATCH 032/132] sudhirbaranwal : ps --- api/application/controllers/PD_Controller.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 5a53f62f..9cca18f8 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -11629,7 +11629,9 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $pd_details['pd_status'] = ALLOCATED_TO_FIA; $pd_details['vendor_status'] = ALLOCATED; - PDALERTS::sendMWcreditPDMail($this,$pd_details,3); + $sudhirbaranwal = (ENVIRONMENT == 'production' ? 187 : 324); + if($pd_details['fk_pd_allocated_to'] != $sudhirbaranwal){ + PDALERTS::sendMWcreditPDMail($this,$pd_details,3);} } else if(count($regional_credit_manager)) { From 5eaa1741c9b50ad3d41c2ed5ea9a491cc822f2ae Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 5 Jul 2022 11:30:04 +0530 Subject: [PATCH 033/132] filterFlyPDList : ps --- api/application/config/routes.php | 1 + .../controllers/Flyhi_Controller.php | 27 ++++++++++++++++ api/application/models/Flyhi_Model.php | 31 +++++++++++-------- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 1fee1767..04c69189 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -389,3 +389,4 @@ $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD'; $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; +$route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 3b0d0acf..71c74368 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -21,6 +21,33 @@ class Flyhi_Controller extends REST_Controller { $this->load->helper('faceapi'); $this->load->library('phpmailer_library'); } + + public function filterFlyPDList_post() { + $records = $this->post('records'); + $pd_status= $records['pd_status']; + $pd_from_date = $records['pd_from_date']; + $pd_to_date = $records['pd_to_date']; + $pd_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $pd_products = isset($records['pd_products']) ? $records['pd_products'] : (ENVIRONMENT == 'production' ? 27 : 26) ; + $pd_applicant_name = strtolower($records['pd_applicant_name']); + $sales_pd_officer_id = isset($records['sales_pd_officer_id']) ? $records['sales_pd_officer_id'] : null ; + $sales_pd_type = isset($records['sales_pd_type']) ? $records['sales_pd_type'] : null ; + $result_data=$this->Flyhi_Model->getFlyPDListwithFilters($pd_status,$pd_from_date,$pd_to_date,$pd_products,$pd_lender,$pd_applicant_name,$sales_pd_officer_id,$sales_pd_type); + if(count($result_data)){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Records Found'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + public function getMasterForFlyhiPD_get(){ $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); diff --git a/api/application/models/Flyhi_Model.php b/api/application/models/Flyhi_Model.php index 90ba047f..b2e2e742 100644 --- a/api/application/models/Flyhi_Model.php +++ b/api/application/models/Flyhi_Model.php @@ -8,23 +8,31 @@ class Flyhi_Model extends SPARQ_Model { public function __construct() { parent::__construct(); } - public function getSalesPDListwithFilters($pd_status = '',$pd_from_date = '',$pd_to_date = '',$pd_products = '',$pd_lender = '',$pd_applicant_name = '',$pd_officer_name = '',$sales_pd_officer_id,$sales_pd_type = '') { + public function getFlyPDListwithFilters($pd_status = '',$pd_from_date = '',$pd_to_date = '',$pd_products = '',$pd_lender = '',$pd_applicant_name = '',$sales_pd_officer_id,$sales_pd_type = '') { // SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.short_name,PRODUCTS.abbr,DATE_FORMAT(SALES_PD_DATA.createdon, "%d/%m/%Y") as pd_createdon,SALES_PD_DATA.status - $this->db->SELECT(' SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.short_name,PRODUCTS.abbr, + $this->db->SELECT(' SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.full_name,ENTITY.short_name,PRODUCTS.abbr, (CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon, - DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string'); + DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string,SALES_PD_DATA.isactive,SALES_PD_DATA.city_id,CITY.name as city_name, + SALES_PD_DATA.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email, + SALES_PD_DATA.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email, + SALES_PD_DATA.pd_branch_id,ENTITYLENDERBRANCH.branch_name,SALES_PD_DATA.loan_amount'); $this->db->from(SALES_PD_DATA.' as SALES_PD_DATA'); $this->db->join(ENTITY.' as ENTITY','ENTITY.entity_id = SALES_PD_DATA.lender_id','INNER'); + $this->db->join(ENTITYLENDERBRANCH.' as ENTITYLENDERBRANCH','SALES_PD_DATA.pd_branch_id = ENTITYLENDERBRANCH.entity_lender_branch_id','LEFT'); $this->db->join(PRODUCTS.' as PRODUCTS', 'PRODUCTS.product_id = SALES_PD_DATA.product_id','INNER'); $this->db->join(USERPROFILE.' as USERPROFILE', 'USERPROFILE.userid = SALES_PD_DATA.createdby','INNER'); + $this->db->join(USERPROFILE.' as LENDERSALESPERSON', 'SALES_PD_DATA.lender_sales_person = LENDERSALESPERSON.userid','LEFT'); + $this->db->join(USERPROFILE.' as LENDERCREDITPERSON', 'SALES_PD_DATA.lender_credit_person = LENDERCREDITPERSON.userid','LEFT'); + $this->db->join(CITY.' as CITY', 'SALES_PD_DATA.city_id = CITY.city_id','LEFT'); +// echo $pd_from_date; if(!empty($pd_status)){ $this->db->where_in('SALES_PD_DATA.status',$pd_status); } if(($pd_from_date != "" || $pd_from_date != null) && ($pd_to_date != "" || $pd_to_date != null)) { // $this->db->where('SALES_PD_DATA.createdon BETWEEN '. "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); - if($pd_status[0] == "STARTED" ){ + if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); - }else if($pd_status[0] == "COMPLETED" ){ + }else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); }else{ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); @@ -33,9 +41,9 @@ class Flyhi_Model extends SPARQ_Model { } else if($pd_from_date != "" && $pd_from_date != null) { // $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); - if($pd_status[0] == "STARTED" ){ + if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); - }else if($pd_status[0] == "COMPLETED" ){ + }else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date); }else{ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date); @@ -44,9 +52,9 @@ class Flyhi_Model extends SPARQ_Model { } else if($pd_to_date != "" && $pd_to_date != null) { // $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); - if($pd_status[0] == "STARTED" ){ + if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); - }else if($pd_status[0] == "COMPLETED" ){ + }else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date); }else{ $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date); @@ -62,9 +70,6 @@ class Flyhi_Model extends SPARQ_Model { if(!empty($pd_applicant_name)) { $this->db->like('SALES_PD_DATA.applicant_name',$pd_applicant_name); } - if(!empty($pd_officer_name)) { - $this->db->like('SALES_PD_DATA.officer_name',$pd_officer_name); - } if(!empty($sales_pd_officer_id)) { $this->db->WHERE('SALES_PD_DATA.createdby',$sales_pd_officer_id); @@ -77,7 +82,7 @@ class Flyhi_Model extends SPARQ_Model { $this->db->limit(1000,0); $result = $this->db->get()->result_array(); // if(ENVIRONMENT == 'development'){echo 'LAST QUERY '. $this->db->last_query();} - //echo $this->db->last_query();die(); + // echo $this->db->last_query();die(); return $result; } public function testSaleSection($id){ From 8d69ff60adbc6b43e3b9c11f91902cc24361a14b Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Thu, 7 Jul 2022 09:05:20 +0000 Subject: [PATCH 034/132] argument missing fixes : ps --- api/application/controllers/Sales_PD_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index c391e5da..510b8030 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -257,7 +257,7 @@ class Sales_PD_Controller extends REST_Controller { $stt_fields = $common_fields; $stt_fields['img_name'] = $view_data['satellite_image'][0]['img_name']; $stt_fields['img'] = $view_data['satellite_image'][0]['img']; - cet_salespd::pushwithcetphotographapi($stt_fields); + cet_salespd::pushwithcetphotographapi($stt_fields,0); } $view_data['product_id'] = $sales_pd_data[0]['product_id']; $view_data['geo_location'] = $sales_pd_data[0]['geo_location']; From c188732cd9b7bc113f7be92da5e7a72c22476d0c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 9 Jul 2022 18:53:44 +0530 Subject: [PATCH 035/132] DIGILOCKER -1 : PS --- api/application/config/constants.php | 10 ++ api/application/config/routes.php | 2 + .../controllers/Flyhi_Controller.php | 116 +++++++++++++++++- .../helpers/digital_locker_helper.php | 66 ++++++++++ api/application/views/digital_locker.php | 116 ++++++++++++++++++ 5 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 api/application/helpers/digital_locker_helper.php create mode 100644 api/application/views/digital_locker.php diff --git a/api/application/config/constants.php b/api/application/config/constants.php index f1cf3277..404ba619 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -129,6 +129,10 @@ defined('CET_SALESPD_INTEGRATION_URL') OR define('CET_SALESPD_INTEGRATION_URL',' defined('CET_SALESPD_INTEGRATION_IMG_URL') OR define('CET_SALESPD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData'); defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); +defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); +defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); +defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); + } else if(ENVIRONMENT == 'testing') { @@ -151,6 +155,9 @@ else if(ENVIRONMENT == 'testing') defined('CET_SALESPD_INTEGRATION_IMG_URL') OR define('CET_SALESPD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData'); defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); + defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); + defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); + defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); } else if(ENVIRONMENT == 'production') { @@ -173,6 +180,9 @@ else if(ENVIRONMENT == 'production') defined('CET_SALESPD_INTEGRATION_IMG_URL') OR define('CET_SALESPD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData'); defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdData'); defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); + defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); + defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); + defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); } /*********************END of AWS resources Constants*************************************************/ diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 04c69189..2a19555c 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -390,3 +390,5 @@ $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; $route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList'; +$route['getDigiLockerDocs']='Flyhi_Controller/getDigiLockerDocs'; +$route['getParticularFile']='Flyhi_Controller/getParticularFile'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 71c74368..9c3e2426 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2186,5 +2186,119 @@ class Flyhi_Controller extends REST_Controller { } } - + public function getDigiLockerDocs_get(){ + $this->load->helper('digital_locker'); + $code = "0049e4a9fa3826e8b64a0882c32038bd84daa0ab"; + // $code = $this->get('code'); + $state = $this->get('state'); + log_message('ERROR',"###Step 1 : Inside Controller GetDigilockerDocs code :".$code); + $response_data = digital_locker::getAccessToken($code); + + if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ + $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; + }else{ + $view_data['list'] = json_decode($response_data['records'], true); + $html_content = $this->load->view("digital_locker",$view_data,true); + echo $html_content;die(); + $response_data['status'] = REST_Controller::HTTP_OK; + } + // $this->response($response_data,REST_Controller::HTTP_OK); + } + + public function getParticularFile_post(){ + log_message('ERROR','####Get Digi Locker Files'); + log_message('ERROR',"### Files :".json_encode($this->post())); + print_r($this->post()); + die(); + } + public function getDigiLockerDocstest_get(){ + $view_data['list2'] = array ( + 'items' => + array ( + 0 => + array ( + 'name' => 'PAN Verification Record', + 'type' => 'file', + 'size' => '', + 'date' => '21-06-2022', + 'parent' => '', + 'mime' => + array ( + 0 => 'application/json', + 1 => 'application/xml', + 2 => 'application/pdf', + ), + 'uri' => 'in.gov.pan-PANCR-GDLPS2188M', + 'doctype' => 'PANCR', + 'description' => 'PAN Verification Record', + 'issuerid' => 'in.gov.pan', + 'issuer' => 'Income Tax Department', + ), + ), + ); + $view_data['list'] = array ( + 'items' => + array ( + 0 => + array ( + 'name' => 'PAN Verification Record', + 'type' => 'file', + 'size' => '', + 'date' => '21-06-2022', + 'parent' => '', + 'mime' => + array ( + 0 => 'application/json', + 1 => 'application/xml', + 2 => 'application/pdf', + ), + 'uri' => 'in.gov.pan-PANCR-GDLPS2188M', + 'doctype' => 'PANCR', + 'description' => 'PAN Verification Record', + 'issuerid' => 'in.gov.pan', + 'issuer' => 'Income Tax Department', + ), + 1 => + array ( + 'name' => '10th marksheet', + 'type' => 'file', + 'size' => '', + 'date' => '21-06-2022', + 'parent' => '', + 'mime' => + array ( + 0 => 'application/json', + 1 => 'application/xml', + 2 => 'application/pdf', + ), + 'uri' => 'in.gov.pan-PANCR-GDLPS2188M', + 'doctype' => 'PANCR', + 'description' => 'PAN Verification Record', + 'issuerid' => 'in.gov.pan', + 'issuer' => 'Income Tax Department', + ), + 2 => + array ( + 'name' => '12th marksheet', + 'type' => 'file', + 'size' => '', + 'date' => '21-06-2022', + 'parent' => '', + 'mime' => + array ( + 0 => 'application/json', + 1 => 'application/xml', + 2 => 'application/pdf', + ), + 'uri' => 'in.gov.pan-PANCR-GDLPS2188M', + 'doctype' => 'PANCR', + 'description' => 'PAN Verification Record', + 'issuerid' => 'in.gov.pan', + 'issuer' => 'Income Tax Department', + ), + ), + ); + $html_content = $this->load->view("digital_locker",$view_data,true); + echo $html_content; die(); + } }// Class Ends diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php new file mode 100644 index 00000000..84551647 --- /dev/null +++ b/api/application/helpers/digital_locker_helper.php @@ -0,0 +1,66 @@ + $code,'grant_type' =>'authorization_code','client_secret' =>'bbda9efeb26bff460434','client_id' =>'FE9E5D06','redirect_uri' => 'https://apitest.pdgenie.com/'); + curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_TOKEN_URI); + curl_setopt( $ch,CURLOPT_POST, true ); + curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); + curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); + curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); + $result=curl_exec($ch); + $response = json_decode($result); + curl_close( $ch ); + + if(isset($response->error_description)){ + return array('dataStatus'=>false,'msg'=>$response->error_description); + }else{ + log_message('ERROR',"### DIGILOCKER TOKEN URI response :".json_encode($response).$response->access_token); + return self::getFileIssuedList($response->access_token); + } + } + + public static function getFileIssuedList($access_token) + { + log_message('ERROR','#### My Access Token'.$access_token); + $CI =&get_instance(); + $headers = array('Authorization: Bearer '.$access_token); + $ch = curl_init(); + curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_FILESLIST_URI); + curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); + curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); + $result=curl_exec($ch); + // $response = json_decode($result); + $response = $result; + log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response)); + curl_close( $ch ); + return array('dataStatus'=>true,'records'=>$response); + } + + public static function getParticularFile($file_uri,$access_token) + { + log_message('ERROR','#### My Access Token'.$access_token); + $CI =&get_instance(); + $headers = array('Authorization: Bearer '.$access_token); + $ch = curl_init(); + curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_GETFILE_URI.$file_uri); + curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); + curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); + $result=curl_exec($ch); + $response = json_decode($result); + log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response)); + curl_close( $ch ); + return $response; + // return array('dataStatus'=>true,'records'=>$response); + } +} + +?> \ No newline at end of file diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php new file mode 100644 index 00000000..157b6957 --- /dev/null +++ b/api/application/views/digital_locker.php @@ -0,0 +1,116 @@ +↑'; + $downarrow = ''; + $dash = ' '; + // echo "kkkk".gettype($list); +?> + + + + + + + + + + +
+
+ Powered By PD Genie Team +
+
+
+ +
+
+
+ + + + + + '; + for($i=0;$i'; //checkbox + echo ''; + echo ''; + } + echo '
DIGI LOCKER Docs List
Serial Number / Checkbox NameDescription
'.($i+1).'
'.$list['items'][$i]['name'].''.$list['items'][$i]['description'].'
+
+
'; + } + else{ + echo ' + + + + s + +
Digi-Locker Docs List
Serial Number / Checkbox NameDescription
There is No Digi-Locker Docs

'; + } + ?> + + \ No newline at end of file From a3b64b1aabee4fc8525df68fab81db17db5eb3a4 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 9 Jul 2022 20:27:41 +0530 Subject: [PATCH 036/132] DIGILOCKER 2 : PS --- api/application/config/constants.php | 3 ++- .../controllers/Flyhi_Controller.php | 23 ++++++++++--------- .../helpers/authorization_helper.php | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 404ba619..ca983c11 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,7 +95,8 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); -defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors +defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs'); +defined('ROUTE_LOGIN_D') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors defined('ROUTE_LOGIN_C') OR define('ROUTE_LOGIN_C', 'getCreditPDReportforCETApp'); defined('ROUTE_LOGIN_B') OR define('ROUTE_LOGIN_B', 'getSalesPDReportforCETApp'); defined('ROUTE_LOGIN_A') OR define('ROUTE_LOGIN_A', 'getAuditedImages'); // no errors diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 9c3e2426..8fa6a097 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -706,8 +706,8 @@ class Flyhi_Controller extends REST_Controller { mkdir($this->external_path.'/sales_pd/'.$pd_id,0777); } - // if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) - if(1) + if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) + // if(1) { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); @@ -2186,21 +2186,22 @@ class Flyhi_Controller extends REST_Controller { } } - public function getDigiLockerDocs_get(){ + public function getDigiLockerDocsu_get(){ $this->load->helper('digital_locker'); - $code = "0049e4a9fa3826e8b64a0882c32038bd84daa0ab"; - // $code = $this->get('code'); + // $code = "0049e4a9fa3826e8b64a0882c32038bd84daa0ab"; + $code = $this->get('code'); $state = $this->get('state'); log_message('ERROR',"###Step 1 : Inside Controller GetDigilockerDocs code :".$code); $response_data = digital_locker::getAccessToken($code); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; + $this->response($response_data,REST_Controller::HTTP_OK); }else{ $view_data['list'] = json_decode($response_data['records'], true); - $html_content = $this->load->view("digital_locker",$view_data,true); - echo $html_content;die(); - $response_data['status'] = REST_Controller::HTTP_OK; + $this->load->view("digital_locker",$view_data,true); + // echo $html_content;die(); + // $response_data['status'] = REST_Controller::HTTP_OK; } // $this->response($response_data,REST_Controller::HTTP_OK); } @@ -2211,7 +2212,7 @@ class Flyhi_Controller extends REST_Controller { print_r($this->post()); die(); } - public function getDigiLockerDocstest_get(){ + public function getDigiLockerDocs_get(){ $view_data['list2'] = array ( 'items' => array ( @@ -2298,7 +2299,7 @@ class Flyhi_Controller extends REST_Controller { ), ), ); - $html_content = $this->load->view("digital_locker",$view_data,true); - echo $html_content; die(); +$this->load->view("digital_locker",$view_data,true); + // echo $html_content; die(); } }// Class Ends diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php index be6c69fb..244485bd 100644 --- a/api/application/helpers/authorization_helper.php +++ b/api/application/helpers/authorization_helper.php @@ -72,7 +72,7 @@ class AUTHORIZATION } - if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C) + if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C || $routingName == ROUTE_LOGIN_D || $routingName == ROUTE_LOGIN_E) { return true; } From 3d0e422c668153d60ad11852826fc2ea7cdd726e Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 12 Jul 2022 17:38:00 +0530 Subject: [PATCH 037/132] Code Committed : ps --- api/application/config/constants.php | 1 + api/application/config/routes.php | 3 +- .../controllers/Flyhi_Controller.php | 53 ++++++++++++++----- .../helpers/authorization_helper.php | 2 +- .../helpers/digital_locker_helper.php | 46 ++++++++++------ api/application/views/digital_locker.php | 33 +++++++----- 6 files changed, 94 insertions(+), 44 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index ca983c11..dfa2a98e 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,6 +95,7 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); +defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs'); defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs'); defined('ROUTE_LOGIN_D') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors defined('ROUTE_LOGIN_C') OR define('ROUTE_LOGIN_C', 'getCreditPDReportforCETApp'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 2a19555c..52216863 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -391,4 +391,5 @@ $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; $route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList'; $route['getDigiLockerDocs']='Flyhi_Controller/getDigiLockerDocs'; -$route['getParticularFile']='Flyhi_Controller/getParticularFile'; +// $route['getDigiLockerDocs2']='Flyhi_Controller/getDigiLockerDos'; +$route['downloadDigiLockerDocs']='Flyhi_Controller/downloadDigiLockerDocs'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 8fa6a097..eddcd5ce 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2186,12 +2186,12 @@ class Flyhi_Controller extends REST_Controller { } } - public function getDigiLockerDocsu_get(){ + public function getDigiLockerDocs_get(){ $this->load->helper('digital_locker'); - // $code = "0049e4a9fa3826e8b64a0882c32038bd84daa0ab"; + // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; $code = $this->get('code'); $state = $this->get('state'); - log_message('ERROR',"###Step 1 : Inside Controller GetDigilockerDocs code :".$code); + log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code); $response_data = digital_locker::getAccessToken($code); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ @@ -2199,20 +2199,41 @@ class Flyhi_Controller extends REST_Controller { $this->response($response_data,REST_Controller::HTTP_OK); }else{ $view_data['list'] = json_decode($response_data['records'], true); - $this->load->view("digital_locker",$view_data,true); - // echo $html_content;die(); + $view_data['token']= $response_data['token']; + log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); + log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); + $this->load->view("digital_locker",$view_data); + // echo $html_content; die(); // $response_data['status'] = REST_Controller::HTTP_OK; } // $this->response($response_data,REST_Controller::HTTP_OK); } - public function getParticularFile_post(){ - log_message('ERROR','####Get Digi Locker Files'); - log_message('ERROR',"### Files :".json_encode($this->post())); - print_r($this->post()); - die(); + public function downloadDigiLockerDocs_post(){ + $this->load->helper('digital_locker'); + log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post())); + $form_data = $this->post(); + $token = $form_data['token']; + log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']); + unset($form_data['token']); + $reindexed_array = array_values($form_data); + if(count($reindexed_array)>0){ + for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); + $this->load->library('upload', $config); + log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse)); + }} + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'File Uploaded Successfully'; + $this->response($data,REST_Controller::HTTP_OK); } - public function getDigiLockerDocs_get(){ + public function getDigiLockerDocs5_get(){ + $this->load->helper('digital_locker'); + echo " 1- ".digital_locker::userCh_check1(); $view_data['list2'] = array ( 'items' => array ( @@ -2235,7 +2256,7 @@ class Flyhi_Controller extends REST_Controller { 'issuerid' => 'in.gov.pan', 'issuer' => 'Income Tax Department', ), - ), + ),'token'=>"response_data[token]" ); $view_data['list'] = array ( 'items' => @@ -2299,7 +2320,11 @@ class Flyhi_Controller extends REST_Controller { ), ), ); -$this->load->view("digital_locker",$view_data,true); - // echo $html_content; die(); +$this->load->view("digital_locker",$view_data); +// echo $html_content; die(); + } + public function getDigiLockerDos_get(){ + $this->load->helper('digital_locker'); + echo " 3- ".digital_locker::userCh_check3(); } }// Class Ends diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php index 244485bd..39a91ee8 100644 --- a/api/application/helpers/authorization_helper.php +++ b/api/application/helpers/authorization_helper.php @@ -72,7 +72,7 @@ class AUTHORIZATION } - if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C || $routingName == ROUTE_LOGIN_D || $routingName == ROUTE_LOGIN_E) + if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C || $routingName == ROUTE_LOGIN_D || $routingName == ROUTE_LOGIN_E || $routingName == ROUTE_LOGIN_F) { return true; } diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index 84551647..aaa9480d 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -3,9 +3,12 @@ class DIGITAL_LOCKER { + static $TOKEN_AS_GLOBAl = null; + static public $myVAR = null; + public static function getAccessToken($code) { - log_message('ERROR','#### Helper Inside Get Access Token'); + log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code); $CI =&get_instance(); $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); @@ -19,18 +22,19 @@ class DIGITAL_LOCKER $result=curl_exec($ch); $response = json_decode($result); curl_close( $ch ); - + log_message('ERROR',"### 2th : getAccessToken Reponse :".json_encode($response)); if(isset($response->error_description)){ + log_message('ERROR',"### 3 : getAccessToken Access Error :".$response->error_description); return array('dataStatus'=>false,'msg'=>$response->error_description); }else{ - log_message('ERROR',"### DIGILOCKER TOKEN URI response :".json_encode($response).$response->access_token); + log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token); return self::getFileIssuedList($response->access_token); } } public static function getFileIssuedList($access_token) { - log_message('ERROR','#### My Access Token'.$access_token); + log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); $headers = array('Authorization: Bearer '.$access_token); $ch = curl_init(); @@ -38,28 +42,40 @@ class DIGITAL_LOCKER curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); $result=curl_exec($ch); - // $response = json_decode($result); - $response = $result; - log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response)); + log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$response); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token); } - public static function getParticularFile($file_uri,$access_token) + public static function downloadFiles($uri,$access_token) { - log_message('ERROR','#### My Access Token'.$access_token); + log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri); $CI =&get_instance(); $headers = array('Authorization: Bearer '.$access_token); $ch = curl_init(); - curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_GETFILE_URI.$file_uri); + curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_GETFILE_URI.$uri); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); $result=curl_exec($ch); - $response = json_decode($result); - log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response)); + log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($result)); curl_close( $ch ); - return $response; - // return array('dataStatus'=>true,'records'=>$response); + return $result; + } + + + public static function userCh_check1(){ + global $myVAR; + self::userCh_check2(); + return $var; + } + public static function userCh_check2(){ + global $myVAR; + $myVAR = 7123; + } + public static function userCh_check3(){ + global $myVAR; + return $myVAR; + } } diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index 157b6957..0ef6c67b 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -3,8 +3,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $uparrow = ''; $downarrow = ''; $dash = ' '; - // echo "kkkk".gettype($list); -?> + +?> + @@ -87,27 +88,33 @@ defined('BASEPATH') OR exit('No direct script access allowed'); + echo '
- - - '; + + + + '; + for($i=0;$i'; //checkbox - echo ''; - echo ''; + echo ''; //checkbox + echo ''; + echo ''; + echo ''; } + echo ''; + echo '
DIGI LOCKER Docs List
Serial Number / Checkbox NameDescription
Serial Number / Checkbox NameDescriptionIssuer
'.($i+1).'
'.$list['items'][$i]['name'].''.$list['items'][$i]['description'].'
'.($i+1).'
'.$list['items'][$i]['name'].''.$list['items'][$i]['description'].''.$list['items'][$i]['issuer'].'

-
'; +
'; } else{ echo ' - - - s + + + +
Digi-Locker Docs List
Serial Number / Checkbox NameDescription
Serial Number / Checkbox NameDescriptionIssuer
There is No Digi-Locker Docs

'; } From 29252cc95d14ee61712ae1c238e5d0e74f0f24ad Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 13 Jul 2022 23:05:52 +0530 Subject: [PATCH 038/132] DigiLocker Coapplicant Related Changes : ps --- .../controllers/Flyhi_Controller.php | 34 +++++++++++++++---- .../helpers/digital_locker_helper.php | 20 ++++++++--- api/application/views/digital_locker.php | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index eddcd5ce..d99e171c 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2190,9 +2190,9 @@ class Flyhi_Controller extends REST_Controller { $this->load->helper('digital_locker'); // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; $code = $this->get('code'); - $state = $this->get('state'); - log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code); - $response_data = digital_locker::getAccessToken($code); + $co_applicant = $this->get('state'); + log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant : ".$co_applicant); + $response_data = digital_locker::getAccessToken($code,$co_applicant); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; @@ -2200,6 +2200,7 @@ class Flyhi_Controller extends REST_Controller { }else{ $view_data['list'] = json_decode($response_data['records'], true); $view_data['token']= $response_data['token']; + $view_data['pd_id']=$response_data['pd_id']; log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); $this->load->view("digital_locker",$view_data); @@ -2214,16 +2215,35 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post())); $form_data = $this->post(); $token = $form_data['token']; + $pd_id = $form_data['pd_id']; log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']); unset($form_data['token']); $reindexed_array = array_values($form_data); if(count($reindexed_array)>0){ for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); - $this->load->library('upload', $config); + // $folder_to_check = XLPATH.'/tmp'; + // $bytes = file_put_contents($folder_to_check, json_decode($reponse, true)); + // $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); + // $this->load->library('upload', $config); + $fields = array('pd_id','fk_lender_id'); + $where_condition_array = array('pd_id' => $pd_id); + $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; + $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; + + $tempdocname = "IDPROOF - ".$i+1; + $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; + $key = 'pd'.$pd_id.'/'.$tempdocname ; + $sourcefile = json_decode($reponse, true); + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>"DigiLocker Files (".$tempdocname.")",'pd_document_name'=>$tempdocname); + $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); + } log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse)); }} $data['dataStatus'] = true; diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index aaa9480d..ec12869c 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -6,9 +6,9 @@ class DIGITAL_LOCKER static $TOKEN_AS_GLOBAl = null; static public $myVAR = null; - public static function getAccessToken($code) + public static function getAccessToken($code,$applicant) { - log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code); + log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code." & applicant :".$applicant); $CI =&get_instance(); $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); @@ -28,11 +28,21 @@ class DIGITAL_LOCKER return array('dataStatus'=>false,'msg'=>$response->error_description); }else{ log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token); - return self::getFileIssuedList($response->access_token); + $CI->db->SELECT("fk_pd_id"); + $CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS"); + $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); + $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); + $dtls = $CI->db->GET()->result_array(); + $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; + + $CI->db->where('pd_co_applicant_id =',$applicant); + $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); + + return self::getFileIssuedList($response->access_token,$pd_id); } } - public static function getFileIssuedList($access_token) + public static function getFileIssuedList($access_token,$pd_id) { log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); @@ -44,7 +54,7 @@ class DIGITAL_LOCKER $result=curl_exec($ch); log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id); } public static function downloadFiles($uri,$access_token) diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index 0ef6c67b..7290e7f0 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -103,6 +103,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''.$list['items'][$i]['issuer'].''; } echo ''; + echo ''; echo '
From de35af21eb3853eadd5d3a5fae17905af4ce9b8a Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 15 Jul 2022 10:06:06 +0530 Subject: [PATCH 039/132] DigiLocker fixes 1 : ps --- .../controllers/Flyhi_Controller.php | 21 ++++++++++++------- .../helpers/digital_locker_helper.php | 11 +++++----- api/application/views/digital_locker.php | 9 +++++++- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index d99e171c..c61f1bc0 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2200,7 +2200,7 @@ class Flyhi_Controller extends REST_Controller { }else{ $view_data['list'] = json_decode($response_data['records'], true); $view_data['token']= $response_data['token']; - $view_data['pd_id']=$response_data['pd_id']; + $view_data['dtls']=$response_data['dtls']; log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); $this->load->view("digital_locker",$view_data); @@ -2216,23 +2216,28 @@ class Flyhi_Controller extends REST_Controller { $form_data = $this->post(); $token = $form_data['token']; $pd_id = $form_data['pd_id']; + $applicant_name = $form_data['applicant_name']; log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']); unset($form_data['token']); + unset($form_data['pd_id']); + unset($form_data['applicant_name']); $reindexed_array = array_values($form_data); if(count($reindexed_array)>0){ for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); - // $this->load->library('upload', $config); + $folder_to_check = XLPATH.'/tmp'; + $bytes = file_put_contents($folder_to_check, json_decode($reponse, true)); + $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); + $this->load->library('upload', $config); $fields = array('pd_id','fk_lender_id'); $where_condition_array = array('pd_id' => $pd_id); $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; - - $tempdocname = "IDPROOF - ".$i+1; + $tempdocname = $applicant_name."-id_proof-".$i+1; $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; $key = 'pd'.$pd_id.'/'.$tempdocname ; $sourcefile = json_decode($reponse, true); @@ -2241,7 +2246,7 @@ class Flyhi_Controller extends REST_Controller { if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>"DigiLocker Files (".$tempdocname.")",'pd_document_name'=>$tempdocname); + $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name); $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); } log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse)); diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index ec12869c..9fcf9078 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -28,21 +28,20 @@ class DIGITAL_LOCKER return array('dataStatus'=>false,'msg'=>$response->error_description); }else{ log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token); - $CI->db->SELECT("fk_pd_id"); + $CI->db->SELECT("fk_pd_id,pd_co_applicant_id,applicant_name"); $CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS"); $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); $dtls = $CI->db->GET()->result_array(); - $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; $CI->db->where('pd_co_applicant_id =',$applicant); $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); - return self::getFileIssuedList($response->access_token,$pd_id); + return self::getFileIssuedList($response->access_token,$dtls); } } - - public static function getFileIssuedList($access_token,$pd_id) + + public static function getFileIssuedList($access_token,$dtls) { log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); @@ -54,7 +53,7 @@ class DIGITAL_LOCKER $result=curl_exec($ch); log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls); } public static function downloadFiles($uri,$access_token) diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index 7290e7f0..fa46e9b0 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -3,7 +3,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $uparrow = ''; $downarrow = ''; $dash = ' '; - + if(count($dtls)>0){ + $pd_id = isset($dtls[0]['fk_pd_id']) ? $dtls[0]['fk_pd_id'] : null; + $applicant_name = isset($dtls[0]['applicant_name']) ? $dtls[0]['applicant_name'] : null; + } + ?> @@ -101,9 +105,12 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''.$list['items'][$i]['name'].''; echo ''.$list['items'][$i]['description'].''; echo ''.$list['items'][$i]['issuer'].''; + echo ''; } echo ''; echo ''; + echo ''; + echo '
From 3f17bd53fe8adb4d35d432174594007c5cd1cad4 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 15 Jul 2022 23:46:39 +0530 Subject: [PATCH 040/132] digi locker fixes 2 : ps --- .../controllers/Flyhi_Controller.php | 36 ++++++++++++++----- .../helpers/digital_locker_helper.php | 30 +++++++++++----- api/application/views/digital_locker.php | 8 ++--- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index c61f1bc0..848ec41d 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2200,7 +2200,8 @@ class Flyhi_Controller extends REST_Controller { }else{ $view_data['list'] = json_decode($response_data['records'], true); $view_data['token']= $response_data['token']; - $view_data['dtls']=$response_data['dtls']; + $view_data['pd_id']=$response_data['pd_id']; + $view_data['applicant_name']=$response_data['applicant_name']; log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); $this->load->view("digital_locker",$view_data); @@ -2221,13 +2222,24 @@ class Flyhi_Controller extends REST_Controller { unset($form_data['token']); unset($form_data['pd_id']); unset($form_data['applicant_name']); + for($i=0;$i0){ + log_message('ERROR','### 5.1th User Choosen Files form data '.json_encode($form_data)); + log_message('ERROR','### 5.2th User Choosen Files reindexed_array '.json_encode($reindexed_array)); + log_message('ERROR','### 5.3th User Choosen Files reindexed_array count '.count($reindexed_array)); + log_message('ERROR','### 5.4th User Choosen Files digilocker_doc_name count '.count($digilocker_doc_name)); + log_message('ERROR','### 5.5th User Choosen Files digilocker_doc_name '.json_encode($digilocker_doc_name)); + if(count($form_data)>0){ for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); @@ -2237,7 +2249,7 @@ class Flyhi_Controller extends REST_Controller { $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; - $tempdocname = $applicant_name."-id_proof-".$i+1; + $tempdocname = $applicant_name."-id_proof-".$digilocker_doc_name[$i]; $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; $key = 'pd'.$pd_id.'/'.$tempdocname ; $sourcefile = json_decode($reponse, true); @@ -2249,16 +2261,16 @@ class Flyhi_Controller extends REST_Controller { $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name); $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); } - log_message('ERROR',"### 7 : Choosen Files reponse :".json_encode($reponse)); + log_message('ERROR',"### 8 : Choosen Files reponse :".json_encode($reponse)); }} $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'File Uploaded Successfully'; $this->response($data,REST_Controller::HTTP_OK); } - public function getDigiLockerDocs5_get(){ + public function getDigiLockerDocs2_get(){ $this->load->helper('digital_locker'); - echo " 1- ".digital_locker::userCh_check1(); + // echo " 1- ".digital_locker::userCh_check1(); $view_data['list2'] = array ( 'items' => array ( @@ -2345,6 +2357,12 @@ class Flyhi_Controller extends REST_Controller { ), ), ); + $code = $this->get('code'); + $co_applicant = $this->get('state'); + $reponse = digital_locker::userCh_check3($code,$co_applicant); + $view_data['token']= "response_data['token']"; + $view_data['pd_id']="3258"; + $view_data['applicant_name']="Sanjeev Soni"; $this->load->view("digital_locker",$view_data); // echo $html_content; die(); } diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index 9fcf9078..de879c37 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -33,15 +33,19 @@ class DIGITAL_LOCKER $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); $dtls = $CI->db->GET()->result_array(); + $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; + $applicant_name = (count($dtls)>0) ? $dtls[0]['applicant_name'] : null; + - $CI->db->where('pd_co_applicant_id =',$applicant); - $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); + $CI->db->where('pd_co_applicant_id',$applicant); + $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $result)); + // print_r($CI->db->last_query()); - return self::getFileIssuedList($response->access_token,$dtls); + return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name); } } - - public static function getFileIssuedList($access_token,$dtls) + + public static function getFileIssuedList($access_token,$pd_id,$applicant_name) { log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); @@ -53,7 +57,7 @@ class DIGITAL_LOCKER $result=curl_exec($ch); log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name); } public static function downloadFiles($uri,$access_token) @@ -81,9 +85,17 @@ class DIGITAL_LOCKER global $myVAR; $myVAR = 7123; } - public static function userCh_check3(){ - global $myVAR; - return $myVAR; + public static function userCh_check3($code,$applicant){ + $CI =&get_instance(); + $CI->db->SELECT("fk_pd_id,pd_co_applicant_id,applicant_name"); + $CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS"); + $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); + $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); + $dtls = $CI->db->GET()->result_array(); + $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; + $response = "bb"; + $CI->db->where('pd_co_applicant_id',$applicant); + $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); } } diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index fa46e9b0..af598a63 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -3,10 +3,6 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $uparrow = ''; $downarrow = ''; $dash = ' '; - if(count($dtls)>0){ - $pd_id = isset($dtls[0]['fk_pd_id']) ? $dtls[0]['fk_pd_id'] : null; - $applicant_name = isset($dtls[0]['applicant_name']) ? $dtls[0]['applicant_name'] : null; - } ?> @@ -101,11 +97,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Issuer'; for($i=0;$i
'.($i+1).'
'; //checkbox + echo '
'.($i+1).' +
'; //checkbox echo ''.$list['items'][$i]['name'].''; echo ''.$list['items'][$i]['description'].''; echo ''.$list['items'][$i]['issuer'].''; - echo ''; } echo ''; echo ''; From 58019d0122c86c9f69c0ebe34b459b113220bef8 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 20 Jul 2022 17:29:57 +0530 Subject: [PATCH 041/132] SMC photo pdf and Zip : ps --- api/application/config/routes.php | 3 + .../controllers/Flyhi_Controller.php | 6 +- .../controllers/SMC_Credit_PD_Controller.php | 38 ++ .../helpers/smc_creditpd_helper.php | 131 +++++ .../views/report_templates/PDSMCIMG_PDF.php | 550 ++++++++++++++++++ 5 files changed, 725 insertions(+), 3 deletions(-) create mode 100644 api/application/views/report_templates/PDSMCIMG_PDF.php diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 52216863..0c3ce829 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -393,3 +393,6 @@ $route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList'; $route['getDigiLockerDocs']='Flyhi_Controller/getDigiLockerDocs'; // $route['getDigiLockerDocs2']='Flyhi_Controller/getDigiLockerDos'; $route['downloadDigiLockerDocs']='Flyhi_Controller/downloadDigiLockerDocs'; + +$route['archivePDSMCImages'] = 'SMC_Credit_PD_Controller/archivePDImages'; +$route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 848ec41d..d718f08b 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2233,8 +2233,8 @@ class Flyhi_Controller extends REST_Controller { log_message('ERROR','### 5.1th User Choosen Files form data '.json_encode($form_data)); log_message('ERROR','### 5.2th User Choosen Files reindexed_array '.json_encode($reindexed_array)); log_message('ERROR','### 5.3th User Choosen Files reindexed_array count '.count($reindexed_array)); - log_message('ERROR','### 5.4th User Choosen Files digilocker_doc_name count '.count($digilocker_doc_name)); - log_message('ERROR','### 5.5th User Choosen Files digilocker_doc_name '.json_encode($digilocker_doc_name)); + log_message('ERROR','### 5.4th User Choosen Files digilocker_doc_name '.json_encode($digilocker_doc_name)); + log_message('ERROR','### 5.5th User Choosen Files digilocker_doc_name count '.count($digilocker_doc_name)); if(count($form_data)>0){ for($i=0;$i $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name); + $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name[$i]); $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); } log_message('ERROR',"### 8 : Choosen Files reponse :".json_encode($reponse)); diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index bd362038..5a1dd017 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1948,6 +1948,44 @@ public function filterSalesPDList_post() { $this->response($data,REST_Controller::HTTP_OK); } + public function archivePDImages_post() + { + $records = $this->post('records'); + $pdid = $records['pd_id']; + $random_string = $records['random_string']; + $regenerate = isset($records['regenerate']) ? $records['regenerate'] : 0; + + $this->load->helper('smc_creditpd'); + $res_data = smc_creditpd::covertSMCImgs2ZIP($pdid,$random_string,array(),$regenerate); + + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $res_data; + $this->response($response_data,REST_Controller::HTTP_OK); + + + + } + + + public function imgPDFDownload_post() + { + $records = $this->post('records'); + $this->load->helper('smc_creditpd'); + + $pdid = $records['pd_id']; + $random_string = $records['random_string']; + $regenerate = isset($records['regenerate']) ? $records['regenerate'] : 0; + + $res_data = smc_creditpd::covertSMCImgs2PDF($pdid,$random_string,array(),$regenerate); + + + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $res_data; + $this->response($response_data,REST_Controller::HTTP_OK); + + } } \ No newline at end of file diff --git a/api/application/helpers/smc_creditpd_helper.php b/api/application/helpers/smc_creditpd_helper.php index ccf662f8..26968d14 100644 --- a/api/application/helpers/smc_creditpd_helper.php +++ b/api/application/helpers/smc_creditpd_helper.php @@ -583,6 +583,137 @@ class smc_creditpd // print_r($json); return $json; } + public static function covertSMCImgs2ZIP($pdid,$random_string,$pd_master_details = array(),$regenerate = 0) + { + $CI =&get_instance(); + $CI->load->model('PD_Model'); + if(!count($pd_master_details)) + { + $pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string,$pd_master_details); + } + if(!file_exists($CI->external_path.'/pd_reports/'.$pdid)) + { + mkdir($CI->external_path.'/pd_reports/'.$pdid,0777); + } + + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $main_applicant_name = $pd_master_details[0]['main_applicant']; + //get zip url from s3 if any + + $key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; + + //$singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + if($pd_master_details[0]['is_zip_created'] && ($regenerate == 0)) + { + return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + + // $response_data['dataStatus'] = true; + // $response_data['status'] = REST_Controller::HTTP_OK; + // $response_data['records'] = $singed_uri; + // $CI->response($response_data,REST_Controller::HTTP_OK); 9344876517 + } else + { + + $all_pd_images = $CI->PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1 , 'img_name !=' => 'satellite'),SMC_CREDIT_PD_DOCS); + + // $all_form_names = array('pd_form_id'=>19,'pd_form_name'=>"photograph"); + // $form_name[19] = "photograph"; + + //Generate zip file + + $CI->load->library('zip'); + + $CI->zip->add_dir('pdimages'); + + foreach($all_pd_images as $image) + { + + $temp_dir_name = 'Common'; + $doc_name = str_replace(':', '-', $image['img_name']); + $src_local_file = XLPATH.'/tmp/'.$doc_name.'.png'; + $ifp = fopen( $src_local_file, 'wb' ); + $img = explode( ',', $image['img'] ); + fwrite( $ifp, base64_decode( $img[ 1 ] ) ); + fclose( $ifp ); + $MyFile = file_get_contents($src_local_file); + $CI->zip->add_data('pdimages/'.$doc_name.'.png',$MyFile); + unlink($src_local_file); + } + + $temp_path = $main_applicant_name.'_'.$pdid.'_'.'pd_images.zip'; + + $CI->zip->archive($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path); + + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path)); + + $s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + //$result_array[0]['content'] + $where_condition_array = array("pd_id" => $pdid); + $temp_array['is_zip_created'] = 1; + $id = $CI->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + unlink($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path); + } + return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + } + + } + public static function covertSMCImgs2PDF($pdid,$random_string,$pd_master_details = array(),$regenerate = 0) + { + //echo 'this is from daiu'; + $CI =&get_instance(); + $CI->load->model('PD_Model'); + $CI->load->library('pdfgenerator'); + + if(!count($pd_master_details)) + { + $pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string); + } + set_time_limit(60); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + $main_applicant_name = $pd_master_details[0]['main_applicant']; + + //get zip url from s3 if any + + $key = 'pd'.$pdid.'/'.$main_applicant_name.'_'.$pdid.'_'.'pd_images.pdf'; + + //$singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + if($pd_master_details[0]['is_img_pdf_created'] && ($regenerate == 0)) + { + return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days'); + } + else + { + $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1,'img_name!=' => 'satellite'),SMC_CREDIT_PD_DOCS); + // $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); + + $data_to_view['all_pd_images'] = $all_pd_images; + $img_pdf_data = $CI->load->view('report_templates/PDSMCIMG_PDF',$data_to_view,true); + //print_r($img_pdf_data);die(); + $pdf_doc = $CI->pdfgenerator->generate($img_pdf_data, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file2 = $CI->external_path ."/pd_reports/" . $pdid . "/pd_images_pdf.pdf"; + $ti = file_put_contents($output_file2, $pdf_doc); + //echo $ti;die(); + + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($output_file2)); + + $s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + //$result_array[0]['content'] + $where_condition_array = array("pd_id" => $pdid); + $temp_array['is_img_pdf_created'] = 1; + $id = $CI->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + unlink($output_file2); + } + + return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days'); + + }} } ?> \ No newline at end of file diff --git a/api/application/views/report_templates/PDSMCIMG_PDF.php b/api/application/views/report_templates/PDSMCIMG_PDF.php new file mode 100644 index 00000000..758d72e1 --- /dev/null +++ b/api/application/views/report_templates/PDSMCIMG_PDF.php @@ -0,0 +1,550 @@ + + + + + + + + + + + + + + +
+
+ Powered by PDGenie +
+
+ +
+
+
+ + '; + echo '

PD Photograph`s :

'; + echo '
'; + echo ''; + $add_factor = 0; + for($img_row = 0; $img_row < $img_row_count; $img_row++) + { + //if($img_row > 0) { break; } + echo ''; + $from = $img_row == 0 ? $img_row : ($img_row+$add_factor); + $to = ($from + 2); + $add_factor = $add_factor + 2; + for($photo_iter = $from; $photo_iter <= $to;$photo_iter++) + { + + if(isset($all_pd_images[$photo_iter])) + { + echo ''; + // unset($all_pd_images[$photo_iter]); + } + + } + //echo "


"; + echo ''; + } + //echo ''; + echo '
'; + echo ''; + echo '
'; + } + // + ?> + + + + + + + \ No newline at end of file From fad9c906537be2e27d91be7449b6e4b1cbeabf34 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 25 Jul 2022 10:00:56 +0530 Subject: [PATCH 042/132] Digilocker Files Changes : ps --- api/application/config/constants.php | 6 +- .../controllers/Flyhi_Controller.php | 64 ++++++++--- .../helpers/digital_locker_helper.php | 37 ++++++- api/application/views/digital_locker.php | 103 +++++++++++++----- 4 files changed, 161 insertions(+), 49 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index dfa2a98e..078f3ba8 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -133,7 +133,7 @@ defined('CET_CREDIT_PD_INTEGRATION_URL') OR define('CET_CREDIT_PD_INTEGRATION_UR defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); -defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); +defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/'); } else if(ENVIRONMENT == 'testing') @@ -159,7 +159,7 @@ else if(ENVIRONMENT == 'testing') defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); - defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); + defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/'); } else if(ENVIRONMENT == 'production') { @@ -184,7 +184,7 @@ else if(ENVIRONMENT == 'production') defined('CET_CREDIT_PD_INTEGRATION_IMG_URL') OR define('CET_CREDIT_PD_INTEGRATION_IMG_URL','https://demo.devopsmcfinance.com/cet_creditpd/api/PullCreditPdPhotographsData'); defined('DIGILOCKER_TOKEN_URI') OR define('DIGILOCKER_TOKEN_URI','https://api.digitallocker.gov.in/public/oauth2/1/token'); defined('DIGILOCKER_FILESLIST_URI') OR define('DIGILOCKER_FILESLIST_URI','https://api.digitallocker.gov.in/public/oauth2/2/files/issued'); - defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/files/'); + defined('DIGILOCKER_GETFILE_URI') OR define('DIGILOCKER_GETFILE_URI','https://api.digitallocker.gov.in/public/oauth2/1/file/'); } /*********************END of AWS resources Constants*************************************************/ diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index d718f08b..adf0c7f7 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2191,7 +2191,7 @@ class Flyhi_Controller extends REST_Controller { // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; $code = $this->get('code'); $co_applicant = $this->get('state'); - log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant : ".$co_applicant); + log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant id : ".$co_applicant); $response_data = digital_locker::getAccessToken($code,$co_applicant); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ @@ -2202,8 +2202,11 @@ class Flyhi_Controller extends REST_Controller { $view_data['token']= $response_data['token']; $view_data['pd_id']=$response_data['pd_id']; $view_data['applicant_name']=$response_data['applicant_name']; + $view_data['applicant_id']=$response_data['applicant_id']; log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); + $this->header_title = "new"; + $view_data['page_title']="PD GENIE : Digitial Documents"; $this->load->view("digital_locker",$view_data); // echo $html_content; die(); // $response_data['status'] = REST_Controller::HTTP_OK; @@ -2214,14 +2217,18 @@ class Flyhi_Controller extends REST_Controller { public function downloadDigiLockerDocs_post(){ $this->load->helper('digital_locker'); log_message('ERROR','### 5 User Choosen Files'.json_encode($this->post())); + $temp_flag = 0 ; $form_data = $this->post(); $token = $form_data['token']; $pd_id = $form_data['pd_id']; $applicant_name = $form_data['applicant_name']; + $applicant_id = $form_data['applicant_id']; + log_message('ERROR','### 5th User Choosen Files token key'.$form_data['token']); unset($form_data['token']); unset($form_data['pd_id']); unset($form_data['applicant_name']); + unset($form_data['applicant_id']); for($i=0;$i $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $reindexed_array[$i]); - $this->load->library('upload', $config); + $doc_name = str_replace(' ', '_',$digilocker_doc_name[$i]); + $doc_renamed = $applicant_name."_".$doc_name.'.pdf'; + log_message('ERROR','### 7.1th doc_name '.$doc_renamed.' inx : '.$i); + $src_local_file = XLPATH.'/tmp/'.$doc_renamed; + $ifp = fopen( $src_local_file, 'wb' ); + fwrite( $ifp, $reponse ); + fclose( $ifp ); + chmod($src_local_file, 0777); + $tempdoc = $src_local_file; + $tempdocname = $doc_renamed; + $fields = array('pd_id','fk_lender_id'); $where_condition_array = array('pd_id' => $pd_id); $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; - $tempdocname = $applicant_name."-id_proof-".$digilocker_doc_name[$i]; + $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; - $key = 'pd'.$pd_id.'/'.$tempdocname ; - $sourcefile = json_decode($reponse, true); + + $key = 'pd'.$pd_id.'/'.$doc_renamed ; + $sourcefile = $tempdoc; + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + // $MyFile = file_get_contents($src_local_file); + log_message('ERROR',"### 7.2 : Choosen Files s3-result :".json_encode($s3result)); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $record_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$tempdocname,'pd_document_name'=>$digilocker_doc_name[$i]); - $this->Flyhi_Model->saveRecords($record_data,PDDOCUMENTS); + $pd_document_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$doc_renamed,'pd_document_name'=>$doc_renamed,'fk_form_id'=>18,'co_applicant_id'=>$applicant_id); + $pd_document_id = $this->Flyhi_Model->saveRecords($pd_document_data,PDDOCUMENTS); + if($pd_document_id != "" || $pd_document_id != null){ $temp_flag++; } + unlink($src_local_file); } log_message('ERROR',"### 8 : Choosen Files reponse :".json_encode($reponse)); }} - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = 'File Uploaded Successfully'; - $this->response($data,REST_Controller::HTTP_OK); + + if($temp_flag != 0){ + $msg = count($reindexed_array). 'User Select File . '.$temp_flag.' File Uploaded Successfully'; + $reponse_data['dataStatus'] = true; + $reponse_data['status'] = REST_Controller::HTTP_OK; + $reponse_data['msg'] = $msg; + echo ''; + // sleep for 8 seconds + sleep(8); + // redirect("https://demo.pdgenie.com/pd/#/home"); + }else{ + $reponse_data['dataStatus'] = false; + $reponse_data['status'] = REST_Controller::HTTP_NO_CONTENT; + $reponse_data['msg'] = 'No File Uploaded'; + } + $this->response($reponse_data,REST_Controller::HTTP_OK); + } public function getDigiLockerDocs2_get(){ $this->load->helper('digital_locker'); diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index de879c37..beff351f 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -35,17 +35,18 @@ class DIGITAL_LOCKER $dtls = $CI->db->GET()->result_array(); $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; $applicant_name = (count($dtls)>0) ? $dtls[0]['applicant_name'] : null; + $applicant_id = $applicant; $CI->db->where('pd_co_applicant_id',$applicant); $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $result)); // print_r($CI->db->last_query()); - return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name); + return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name,$applicant_id); } } - public static function getFileIssuedList($access_token,$pd_id,$applicant_name) + public static function getFileIssuedList($access_token,$pd_id,$applicant_name,$applicant_id) { log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); $CI =&get_instance(); @@ -57,9 +58,33 @@ class DIGITAL_LOCKER $result=curl_exec($ch); log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name,'applicant_id'=>$applicant_id); } +// public static function downloadFiles($uri,$access_token) +// { +// log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri); +// log_message('ERROR',"### 6.1 : Dummy API "); +// $image_url = "http://p.twimg.com/AW2-vIUCAAE_1FN.png"; + +// $ch = curl_init(); +// curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); +// curl_setopt ($ch, CURLOPT_URL, $image_url); +// curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20); +// curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); +// curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); +// curl_setopt($ch, CURLOPT_HEADER, true); +// curl_setopt($ch, CURLOPT_NOBODY, true); + +// $content = curl_exec ($ch); +// log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($content)); +// $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); +// echo $contentType; +// echo "
"; +// curl_close ($ch); +// echo "
";
+//   print_r($content);
+//   }
 	public static function downloadFiles($uri,$access_token)
 	{   	
 		log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri);
@@ -70,8 +95,10 @@ class DIGITAL_LOCKER
 		curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
 		curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
 		$result=curl_exec($ch);
-		log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($result));
-		curl_close( $ch );
+		log_message('ERROR',"### 6.1 : DIGILOCKERGETFILEURI Reponse :".json_encode($result));
+		$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
+		log_message('ERROR',"### 6.2 : DIGILOCKERGETFILEURI contentType:".$contentType);
+		curl_close ($ch);
         return $result;
 	}
 	
diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php
index af598a63..e7a20a78 100644
--- a/api/application/views/digital_locker.php
+++ b/api/application/views/digital_locker.php
@@ -11,8 +11,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
 	
 	
 	 
+        
 	
-	
+<?php echo $page_title; ?>	
 
-
+
+
+
+

@@ -88,40 +120,57 @@ defined('BASEPATH') OR exit('No direct script access allowed'); + + Digital Documents +
+ Applicant Name : "'.$applicant_name.'"
+
'; + echo '
- - - - - '; + + + + + + + '; + for($i=0;$i + '; //checkbox - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; } echo ''; echo ''; - echo ''; - - + echo ''; + echo ''; echo '
DIGI LOCKER Docs List
Serial Number / Checkbox NameDescriptionIssuer
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
'.($i+1).' + echo '
'.($i+1).' +
'.$list['items'][$i]['name'].''.$list['items'][$i]['description'].''.$list['items'][$i]['issuer'].'
'.$list['items'][$i]['name'].'
'.$list['items'][$i]['date'].'
'.$list['items'][$i]['description'].'
'.$list['items'][$i]['issuer'].'

-
'; +
+ +
'; } else{ echo ' - - - - - - + + + + + + + +
Digi-Locker Docs List
Serial Number / Checkbox NameDescriptionIssuer
There is No Digi-Locker Docs
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
There is No Digi-Locker Docs

'; } ?> + \ No newline at end of file From da6f0b8be359ea50eb3017f6567c472a20d8a43c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 25 Jul 2022 16:04:44 +0530 Subject: [PATCH 043/132] SMC satellite image added : ps --- api/application/helpers/smc_creditpd_helper.php | 11 ++++++++--- .../views/report_templates/PDSMCIMG_PDF.php | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/api/application/helpers/smc_creditpd_helper.php b/api/application/helpers/smc_creditpd_helper.php index 26968d14..5b04a3b4 100644 --- a/api/application/helpers/smc_creditpd_helper.php +++ b/api/application/helpers/smc_creditpd_helper.php @@ -615,7 +615,7 @@ class smc_creditpd } else { - $all_pd_images = $CI->PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1 , 'img_name !=' => 'satellite'),SMC_CREDIT_PD_DOCS); + $all_pd_images = $CI->PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1 ),SMC_CREDIT_PD_DOCS); // $all_form_names = array('pd_form_id'=>19,'pd_form_name'=>"photograph"); // $form_name[19] = "photograph"; @@ -634,7 +634,12 @@ class smc_creditpd $src_local_file = XLPATH.'/tmp/'.$doc_name.'.png'; $ifp = fopen( $src_local_file, 'wb' ); $img = explode( ',', $image['img'] ); - fwrite( $ifp, base64_decode( $img[ 1 ] ) ); + // fwrite( $ifp, base64_decode( $img[ 1 ] ) ); + if($doc_name == "satellite"){ + fwrite( $ifp, base64_decode($image['img']) ); + }else{ + fwrite( $ifp, base64_decode( $img[ 1 ] ) ); + } fclose( $ifp ); $MyFile = file_get_contents($src_local_file); $CI->zip->add_data('pdimages/'.$doc_name.'.png',$MyFile); @@ -687,7 +692,7 @@ class smc_creditpd } else { - $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1,'img_name!=' => 'satellite'),SMC_CREDIT_PD_DOCS); + $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); // $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); $data_to_view['all_pd_images'] = $all_pd_images; diff --git a/api/application/views/report_templates/PDSMCIMG_PDF.php b/api/application/views/report_templates/PDSMCIMG_PDF.php index 758d72e1..f7f880b5 100644 --- a/api/application/views/report_templates/PDSMCIMG_PDF.php +++ b/api/application/views/report_templates/PDSMCIMG_PDF.php @@ -522,7 +522,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); { echo ''; echo ''; echo ''; From b9f41c853a62ca585f414b83052c7a2700b3cac3 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 26 Jul 2022 13:11:16 +0530 Subject: [PATCH 044/132] Auto Trigger GSHEET : ps --- .../controllers/Data_Dump_Controller.php | 42 ++++++++++++++++--- api/application/models/Data_Dump_Model.php | 2 + 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index d28f4aab..6b1e2b77 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -185,14 +185,31 @@ class Data_Dump_Controller extends REST_Controller { // log_message('ERROR',"G-Sheet For PD Step 2.4 (Fourth Cell mobilenumber) GSheet data : ".$GSdata['ContactNumber']); // } $applicatantParts =""; + $Totalapplicatantcount = 0; if(isset($GSdata["ApplicantName"]) && $GSdata["ApplicantName"] != ""){ $applicatantParts = explode(',',$GSdata["ApplicantName"]); if(count($applicatantParts)>1){ + $Totalapplicatantcount = count($applicatantParts); for($j=0;$j1){ + $pd_applicant_details[$j]['applicant_name'] = $applicant_title_name[1]; + $pd_applicant_details[$j]['applicant_title_name'] = $this->Data_Dump_Model->getId(10,$applicant_title_name[0]); + $this->Data_Dump_Model->getId(10,$GSdata["LenderCreditName"]); + + }else{ + $pd_applicant_details[$j]['applicant_name'] = $applicatantParts[$j]; + } } }else{ - $pd_applicant_details[0]['applicant_name'] = $applicatantParts[0]; + $applicant_title_name = explode('.',$applicatantParts[0]); + if(count($applicant_title_name)>1){ + $pd_applicant_details[0]['applicant_name'] = $applicant_title_name[1]; + $pd_applicant_details[0]['applicant_title_name'] = $this->Data_Dump_Model->getId(10,$applicant_title_name[0]); + + }else{ + $pd_applicant_details[0]['applicant_name'] = $applicatantParts[0]; + } } $pd_applicant_details[0]['company_name'] = (isset($GSdata["CompanyName"]) && $GSdata["CompanyName"] != "") ? $GSdata["CompanyName"] : null ; @@ -201,10 +218,25 @@ class Data_Dump_Controller extends REST_Controller { log_message('ERROR',"G-Sheet For PD Step 2.4 (company) GSheet data : ".$GSdata["CompanyName"]); } if(isset($GSdata["ContactNumber"]) && $GSdata["ContactNumber"] != ""){ - $ContactNumber = explode(',',$GSdata["ContactNumber"]); + $ContactNumber = explode(',',trim($GSdata["ContactNumber"])); + // Contact number as below Format + // mentioned (9999999999, 8888888888, 7777777777) in Gsheet, then: + // 1st number mentioned as primary number in PD genie, + // 2nd number as additional number, (if applicant has no additional number they mentioned as Single 0 only) + // 3rd number as co-applicant number. if(count($ContactNumber)>1){ for($j=0;$j1 && $Totalapplicatantcount > ($j-1)) { + // here if condition $J inx should greater than 1 and total applicant count is also greater then index . + $pd_applicant_details[$j-1]['mobile_no'] = $ContactNumber[$j]; + } } }else{ $pd_applicant_details[0]['mobile_no'] = $ContactNumber[0]; @@ -323,8 +355,6 @@ class Data_Dump_Controller extends REST_Controller { 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'); diff --git a/api/application/models/Data_Dump_Model.php b/api/application/models/Data_Dump_Model.php index c7fffaa7..3fa96e75 100755 --- a/api/application/models/Data_Dump_Model.php +++ b/api/application/models/Data_Dump_Model.php @@ -141,6 +141,8 @@ class Data_Dump_Model extends SPARQ_Model { $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";} + if($flag == 10){ $value = trim($keyword);$value = strtolower($value); + $select = "title_id";$where = "name";$table = "m_titles";} $this->db->select($select); $this->db->from($table); From 347dbde7e9ac51d48eaa4c9b7c76d2821591c32e Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 26 Jul 2022 19:49:55 +0530 Subject: [PATCH 045/132] VideoStatus : ps --- api/application/controllers/PD_Controller.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 9cca18f8..83a18022 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -10250,7 +10250,12 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $this->load->library('twlio'); $result_data = 0; // $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;"; - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + if($pd_category == "1"){ + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + }else{ + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA); + } + $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0 and pd_category = $pd_category";// and twilo_status = 'enqueued' and composition_id is not null;"; if($room_id) { @@ -10264,14 +10269,14 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() foreach ($video_info as $key => $value) { - if($value['composition_id'] && $value['vps'] != 'google') + if($value['composition_id'] && $value['vsp'] != 'google') { $res = $this->twlio->getCompositionStatus($value['composition_id']); //echo $res['status']; if(count($res) && $res['status'] == 'completed') { - $is_copied = $this->copyMediaFromTwiloToS3($pd_master_details,$value);// copy media from twlio s3 to our s3 + $is_copied = $this->copyMediaFromTwiloToS3($pd_master_details,$value,$pd_category);// copy media from twlio s3 to our s3 $fields_to_update = array('twilo_status' => 'completed'); if($is_copied) { $fields_to_update['s3_copied'] = 1; } $id = $this->PD_Model->updateRecords($fields_to_update,VIDEO_ROOM_INFO,array('video_room_info_id' => $value['video_room_info_id'])); @@ -10313,7 +10318,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); //echo $singed_uri; $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ; - $lender_id = $pd_catgory == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $lender_id = $pd_master_details[0]['fk_lender_id']; $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); //echo $internal_server_tmp_location; From 865c29d5ac577964e44726bfd6b02dac94bf6795 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 3 Aug 2022 21:26:53 +0530 Subject: [PATCH 046/132] FInal Digilocker : ps --- api/application/config/constants.php | 3 +- api/application/config/routes.php | 2 + .../controllers/Flyhi_Controller.php | 137 ++++++++++++++++-- api/application/controllers/PD_Controller.php | 12 +- .../helpers/digital_locker_helper.php | 44 +++--- api/application/views/digital_locker.php | 66 ++++++--- 6 files changed, 205 insertions(+), 59 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 078f3ba8..664634bc 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,7 +95,8 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); -defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs'); +defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'previewDigiLockerDocs'); +// defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs'); defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs'); defined('ROUTE_LOGIN_D') OR define('ROUTE_LOGIN_D', 'saveFlyhiPDImage'); // no errors defined('ROUTE_LOGIN_C') OR define('ROUTE_LOGIN_C', 'getCreditPDReportforCETApp'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 0c3ce829..7784bdfc 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -396,3 +396,5 @@ $route['downloadDigiLockerDocs']='Flyhi_Controller/downloadDigiLockerDocs'; $route['archivePDSMCImages'] = 'SMC_Credit_PD_Controller/archivePDImages'; $route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; +$route['myFunction']='Flyhi_Controller/myFunction'; +$route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index adf0c7f7..600138fd 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -2186,25 +2186,29 @@ class Flyhi_Controller extends REST_Controller { } } - public function getDigiLockerDocs_get(){ + public function getDigiLockerDocs_get(){ $this->load->helper('digital_locker'); // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; $code = $this->get('code'); $co_applicant = $this->get('state'); - log_message('ERROR',"### 1 : Inside Controller GetDigilockerDocs code :".$code." & applicant id : ".$co_applicant); + log_message('ERROR',"### 1 Msg : Inside flyhi Controller GetDigilockerDocs fns"); + log_message('ERROR',"### 1 Params : i have code :".$code." & applicant id : ".$co_applicant); $response_data = digital_locker::getAccessToken($code,$co_applicant); - + log_message('ERROR',"### 5 Helper Reponse : ".json_encode($response_data)); if(isset($response_data['dataStatus']) && $response_data['dataStatus'] == false){ $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; $this->response($response_data,REST_Controller::HTTP_OK); }else{ - $view_data['list'] = json_decode($response_data['records'], true); + $other_data = $response_data['dtls']; + $view_data['token']= $response_data['token']; - $view_data['pd_id']=$response_data['pd_id']; - $view_data['applicant_name']=$response_data['applicant_name']; - $view_data['applicant_id']=$response_data['applicant_id']; - log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs reponse :".json_encode($response_data)); - log_message('ERROR',"### 1st : Inside Controller GetDigilockerDocs viewdata :".json_encode($view_data)); + $view_data['list'] = json_decode($response_data['records'], true); + $view_data['pd_id'] = (count($other_data)>0) ? $other_data[0]['fk_pd_id'] : null; + $view_data['applicant_name'] = (count($other_data)>0) ? $other_data[0]['applicant_name'] : null; + $view_data['pd_sno'] = (count($other_data)>0) ? $other_data[0]['pd_sno'] : null; + $view_data['applicant_id']=(count($other_data)>0) ? $other_data[0]['pd_co_applicant_id'] : null; + + log_message('ERROR',"### 5 ViewData :".json_encode($view_data)); $this->header_title = "new"; $view_data['page_title']="PD GENIE : Digitial Documents"; $this->load->view("digital_locker",$view_data); @@ -2304,7 +2308,12 @@ class Flyhi_Controller extends REST_Controller { $this->response($reponse_data,REST_Controller::HTTP_OK); } - public function getDigiLockerDocs2_get(){ + public function myFunction_post(){ + echo ''; + } + public function getDigiLockerDocs3_get(){ $this->load->helper('digital_locker'); // echo " 1- ".digital_locker::userCh_check1(); $view_data['list2'] = array ( @@ -2398,7 +2407,9 @@ class Flyhi_Controller extends REST_Controller { $reponse = digital_locker::userCh_check3($code,$co_applicant); $view_data['token']= "response_data['token']"; $view_data['pd_id']="3258"; - $view_data['applicant_name']="Sanjeev Soni"; + $view_data['applicant_name']="Sanjeev "; + $view_data['applicant_id']="7128"; + $view_data['pd_sno']="M7128"; $this->load->view("digital_locker",$view_data); // echo $html_content; die(); } @@ -2406,4 +2417,108 @@ $this->load->view("digital_locker",$view_data); $this->load->helper('digital_locker'); echo " 3- ".digital_locker::userCh_check3(); } + public function previewDigiLockerDocs_post(){ + $this->load->helper('digital_locker'); + log_message('ERROR',"### 6 Msg : inside Controller PreviewDigiLockerDocs fns"); + log_message('ERROR','### 6 Params : '.json_encode($this->post())); + $temp_flag = 0 ; + $form_data = $this->post(); + $token = $form_data['token']; + $pd_id = $form_data['pd_id']; + $applicant_name = $form_data['applicant_name']; + $applicant_id = $form_data['applicant_id']; + $doc_name = $form_data['doc_name']; + $doc_uri = $form_data['doc_uri']; + log_message('ERROR','### 6 Form data : '.json_encode($form_data)); + if(count($form_data)>0){ + $doc_name = str_replace(' ', '_',$doc_name); + $doc_renamed = $applicant_name."_".$doc_name.'.pdf'; + log_message('ERROR','### 6 Doc renamed : '.$doc_renamed); + // $src_local_file = XLPATH.'/tmp/'.$doc_renamed; + $src_local_file = XLPATH.'/pd_reports/'. $pd_id .'/'.$doc_name.'.pdf'; + log_message('ERROR','### 6 Doc path : '.$doc_renamed); + if(!file_exists($src_local_file)) + { + mkdir(XLPATH.'/pd_reports/'. $pd_id .'/',0777); + $reponse = digital_locker::downloadFiles($doc_uri,$token); + log_message('ERROR',"### 6 Reponse :".json_encode($reponse)); + $ifp = fopen( $src_local_file, 'wb' ); + fwrite( $ifp, $reponse ); + fclose( $ifp ); + + $tempdoc = $src_local_file; + $tempdocname = $doc_renamed; + + $fields = array('pd_id','fk_lender_id'); + $where_condition_array = array('pd_id' => $pd_id); + $dtls = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $pd_id = (count($dtls)>0) ? $dtls[0]['pd_id'] : null; + $fk_lender_id = (count($dtls)>0) ? $dtls[0]['fk_lender_id'] : null; + + $bucketname = LENDER_BUCKET_NAME_PREFIX.$fk_lender_id; + + $key = 'pd'.$pd_id.'/'.$doc_renamed ; + $sourcefile = $tempdoc; + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + log_message('ERROR',"### 8 S3-result :".json_encode($s3result)); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $pd_document_data = array('fk_pd_id' => $pd_id,'img_type' => 2,'pd_document_title'=>$doc_renamed,'pd_document_name'=>$doc_renamed,'fk_form_id'=>18,'co_applicant_id'=>$applicant_id); + $pd_document_id = $this->Flyhi_Model->saveRecords($pd_document_data,PDDOCUMENTS); + if($pd_document_id != "" || $pd_document_id != null){ $temp_flag++; } + // unlink($src_local_file); + } + + }else{ + log_message('ERROR','### 6 else '); + } + // chmod($src_local_file, 0777); + $this->readfile($src_local_file); + + // $tofile= realpath($src_local_file); + // header('Content-Type: application/pdf'); + // // $MyFile = file_get_contents($src_local_file); + // readfile($tofile); + }else{ + $reponse_data['dataStatus'] = false; + $reponse_data['status'] = REST_Controller::HTTP_NO_CONTENT; + $reponse_data['msg'] = 'No File Uploaded'; + $this->response($reponse_data,REST_Controller::HTTP_OK); + } + } + public function readfile($file){ + chmod($file, 0777); + $tofile= realpath($file); + header('Content-Type: application/pdf'); + // $MyFile = file_get_contents($file); + readfile($tofile); +} + + public function previewDigiLockerDoc_get(){ + $this->load->helper('digital_locker'); + $fname = $this->get('doc'); + $fname = "Komal_Covid_old.pdf"; + $token = $this->get('token'); + $pdid = $this->get('pdid'); + $src_local_file = XLPATH.'/tmp/'.$fname; + // $src_local_file = XLPATH.'/pd_reports/'. $pdid .'/'.$fname.'.pdf'; + if(!file_exists($src_local_file)) + { + // $reponse = digital_locker::downloadFiles($fname,$token); + // $ifp = fopen( $src_local_file, 'wb' ); + // fwrite( $ifp, $reponse ); + // fclose( $ifp ); + } + chmod($src_local_file, 0777); + $tofile= realpath($src_local_file); + header('Content-Type: application/pdf'); + readfile($tofile); + // $call = digital_locker::callTheFiles($src_local_file); + // return $fname; + // $tofile= realpath("uploaddir/".$fname); + // header('Content-Type: application/pdf'); + // readfile($tofile); + } }// Class Ends diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 83a18022..5a62c77e 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -10265,14 +10265,14 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() if($video_info->num_rows()) { $video_info = $video_info->result_array(); - //print_r($video_info);die(); + foreach ($video_info as $key => $value) { if($value['composition_id'] && $value['vsp'] != 'google') { $res = $this->twlio->getCompositionStatus($value['composition_id']); - //echo $res['status']; + if(count($res) && $res['status'] == 'completed') { @@ -10319,10 +10319,12 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() //echo $singed_uri; $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ; $lender_id = $pd_master_details[0]['fk_lender_id']; - $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; + $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; + if($pd_catgory == "2"){ + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id'],$internal_server_tmp_location); + } $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); - //echo $internal_server_tmp_location; - if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location); }; + if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location,0777); }; $is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri)); //upload it to aws s3 $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index beff351f..ce69f087 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -8,7 +8,8 @@ class DIGITAL_LOCKER public static function getAccessToken($code,$applicant) { - log_message('ERROR',"### 2 : Inside Helper getAccessToken code :".$code." & applicant :".$applicant); + log_message('ERROR',"### 2 Msg : Inside Digi Helper getAccessToken Fns"); + log_message('ERROR',"### 2 Params : i have code :".$code." & applicant :".$applicant); $CI =&get_instance(); $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); @@ -22,33 +23,32 @@ class DIGITAL_LOCKER $result=curl_exec($ch); $response = json_decode($result); curl_close( $ch ); - log_message('ERROR',"### 2th : getAccessToken Reponse :".json_encode($response)); + log_message('ERROR',"### 2 Response :".json_encode($response)); if(isset($response->error_description)){ - log_message('ERROR',"### 3 : getAccessToken Access Error :".$response->error_description); + log_message('ERROR',"### 2 Error :".$response->error_description); return array('dataStatus'=>false,'msg'=>$response->error_description); }else{ - log_message('ERROR',"### 3 : getAccessToken URI :".$response->access_token); - $CI->db->SELECT("fk_pd_id,pd_co_applicant_id,applicant_name"); + log_message('ERROR',"### 3 Token :".$response->access_token); + $CI->db->SELECT("PDAPPLICANTSDETAILS.fk_pd_id,PDAPPLICANTSDETAILS.pd_co_applicant_id,PDAPPLICANTSDETAILS.applicant_name, + PDTRIGGER.lender_applicant_id, PDTRIGGER.pd_sno"); $CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS"); + $CI->db->JOIN(PDTRIGGER .' as PDTRIGGER','PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id','LEFT'); $CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant); $CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1); $dtls = $CI->db->GET()->result_array(); - $pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null; - $applicant_name = (count($dtls)>0) ? $dtls[0]['applicant_name'] : null; - $applicant_id = $applicant; - - + // 9 840-2 714 $CI->db->where('pd_co_applicant_id',$applicant); $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $result)); - // print_r($CI->db->last_query()); - - return self::getFileIssuedList($response->access_token,$pd_id,$applicant_name,$applicant_id); + // print_r($CI->db->last_query());die(); + log_message('ERROR',"### 3 SQL Reponse :".json_encode($dtls)); + return self::getFileIssuedList($response->access_token,$dtls); } } - public static function getFileIssuedList($access_token,$pd_id,$applicant_name,$applicant_id) + public static function getFileIssuedList($access_token,$dtls) { - log_message('ERROR',"### 4 : Inside Helper getFileIssuedList Token :".$access_token); + log_message('ERROR',"### 4 Msg : Inside Helper getFileIssuedList"); + log_message('ERROR',"### 4 Token :".$access_token); $CI =&get_instance(); $headers = array('Authorization: Bearer '.$access_token); $ch = curl_init(); @@ -56,9 +56,9 @@ class DIGITAL_LOCKER curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); $result=curl_exec($ch); - log_message('ERROR',"### 4th : getFileIssuedList Filelist Reponse :".json_encode($result)); + log_message('ERROR',"### 4 Reponse :".json_encode($result)); curl_close( $ch ); - return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'pd_id'=>$pd_id,'applicant_name'=>$applicant_name,'applicant_id'=>$applicant_id); + return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls); } // public static function downloadFiles($uri,$access_token) @@ -87,7 +87,8 @@ class DIGITAL_LOCKER // } public static function downloadFiles($uri,$access_token) { - log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri); + log_message('ERROR',"### 7 MSG : Inside Helper DIGILOCKERGETFILEURI"); + log_message('ERROR',"### 7 Token :".$access_token." & URI :".$uri); $CI =&get_instance(); $headers = array('Authorization: Bearer '.$access_token); $ch = curl_init(); @@ -95,9 +96,9 @@ class DIGITAL_LOCKER curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); $result=curl_exec($ch); - log_message('ERROR',"### 6.1 : DIGILOCKERGETFILEURI Reponse :".json_encode($result)); + log_message('ERROR',"### 7 Reponse :".json_encode($result)); $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); - log_message('ERROR',"### 6.2 : DIGILOCKERGETFILEURI contentType:".$contentType); + log_message('ERROR',"### 7 ContentType :".$contentType); curl_close ($ch); return $result; } @@ -124,6 +125,9 @@ class DIGITAL_LOCKER $CI->db->where('pd_co_applicant_id',$applicant); $CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response)); + } + public static function callTheFiles($src_local_file){ + } } diff --git a/api/application/views/digital_locker.php b/api/application/views/digital_locker.php index e7a20a78..fc80b677 100644 --- a/api/application/views/digital_locker.php +++ b/api/application/views/digital_locker.php @@ -84,7 +84,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); background-color: #FF0000; border: none; color: white; - padding: 14px; + padding: 8px; text-align: center; text-decoration: none; display: inline-block; @@ -99,7 +99,25 @@ defined('BASEPATH') OR exit('No direct script access allowed'); page-break-inside: inline; } - + + .fa-disabled { + opacity: 0.6; + cursor: not-allowed; +} + + + a i { + transition: all 0.3s linear; + } + + a:hover i { + transform: scale(1.5); + } + + a:hover { + color: red; + } + <?php echo $page_title; ?> @@ -124,49 +142,53 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Digital Documents
+ PD Number : "'.$pd_sno.'/'.$pd_id.'"
Applicant Name : "'.$applicant_name.'"
'; - echo '
- + echo '
- - '; + + '; for($i=0;$i - '; //checkbox + echo ''; //checkbox echo ''; echo ''; echo ''; - echo ''; + echo ''; + echo ' + + '; } - echo ''; - echo ''; - echo ''; - echo ''; - echo '
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
Document Issuer Action
'.($i+1).' -
-
'.($i+1).'
'.$list['items'][$i]['name'].'
'.$list['items'][$i]['date'].'
'.$list['items'][$i]['description'].'
'.$list['items'][$i]['issuer'].'
'.$list['items'][$i]['issuer'].'
+ + + + + + + +
-
-
- -
'; + echo ''; + // + //
+ // + //
} else{ echo ' - - + +
Sr. No. Select Document Name Document Uploaded Date Document Description Document Issuer
Document Issuer Action
There is No Digi-Locker Docs

'; } From 56b76d8672a02a50e5610a319f646c3b205f3f23 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 8 Aug 2022 16:14:31 +0530 Subject: [PATCH 047/132] Impact of GST on business REMOVED : ps --- api/application/views/report_templates/JSONTOREPORT_CLIX.php | 2 +- .../views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php | 2 +- .../views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX.php b/api/application/views/report_templates/JSONTOREPORT_CLIX.php index 9d0161c0..e1512099 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX.php @@ -2010,7 +2010,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo 'USP of the business (How applicant’s business is different from others in the business)'.$future_plan_business_environment['usp_of_the_business'].''; echo 'Future plan for business expansion'.$future_plan_business_environment['future_plans_for_business_expansion'].''; - echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; + // echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; echo 'Key competitors in the business'.$future_plan_business_environment['key_competitors'].''; echo 'Succession Plan for business'.$future_plan_business_environment['succession_plan'].''; echo 'Brief of other group concerns/ Business run by the applicant'.$future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'].''; diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php index 4bcf0aef..6ffa6ee8 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php @@ -2017,7 +2017,7 @@ font-weight: bolder;; echo 'USP of the business (How applicant’s business is different from others in the business)'.$future_plan_business_environment['usp_of_the_business'].''; echo 'Future plan for business expansion'.$future_plan_business_environment['future_plans_for_business_expansion'].''; - echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; + // echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; echo 'Key competitors in the business'.$future_plan_business_environment['key_competitors'].''; echo 'Succession Plan for business'.$future_plan_business_environment['succession_plan'].''; echo 'Brief of other group concerns/ Business run by the applicant'.$future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'].''; diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php b/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php index 3ad97edf..d87e6319 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php @@ -2013,7 +2013,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo 'USP of the business (How applicant’s business is different from others in the business)'.$future_plan_business_environment['usp_of_the_business'].''; echo 'Future plan for business expansion'.$future_plan_business_environment['future_plans_for_business_expansion'].''; - echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; + // echo 'Impact of GST on business'.$future_plan_business_environment['impact_of_gst_on_the_business'].''; echo 'Key competitors in the business'.$future_plan_business_environment['key_competitors'].''; echo 'Succession Plan for business'.$future_plan_business_environment['succession_plan'].''; echo 'Brief of other group concerns/ Business run by the applicant'.$future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'].''; From 5a308b754421dcf27fa429cc401b987d87a2e761 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 18 Aug 2022 21:30:15 +0530 Subject: [PATCH 048/132] SMC report lpic ink Changes : ps --- .../controllers/SMC_Credit_PD_Controller.php | 5 ++-- .../helpers/report_attachments_helper.php | 17 +++++++++++++ .../helpers/url_shortener_helper.php | 25 +++++++++++++++++++ .../views/smc_creditpd_reports/MWISE.php | 6 +++-- .../views/smc_creditpd_reports/NBFC.php | 6 +++-- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index 5a1dd017..e312cffb 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1522,6 +1522,7 @@ public function filterSalesPDList_post() { $this->load->helper('smc_creditpd'); $this->load->helper('cet_creditpd'); $this->load->helper('smcpdscore'); + $this->load->helper('report_attachments'); $view_data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($records['pd_id']); @@ -1684,14 +1685,14 @@ public function filterSalesPDList_post() { } cet_creditpd::pushwithcetcreditpdapi($common_fields,$CETAPP_creditPD_data); - + $view_data['report_attachments'] = (new report_attachments)->getSMCReportAttchments($records['pd_id'],$view_data['pd_master_details'][0]['random_string'],$view_data['pd_master_details']); if($view_data['pd_master_details'][0]['product_abbr'] == "NBFC/MFI"){ $html_content = $this->load->view('smc_creditpd_reports/NBFC',$view_data,true); }else{ $html_content = $this->load->view('smc_creditpd_reports/MWISE',$view_data,true); } - // print_r($html_content);exit(); + print_r($html_content);exit(); $pdf_name = $view_data['pd_master_details'][0]['main_applicant']; $new_pdf_name = "PD_Report_".$view_data['pd_master_details'][0]['main_applicant']; diff --git a/api/application/helpers/report_attachments_helper.php b/api/application/helpers/report_attachments_helper.php index f8894673..a8e2b426 100644 --- a/api/application/helpers/report_attachments_helper.php +++ b/api/application/helpers/report_attachments_helper.php @@ -43,6 +43,23 @@ class report_attachments return $attachment; } + + public function getSMCReportAttchments($pdid,$random_string,$pd_master_details = array()) + { + $CI =&get_instance(); + + $CI->load->helper('url_shortener'); + + $uri = url_shortener::SMC_report_url_shorten($pdid,$random_string); + + $attachment = '
+

Data Links

+

Click here for Image PDF Link

Click here for Image ZIP Link

'; + + $attachment.= '


(Note all links will expire in 15 days from the date of report generation.)

'; + + return $attachment; + } } diff --git a/api/application/helpers/url_shortener_helper.php b/api/application/helpers/url_shortener_helper.php index 0ac10d06..eb7c1b9d 100644 --- a/api/application/helpers/url_shortener_helper.php +++ b/api/application/helpers/url_shortener_helper.php @@ -44,6 +44,31 @@ class url_shortener } + + public static function SMC_report_url_shorten($pdid,$random_string,$type = '') + { + //echo 'this is from daiu'; + $CI =&get_instance(); + $CI->load->model('PD_Model'); + + $date_of_creation = date('Ymd'); + $uri = array(); + if($type) + { + $uri[ $type ] = $type.'/'.$date_of_creation.'/'.$pdid.'/'.$random_string; + } + else + { + $uri[ 'ppdf' ] = custom_encryption::encode ( 'ppdf/'.$date_of_creation.'/'.$pdid.'/'.$random_string); + $uri[ 'zip' ] = custom_encryption::encode ( 'zip/'.$date_of_creation.'/'.$pdid.'/'.$random_string ); + } + // print_r($uri);die(); + return $uri; + + + + } + } diff --git a/api/application/views/smc_creditpd_reports/MWISE.php b/api/application/views/smc_creditpd_reports/MWISE.php index 77327ae7..0fe02c80 100644 --- a/api/application/views/smc_creditpd_reports/MWISE.php +++ b/api/application/views/smc_creditpd_reports/MWISE.php @@ -1552,8 +1552,10 @@ if(count($smc_images)) - - + diff --git a/api/application/views/smc_creditpd_reports/NBFC.php b/api/application/views/smc_creditpd_reports/NBFC.php index 881f8eb0..dc9992a8 100644 --- a/api/application/views/smc_creditpd_reports/NBFC.php +++ b/api/application/views/smc_creditpd_reports/NBFC.php @@ -594,8 +594,10 @@ if(count($smc_images)) - - + From 4668159512bbe56d141187f09f392b50b0b17263 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 19 Aug 2022 07:36:35 +0000 Subject: [PATCH 049/132] SMC_Credit_PD_Controller.php edited online with Bitbucket --- api/application/controllers/SMC_Credit_PD_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index e312cffb..ab339b78 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1692,7 +1692,7 @@ public function filterSalesPDList_post() { }else{ $html_content = $this->load->view('smc_creditpd_reports/MWISE',$view_data,true); } - print_r($html_content);exit(); + // print_r($html_content);exit(); $pdf_name = $view_data['pd_master_details'][0]['main_applicant']; $new_pdf_name = "PD_Report_".$view_data['pd_master_details'][0]['main_applicant']; From b9c5ef3d1f6ccb1ee47699ba55b3da13b89ba3fa Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 20 Aug 2022 22:18:44 +0530 Subject: [PATCH 050/132] renaming Existing PD info : ps --- api/application/config/routes.php | 2 + .../controllers/Data_Dump_Controller.php | 435 ++++++++++++++++++ api/application/controllers/PD_Controller.php | 2 +- api/application/models/PD_Model.php | 4 +- 4 files changed, 440 insertions(+), 3 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 7784bdfc..739f251c 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -398,3 +398,5 @@ $route['archivePDSMCImages'] = 'SMC_Credit_PD_Controller/archivePDImages'; $route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; $route['myFunction']='Flyhi_Controller/myFunction'; $route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs'; + +$route['renamingExistingPDinfo']='Data_Dump_Controller/renamingExistingPDinfo'; \ 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 6b1e2b77..c4fa8b74 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -495,4 +495,439 @@ class Data_Dump_Controller extends REST_Controller { log_message('ERROR',"#/# G-Sheet Final PDID : ".$pd_id); return $pd_id; } + + // delete Old PD. + // step 1 : DB-tables update + // step 2 : json and processed_json + // step 3 : rar images docs..... + // step 4 : processjson inactive data deleted.. + + //working fine on tables. + public function deleteOldPDbk_up_get(){ + $_90th_date = date("Y/m/d",strtotime('-90 days')); + + $columns = array('PDTRIGGER.pd_id','PDTRIGGER.addressline1','PDTRIGGER.addressline2','PDTRIGGER.addressline3','PDTRIGGER.pd_contact_mobileno','PDTRIGGER.pd_contact_landline','PDTRIGGER.pd_sno','DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','PDAPPLICANTSDETAILS.pd_co_applicant_id','PDTRIGGER.pd_contact_person_mail'); + $table = PDTRIGGER.' as PDTRIGGER'; + $joins = array(array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', + 'condition' =>'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', + 'jointype' => 'LEFT')); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date ); + $tgr_dtls = $this->PD_Model->getJoinRecords($columns,$table,$joins,$tgr_cond_arr); + $i = 0; // testing Purpose only + // for($i = 0 ;$i < count($tgr_dtls);$i++){ + $pdid = $tgr_dtls[$i]['pd_id']; + $pdsno = $tgr_dtls[$i]['pd_sno']; + $pdappcntid = $tgr_dtls[$i]['pd_co_applicant_id']; + $general_format = $pdsno."-".$pdid."-".$pdappcntid; + + $updt_on_tgr['addressline1'] = $tgr_dtls[$i]['addressline1'] ? $general_format.' - addressline1' : null ; + $updt_on_tgr['addressline2'] = $tgr_dtls[$i]['addressline2'] ? $general_format.' - addressline2' : null ; + $updt_on_tgr['addressline3'] = $tgr_dtls[$i]['addressline3'] ? $general_format.' - addressline3' : null ; + $updt_on_tgr['pd_contact_mobileno'] = $tgr_dtls[$i]['pd_contact_mobileno'] ? $general_format.' - mobileno' : null; + $updt_on_tgr['pd_contact_landline'] = $tgr_dtls[$i]['pd_contact_landline'] ? $general_format.' - landline' : null; + $updt_on_tgr['pd_contact_person_mail'] = $tgr_dtls[$i]['pd_contact_person_mail'] ? $general_format.' - person_mail' : null; + $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); + + $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); + + if(!empty($pdid)){ + $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name'); + $apcnt_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields,$apcnt_cond_arr,PDAPPLICANTSDETAILS); + if(!empty($apcnt_dtls)){ + for($j = 0 ;$j < count($apcnt_dtls);$j++){ + $appcnt_id = $pdsno."-".$pdid."-".$apcnt_dtls[$j]['pd_co_applicant_id']; + $updt_apcnt_dtls['applicant_name'] = $appcnt_id; + $updt_apcnt_dtls['mobile_no'] = $apcnt_dtls[$j]['mobile_no'] ? $appcnt_id.' - mobile_no' : null ; + $updt_apcnt_dtls['additional_mobile_no'] = $apcnt_dtls[$j]['additional_mobile_no'] ? $appcnt_id.' - additional_mobile_no' : null ; + $updt_apcnt_dtls['landline'] = $apcnt_dtls[$j]['landline'] ? $appcnt_id.' - landline' : null ; + $updt_apcnt_dtls['email'] = $apcnt_dtls[$j]['email'] ? $appcnt_id.' - email' : null ; + $updt_apcnt_dtls['addressline1'] = $apcnt_dtls[$j]['addressline1'] ? $appcnt_id.' - addressline1' : null ; + $updt_apcnt_dtls['addressline2'] = $apcnt_dtls[$j]['addressline2'] ? $appcnt_id.' - addressline2' : null ; + $updt_apcnt_dtls['addressline3'] = $apcnt_dtls[$j]['addressline3'] ? $appcnt_id.' - addressline3' : null ; + $updt_apcnt_dtls['company_name'] = $apcnt_dtls[$j]['company_name'] ? $appcnt_id.' - company_name' : null ; + + $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); + } + } + + $addr_fields = array('pd_address_id', 'addressline1'); + $addr_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields,$addr_cond_arr,PDADDRESS); + if(!empty($addr_dtls)){ + for($k = 0 ;$k < count($addr_dtls);$k++){ + $updt_addr_dtls['addressline1'] = $addr_dtls[$k]['addressline1'] ? $general_format.' - addressline1' : null ; + $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); + } + } + $json_fields = array('json','processed_json'); + $json_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $json_dtls = $this->PD_Model->selectCustomRecords($json_fields,$json_cond_arr,PDFORMDETAILSJSON); + + + + // -- replace(COL,Wrong Value,New Value) + // UPDATE sineedgeprod.t_salespd_section_data + // SET section_data = replace(CONVERT(section_data USING utf8), '[answer_value] =>"SAVED"','"answer_value":""') + // where sales_pd_id = 5620 and section_id = 9 and isactive = 1; + } + // } // undo the command + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + // $data['query'] = $this->db->last_query(); + // $data['total data'] =count($tgr_dtls); + // $data['before 90 days data'] = $tgr_dtls; + $this->response($data,REST_Controller::HTTP_OK); + } + + public function renamingExistingPDinfo_get(){ + log_message('ERROR',"renamingExistingPDinfo Called"); + $_90th_date = date("Y/m/d",strtotime('-90 days')); + log_message('ERROR',"90th date => ".$_90th_date); + $pdid_arr = array();// testing purpose + $columns = array('PDTRIGGER.pd_id','PDTRIGGER.addressline1','PDTRIGGER.addressline2','PDTRIGGER.addressline3','PDTRIGGER.pd_contact_mobileno','PDTRIGGER.pd_contact_landline','PDTRIGGER.pd_sno','DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','PDAPPLICANTSDETAILS.pd_co_applicant_id','PDTRIGGER.pd_contact_person_mail','PDTRIGGER.fk_lender_id'); + $table = PDTRIGGER.' as PDTRIGGER'; + $joins = array(array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', + 'condition' =>'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', + 'jointype' => 'LEFT')); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); + // 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11 + log_message('ERROR',"trigger details count ".count($tgr_cond_arr)); + + $tgr_dtls = $this->PD_Model->getJoinRecords($columns,$table,$joins,$tgr_cond_arr); + // $i = 0; // testing Purpose only + // for($i = 0 ;$i < 3;$i++){ // testing purpose only. + for($i = 0 ;$i < count($tgr_dtls);$i++){ + $pdid = $tgr_dtls[$i]['pd_id']; + $earliest['trigger_details'] = $tgr_dtls[$i] ; + if(!empty($pdid)){ + $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name','applicant_name'); + $apcnt_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields,$apcnt_cond_arr,PDAPPLICANTSDETAILS); + if(!empty($apcnt_dtls)){ + $earliest['applicant_details'] = $apcnt_dtls; + } + $addr_fields = array('pd_address_id', 'addressline1'); + $addr_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields,$addr_cond_arr,PDADDRESS); + if(!empty($addr_dtls)){ + $earliest['address_details'] = $addr_dtls; + } + $json_fields = array('pd_form_detail_json_id','json','processed_json','fk_pd_id', 'fk_form_id'); + $json_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $json_dtls = $this->PD_Model->selectCustomRecords($json_fields,$json_cond_arr,PDFORMDETAILSJSON); + if(!empty($json_dtls)){ + $earliest['json_details'] = $json_dtls; + } + $previous_json_fields = array('pd_form_detail_json_id'); + $previous_json_cond_arr = array('isactive' => 0,'fk_pd_id'=>$pdid); + $previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields,$previous_json_cond_arr,PDFORMDETAILSJSON); + if(!empty($previous_json_dtls)){ + foreach($previous_json_dtls as $val) { + $result[] = $val['pd_form_detail_json_id']; + } + $this->db->where_in('pd_form_detail_json_id',$result); + $this->db->delete(PDFORMDETAILSJSON); + } + + $docs_fields = array('pd_document_id', 'pd_document_title', 'pd_document_name'); + $docs_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); + $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields,$docs_cond_arr,PDDOCUMENTS); + if(!empty($docs_dtls)){ + $earliest['docs_details'] = $docs_dtls; + } + + + } + + $return = $this->renamingProcess($earliest); + array_push($pdid_arr['updated pdid'],$return); + array_push($pdid_arr['data'],$earliest); + } // undo the command + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['arr'] = $pdid_arr; + // $data['earliest'] = $earliest; + // $data['totalDetailsInCount'] =count($tgr_dtls); + // $data['before 90 days data'] = $tgr_dtls; + $this->response($data,REST_Controller::HTTP_OK); + } + + public function renamingProcess($details){ + + $have_to_replace = array(); + + $tgr_dtls = $details['trigger_details'] ; + $apcnt_dtls = $details['applicant_details']; + //print_r($apcnt_dtls);die(); + $addr_dtls = $details['address_details']; + $json_dtls = $details['json_details']; + $docs_dtls = $details['docs_details']; + + $pdid = $tgr_dtls['pd_id']; + $pdsno = $tgr_dtls['pd_sno']; + $pdlenid = $tgr_dtls['fk_lender_id']; + + $pdappcntid = $tgr_dtls['pd_co_applicant_id']; + $general_format = $pdsno."-".$pdid."-".$pdappcntid; + + + if(!empty($tgr_dtls)){ + if($tgr_dtls['addressline1']){ + $updt_on_tgr['addressline1'] = $general_format.'-addressline1' ; + $have_to_replace[$tgr_dtls['addressline1']] = $general_format.'-addressline1'; + }else{ $updt_on_tgr['addressline1'] = null; } + if($tgr_dtls['addressline2']){ + $updt_on_tgr['addressline2'] = $general_format.' - addressline2'; + $have_to_replace[$tgr_dtls['addressline2']] = $general_format.'-addressline2'; + }else{ $updt_on_tgr['addressline1'] = null; } + if($tgr_dtls['addressline3']){ + $updt_on_tgr['addressline3'] = $general_format.'-addressline3'; + $have_to_replace[$tgr_dtls['addressline3']] = $general_format.'-addressline3'; + }else{ $updt_on_tgr['addressline1'] = null; } + if($tgr_dtls['pd_contact_mobileno']){ + $updt_on_tgr['pd_contact_mobileno'] = $general_format.'-mobileno' ; + $have_to_replace[$tgr_dtls['pd_contact_mobileno']] = $general_format.'-mobileno'; + }else{ $updt_on_tgr['pd_contact_mobileno'] = null; } + if($tgr_dtls['pd_contact_landline']){ + $updt_on_tgr['pd_contact_landline'] = $general_format.'-landline' ; + $have_to_replace[$tgr_dtls['pd_contact_landline']] = $general_format.'-landline'; + }else{ $updt_on_tgr['pd_contact_landline'] = null; } + if($tgr_dtls['pd_contact_person_mail']){ + $updt_on_tgr['pd_contact_person_mail'] = $general_format.'-mail' ; + $have_to_replace[$tgr_dtls['pd_contact_person_mail']] = $general_format.'-mail'; + }else{ $updt_on_tgr['pd_contact_person_mail'] = null ; } + } + + if(!empty($apcnt_dtls)){ + for($j = 0 ;$j < count($apcnt_dtls);$j++){ + $appcnt_id = $pdsno."-".$pdid."-".$apcnt_dtls[$j]['pd_co_applicant_id']; + + if($apcnt_dtls[$j]['applicant_name']){ + // $have_to_replace[str_replace(' ','',$apcnt_dtls[$j]['applicant_name'])] = $appcnt_id; + $have_to_replace[$apcnt_dtls[$j]['applicant_name']] = $appcnt_id; + $updt_apcnt_dtls['applicant_name'] = $appcnt_id; + } + + if($apcnt_dtls[$j]['mobile_no']){ + $updt_apcnt_dtls['mobile_no'] = $appcnt_id.'-mobile_no'; + $have_to_replace[$apcnt_dtls[$j]['mobile_no']] = $appcnt_id.'-mobile_no'; + }else{ $updt_apcnt_dtls['mobile_no'] = null ; } + + if($apcnt_dtls[$j]['additional_mobile_no']){ + $updt_apcnt_dtls['additional_mobile_no'] = $appcnt_id.'-additional_mobile_no'; + $have_to_replace[$apcnt_dtls[$j]['additional_mobile_no']] = $appcnt_id.'-additional_mobile_no'; + }else{ $updt_apcnt_dtls['additional_mobile_no'] = null ; } + + if($apcnt_dtls[$j]['landline']){ + $updt_apcnt_dtls['landline'] = $appcnt_id.'-landline'; + $have_to_replace[$apcnt_dtls[$j]['landline']] = $appcnt_id.'-landline'; + }else{ $updt_apcnt_dtls['landline'] = null ; } + + if($apcnt_dtls[$j]['email']){ + $updt_apcnt_dtls['email'] = $appcnt_id.'-email'; + $have_to_replace[$apcnt_dtls[$j]['email']] = $appcnt_id.'-email'; + }else{ $updt_apcnt_dtls['email'] = null ; } + + if($apcnt_dtls[$j]['addressline1']){ + $updt_apcnt_dtls['addressline1'] = $appcnt_id.'-addressline1'; + $have_to_replace[$apcnt_dtls[$j]['addressline1']] = $appcnt_id.'-addressline1'; + }else{ $updt_apcnt_dtls['addressline1'] = null ; } + + if($apcnt_dtls[$j]['addressline2']){ + $updt_apcnt_dtls['addressline2'] = $appcnt_id.'-addressline2'; + $have_to_replace[$apcnt_dtls[$j]['addressline2']] = $appcnt_id.'-addressline2'; + }else{ $updt_apcnt_dtls['addressline2'] = null ; } + + if($apcnt_dtls[$j]['addressline3']){ + $updt_apcnt_dtls['addressline3'] = $appcnt_id.'-addressline3'; + $have_to_replace[$apcnt_dtls[$j]['addressline3']] = $appcnt_id.'-addressline3'; + }else{ $updt_apcnt_dtls['addressline3'] = null ; } + + if($apcnt_dtls[$j]['company_name']){ + $updt_apcnt_dtls['company_name'] = $appcnt_id.'-company_name'; + $have_to_replace[$apcnt_dtls[$j]['company_name']] = $appcnt_id.'-company_name'; + }else{ $updt_apcnt_dtls['company_name'] = null ; } + + $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); + } + } + + + if(!empty($addr_dtls)){ + for($k = 0 ;$k < count($addr_dtls);$k++){ + if($addr_dtls[$k]['addressline1']){ + $updt_addr_dtls['addressline1'] = $general_format.'-addressline1'; + $have_to_replace[$addr_dtls[$k]['addressline1']] = $general_format.'-addressline1'; + }else{ + $updt_addr_dtls['addressline1'] = null ; + } + $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); + } + } + + if(!empty($json_dtls)){ + + for($l = 0 ;$l < count($json_dtls);$l++){ + $fid = $json_dtls[$l]['fk_form_id']; + // echo count($json_dtls); + // pd_form_detail_json_id, fk_pd_id, fk_form_id, company_id, isactive, json, processed_json, + $original_j_arr = json_decode($json_dtls[$l]['json'],true); + $original_pj_arr = json_decode($json_dtls[$l]['processed_json'],true); + // $have_to_replace["is_person_met_pic"] = ""; + foreach($have_to_replace as $key => $value){ + $replaced_pj_arr = $this->replace_in_array($key, $value, $original_pj_arr); + $replaced_j_arr = $this->replace_in_array($key, $value, $original_j_arr); + } + // $fid=18; + switch($fid) + { + case 1: + // 1 trade_product_contact_person_name , person_landline ,person_stdcode + $arr1 = array('trade_product_contact_person_name' , 'person_landline' ,'person_stdcode'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr1,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr1,$general_format); + break; + case 2: + // 2 trade_product_contact_person_name , person_landline + $arr2 = array('trade_product_contact_person_name' , 'person_landline'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr2,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr2,$general_format); + break; + case 5: + // 5 alternative_address + $arr5 = array('alternative_address','address'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr5,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr5,$general_format); + break; + case 6: + // 6 residence_place + $arr6 = array('residence_place','earning_name_of_the_employer_or_business','family_member_name'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr6,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr6,$general_format); + break; + case 8: + // 8 label + $arr8 = array('label'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr8,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr8,$general_format); + break; + case 9: + // 9 address + $arr9 = array('address'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr9,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr9,$general_format); + break; + case 10: + $arr10 = array('address','property_seller'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr10,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr10,$general_format); + break; + case 12: + $arr9 = array("employer_name","designation_person_met"); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr12,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr12,$general_format); + break; + case 13: + // 13 partner_name_master . gst_Regn_cert_pic , shop_eat_act_cert_pic + $arr13 = array("partner_name_master","gst_Regn_cert_pic","shop_eat_act_cert_pic","export_import_cert_pic","factory_cert_pic","pf_regn_pic","esic_regn_pic","eb_bill_pic"); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr13,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr13,$general_format); + break; + case 17: + $arr17 = array('address_property'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr17,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr17,$general_format); + break; + case 18: + // 18 is_person_met_pic , is_person_met_id_proof + $arr18 = array('is_person_met_pic' , 'is_person_met_id_proof'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr18,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr18,$general_format); + + break; + case 19: + // 19 neighbourhood_name + $arr19 = array('neighbourhood_name'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr19,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr19,$general_format); + break; + case 22: + // 22 address_label,address_label + $arr22 = array('address_label' , 'address_label'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr22,$general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr22,$general_format); + break; + + } + // traverseArray(&$array, $keys) + $update_json_arr['json'] = json_encode($replaced_j_arr); + $update_json_arr['processed_json'] = json_encode($replaced_pj_arr); + $this->PD_Model->updateRecords($update_json_arr,PDFORMDETAILSJSON,array('pd_form_detail_json_id' => $json_dtls[$l]['pd_form_detail_json_id'] )); + // $data['have_to_replace_this'] = $have_to_replace; + // $data['replaced_pj_array'] = $replaced_pj_arr; + // $data['original_pj_array'] = $original_pj_arr; + // $data['original_j_array'] = $original_j_arr; + // $data['replaced_j_array'] = $replaced_j_arr; + } + } + // $earliest['docs_details'] = $docs_dtls; + if(!empty($doc_dtls)){ + for($m = 0 ;$m < count($doc_dtls);$m++){ + $docname = $doc_dtls[$m]['pd_document_name']; + $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$docname; + // unlink($destination_path); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pdlenid; + $key = 'pd'.$pdid.'/'.$docname; + // $s3result= $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); + // if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + // {} + + } + } + $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); + $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); + return $pdid; + // $data['pdid'] = $pdid ; + // $this->response($data,REST_Controller::HTTP_OK); + } + + function replace_in_array($find, $replace, &$array) { + array_walk_recursive($array, function(&$array) use($find, $replace) { + if($array === $find) { + $array= $replace; + } + }); + return $array; + } + + + + function traverseArray(&$array, $keys,$format) { + foreach ($array as $key => &$value) { + if (is_array($value)) { + $this->traverseArray($value, $keys,$format); + } else { + if (in_array($key, $keys)){ + // unset($array[$key]); + $array[$key] = $format."-".$key; + } + } + } + return $array; + } + + function delete_file_destination($file,$pdid) { + + // foreach ($files as $file) { + // if (file_exists($file)) { + // unlink($file); + $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$file; + unlink($destination_path); + // } else { + // // File not found. + // } + // } + } + } \ No newline at end of file diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 5a62c77e..98327bd2 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -11744,7 +11744,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } function PDjson_get(){ - $data = $this->PD_Model->testSection($this->get('id')); + $data = $this->PD_Model->testSection($this->get('id'),$this->get('fid')); $this->response($data,REST_Controller::HTTP_OK); } function checkmail_post(){ diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 6457d14b..f363a729 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -2641,8 +2641,8 @@ class PD_Model extends SPARQ_Model { return $result_data; } - public function testSection($id){ - $this->db->SELECT('*')->FROM("t_pd_form_details_json")->WHERE('fk_pd_id',$id)->WHERE('isactive',1)->WHERE('fk_form_id',5); + public function testSection($id,$fid){ + $this->db->SELECT('*')->FROM("t_pd_form_details_json")->WHERE('fk_pd_id',$id)->WHERE('isactive',1)->WHERE('fk_form_id',$fid); // ->WHERE('company_id',1); $query = $this->db->get(); return $query->result(); From df8c0354be8e0fe24fb9047f3c4f0998ed5cdc07 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sun, 21 Aug 2022 15:06:14 +0530 Subject: [PATCH 051/132] renamingExistingPDinfo : ps --- api/application/config/constants.php | 1 + api/application/config/routes.php | 2 +- .../controllers/Data_Dump_Controller.php | 79 +++++++++++++------ .../helpers/authorization_helper.php | 2 +- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 664634bc..f4f020ef 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,6 +95,7 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); +defined('ROUTE_LOGIN_S') OR define('ROUTE_LOGIN_S', 'renamingExistingPDinfo'); defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'previewDigiLockerDocs'); // defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs'); defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 739f251c..481db59f 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -399,4 +399,4 @@ $route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; $route['myFunction']='Flyhi_Controller/myFunction'; $route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs'; -$route['renamingExistingPDinfo']='Data_Dump_Controller/renamingExistingPDinfo'; \ No newline at end of file +$route['purgePDdata']='Data_Dump_Controller/renamingExistingPDinfo'; \ 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 c4fa8b74..69af62f6 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -581,47 +581,59 @@ class Data_Dump_Controller extends REST_Controller { } public function renamingExistingPDinfo_get(){ - log_message('ERROR',"renamingExistingPDinfo Called"); + log_message('ERROR',"renamingExistingPDinfo Fns Called"); $_90th_date = date("Y/m/d",strtotime('-90 days')); - log_message('ERROR',"90th date => ".$_90th_date); + $pdsno = $this->get('pdsno'); + $pdid_arr = array();// testing purpose $columns = array('PDTRIGGER.pd_id','PDTRIGGER.addressline1','PDTRIGGER.addressline2','PDTRIGGER.addressline3','PDTRIGGER.pd_contact_mobileno','PDTRIGGER.pd_contact_landline','PDTRIGGER.pd_sno','DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','PDAPPLICANTSDETAILS.pd_co_applicant_id','PDTRIGGER.pd_contact_person_mail','PDTRIGGER.fk_lender_id'); $table = PDTRIGGER.' as PDTRIGGER'; $joins = array(array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', 'condition' =>'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', 'jointype' => 'LEFT')); - $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); - // 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11 - log_message('ERROR',"trigger details count ".count($tgr_cond_arr)); + if(!empty($pdsno)){ + log_message('ERROR',"PD Serial No => ".$pdsno); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'PDTRIGGER.pd_sno' => $pdsno ); + }else{ + log_message('ERROR',"90th date => ".$_90th_date); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); + } + // 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11 + log_message('ERROR',"trigger details Total count ".count($tgr_cond_arr)); $tgr_dtls = $this->PD_Model->getJoinRecords($columns,$table,$joins,$tgr_cond_arr); // $i = 0; // testing Purpose only // for($i = 0 ;$i < 3;$i++){ // testing purpose only. for($i = 0 ;$i < count($tgr_dtls);$i++){ $pdid = $tgr_dtls[$i]['pd_id']; + log_message('ERROR',"trigger details for Loop inx = ".$i." PDID = ".$pdid); $earliest['trigger_details'] = $tgr_dtls[$i] ; if(!empty($pdid)){ $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name','applicant_name'); $apcnt_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields,$apcnt_cond_arr,PDAPPLICANTSDETAILS); + log_message('ERROR',"Total Applicant Details for ".$pdid." = ".count($apcnt_dtls)); if(!empty($apcnt_dtls)){ $earliest['applicant_details'] = $apcnt_dtls; } $addr_fields = array('pd_address_id', 'addressline1'); $addr_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields,$addr_cond_arr,PDADDRESS); + log_message('ERROR',"Total Address Details for ".$pdid." = ".count($addr_dtls)); if(!empty($addr_dtls)){ $earliest['address_details'] = $addr_dtls; } $json_fields = array('pd_form_detail_json_id','json','processed_json','fk_pd_id', 'fk_form_id'); $json_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); $json_dtls = $this->PD_Model->selectCustomRecords($json_fields,$json_cond_arr,PDFORMDETAILSJSON); + log_message('ERROR',"Total JSON Details for ".$pdid." = ".count($json_dtls)); if(!empty($json_dtls)){ $earliest['json_details'] = $json_dtls; } $previous_json_fields = array('pd_form_detail_json_id'); $previous_json_cond_arr = array('isactive' => 0,'fk_pd_id'=>$pdid); $previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields,$previous_json_cond_arr,PDFORMDETAILSJSON); + log_message('ERROR',"Total IN-Active JSON Details for ".$pdid." = ".count($previous_json_dtls)); if(!empty($previous_json_dtls)){ foreach($previous_json_dtls as $val) { $result[] = $val['pd_form_detail_json_id']; @@ -633,6 +645,7 @@ class Data_Dump_Controller extends REST_Controller { $docs_fields = array('pd_document_id', 'pd_document_title', 'pd_document_name'); $docs_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields,$docs_cond_arr,PDDOCUMENTS); + log_message('ERROR',"Total Document Details for ".$pdid." = ".count($docs_dtls)); if(!empty($docs_dtls)){ $earliest['docs_details'] = $docs_dtls; } @@ -641,12 +654,13 @@ class Data_Dump_Controller extends REST_Controller { } $return = $this->renamingProcess($earliest); - array_push($pdid_arr['updated pdid'],$return); - array_push($pdid_arr['data'],$earliest); - } // undo the command + + // if(!empty($return)){ + // array_push($pdid_arr['updated pdid'],$return); + // array_push($pdid_arr['data'],$earliest);} + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['arr'] = $pdid_arr; // $data['earliest'] = $earliest; // $data['totalDetailsInCount'] =count($tgr_dtls); // $data['before 90 days data'] = $tgr_dtls; @@ -654,15 +668,15 @@ class Data_Dump_Controller extends REST_Controller { } public function renamingProcess($details){ - + log_message('ERROR',"renamingProcess Fns Called"); $have_to_replace = array(); - $tgr_dtls = $details['trigger_details'] ; - $apcnt_dtls = $details['applicant_details']; + $tgr_dtls = isset($details['trigger_details']) ? $details['trigger_details'] : array(); ; + $apcnt_dtls = isset($details['applicant_details']) ? $details['applicant_details'] : array(); //print_r($apcnt_dtls);die(); - $addr_dtls = $details['address_details']; - $json_dtls = $details['json_details']; - $docs_dtls = $details['docs_details']; + $addr_dtls = isset($details['address_details']) ? $details['address_details'] : array(); + $json_dtls = isset($details['json_details']) ? $details['json_details'] : array(); + $docs_dtls = isset($details['docs_details']) ? $details['docs_details'] : array(); $pdid = $tgr_dtls['pd_id']; $pdsno = $tgr_dtls['pd_sno']; @@ -670,7 +684,7 @@ class Data_Dump_Controller extends REST_Controller { $pdappcntid = $tgr_dtls['pd_co_applicant_id']; $general_format = $pdsno."-".$pdid."-".$pdappcntid; - + log_message('ERROR',"Format generated => ".$general_format); if(!empty($tgr_dtls)){ if($tgr_dtls['addressline1']){ @@ -749,7 +763,9 @@ class Data_Dump_Controller extends REST_Controller { $have_to_replace[$apcnt_dtls[$j]['company_name']] = $appcnt_id.'-company_name'; }else{ $updt_apcnt_dtls['company_name'] = null ; } - $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); + $apcnt_result = $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); + if($apcnt_result){ log_message('ERROR',"applicant updated => ".$apcnt_dtls[$j]['pd_co_applicant_id']." Updated successfully ( ".($j+1)." )");} + else{ log_message('ERROR',"Check here Applicant Not updated ( ".($j+1)." ) pkid = ".$apcnt_dtls[$j]['pd_co_applicant_id']); } } } @@ -762,7 +778,9 @@ class Data_Dump_Controller extends REST_Controller { }else{ $updt_addr_dtls['addressline1'] = null ; } - $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); + $addr_result = $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); + if($addr_result){ log_message('ERROR',"address updated => ".$addr_dtls[$k]['pd_address_id']." Updated successfully ( ".($k+1)." )");} + else{ log_message('ERROR',"Check here Adress table Not updated ( ".($k+1)." ) pkid = ".$addr_dtls[$k]['pd_address_id']); } } } @@ -770,6 +788,10 @@ class Data_Dump_Controller extends REST_Controller { for($l = 0 ;$l < count($json_dtls);$l++){ $fid = $json_dtls[$l]['fk_form_id']; + $fields = array('pd_form_name'); + $where_condition_array = array("pd_form_id"=>$fid); + $form_table = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMS); + $form_name = count($form_table)>0 ? $form_table[0]['pd_form_name'] : ''; // echo count($json_dtls); // pd_form_detail_json_id, fk_pd_id, fk_form_id, company_id, isactive, json, processed_json, $original_j_arr = json_decode($json_dtls[$l]['json'],true); @@ -863,7 +885,9 @@ class Data_Dump_Controller extends REST_Controller { // traverseArray(&$array, $keys) $update_json_arr['json'] = json_encode($replaced_j_arr); $update_json_arr['processed_json'] = json_encode($replaced_pj_arr); - $this->PD_Model->updateRecords($update_json_arr,PDFORMDETAILSJSON,array('pd_form_detail_json_id' => $json_dtls[$l]['pd_form_detail_json_id'] )); + $json_result =$this->PD_Model->updateRecords($update_json_arr,PDFORMDETAILSJSON,array('pd_form_detail_json_id' => $json_dtls[$l]['pd_form_detail_json_id'] )); + if($json_result){ log_message('ERROR',"JSON updated => ".$form_name." Updated successfully ( ".($l+1)." ) json table id = ".$json_dtls[$l]['pd_form_detail_json_id']);} + else{ log_message('ERROR',"Check here JSON Not updated ".$form_name." ( ".($l+1)." ) json table id = ".$json_dtls[$l]['pd_form_detail_json_id']); } // $data['have_to_replace_this'] = $have_to_replace; // $data['replaced_pj_array'] = $replaced_pj_arr; // $data['original_pj_array'] = $original_pj_arr; @@ -874,19 +898,26 @@ class Data_Dump_Controller extends REST_Controller { // $earliest['docs_details'] = $docs_dtls; if(!empty($doc_dtls)){ for($m = 0 ;$m < count($doc_dtls);$m++){ + log_message('ERROR',"Document ".$doc_dtls[$m]['pd_document_name'] ); $docname = $doc_dtls[$m]['pd_document_name']; $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$docname; - // unlink($destination_path); + unlink($destination_path); + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pdlenid; $key = 'pd'.$pdid.'/'.$docname; - // $s3result= $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); - // if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - // {} + $s3result= $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + log_message('ERROR',"s3result ".$s3result['@metadata']['statusCode'] ); + } + else{ log_message('ERROR',"Check here Not updated on S3 result ".$s3result['@metadata']['statusCode'] ); } } } $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); - $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); + $trg_result = $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); + if($trg_result){ log_message('ERROR',"Trigger table updated pdid => ".$pdid." Updated successfully ");} + else{ log_message('ERROR',"Check here Trigger table Not updated pdid = ".$pdid); } return $pdid; // $data['pdid'] = $pdid ; // $this->response($data,REST_Controller::HTTP_OK); diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php index 39a91ee8..8ccfe153 100644 --- a/api/application/helpers/authorization_helper.php +++ b/api/application/helpers/authorization_helper.php @@ -72,7 +72,7 @@ class AUTHORIZATION } - if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C || $routingName == ROUTE_LOGIN_D || $routingName == ROUTE_LOGIN_E || $routingName == ROUTE_LOGIN_F) + if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API || $routingName ==SAVESMCCREDITPDIMAGE_API || $routingName ==GETSMCPDIMGSECTIONDATA_API || $routingName == ROUTE_LOGIN_T || $routingName == ROUTE_LOGIN_U || $routingName == ROUTE_LOGIN_B || $routingName == ROUTE_LOGIN_C || $routingName == ROUTE_LOGIN_D || $routingName == ROUTE_LOGIN_E || $routingName == ROUTE_LOGIN_F || $routingName == ROUTE_LOGIN_S) { return true; } From b86eed3d8d0fa63be8c9df2e24c3b143e7fc5fbe Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Sun, 21 Aug 2022 09:54:41 +0000 Subject: [PATCH 052/132] routes.php edited online with Bitbucket --- api/application/config/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 481db59f..2988aae8 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -399,4 +399,4 @@ $route['smcPhotoPDFDownload'] = 'SMC_Credit_PD_Controller/imgPDFDownload'; $route['myFunction']='Flyhi_Controller/myFunction'; $route['previewDigiLockerDocs']='Flyhi_Controller/previewDigiLockerDocs'; -$route['purgePDdata']='Data_Dump_Controller/renamingExistingPDinfo'; \ No newline at end of file +$route['purge_pddata']='Data_Dump_Controller/renamingExistingPDinfo'; \ No newline at end of file From 877ab03d4c3368c9aeb7076f7b05c4edd1f6b4bf Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Sun, 21 Aug 2022 09:57:45 +0000 Subject: [PATCH 053/132] constants.php edited online with Bitbucket --- api/application/config/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index f4f020ef..d997627a 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -95,7 +95,7 @@ defined('ROUTE_LOGIN_W') OR define('ROUTE_LOGIN_W', 'saveSalesPDImage'); defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg'); // no errors defined('ROUTE_LOGIN_U') OR define('ROUTE_LOGIN_U', 'generateOTP'); defined('ROUTE_LOGIN_T') OR define('ROUTE_LOGIN_T', 'verifyOTP'); -defined('ROUTE_LOGIN_S') OR define('ROUTE_LOGIN_S', 'renamingExistingPDinfo'); +defined('ROUTE_LOGIN_S') OR define('ROUTE_LOGIN_S', 'purge_pddata'); defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'previewDigiLockerDocs'); // defined('ROUTE_LOGIN_F') OR define('ROUTE_LOGIN_F', 'downloadDigiLockerDocs'); defined('ROUTE_LOGIN_E') OR define('ROUTE_LOGIN_E', 'getDigiLockerDocs'); From 4bb2bd6522f2f97ee132a3a2f9d813cdad15fbf3 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 22 Aug 2022 04:39:29 +0000 Subject: [PATCH 054/132] pd_status ARCHIVED : ps --- api/application/controllers/Data_Dump_Controller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index 69af62f6..84bf5f3a 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -439,7 +439,7 @@ class Data_Dump_Controller extends REST_Controller { } } - ## Credit Manager’s Specific Queries + ## Credit Managers Specific Queries if($pd_id != ""){ if($addi_requirements != "" || $addi_requirements != null) { @@ -914,6 +914,7 @@ class Data_Dump_Controller extends REST_Controller { } } + $updt_on_tgr['pd_status'] = ARCHIVED ; $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); $trg_result = $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); if($trg_result){ log_message('ERROR',"Trigger table updated pdid => ".$pdid." Updated successfully ");} From 7958ea90ccb42e29a1615da7aee2afcb6cd13647 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 22 Aug 2022 17:55:54 +0530 Subject: [PATCH 055/132] Fly Feedback 1 : ps --- .../controllers/Data_Dump_Controller.php | 2 +- .../controllers/Flyhi_Controller.php | 9 ++-- .../views/sale_pd_templates/FHFSL.php | 42 ++++++++++--------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index 69af62f6..a86fe763 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -846,7 +846,7 @@ class Data_Dump_Controller extends REST_Controller { $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr10,$general_format); break; case 12: - $arr9 = array("employer_name","designation_person_met"); + $arr12 = array("employer_name","designation_person_met"); $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr12,$general_format); $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr12,$general_format); break; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 600138fd..3efc140e 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -206,11 +206,11 @@ class Flyhi_Controller extends REST_Controller { public function listFlyhiPD_get(){ $user_id = $this->uri->segment(1); - $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', 'SALES_PD_DATA.lender_sales_person','concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name','LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno','LENDERSALESPERSON.email as lender_sales_person_email', 'SALES_PD_DATA.lender_credit_person','concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name','LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno','LENDERCREDITPERSON.email as lender_credit_person_email', 'SALES_PD_DATA.pd_branch_id','ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount', + '(CASE WHEN SALES_PD_DATA.sales_pd_type = 3 THEN "Workplace verification" WHEN SALES_PD_DATA.sales_pd_type = 4 THEN "Residence verification" ELSE "-" END) AS sales_pd_type_master', '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; @@ -687,9 +687,10 @@ class Flyhi_Controller extends REST_Controller { // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $flyhipd_id); $flyhipd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); $pd_type = ""; - if($flyhipd_data[0]['sales_pd_type'] == 3){$pd_type = "Office FI PD-"; }else if($flyhipd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} - + if($flyhipd_data[0]['sales_pd_type'] == 3){$pd_type = "Workplace FI PD-"; }else if($flyhipd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} + // print_r($flyhipd_data);die(); if($flyhipd_data) + // if(1) { ini_set('max_execution_time', 0); $bucket_name = LENDER_BUCKET_NAME_PREFIX.$flyhipd_data[0]['lender_id']; @@ -733,7 +734,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - //echo $html_content;die(); + // echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index a5db735a..37ef9737 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -1,13 +1,15 @@ ↑'; $downarrow = ''; $dash = ' '; - $product_name = $master[0]['abbr']; + $product_abbr = $master[0]['abbr']; + $product = $master[0]['name']; $rupee_symbol = ""; $title = ""; - if($section1['verification_type'] == "Office verification"){$title = "Office FI "; }else if($section1['verification_type'] == "Residence verification"){$title = "Residence FI ";} + if($section1['verification_type'] == "Office verification" || $section1['verification_type'] == "Workplace verification"){$title = "Workplace FI for ".$product; } + else if($section1['verification_type'] == "Residence verification"){$title = "Residence FI for ".$product;} $smc_emp_code = $master[0]['smc_emp_code']; $residence_ownership_arr = array("self_owned" => "Self-Owned","parental"=>"Parental","family_owned"=>"Family Owned","rented"=>"Rented"); $residence_yr_arr = array("0"=>"< 1 yr","1"=>"1-2 yrs","2"=>"2 to 5 yrs","3"=>"> 5 yrs"); @@ -142,7 +144,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');

- Powered By PD Genie (FLYHI Team) + Powered By PD Genie
@@ -155,7 +157,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Personal Discussion by FlyHI Team - + Lender Name @@ -186,11 +188,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Application Name + Applicant Name - Application Mobile Number + Applicant Mobile Number @@ -224,14 +226,14 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Residence Ownership - + Years at Current Residence - Same as Current Residence Address + Permanent Address Same as Current Residence Address @@ -280,13 +282,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Occupation of the Loan Applicant - + Employer/Business Name - + - Constitution of Employer /Business Applicant - + Constitution of Employer /Business + Years at Current employment/Business - Total Work Experience + Total Work Experience (in Years) - Net Monthly Salary/ Net Income - + Net Monthly Salary/ Net Income (Rs) + @@ -364,11 +366,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - Educational Institute Fee - + Educational Institute Fee (Rs) + - Duration of the Course + Duration of the Course (months) From 54687cf5a8c68cb526063ed5091c3d70abbabfd3 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 23 Aug 2022 09:58:11 +0530 Subject: [PATCH 056/132] Regenerate Flyhi report : ps --- api/application/config/routes.php | 2 ++ .../controllers/Flyhi_Controller.php | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 2988aae8..d902183b 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -390,6 +390,8 @@ $route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage'; $route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink'; $route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection'; $route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList'; +$route['regenerateFlyhiReport'] = 'Flyhi_Controller/regenerateFlyhiReport'; + $route['getDigiLockerDocs']='Flyhi_Controller/getDigiLockerDocs'; // $route['getDigiLockerDocs2']='Flyhi_Controller/getDigiLockerDos'; $route['downloadDigiLockerDocs']='Flyhi_Controller/downloadDigiLockerDocs'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 3efc140e..5ec7016e 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -700,7 +700,7 @@ class Flyhi_Controller extends REST_Controller { $pdf_name .= '-'.$pd_type.$flyhipd_data[0]['abbr']; $pdf_name .= '-'.(date('dmY',strtotime($flyhipd_data[0]['completed_date']))); $key = 'sales_pd/'.$pd_id.'/'.$pdf_name.'.pdf'; - //$this->Flyhi_Model->updateRecords(array('pd_report_filename' => 'PD_Report-'.$pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); + $this->Flyhi_Model->updateRecords(array('pd_report_filename' => $pdf_name),SALES_PD_DATA,array('sales_pd_id' => $pd_id)); if(!file_exists($this->external_path.'/sales_pd/'.$pd_id)) { @@ -2187,6 +2187,21 @@ class Flyhi_Controller extends REST_Controller { } } + //api for Manually Report Generation. + public function regenerateFlyhiReport_get(){ + $sales_pd_id = $this->get('sales_pd_id'); + if(!empty($sales_pd_id)){ + $this->Sales_PD_Model->updateRecords(array('is_pdf' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + log_message('ERROR','####Manually Called - Report Generated Flyhi pd = '.$sales_pd_id); + $this->prepareFlyhiPDReport($sales_pd_id);} + else{ + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Sales PDID Not Found !'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + public function getDigiLockerDocs_get(){ $this->load->helper('digital_locker'); // $code = "66e28b748d5f73186206a03f27f6aee73191a087"; From 9e301beae34cd34868116c3c80af753b59ab6dd2 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 23 Aug 2022 22:28:03 +0530 Subject: [PATCH 057/132] upload Sales PD Data To CET App api : ps --- api/application/config/routes.php | 1 + .../controllers/Sales_PD_Controller.php | 142 ++++++++++++------ 2 files changed, 96 insertions(+), 47 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index d902183b..1a20bda2 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -370,6 +370,7 @@ $route['getEvent'] = 'GC_Event_Controller/getEventFromGoogleCalender';//dummy ch $route['createGmeetLink'] = 'PD_Controller/createGmeetLink'; //only developer testing, not for APP use $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only developer testing, not for APP use +$route['uploadSalesPDDataToCETApp'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp'; $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 510b8030..0d1a7c0b 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -205,63 +205,17 @@ class Sales_PD_Controller extends REST_Controller { $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); // print_r(json_decode($all_section_data[0]['section_data'],true));die(); $view_data['master'] = $sales_pd_data; - $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], - 'product'=>$sales_pd_data[0]['abbr'], - 'caseno'=>$sales_pd_data[0]['sales_pd_sno']); foreach ($all_section_data as $sec_key => $section) { // print_r($section['section_id']);die(); - // log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$sales_pd_id); $view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);//die(); - $section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); } // print_r($view_data['section3']);die(); $view_data['section9'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); - if(count($view_data['section9'])>0){ - for ($i = 0; $i < count($view_data['section9']); $i++){ - $img_fields = $common_fields; - $img_fields['img_name'] = $view_data['section9'][$i]['img_name']; - $img_split = explode( ',', $view_data['section9'][$i]['img']); - $img_fields['img'] = $img_split[1]; - // $img_fields[0]['img'] = $view_data['section9'][$i]['img']; - cet_salespd::pushwithcetphotographapi($img_fields,$i); - } - // "section9":{"selfie_with_person_met":"SAVED","approach_to_pd_location":["SAVED",""],"name_board_seen":["SAVED",""],"stock_image":["SAVED","SAVED","SAVED","SAVED",""],"workplace_interior_image":["SAVED","SAVED",""]}} - // $arr1 =array();$arr2 =array(); - //for ($i = 0; $i < count($view_data['section9']); $i++){ - // $img_name = $view_data['section9'][$i]['img_name']; - // if(!in_array($img_name, $arr1)){ - // array_push($arr1,$img_name); - // } - // $k = array_search($img_name, $arr1); //$k = 1; - // $arr2[$k][] = $view_data['section9'][$i]['img']; - // for ($j = 0; $j < count($arr1); $j++) { - // $section_fields['section9'][$arr1[$j]] = $arr2[$j]; - // } - //} - } - // cet_salespd::pushwithcetsalespdapi($common_fields,$section_fields,1); - $CETAPP_salesPD_data = $section_fields; - $officer_name = isset($CETAPP_salesPD_data['section8']['name_of_sales_team_member']) ? $CETAPP_salesPD_data['section8']['name_of_sales_team_member'] : ''; - if(!empty($officer_name)){ - $officer_details = $this->Sales_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer_full_name'),array('first_name' => $officer_name),USERPROFILE); - if(!empty($officer_details)){ - foreach($officer_details as $key=>$value) { - $CETAPP_salesPD_data['section8'] = array_merge($section_fields['section8'],$value); - } - } - } - cet_salespd::pushwithcetsalespdapi($common_fields,$CETAPP_salesPD_data,1); $view_data['satellite_image'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS); - if(!empty($view_data['satellite_image'])){ - $stt_fields = $common_fields; - $stt_fields['img_name'] = $view_data['satellite_image'][0]['img_name']; - $stt_fields['img'] = $view_data['satellite_image'][0]['img']; - cet_salespd::pushwithcetphotographapi($stt_fields,0); - } $view_data['product_id'] = $sales_pd_data[0]['product_id']; $view_data['geo_location'] = $sales_pd_data[0]['geo_location']; - // die(); + //print_r($this->db->last_query());die(); //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; $view_name = $sales_pd_data[0]['short_name'];if( $sales_pd_data[0]['abbr'] == 'MEQ'){ $view_name = $sales_pd_data[0]['abbr']; } $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); @@ -316,6 +270,100 @@ class Sales_PD_Controller extends REST_Controller { } } } + + function uploadSalesPDDataToCETApp_get() + { + log_message('ERROR','#### upload SalesPDData To CETApp Called'); + $sales_pd_id = $this->uri->segment(2); + if(!empty($sales_pd_id)){ + log_message('ERROR','#### Sales PD = '.$sales_pd_id); + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr','USERPROFILE.smc_emp_code'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + array('table' => PRODUCTS. ' as PRODUCT', + 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + 'jointype' => 'INNER'), + array('table' => USERPROFILE. ' as USERPROFILE', + 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', + 'jointype' => 'LEFT') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); + $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + log_message('ERROR','#### Total Sales PD is '.count($sales_pd_data)); + if(count($sales_pd_data)>0) + { + $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); + + $common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'], + 'product'=>$sales_pd_data[0]['abbr'], + 'caseno'=>$sales_pd_data[0]['sales_pd_sno']); + + foreach ($all_section_data as $sec_key => $section) + { + $section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); + } + + $photograph_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); + + if(count($photograph_data)>0){ + for ($i = 0; $i < count($photograph_data); $i++){ + $img_fields = $common_fields; + $img_fields['img_name'] = $photograph_data[$i]['img_name']; + $img_split = explode( ',', $photograph_data[$i]['img']); + $img_fields['img'] = $img_split[1]; + // $img_fields[0]['img'] = $photograph_data[$i]['img']; + cet_salespd::pushwithcetphotographapi($img_fields,$i); + } + } + + // cet_salespd::pushwithcetsalespdapi($common_fields,$section_fields,1); + $CETAPP_salesPD_data = $section_fields; + $officer_name = isset($CETAPP_salesPD_data['section8']['name_of_sales_team_member']) ? $CETAPP_salesPD_data['section8']['name_of_sales_team_member'] : ''; + if(!empty($officer_name)){ + $officer_details = $this->Sales_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer_full_name'),array('first_name' => $officer_name),USERPROFILE); + if(!empty($officer_details)){ + foreach($officer_details as $key=>$value) { + $CETAPP_salesPD_data['section8'] = array_merge($section_fields['section8'],$value); + } + } + } + cet_salespd::pushwithcetsalespdapi($common_fields,$CETAPP_salesPD_data,1); + + $satellite_image = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS); + if(!empty($satellite_image)){ + $stt_fields = $common_fields; + $stt_fields['img_name'] = $satellite_image[0]['img_name']; + $stt_fields['img'] = $satellite_image[0]['img']; + cet_salespd::pushwithcetphotographapi($stt_fields,0); + } + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Data Shared Successfully'; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + log_message('ERROR','#### There is No Data Found relevant Sales PDID '); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'There is No Data Found relevant Sales PDID ! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + }else{ + log_message('ERROR','#### Can`t able Found the Sales PDID '); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Can`t able Found the Sales PDID ! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + public function getSalesPDReport_get() { $sales_pd_id = $this->uri->segment(2); From 0cb76c57b72c8b7acd0d395f0bf8f8fc69c2f1b2 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 24 Aug 2022 10:38:18 +0000 Subject: [PATCH 058/132] routes.php edited online with Bitbucket --- api/application/config/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 1a20bda2..375360da 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -370,7 +370,7 @@ $route['getEvent'] = 'GC_Event_Controller/getEventFromGoogleCalender';//dummy ch $route['createGmeetLink'] = 'PD_Controller/createGmeetLink'; //only developer testing, not for APP use $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only developer testing, not for APP use -$route['uploadSalesPDDataToCETApp'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp'; +$route['uploadSalesPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp'; $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; From d5c70ab5b8472fab3cc9dacc1f874090d5abf7a6 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 25 Aug 2022 18:21:26 +0530 Subject: [PATCH 059/132] flyhi image location : ps --- api/application/controllers/Flyhi_Controller.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 5ec7016e..486c2635 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -572,9 +572,8 @@ class Flyhi_Controller extends REST_Controller { if($records['section_id'] == 9 && count($section_data)) { $all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); - //print_r($all_sales_pd_images);die(); + // print_r($all_sales_pd_images);die(); $photo_questions = (json_decode(($section_data[0]['section_data']),true)); - // print_r($photo_questions); foreach ($photo_questions['questions'] as $key => $value) { if(isset($value['answer_value']) && $value['answer_value'] && !$value['is_repeatable']) @@ -583,6 +582,7 @@ class Flyhi_Controller extends REST_Controller { if(count($selfie)) { $photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img']; + $photo_questions['questions'][$key]['image_location'] = $selfie[0]['location']; //$photo_questions['questions'][$key]['answer_value'] = "CHNAGED"; } } @@ -600,6 +600,7 @@ class Flyhi_Controller extends REST_Controller { if($individual_value['questions'][0]['question_key'] == $img_value['img_name']) { $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img']; + $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_location'] = $img_value['location']; //$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = "CHANGED"; unset($all_sales_pd_images[$img_key]); break; @@ -609,7 +610,7 @@ class Flyhi_Controller extends REST_Controller { } } } - //die(); + $photo_questions = json_encode($photo_questions); $section_data[0]['section_data'] = $photo_questions; } From 5a68f8a3c4ea46916569f90960543596d0dca912 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 25 Aug 2022 22:54:50 +0530 Subject: [PATCH 060/132] fixes : ps --- .../controllers/Data_Dump_Controller.php | 1562 +++++++++-------- 1 file changed, 798 insertions(+), 764 deletions(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index 14dbb7aa..a138ba13 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -1,4 +1,5 @@ load->model('PD_Model','PD_Model'); - $this->load->model('Data_Dump_Model','Data_Dump_Model'); + function __construct() + { + + parent::__construct(); + $this->load->model('PD_Model', 'PD_Model'); + $this->load->model('Data_Dump_Model', 'Data_Dump_Model'); //$this->load->library('AWS_S3'); - } - - public function getRawData_get() - { - - $pdid = $this->get('pdid'); - $rs = $this->get('rs'); - $pd_processed_forms = array(); - $master = $this->PD_Model->getPDMasterDetails($pdid); + } - if($pdid != '')// && $rs != '') - { - $this->load->helper('data_dump'); + public function getRawData_get() + { - for($i = 1;$i<=30;$i++) - { + $pdid = $this->get('pdid'); + $rs = $this->get('rs'); + $pd_processed_forms = array(); + $master = $this->PD_Model->getPDMasterDetails($pdid); + + if ($pdid != '') // && $rs != '') + { + $this->load->helper('data_dump'); + + for ($i = 1; $i <= 30; $i++) { $fields = array('processed_json'); - $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i); + $where_condition_array = array('isactive' => 1, 'fk_pd_id' => $pdid, 'fk_form_id' => $i); - $pd_processed_forms[$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); + $pd_processed_forms[$i] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON, array(), '', 'company_id', 'ASC'); // $fields2 = array('*'); // $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i,null,null,null,'report'); } //get General form dump $gen_data_dump = array(); - if(isset($pd_processed_forms[18])) - { - $gen_data = (json_decode($pd_processed_forms[18][0]['processed_json'],TRUE)); + if (isset($pd_processed_forms[18])) { + $gen_data = (json_decode($pd_processed_forms[18][0]['processed_json'], TRUE)); //print_r($gen_data);die(); - $gen_data_dump = DATA_DUMP::convertGeneralDetailsForm($gen_data,$master); + $gen_data_dump = DATA_DUMP::convertGeneralDetailsForm($gen_data, $master); print_r($gen_data_dump); $this->Data_Dump_Model->saveGenDumpData($gen_data_dump); } - if(isset($pd_processed_forms[13])) - { - if(array_key_exists('company_data', $gen_data_dump) && count($gen_data_dump)) - { - $business_data = (json_decode($pd_processed_forms[13][0]['processed_json'],TRUE)); + if (isset($pd_processed_forms[13])) { + if (array_key_exists('company_data', $gen_data_dump) && count($gen_data_dump)) { + $business_data = (json_decode($pd_processed_forms[13][0]['processed_json'], TRUE)); //print_r($business_data);die(); - $business_data_dump = DATA_DUMP::convertBusinessDetailsForm($business_data,$master,$gen_data_dump['company_data']); + $business_data_dump = DATA_DUMP::convertBusinessDetailsForm($business_data, $master, $gen_data_dump['company_data']); print_r($business_data_dump); $this->Data_Dump_Model->saveBusinessDUmpData($business_data_dump); } } - } + } + } - } + //[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] - //[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(){ + public function googleSheet_post() + { // $logger = MYLOG::logFunction(null,"Gsheet"); - log_message('ERROR','#/# G-Sheet Fns Entered - '.date('Y-m-d H:i:s A')); + 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){ + log_message('ERROR', '#/# Params Count - ' . count($sheetData)); + if (count($sheetData) > 0) { $pd_id = $this->modificationGsheetData($sheetData); - if($pd_id != null || $pd_id != '') - { + 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); + 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['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); + $this->response($data, REST_Controller::HTTP_OK); } - }else{ - log_message("ERROR","#/# G-Sheet Data Not Founded"); + } 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); + $this->response($data, REST_Controller::HTTP_OK); } // if($reponse){ // $data['dataStatus'] = true; @@ -126,373 +121,361 @@ class Data_Dump_Controller extends REST_Controller { // $data['sheetData'] = $sheetData; // $data['modifiedData'] = $modified; // } - } + } - public function modificationGsheetData($GSdata){ + public function modificationGsheetData($GSdata) + { // $logger = MYLOG::logFunction(null,"Gsheet"); - log_message('ERROR',"G-Sheet For PD Step 1 (G-sheet Data)"); - + 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 =""; - $Totalapplicatantcount = 0; - if(isset($GSdata["ApplicantName"]) && $GSdata["ApplicantName"] != ""){ - $applicatantParts = explode(',',$GSdata["ApplicantName"]); - if(count($applicatantParts)>1){ - $Totalapplicatantcount = count($applicatantParts); - for($j=0;$j1){ - $pd_applicant_details[$j]['applicant_name'] = $applicant_title_name[1]; - $pd_applicant_details[$j]['applicant_title_name'] = $this->Data_Dump_Model->getId(10,$applicant_title_name[0]); - $this->Data_Dump_Model->getId(10,$GSdata["LenderCreditName"]); - - }else{ - $pd_applicant_details[$j]['applicant_name'] = $applicatantParts[$j]; - } - } - }else{ - $applicant_title_name = explode('.',$applicatantParts[0]); - if(count($applicant_title_name)>1){ - $pd_applicant_details[0]['applicant_name'] = $applicant_title_name[1]; - $pd_applicant_details[0]['applicant_title_name'] = $this->Data_Dump_Model->getId(10,$applicant_title_name[0]); - - }else{ - $pd_applicant_details[0]['applicant_name'] = $applicatantParts[0]; - } - - } - $pd_applicant_details[0]['company_name'] = (isset($GSdata["CompanyName"]) && $GSdata["CompanyName"] != "") ? $GSdata["CompanyName"] : null ; - $pd_applicant_details[0]['applicant_type'] = 1; - 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 (company) GSheet data : ".$GSdata["CompanyName"]); - } - if(isset($GSdata["ContactNumber"]) && $GSdata["ContactNumber"] != ""){ - $ContactNumber = explode(',',trim($GSdata["ContactNumber"])); - // Contact number as below Format - // mentioned (9999999999, 8888888888, 7777777777) in Gsheet, then: - // 1st number mentioned as primary number in PD genie, - // 2nd number as additional number, (if applicant has no additional number they mentioned as Single 0 only) - // 3rd number as co-applicant number. - if(count($ContactNumber)>1){ - for($j=0;$j1 && $Totalapplicatantcount > ($j-1)) { - // here if condition $J inx should greater than 1 and total applicant count is also greater then index . - $pd_applicant_details[$j-1]['mobile_no'] = $ContactNumber[$j]; - } - } - }else{ - $pd_applicant_details[0]['mobile_no'] = $ContactNumber[0]; - - } - log_message('ERROR',"G-Sheet For PD Step 2.5 (mobile number) GSheet data : ".$GSdata['ContactNumber']); - } + // 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}] - //address section. - if(isset($GSdata["PDLocation"]) && $GSdata["PDLocation"] != ""){ - $NormalParts = explode(',', $GSdata["PDLocation"]); - $stateAndPincode = end($NormalParts); - $splitStateAndPincode = explode('-',$stateAndPincode , 2); - $addresses['fk_state']=$this->Data_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']); + 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["AdditionalRequirements"]) && $GSdata["AdditionalRequirements"] != ""){ - $requirements = explode(',',$GSdata["AdditionalRequirements"]); - if(count($requirements)>1){ - for($j=0;$j1){ + // 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 = ""; + $Totalapplicatantcount = 0; + if (isset($GSdata["ApplicantName"]) && $GSdata["ApplicantName"] != "") { + $applicatantParts = explode(',', $GSdata["ApplicantName"]); + if (count($applicatantParts) > 1) { + $Totalapplicatantcount = count($applicatantParts); + for ($j = 0; $j < count($applicatantParts); $j++) { + $applicant_title_name = explode('.', $applicatantParts[$j]); + if (count($applicant_title_name) > 1) { + $pd_applicant_details[$j]['applicant_name'] = $applicant_title_name[1]; + $pd_applicant_details[$j]['applicant_title_name'] = $this->Data_Dump_Model->getId(10, $applicant_title_name[0]); + $this->Data_Dump_Model->getId(10, $GSdata["LenderCreditName"]); + } else { + $pd_applicant_details[$j]['applicant_name'] = $applicatantParts[$j]; } - }else{ - $addi_requirements[0]['add_requirement'] = $requirements[0]; - } - log_message('ERROR',"G-Sheet For PD Step 2.13 ( additional requirements) GSheet data : ".$GSdata["AdditionalRequirements"]." PD details :".json_encode($addi_requirements)); + } else { + $applicant_title_name = explode('.', $applicatantParts[0]); + if (count($applicant_title_name) > 1) { + $pd_applicant_details[0]['applicant_name'] = $applicant_title_name[1]; + $pd_applicant_details[0]['applicant_title_name'] = $this->Data_Dump_Model->getId(10, $applicant_title_name[0]); + } else { + $pd_applicant_details[0]['applicant_name'] = $applicatantParts[0]; + } } - 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']); + $pd_applicant_details[0]['company_name'] = (isset($GSdata["CompanyName"]) && $GSdata["CompanyName"] != "") ? $GSdata["CompanyName"] : null; + $pd_applicant_details[0]['applicant_type'] = 1; + 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 (company) GSheet data : " . $GSdata["CompanyName"]); + } + if (isset($GSdata["ContactNumber"]) && $GSdata["ContactNumber"] != "") { + $ContactNumber = explode(',', trim($GSdata["ContactNumber"])); + // Contact number as below Format + // mentioned (9999999999, 8888888888, 7777777777) in Gsheet, then: + // 1st number mentioned as primary number in PD genie, + // 2nd number as additional number, (if applicant has no additional number they mentioned as Single 0 only) + // 3rd number as co-applicant number. + if (count($ContactNumber) > 1) { + for ($j = 0; $j < count($ContactNumber); $j++) { + if ($j == 0 || $j == 1) { + if ($j == 0 && !empty($ContactNumber[$j]) && $ContactNumber[$j] != 0) { + $pd_applicant_details[0]['mobile_no'] = $ContactNumber[$j]; + } + if ($j == 1 && !empty($ContactNumber[$j]) && $ContactNumber[$j] != 0) { + $pd_applicant_details[0]['additional_mobile_no'] = $ContactNumber[$j]; + } + } else if ($j > 1 && $Totalapplicatantcount > ($j - 1)) { + // here if condition $J inx should greater than 1 and total applicant count is also greater then index . + $pd_applicant_details[$j - 1]['mobile_no'] = $ContactNumber[$j]; + } + } + } else { + $pd_applicant_details[0]['mobile_no'] = $ContactNumber[0]; } - 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"]); + log_message('ERROR', "G-Sheet For PD Step 2.5 (mobile number) GSheet data : " . $GSdata['ContactNumber']); + } + + //address section. + if (isset($GSdata["PDLocation"]) && $GSdata["PDLocation"] != "") { + $NormalParts = explode(',', $GSdata["PDLocation"]); + $stateAndPincode = end($NormalParts); + $splitStateAndPincode = explode('-', $stateAndPincode, 2); + $addresses['fk_state'] = $this->Data_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; $j < count($requirements); $j++) { + $addi_requirements[$j]['add_requirement'] = $requirements[$j]; + } + } else { + $addi_requirements[0]['add_requirement'] = $requirements[0]; } - + log_message('ERROR', "G-Sheet For PD Step 2.13 ( additional requirements) GSheet data : " . $GSdata["AdditionalRequirements"] . " PD details :" . json_encode($addi_requirements)); + } + 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"]); + } + ## 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); + $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++) + $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')) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; + $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) } - $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'); + } + + + ## 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 4 (PDID gotten) ERR : ".$e->getMessage()); + log_message('ERROR', "G-Sheet For PD Step 6 (Addresses) 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 Managers 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()); - } - } + // $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); - log_message('ERROR',"#/# G-Sheet Final PDID : ".$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; } @@ -503,175 +486,180 @@ class Data_Dump_Controller extends REST_Controller { // step 4 : processjson inactive data deleted.. //working fine on tables. - public function deleteOldPDbk_up_get(){ - $_90th_date = date("Y/m/d",strtotime('-90 days')); - - $columns = array('PDTRIGGER.pd_id','PDTRIGGER.addressline1','PDTRIGGER.addressline2','PDTRIGGER.addressline3','PDTRIGGER.pd_contact_mobileno','PDTRIGGER.pd_contact_landline','PDTRIGGER.pd_sno','DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','PDAPPLICANTSDETAILS.pd_co_applicant_id','PDTRIGGER.pd_contact_person_mail'); - $table = PDTRIGGER.' as PDTRIGGER'; - $joins = array(array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', - 'condition' =>'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', - 'jointype' => 'LEFT')); - $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date ); - $tgr_dtls = $this->PD_Model->getJoinRecords($columns,$table,$joins,$tgr_cond_arr); + public function deleteOldPDbk_up_get() + { + $_90th_date = date("Y/m/d", strtotime('-90 days')); + + $columns = array('PDTRIGGER.pd_id', 'PDTRIGGER.addressline1', 'PDTRIGGER.addressline2', 'PDTRIGGER.addressline3', 'PDTRIGGER.pd_contact_mobileno', 'PDTRIGGER.pd_contact_landline', 'PDTRIGGER.pd_sno', 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon', 'PDAPPLICANTSDETAILS.pd_co_applicant_id', 'PDTRIGGER.pd_contact_person_mail'); + $table = PDTRIGGER . ' as PDTRIGGER'; + $joins = array(array( + 'table' => PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', + 'condition' => 'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', + 'jointype' => 'LEFT' + )); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); + $tgr_dtls = $this->PD_Model->getJoinRecords($columns, $table, $joins, $tgr_cond_arr); $i = 0; // testing Purpose only // for($i = 0 ;$i < count($tgr_dtls);$i++){ - $pdid = $tgr_dtls[$i]['pd_id']; - $pdsno = $tgr_dtls[$i]['pd_sno']; - $pdappcntid = $tgr_dtls[$i]['pd_co_applicant_id']; - $general_format = $pdsno."-".$pdid."-".$pdappcntid; + $pdid = $tgr_dtls[$i]['pd_id']; + $pdsno = $tgr_dtls[$i]['pd_sno']; + $pdappcntid = $tgr_dtls[$i]['pd_co_applicant_id']; + $general_format = $pdsno . "-" . $pdid . "-" . $pdappcntid; - $updt_on_tgr['addressline1'] = $tgr_dtls[$i]['addressline1'] ? $general_format.' - addressline1' : null ; - $updt_on_tgr['addressline2'] = $tgr_dtls[$i]['addressline2'] ? $general_format.' - addressline2' : null ; - $updt_on_tgr['addressline3'] = $tgr_dtls[$i]['addressline3'] ? $general_format.' - addressline3' : null ; - $updt_on_tgr['pd_contact_mobileno'] = $tgr_dtls[$i]['pd_contact_mobileno'] ? $general_format.' - mobileno' : null; - $updt_on_tgr['pd_contact_landline'] = $tgr_dtls[$i]['pd_contact_landline'] ? $general_format.' - landline' : null; - $updt_on_tgr['pd_contact_person_mail'] = $tgr_dtls[$i]['pd_contact_person_mail'] ? $general_format.' - person_mail' : null; - $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); + $updt_on_tgr['addressline1'] = $tgr_dtls[$i]['addressline1'] ? $general_format . ' - addressline1' : null; + $updt_on_tgr['addressline2'] = $tgr_dtls[$i]['addressline2'] ? $general_format . ' - addressline2' : null; + $updt_on_tgr['addressline3'] = $tgr_dtls[$i]['addressline3'] ? $general_format . ' - addressline3' : null; + $updt_on_tgr['pd_contact_mobileno'] = $tgr_dtls[$i]['pd_contact_mobileno'] ? $general_format . ' - mobileno' : null; + $updt_on_tgr['pd_contact_landline'] = $tgr_dtls[$i]['pd_contact_landline'] ? $general_format . ' - landline' : null; + $updt_on_tgr['pd_contact_person_mail'] = $tgr_dtls[$i]['pd_contact_person_mail'] ? $general_format . ' - person_mail' : null; + $updt_tgr_where = array('pd_id' => $pdid, 'pd_status' => QC_COMPLETED); - $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); + $this->PD_Model->updateRecords($updt_on_tgr, PDTRIGGER, $updt_tgr_where); - if(!empty($pdid)){ - $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name'); - $apcnt_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields,$apcnt_cond_arr,PDAPPLICANTSDETAILS); - if(!empty($apcnt_dtls)){ - for($j = 0 ;$j < count($apcnt_dtls);$j++){ - $appcnt_id = $pdsno."-".$pdid."-".$apcnt_dtls[$j]['pd_co_applicant_id']; - $updt_apcnt_dtls['applicant_name'] = $appcnt_id; - $updt_apcnt_dtls['mobile_no'] = $apcnt_dtls[$j]['mobile_no'] ? $appcnt_id.' - mobile_no' : null ; - $updt_apcnt_dtls['additional_mobile_no'] = $apcnt_dtls[$j]['additional_mobile_no'] ? $appcnt_id.' - additional_mobile_no' : null ; - $updt_apcnt_dtls['landline'] = $apcnt_dtls[$j]['landline'] ? $appcnt_id.' - landline' : null ; - $updt_apcnt_dtls['email'] = $apcnt_dtls[$j]['email'] ? $appcnt_id.' - email' : null ; - $updt_apcnt_dtls['addressline1'] = $apcnt_dtls[$j]['addressline1'] ? $appcnt_id.' - addressline1' : null ; - $updt_apcnt_dtls['addressline2'] = $apcnt_dtls[$j]['addressline2'] ? $appcnt_id.' - addressline2' : null ; - $updt_apcnt_dtls['addressline3'] = $apcnt_dtls[$j]['addressline3'] ? $appcnt_id.' - addressline3' : null ; - $updt_apcnt_dtls['company_name'] = $apcnt_dtls[$j]['company_name'] ? $appcnt_id.' - company_name' : null ; - - $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); - } + if (!empty($pdid)) { + $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name'); + $apcnt_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields, $apcnt_cond_arr, PDAPPLICANTSDETAILS); + if (!empty($apcnt_dtls)) { + for ($j = 0; $j < count($apcnt_dtls); $j++) { + $appcnt_id = $pdsno . "-" . $pdid . "-" . $apcnt_dtls[$j]['pd_co_applicant_id']; + $updt_apcnt_dtls['applicant_name'] = $appcnt_id; + $updt_apcnt_dtls['mobile_no'] = $apcnt_dtls[$j]['mobile_no'] ? $appcnt_id . ' - mobile_no' : null; + $updt_apcnt_dtls['additional_mobile_no'] = $apcnt_dtls[$j]['additional_mobile_no'] ? $appcnt_id . ' - additional_mobile_no' : null; + $updt_apcnt_dtls['landline'] = $apcnt_dtls[$j]['landline'] ? $appcnt_id . ' - landline' : null; + $updt_apcnt_dtls['email'] = $apcnt_dtls[$j]['email'] ? $appcnt_id . ' - email' : null; + $updt_apcnt_dtls['addressline1'] = $apcnt_dtls[$j]['addressline1'] ? $appcnt_id . ' - addressline1' : null; + $updt_apcnt_dtls['addressline2'] = $apcnt_dtls[$j]['addressline2'] ? $appcnt_id . ' - addressline2' : null; + $updt_apcnt_dtls['addressline3'] = $apcnt_dtls[$j]['addressline3'] ? $appcnt_id . ' - addressline3' : null; + $updt_apcnt_dtls['company_name'] = $apcnt_dtls[$j]['company_name'] ? $appcnt_id . ' - company_name' : null; + + $this->PD_Model->updateRecords($updt_apcnt_dtls, PDAPPLICANTSDETAILS, array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); } + } - $addr_fields = array('pd_address_id', 'addressline1'); - $addr_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields,$addr_cond_arr,PDADDRESS); - if(!empty($addr_dtls)){ - for($k = 0 ;$k < count($addr_dtls);$k++){ - $updt_addr_dtls['addressline1'] = $addr_dtls[$k]['addressline1'] ? $general_format.' - addressline1' : null ; - $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); - } + $addr_fields = array('pd_address_id', 'addressline1'); + $addr_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields, $addr_cond_arr, PDADDRESS); + if (!empty($addr_dtls)) { + for ($k = 0; $k < count($addr_dtls); $k++) { + $updt_addr_dtls['addressline1'] = $addr_dtls[$k]['addressline1'] ? $general_format . ' - addressline1' : null; + $this->PD_Model->updateRecords($updt_addr_dtls, PDADDRESS, array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); } - $json_fields = array('json','processed_json'); - $json_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $json_dtls = $this->PD_Model->selectCustomRecords($json_fields,$json_cond_arr,PDFORMDETAILSJSON); + } + $json_fields = array('json', 'processed_json'); + $json_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $json_dtls = $this->PD_Model->selectCustomRecords($json_fields, $json_cond_arr, PDFORMDETAILSJSON); + + - - // -- replace(COL,Wrong Value,New Value) // UPDATE sineedgeprod.t_salespd_section_data // SET section_data = replace(CONVERT(section_data USING utf8), '[answer_value] =>"SAVED"','"answer_value":""') // where sales_pd_id = 5620 and section_id = 9 and isactive = 1; - } + } // } // undo the command $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; // $data['query'] = $this->db->last_query(); // $data['total data'] =count($tgr_dtls); // $data['before 90 days data'] = $tgr_dtls; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - public function renamingExistingPDinfo_get(){ - log_message('ERROR',"renamingExistingPDinfo Fns Called"); - $_90th_date = date("Y/m/d",strtotime('-90 days')); + public function renamingExistingPDinfo_get() + { + log_message('ERROR', "renamingExistingPDinfo Fns Called"); + $_90th_date = date("Y/m/d", strtotime('-90 days')); $pdsno = $this->get('pdsno'); - $pdid_arr = array();// testing purpose - $columns = array('PDTRIGGER.pd_id','PDTRIGGER.addressline1','PDTRIGGER.addressline2','PDTRIGGER.addressline3','PDTRIGGER.pd_contact_mobileno','PDTRIGGER.pd_contact_landline','PDTRIGGER.pd_sno','DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','PDAPPLICANTSDETAILS.pd_co_applicant_id','PDTRIGGER.pd_contact_person_mail','PDTRIGGER.fk_lender_id'); - $table = PDTRIGGER.' as PDTRIGGER'; - $joins = array(array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', - 'condition' =>'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', - 'jointype' => 'LEFT')); - if(!empty($pdsno)){ - log_message('ERROR',"PD Serial No => ".$pdsno); - $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'PDTRIGGER.pd_sno' => $pdsno ); - }else{ - log_message('ERROR',"90th date => ".$_90th_date); - $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED ,'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); + $pdid_arr = array(); // testing purpose + $columns = array('PDTRIGGER.pd_id', 'PDTRIGGER.addressline1', 'PDTRIGGER.addressline2', 'PDTRIGGER.addressline3', 'PDTRIGGER.pd_contact_mobileno', 'PDTRIGGER.pd_contact_landline', 'PDTRIGGER.pd_sno', 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon', 'PDAPPLICANTSDETAILS.pd_co_applicant_id', 'PDTRIGGER.pd_contact_person_mail', 'PDTRIGGER.fk_lender_id'); + $table = PDTRIGGER . ' as PDTRIGGER'; + $joins = array(array( + 'table' => PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', + 'condition' => 'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', + 'jointype' => 'LEFT' + )); + if (!empty($pdsno)) { + log_message('ERROR', "PD Serial No => " . $pdsno); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'PDTRIGGER.pd_sno' => $pdsno); + } else { + log_message('ERROR', "90th date => " . $_90th_date); + $tgr_cond_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") <=' => $_90th_date); } - + // 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11 - log_message('ERROR',"trigger details Total count ".count($tgr_cond_arr)); - $tgr_dtls = $this->PD_Model->getJoinRecords($columns,$table,$joins,$tgr_cond_arr); + log_message('ERROR', "trigger details Total count " . count($tgr_cond_arr)); + $tgr_dtls = $this->PD_Model->getJoinRecords($columns, $table, $joins, $tgr_cond_arr); // $i = 0; // testing Purpose only // for($i = 0 ;$i < 3;$i++){ // testing purpose only. - for($i = 0 ;$i < count($tgr_dtls);$i++){ + for ($i = 0; $i < count($tgr_dtls); $i++) { $pdid = $tgr_dtls[$i]['pd_id']; - log_message('ERROR',"trigger details for Loop inx = ".$i." PDID = ".$pdid); - $earliest['trigger_details'] = $tgr_dtls[$i] ; - if(!empty($pdid)){ - $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name','applicant_name'); - $apcnt_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields,$apcnt_cond_arr,PDAPPLICANTSDETAILS); - log_message('ERROR',"Total Applicant Details for ".$pdid." = ".count($apcnt_dtls)); - if(!empty($apcnt_dtls)){ + log_message('ERROR', "trigger details for Loop inx = " . $i . " PDID = " . $pdid); + $earliest['trigger_details'] = $tgr_dtls[$i]; + if (!empty($pdid)) { + $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name', 'applicant_name'); + $apcnt_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields, $apcnt_cond_arr, PDAPPLICANTSDETAILS); + log_message('ERROR', "Total Applicant Details for " . $pdid . " = " . count($apcnt_dtls)); + if (!empty($apcnt_dtls)) { $earliest['applicant_details'] = $apcnt_dtls; } $addr_fields = array('pd_address_id', 'addressline1'); - $addr_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields,$addr_cond_arr,PDADDRESS); - log_message('ERROR',"Total Address Details for ".$pdid." = ".count($addr_dtls)); - if(!empty($addr_dtls)){ + $addr_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields, $addr_cond_arr, PDADDRESS); + log_message('ERROR', "Total Address Details for " . $pdid . " = " . count($addr_dtls)); + if (!empty($addr_dtls)) { $earliest['address_details'] = $addr_dtls; } - $json_fields = array('pd_form_detail_json_id','json','processed_json','fk_pd_id', 'fk_form_id'); - $json_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $json_dtls = $this->PD_Model->selectCustomRecords($json_fields,$json_cond_arr,PDFORMDETAILSJSON); - log_message('ERROR',"Total JSON Details for ".$pdid." = ".count($json_dtls)); - if(!empty($json_dtls)){ + $json_fields = array('pd_form_detail_json_id', 'json', 'processed_json', 'fk_pd_id', 'fk_form_id'); + $json_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $json_dtls = $this->PD_Model->selectCustomRecords($json_fields, $json_cond_arr, PDFORMDETAILSJSON); + log_message('ERROR', "Total JSON Details for " . $pdid . " = " . count($json_dtls)); + if (!empty($json_dtls)) { $earliest['json_details'] = $json_dtls; } $previous_json_fields = array('pd_form_detail_json_id'); - $previous_json_cond_arr = array('isactive' => 0,'fk_pd_id'=>$pdid); - $previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields,$previous_json_cond_arr,PDFORMDETAILSJSON); - log_message('ERROR',"Total IN-Active JSON Details for ".$pdid." = ".count($previous_json_dtls)); - if(!empty($previous_json_dtls)){ - foreach($previous_json_dtls as $val) { + $previous_json_cond_arr = array('isactive' => 0, 'fk_pd_id' => $pdid); + $previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields, $previous_json_cond_arr, PDFORMDETAILSJSON); + log_message('ERROR', "Total IN-Active JSON Details for " . $pdid . " = " . count($previous_json_dtls)); + if (!empty($previous_json_dtls)) { + foreach ($previous_json_dtls as $val) { $result[] = $val['pd_form_detail_json_id']; } - $this->db->where_in('pd_form_detail_json_id',$result); + $this->db->where_in('pd_form_detail_json_id', $result); $this->db->delete(PDFORMDETAILSJSON); } $docs_fields = array('pd_document_id', 'pd_document_title', 'pd_document_name'); - $docs_cond_arr = array('isactive' => 1,'fk_pd_id'=>$pdid); - $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields,$docs_cond_arr,PDDOCUMENTS); - log_message('ERROR',"Total Document Details for ".$pdid." = ".count($docs_dtls)); - if(!empty($docs_dtls)){ + $docs_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); + $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields, $docs_cond_arr, PDDOCUMENTS); + log_message('ERROR', "Total Document Details for " . $pdid . " = " . count($docs_dtls)); + if (!empty($docs_dtls)) { $earliest['docs_details'] = $docs_dtls; } - - } - + $return = $this->renamingProcess($earliest); // if(!empty($return)){ // array_push($pdid_arr['updated pdid'],$return); // array_push($pdid_arr['data'],$earliest);} - } + } $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; + $data['status'] = REST_Controller::HTTP_OK; // $data['earliest'] = $earliest; // $data['totalDetailsInCount'] =count($tgr_dtls); // $data['before 90 days data'] = $tgr_dtls; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - public function renamingProcess($details){ - log_message('ERROR',"renamingProcess Fns Called"); + public function renamingProcess($details) + { + log_message('ERROR', "renamingProcess Fns Called"); $have_to_replace = array(); - $tgr_dtls = isset($details['trigger_details']) ? $details['trigger_details'] : array(); ; + $tgr_dtls = isset($details['trigger_details']) ? $details['trigger_details'] : array();; $apcnt_dtls = isset($details['applicant_details']) ? $details['applicant_details'] : array(); //print_r($apcnt_dtls);die(); $addr_dtls = isset($details['address_details']) ? $details['address_details'] : array(); @@ -681,253 +669,298 @@ class Data_Dump_Controller extends REST_Controller { $pdid = $tgr_dtls['pd_id']; $pdsno = $tgr_dtls['pd_sno']; $pdlenid = $tgr_dtls['fk_lender_id']; - + $pdappcntid = $tgr_dtls['pd_co_applicant_id']; - $general_format = $pdsno."-".$pdid."-".$pdappcntid; - log_message('ERROR',"Format generated => ".$general_format); + $general_format = $pdsno . "-" . $pdid . "-" . $pdappcntid; + log_message('ERROR', "Format generated => " . $general_format); - if(!empty($tgr_dtls)){ - if($tgr_dtls['addressline1']){ - $updt_on_tgr['addressline1'] = $general_format.'-addressline1' ; - $have_to_replace[$tgr_dtls['addressline1']] = $general_format.'-addressline1'; - }else{ $updt_on_tgr['addressline1'] = null; } - if($tgr_dtls['addressline2']){ - $updt_on_tgr['addressline2'] = $general_format.' - addressline2'; - $have_to_replace[$tgr_dtls['addressline2']] = $general_format.'-addressline2'; - }else{ $updt_on_tgr['addressline1'] = null; } - if($tgr_dtls['addressline3']){ - $updt_on_tgr['addressline3'] = $general_format.'-addressline3'; - $have_to_replace[$tgr_dtls['addressline3']] = $general_format.'-addressline3'; - }else{ $updt_on_tgr['addressline1'] = null; } - if($tgr_dtls['pd_contact_mobileno']){ - $updt_on_tgr['pd_contact_mobileno'] = $general_format.'-mobileno' ; - $have_to_replace[$tgr_dtls['pd_contact_mobileno']] = $general_format.'-mobileno'; - }else{ $updt_on_tgr['pd_contact_mobileno'] = null; } - if($tgr_dtls['pd_contact_landline']){ - $updt_on_tgr['pd_contact_landline'] = $general_format.'-landline' ; - $have_to_replace[$tgr_dtls['pd_contact_landline']] = $general_format.'-landline'; - }else{ $updt_on_tgr['pd_contact_landline'] = null; } - if($tgr_dtls['pd_contact_person_mail']){ - $updt_on_tgr['pd_contact_person_mail'] = $general_format.'-mail' ; - $have_to_replace[$tgr_dtls['pd_contact_person_mail']] = $general_format.'-mail'; - }else{ $updt_on_tgr['pd_contact_person_mail'] = null ; } - } - - if(!empty($apcnt_dtls)){ - for($j = 0 ;$j < count($apcnt_dtls);$j++){ - $appcnt_id = $pdsno."-".$pdid."-".$apcnt_dtls[$j]['pd_co_applicant_id']; - - if($apcnt_dtls[$j]['applicant_name']){ - // $have_to_replace[str_replace(' ','',$apcnt_dtls[$j]['applicant_name'])] = $appcnt_id; - $have_to_replace[$apcnt_dtls[$j]['applicant_name']] = $appcnt_id; - $updt_apcnt_dtls['applicant_name'] = $appcnt_id; - } - - if($apcnt_dtls[$j]['mobile_no']){ - $updt_apcnt_dtls['mobile_no'] = $appcnt_id.'-mobile_no'; - $have_to_replace[$apcnt_dtls[$j]['mobile_no']] = $appcnt_id.'-mobile_no'; - }else{ $updt_apcnt_dtls['mobile_no'] = null ; } - - if($apcnt_dtls[$j]['additional_mobile_no']){ - $updt_apcnt_dtls['additional_mobile_no'] = $appcnt_id.'-additional_mobile_no'; - $have_to_replace[$apcnt_dtls[$j]['additional_mobile_no']] = $appcnt_id.'-additional_mobile_no'; - }else{ $updt_apcnt_dtls['additional_mobile_no'] = null ; } - - if($apcnt_dtls[$j]['landline']){ - $updt_apcnt_dtls['landline'] = $appcnt_id.'-landline'; - $have_to_replace[$apcnt_dtls[$j]['landline']] = $appcnt_id.'-landline'; - }else{ $updt_apcnt_dtls['landline'] = null ; } - - if($apcnt_dtls[$j]['email']){ - $updt_apcnt_dtls['email'] = $appcnt_id.'-email'; - $have_to_replace[$apcnt_dtls[$j]['email']] = $appcnt_id.'-email'; - }else{ $updt_apcnt_dtls['email'] = null ; } - - if($apcnt_dtls[$j]['addressline1']){ - $updt_apcnt_dtls['addressline1'] = $appcnt_id.'-addressline1'; - $have_to_replace[$apcnt_dtls[$j]['addressline1']] = $appcnt_id.'-addressline1'; - }else{ $updt_apcnt_dtls['addressline1'] = null ; } - - if($apcnt_dtls[$j]['addressline2']){ - $updt_apcnt_dtls['addressline2'] = $appcnt_id.'-addressline2'; - $have_to_replace[$apcnt_dtls[$j]['addressline2']] = $appcnt_id.'-addressline2'; - }else{ $updt_apcnt_dtls['addressline2'] = null ; } - - if($apcnt_dtls[$j]['addressline3']){ - $updt_apcnt_dtls['addressline3'] = $appcnt_id.'-addressline3'; - $have_to_replace[$apcnt_dtls[$j]['addressline3']] = $appcnt_id.'-addressline3'; - }else{ $updt_apcnt_dtls['addressline3'] = null ; } - - if($apcnt_dtls[$j]['company_name']){ - $updt_apcnt_dtls['company_name'] = $appcnt_id.'-company_name'; - $have_to_replace[$apcnt_dtls[$j]['company_name']] = $appcnt_id.'-company_name'; - }else{ $updt_apcnt_dtls['company_name'] = null ; } - - $apcnt_result = $this->PD_Model->updateRecords($updt_apcnt_dtls,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); - if($apcnt_result){ log_message('ERROR',"applicant updated => ".$apcnt_dtls[$j]['pd_co_applicant_id']." Updated successfully ( ".($j+1)." )");} - else{ log_message('ERROR',"Check here Applicant Not updated ( ".($j+1)." ) pkid = ".$apcnt_dtls[$j]['pd_co_applicant_id']); } - } + if (!empty($tgr_dtls)) { + if ($tgr_dtls['addressline1']) { + $updt_on_tgr['addressline1'] = $general_format . '-addressline1'; + $have_to_replace[$tgr_dtls['addressline1']] = $general_format . '-addressline1'; + } else { + $updt_on_tgr['addressline1'] = null; + } + if ($tgr_dtls['addressline2']) { + $updt_on_tgr['addressline2'] = $general_format . ' - addressline2'; + $have_to_replace[$tgr_dtls['addressline2']] = $general_format . '-addressline2'; + } else { + $updt_on_tgr['addressline1'] = null; + } + if ($tgr_dtls['addressline3']) { + $updt_on_tgr['addressline3'] = $general_format . '-addressline3'; + $have_to_replace[$tgr_dtls['addressline3']] = $general_format . '-addressline3'; + } else { + $updt_on_tgr['addressline1'] = null; + } + if ($tgr_dtls['pd_contact_mobileno']) { + $updt_on_tgr['pd_contact_mobileno'] = $general_format . '-mobileno'; + $have_to_replace[$tgr_dtls['pd_contact_mobileno']] = $general_format . '-mobileno'; + } else { + $updt_on_tgr['pd_contact_mobileno'] = null; + } + if ($tgr_dtls['pd_contact_landline']) { + $updt_on_tgr['pd_contact_landline'] = $general_format . '-landline'; + $have_to_replace[$tgr_dtls['pd_contact_landline']] = $general_format . '-landline'; + } else { + $updt_on_tgr['pd_contact_landline'] = null; + } + if ($tgr_dtls['pd_contact_person_mail']) { + $updt_on_tgr['pd_contact_person_mail'] = $general_format . '-mail'; + $have_to_replace[$tgr_dtls['pd_contact_person_mail']] = $general_format . '-mail'; + } else { + $updt_on_tgr['pd_contact_person_mail'] = null; + } } - - if(!empty($addr_dtls)){ - for($k = 0 ;$k < count($addr_dtls);$k++){ - if($addr_dtls[$k]['addressline1']){ - $updt_addr_dtls['addressline1'] = $general_format.'-addressline1'; - $have_to_replace[$addr_dtls[$k]['addressline1']] = $general_format.'-addressline1'; - }else{ - $updt_addr_dtls['addressline1'] = null ; - } - $addr_result = $this->PD_Model->updateRecords($updt_addr_dtls,PDADDRESS,array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); - if($addr_result){ log_message('ERROR',"address updated => ".$addr_dtls[$k]['pd_address_id']." Updated successfully ( ".($k+1)." )");} - else{ log_message('ERROR',"Check here Adress table Not updated ( ".($k+1)." ) pkid = ".$addr_dtls[$k]['pd_address_id']); } - } + if (!empty($apcnt_dtls)) { + for ($j = 0; $j < count($apcnt_dtls); $j++) { + $appcnt_id = $pdsno . "-" . $pdid . "-" . $apcnt_dtls[$j]['pd_co_applicant_id']; + + if ($apcnt_dtls[$j]['applicant_name']) { + // $have_to_replace[str_replace(' ','',$apcnt_dtls[$j]['applicant_name'])] = $appcnt_id; + $have_to_replace[$apcnt_dtls[$j]['applicant_name']] = $appcnt_id; + $updt_apcnt_dtls['applicant_name'] = $appcnt_id; } - if(!empty($json_dtls)){ - - for($l = 0 ;$l < count($json_dtls);$l++){ - $fid = $json_dtls[$l]['fk_form_id']; - $fields = array('pd_form_name'); - $where_condition_array = array("pd_form_id"=>$fid); - $form_table = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMS); - $form_name = count($form_table)>0 ? $form_table[0]['pd_form_name'] : ''; - // echo count($json_dtls); - // pd_form_detail_json_id, fk_pd_id, fk_form_id, company_id, isactive, json, processed_json, - $original_j_arr = json_decode($json_dtls[$l]['json'],true); - $original_pj_arr = json_decode($json_dtls[$l]['processed_json'],true); - // $have_to_replace["is_person_met_pic"] = ""; - foreach($have_to_replace as $key => $value){ - $replaced_pj_arr = $this->replace_in_array($key, $value, $original_pj_arr); - $replaced_j_arr = $this->replace_in_array($key, $value, $original_j_arr); - } - // $fid=18; - switch($fid) - { - case 1: - // 1 trade_product_contact_person_name , person_landline ,person_stdcode - $arr1 = array('trade_product_contact_person_name' , 'person_landline' ,'person_stdcode'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr1,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr1,$general_format); - break; - case 2: - // 2 trade_product_contact_person_name , person_landline - $arr2 = array('trade_product_contact_person_name' , 'person_landline'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr2,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr2,$general_format); - break; - case 5: - // 5 alternative_address - $arr5 = array('alternative_address','address'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr5,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr5,$general_format); - break; - case 6: - // 6 residence_place - $arr6 = array('residence_place','earning_name_of_the_employer_or_business','family_member_name'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr6,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr6,$general_format); - break; - case 8: - // 8 label - $arr8 = array('label'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr8,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr8,$general_format); - break; - case 9: - // 9 address - $arr9 = array('address'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr9,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr9,$general_format); - break; - case 10: - $arr10 = array('address','property_seller'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr10,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr10,$general_format); - break; - case 12: - $arr12 = array("employer_name","designation_person_met"); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr12,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr12,$general_format); - break; - case 13: - // 13 partner_name_master . gst_Regn_cert_pic , shop_eat_act_cert_pic - $arr13 = array("partner_name_master","gst_Regn_cert_pic","shop_eat_act_cert_pic","export_import_cert_pic","factory_cert_pic","pf_regn_pic","esic_regn_pic","eb_bill_pic"); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr13,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr13,$general_format); - break; - case 17: - $arr17 = array('address_property'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr17,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr17,$general_format); - break; - case 18: - // 18 is_person_met_pic , is_person_met_id_proof - $arr18 = array('is_person_met_pic' , 'is_person_met_id_proof'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr18,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr18,$general_format); - - break; - case 19: - // 19 neighbourhood_name - $arr19 = array('neighbourhood_name'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr19,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr19,$general_format); - break; - case 22: - // 22 address_label,address_label - $arr22 = array('address_label' , 'address_label'); - $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr22,$general_format); - $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr22,$general_format); - break; - - } - // traverseArray(&$array, $keys) - $update_json_arr['json'] = json_encode($replaced_j_arr); - $update_json_arr['processed_json'] = json_encode($replaced_pj_arr); - $json_result =$this->PD_Model->updateRecords($update_json_arr,PDFORMDETAILSJSON,array('pd_form_detail_json_id' => $json_dtls[$l]['pd_form_detail_json_id'] )); - if($json_result){ log_message('ERROR',"JSON updated => ".$form_name." Updated successfully ( ".($l+1)." ) json table id = ".$json_dtls[$l]['pd_form_detail_json_id']);} - else{ log_message('ERROR',"Check here JSON Not updated ".$form_name." ( ".($l+1)." ) json table id = ".$json_dtls[$l]['pd_form_detail_json_id']); } - // $data['have_to_replace_this'] = $have_to_replace; - // $data['replaced_pj_array'] = $replaced_pj_arr; - // $data['original_pj_array'] = $original_pj_arr; - // $data['original_j_array'] = $original_j_arr; - // $data['replaced_j_array'] = $replaced_j_arr; - } + if ($apcnt_dtls[$j]['mobile_no']) { + $updt_apcnt_dtls['mobile_no'] = $appcnt_id . '-mobile_no'; + $have_to_replace[$apcnt_dtls[$j]['mobile_no']] = $appcnt_id . '-mobile_no'; + } else { + $updt_apcnt_dtls['mobile_no'] = null; } - // $earliest['docs_details'] = $docs_dtls; - if(!empty($doc_dtls)){ - for($m = 0 ;$m < count($doc_dtls);$m++){ - log_message('ERROR',"Document ".$doc_dtls[$m]['pd_document_name'] ); - $docname = $doc_dtls[$m]['pd_document_name']; - $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$docname; - unlink($destination_path); - - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pdlenid; - $key = 'pd'.$pdid.'/'.$docname; - $s3result= $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR',"s3result ".$s3result['@metadata']['statusCode'] ); - } - else{ log_message('ERROR',"Check here Not updated on S3 result ".$s3result['@metadata']['statusCode'] ); } - } + if ($apcnt_dtls[$j]['additional_mobile_no']) { + $updt_apcnt_dtls['additional_mobile_no'] = $appcnt_id . '-additional_mobile_no'; + $have_to_replace[$apcnt_dtls[$j]['additional_mobile_no']] = $appcnt_id . '-additional_mobile_no'; + } else { + $updt_apcnt_dtls['additional_mobile_no'] = null; } - $updt_on_tgr['pd_status'] = ARCHIVED ; - $updt_tgr_where = array('pd_id' => $pdid,'pd_status' => QC_COMPLETED); - $trg_result = $this->PD_Model->updateRecords($updt_on_tgr,PDTRIGGER,$updt_tgr_where); - if($trg_result){ log_message('ERROR',"Trigger table updated pdid => ".$pdid." Updated successfully ");} - else{ log_message('ERROR',"Check here Trigger table Not updated pdid = ".$pdid); } - return $pdid; - // $data['pdid'] = $pdid ; - // $this->response($data,REST_Controller::HTTP_OK); + + if ($apcnt_dtls[$j]['landline']) { + $updt_apcnt_dtls['landline'] = $appcnt_id . '-landline'; + $have_to_replace[$apcnt_dtls[$j]['landline']] = $appcnt_id . '-landline'; + } else { + $updt_apcnt_dtls['landline'] = null; + } + + if ($apcnt_dtls[$j]['email']) { + $updt_apcnt_dtls['email'] = $appcnt_id . '-email'; + $have_to_replace[$apcnt_dtls[$j]['email']] = $appcnt_id . '-email'; + } else { + $updt_apcnt_dtls['email'] = null; + } + + if ($apcnt_dtls[$j]['addressline1']) { + $updt_apcnt_dtls['addressline1'] = $appcnt_id . '-addressline1'; + $have_to_replace[$apcnt_dtls[$j]['addressline1']] = $appcnt_id . '-addressline1'; + } else { + $updt_apcnt_dtls['addressline1'] = null; + } + + if ($apcnt_dtls[$j]['addressline2']) { + $updt_apcnt_dtls['addressline2'] = $appcnt_id . '-addressline2'; + $have_to_replace[$apcnt_dtls[$j]['addressline2']] = $appcnt_id . '-addressline2'; + } else { + $updt_apcnt_dtls['addressline2'] = null; + } + + if ($apcnt_dtls[$j]['addressline3']) { + $updt_apcnt_dtls['addressline3'] = $appcnt_id . '-addressline3'; + $have_to_replace[$apcnt_dtls[$j]['addressline3']] = $appcnt_id . '-addressline3'; + } else { + $updt_apcnt_dtls['addressline3'] = null; + } + + if ($apcnt_dtls[$j]['company_name']) { + $updt_apcnt_dtls['company_name'] = $appcnt_id . '-company_name'; + $have_to_replace[$apcnt_dtls[$j]['company_name']] = $appcnt_id . '-company_name'; + } else { + $updt_apcnt_dtls['company_name'] = null; + } + + $apcnt_result = $this->PD_Model->updateRecords($updt_apcnt_dtls, PDAPPLICANTSDETAILS, array('pd_co_applicant_id' => $apcnt_dtls[$j]['pd_co_applicant_id'])); + if ($apcnt_result) { + log_message('ERROR', "applicant updated => " . $apcnt_dtls[$j]['pd_co_applicant_id'] . " Updated successfully ( " . ($j + 1) . " )"); + } else { + log_message('ERROR', "Check here Applicant Not updated ( " . ($j + 1) . " ) pkid = " . $apcnt_dtls[$j]['pd_co_applicant_id']); + } + } + } + + + if (!empty($addr_dtls)) { + for ($k = 0; $k < count($addr_dtls); $k++) { + if ($addr_dtls[$k]['addressline1']) { + $updt_addr_dtls['addressline1'] = $general_format . '-addressline1'; + $have_to_replace[$addr_dtls[$k]['addressline1']] = $general_format . '-addressline1'; + } else { + $updt_addr_dtls['addressline1'] = null; + } + $addr_result = $this->PD_Model->updateRecords($updt_addr_dtls, PDADDRESS, array('pd_address_id' => $addr_dtls[$k]['pd_address_id'])); + if ($addr_result) { + log_message('ERROR', "address updated => " . $addr_dtls[$k]['pd_address_id'] . " Updated successfully ( " . ($k + 1) . " )"); + } else { + log_message('ERROR', "Check here Adress table Not updated ( " . ($k + 1) . " ) pkid = " . $addr_dtls[$k]['pd_address_id']); + } + } + } + + if (!empty($json_dtls)) { + + for ($l = 0; $l < count($json_dtls); $l++) { + $fid = $json_dtls[$l]['fk_form_id']; + $fields = array('pd_form_name'); + $where_condition_array = array("pd_form_id" => $fid); + $form_table = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMS); + $form_name = count($form_table) > 0 ? $form_table[0]['pd_form_name'] : ''; + // echo count($json_dtls); + // pd_form_detail_json_id, fk_pd_id, fk_form_id, company_id, isactive, json, processed_json, + $original_j_arr = json_decode($json_dtls[$l]['json'], true); + $original_pj_arr = json_decode($json_dtls[$l]['processed_json'], true); + // $have_to_replace["is_person_met_pic"] = ""; + foreach ($have_to_replace as $key => $value) { + $replaced_pj_arr = $this->replace_in_array($key, $value, $original_pj_arr); + $replaced_j_arr = $this->replace_in_array($key, $value, $original_j_arr); + } + // $fid=18; + switch ($fid) { + case 1: + // 1 trade_product_contact_person_name , person_landline ,person_stdcode + $arr1 = array('trade_product_contact_person_name', 'person_landline', 'person_stdcode'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr1, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr1, $general_format); + break; + case 2: + // 2 trade_product_contact_person_name , person_landline + $arr2 = array('trade_product_contact_person_name', 'person_landline'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr2, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr2, $general_format); + break; + case 4: + // 4 other asset + $arr4 = array('address_of_the_property'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr4, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr4, $general_format); + break; + case 5: + // 5 alternative_address + $arr5 = array('alternative_address', 'address'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr5, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr5, $general_format); + break; + case 6: + // 6 residence_place + $arr6 = array('residence_place', 'earning_name_of_the_employer_or_business', 'family_member_name'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr6, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr6, $general_format); + break; + case 8: + // 8 label + $arr8 = array('label'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr8, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr8, $general_format); + break; + case 9: + // 9 address + $arr9 = array('address'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr9, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr9, $general_format); + break; + case 10: + $arr10 = array('address', 'property_seller'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr10, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr10, $general_format); + break; + case 12: + $arr12 = array("employer_name", "designation_person_met"); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr12, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr12, $general_format); + break; + case 13: + // 13 partner_name_master . gst_Regn_cert_pic , shop_eat_act_cert_pic + $arr13 = array("partner_name_master", "gst_Regn_cert_pic", "shop_eat_act_cert_pic", "export_import_cert_pic", "factory_cert_pic", "pf_regn_pic", "esic_regn_pic", "eb_bill_pic"); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr13, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr13, $general_format); + break; + case 17: + $arr17 = array('address_property'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr17, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr17, $general_format); + break; + case 18: + // 18 is_person_met_pic , is_person_met_id_proof + $arr18 = array('is_person_met_pic', 'is_person_met_id_proof'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr18, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr18, $general_format); + break; + case 19: + // 19 neighbourhood_name + $arr19 = array('neighbourhood_name'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr19, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr19, $general_format); + break; + case 22: + // 22 address_label,address_label + $arr22 = array('address_label', 'address_label'); + $replaced_pj_arr = $this->traverseArray($replaced_pj_arr, $arr22, $general_format); + $replaced_j_arr = $this->traverseArray($replaced_j_arr, $arr22, $general_format); + break; + } + // traverseArray(&$array, $keys) + $update_json_arr['json'] = json_encode($replaced_j_arr); + $update_json_arr['processed_json'] = json_encode($replaced_pj_arr); + $json_result = $this->PD_Model->updateRecords($update_json_arr, PDFORMDETAILSJSON, array('pd_form_detail_json_id' => $json_dtls[$l]['pd_form_detail_json_id'])); + if ($json_result) { + log_message('ERROR', "JSON updated => " . $form_name . " Updated successfully ( " . ($l + 1) . " ) json table id = " . $json_dtls[$l]['pd_form_detail_json_id']); + } else { + log_message('ERROR', "Check here JSON Not updated " . $form_name . " ( " . ($l + 1) . " ) json table id = " . $json_dtls[$l]['pd_form_detail_json_id']); + } + // $data['have_to_replace_this'] = $have_to_replace; + // $data['replaced_pj_array'] = $replaced_pj_arr; + // $data['original_pj_array'] = $original_pj_arr; + // $data['original_j_array'] = $original_j_arr; + // $data['replaced_j_array'] = $replaced_j_arr; + } + } + // $earliest['docs_details'] = $docs_dtls; + if (!empty($docs_dtls)) { + for ($m = 0; $m < count($docs_dtls); $m++) { + log_message('ERROR', "Document " . $docs_dtls[$m]['pd_document_name']); + $docname = $docs_dtls[$m]['pd_document_name']; + $destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $docname; + if (file_exists($destination_path)) { + unlink($destination_path); + } + + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pdlenid; + $key = 'pd' . $pdid . '/' . $docname; + $s3result = $this->aws_s3->deleteSingleObjFromBucket($bucketname, $key); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', "s3result " . $s3result['@metadata']['statusCode']); + } else { + log_message('ERROR', "Check here Not updated on S3 result " . $s3result['@metadata']['statusCode']); + } + } + } + $updt_on_tgr['pd_status'] = ARCHIVED; + $updt_tgr_where = array('pd_id' => $pdid, 'pd_status' => QC_COMPLETED); + $trg_result = $this->PD_Model->updateRecords($updt_on_tgr, PDTRIGGER, $updt_tgr_where); + if ($trg_result) { + log_message('ERROR', "Trigger table updated pdid => " . $pdid . " Updated successfully "); + } else { + log_message('ERROR', "Check here Trigger table Not updated pdid = " . $pdid); + } + return $pdid; + // $data['pdid'] = $pdid ; + // $this->response($data,REST_Controller::HTTP_OK); } - function replace_in_array($find, $replace, &$array) { - array_walk_recursive($array, function(&$array) use($find, $replace) { - if($array === $find) { - $array= $replace; + function replace_in_array($find, $replace, &$array) + { + array_walk_recursive($array, function (&$array) use ($find, $replace) { + if ($array === $find) { + $array = $replace; } }); return $array; @@ -935,31 +968,32 @@ class Data_Dump_Controller extends REST_Controller { - function traverseArray(&$array, $keys,$format) { - foreach ($array as $key => &$value) { - if (is_array($value)) { - $this->traverseArray($value, $keys,$format); - } else { - if (in_array($key, $keys)){ - // unset($array[$key]); - $array[$key] = $format."-".$key; + function traverseArray(&$array, $keys, $format) + { + foreach ($array as $key => &$value) { + if (is_array($value)) { + $this->traverseArray($value, $keys, $format); + } else { + if (in_array($key, $keys)) { + // unset($array[$key]); + $array[$key] = $format . "-" . $key; + } } - } } return $array; - } + } - function delete_file_destination($file,$pdid) { + function delete_file_destination($file, $pdid) + { // foreach ($files as $file) { // if (file_exists($file)) { - // unlink($file); - $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$file; - unlink($destination_path); - // } else { - // // File not found. - // } + // unlink($file); + $destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $file; + unlink($destination_path); + // } else { + // // File not found. + // } // } } - -} \ No newline at end of file +} From eadc2d0cb97e5cc3d3e8e5ae7245ac4489094362 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 26 Aug 2022 11:45:35 +0530 Subject: [PATCH 061/132] Image primary Key added : ps --- api/application/controllers/Flyhi_Controller.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 486c2635..367caf40 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -583,6 +583,7 @@ class Flyhi_Controller extends REST_Controller { { $photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img']; $photo_questions['questions'][$key]['image_location'] = $selfie[0]['location']; + $photo_questions['questions'][$key]['image_id'] = $selfie[0]['doc_id']; //$photo_questions['questions'][$key]['answer_value'] = "CHNAGED"; } } @@ -601,6 +602,7 @@ class Flyhi_Controller extends REST_Controller { { $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img']; $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_location'] = $img_value['location']; + $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_id'] = $img_value['doc_id']; //$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = "CHANGED"; unset($all_sales_pd_images[$img_key]); break; @@ -1174,6 +1176,10 @@ class Flyhi_Controller extends REST_Controller { } + if(!empty($records['img_id']) && $records['img_name'] != 'selfie_with_person_met'){ + $update_fields2 = array('isactive' => 0); + $this->Flyhi_Model->updateRecords($update_fields2,SALEPD_DOCS,array('doc_id'=>$records['img_id'])); + } $id = $this->Flyhi_Model->saveRecords($records,SALEPD_DOCS); if($id) From 49469018b7958c1194af390fa61f2509119c4721 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 26 Aug 2022 06:31:51 +0000 Subject: [PATCH 062/132] Flyhi_Controller.php edited online with Bitbucket --- api/application/controllers/Flyhi_Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 367caf40..a499447d 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -1180,7 +1180,7 @@ class Flyhi_Controller extends REST_Controller { $update_fields2 = array('isactive' => 0); $this->Flyhi_Model->updateRecords($update_fields2,SALEPD_DOCS,array('doc_id'=>$records['img_id'])); } - + unset($records['img_id']); $id = $this->Flyhi_Model->saveRecords($records,SALEPD_DOCS); if($id) { From dfee473871ddd252e4ce63fdce6845091f6d5a93 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 29 Aug 2022 12:20:31 +0530 Subject: [PATCH 063/132] digilocker access key : ps --- api/application/models/Entity_Management_Model.php | 2 +- api/application/models/PD_Model.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/application/models/Entity_Management_Model.php b/api/application/models/Entity_Management_Model.php index 30da3659..19d044dd 100644 --- a/api/application/models/Entity_Management_Model.php +++ b/api/application/models/Entity_Management_Model.php @@ -14,7 +14,7 @@ class Entity_Management_Model extends SPARQ_Model { { $result_data = array(); - $this->db->SELECT('ENTITY.entity_id, ENTITY.full_name, ENTITY.short_name,ENTITY.createdon, ENTITY.fk_createdby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby, ENTITY.updatedon, ENTITY.fk_updatedby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, ENTITY.isactive,ENTITY.fk_entity_type_id,ENTITYTYPE.name as entity_name,ENTITY.is_otp_enabled,ENTITY.is_score_card_enabled,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,ENTITY.is_face_api_enabled'); + $this->db->SELECT('ENTITY.entity_id, ENTITY.full_name, ENTITY.short_name,ENTITY.createdon, ENTITY.fk_createdby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby, ENTITY.updatedon, ENTITY.fk_updatedby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, ENTITY.isactive,ENTITY.fk_entity_type_id,ENTITYTYPE.name as entity_name,ENTITY.is_otp_enabled,ENTITY.is_score_card_enabled,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,ENTITY.is_face_api_enabled,ENTITY.digilocker_access'); $this->db->FROM(ENTITY.' as ENTITY'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','ENTITY.fk_createdby = USERPROFILE.userid','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE1','ENTITY.fk_updatedby = USERPROFILE1.userid','LEFT'); diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index f363a729..e1e7f381 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -14,7 +14,7 @@ class PD_Model extends SPARQ_Model { public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status,$lender_details,$pdagencyid,$vendor_pdofficer,$user_type,$createdby,$client,$is_smc_vendor)// $page represents mysql offset { // echo $lenderid;die(); - $this->db->SELECT('PDTRIGGER.pd_id,PDTRIGGER.imgc_fin_institute,PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as master_updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,AGENCY.is_qc_enabled, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDTRIGGER.other_pincode,PDAPPLICANTSDETAILS.applicant_name,PDTRIGGER.is_otp_done,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.encrypted_url,PDTRIGGER.random_string,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,ENTITY.is_face_api_enabled,PDTRIGGER.is_notify_enabled,(SELECT DATE_FORMAT(createdon,"%d/%m/%Y") FROM h_common_masters where PDTRIGGER.pd_id = primary_key AND field_name = "pd_status" order by log_id DESC limit 1) as updatedon,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,AGENCYLIST.agency_name as SMC_vendor_agency_name,AGENCYLIST.agency_abbr as SMC_vendor_agency_short_name'); + $this->db->SELECT('PDTRIGGER.pd_id,PDTRIGGER.imgc_fin_institute,PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.sub_entity_id,SUBENTITY.short_name as sub_entity_short_name,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PRODUCTS.prod_catagory,PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as master_updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name,AGENCY.short_name as agency_short_name,AGENCY.is_qc_enabled, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDTRIGGER.other_pincode,PDAPPLICANTSDETAILS.applicant_name,PDTRIGGER.is_otp_done,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.encrypted_url,PDTRIGGER.random_string,PDTRIGGER.pd_qc_note,ENTITY.is_sms_enabled,ENTITY.is_mail_enabled,ENTITY.is_app_notify_enabled,ENTITY.is_face_api_enabled,PDTRIGGER.is_notify_enabled,(SELECT DATE_FORMAT(createdon,"%d/%m/%Y") FROM h_common_masters where PDTRIGGER.pd_id = primary_key AND field_name = "pd_status" order by log_id DESC limit 1) as updatedon,ENTITYFININSTITUTION.institute_name as fin_institute_name,PDTRIGGER.is_video_merged,PDTRIGGER.vendor_status,AGENCYLIST.agency_name as SMC_vendor_agency_name,AGENCYLIST.agency_abbr as SMC_vendor_agency_short_name,ENTITY.digilocker_access'); //$this->db->SELECT('pd_sno,fk_lender_id,pd_agency_id,pd_status,vendor_status'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); @@ -280,7 +280,7 @@ class PD_Model extends SPARQ_Model { if($is_smc_vendor == true){ // if($is_smc_vendor == true && $pd_status != "" || $pd_status != null){ // echo "in IF"; - $this->db->WHERE('PDTRIGGER.vendor_status',$status); + $this->db->WHERE('PDTRIGGER.vendor_status',$pd_status); }else{ // echo "in ELSE"; $this->db->WHERE_IN('PDTRIGGER.pd_status',$pd_status); From ac4f101ffdc258203d52531caa9c76b45e42171b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 29 Aug 2022 13:10:02 +0530 Subject: [PATCH 064/132] uri changed in digilocker : ps --- api/application/helpers/digital_locker_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/application/helpers/digital_locker_helper.php b/api/application/helpers/digital_locker_helper.php index ce69f087..9e95f286 100644 --- a/api/application/helpers/digital_locker_helper.php +++ b/api/application/helpers/digital_locker_helper.php @@ -14,7 +14,7 @@ class DIGITAL_LOCKER $headers = array('Content-Type: multipart/form-data'); // $headers = array('Content-Type: application/json'); $ch = curl_init(); - $fields = array('code' => $code,'grant_type' =>'authorization_code','client_secret' =>'bbda9efeb26bff460434','client_id' =>'FE9E5D06','redirect_uri' => 'https://apitest.pdgenie.com/'); + $fields = array('code' => $code,'grant_type' =>'authorization_code','client_secret' =>'bbda9efeb26bff460434','client_id' =>'FE9E5D06','redirect_uri' => 'https://apitest.pdgenie.com/sparqtest/api/getDigiLockerDocs'); curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_TOKEN_URI); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); From cc7ac5ff04bba93d9817673aacfebb841d87b499 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 1 Sep 2022 22:56:32 +0530 Subject: [PATCH 065/132] upload Credit PD Data To CET App api : ps --- api/application/config/routes.php | 1 + .../controllers/SMC_Credit_PD_Controller.php | 188 +++++++++++++----- 2 files changed, 144 insertions(+), 45 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 375360da..5c849cff 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -372,6 +372,7 @@ $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only deve $route['uploadSalesPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp'; $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; +$route['uploadCreditPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadCreditPDDataToCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index ab339b78..a2377e69 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -267,6 +267,149 @@ class SMC_Credit_PD_Controller extends REST_Controller { } + function uploadCreditPDDataToCETApp_get() + { + log_message('ERROR', '#### upload SMC Credit PDData To CETApp Called'); + $smc_credit_pd = $this->uri->segment(2); + if (!empty($smc_credit_pd)) { + log_message('ERROR', '#### SMC Credit PD = ' . $smc_credit_pd); + $columns = array('SMC_CREDIT_PD.*', 'ENTITY.short_name', 'PRODUCT.abbr'); + $table = SMC_CREDIT_PD . ' as SMC_CREDIT_PD'; + $joins = array( + array( + 'table' => ENTITY . ' as ENTITY', + 'condition' => 'SMC_CREDIT_PD.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER' + ), + array( + 'table' => PRODUCTS . ' as PRODUCT', + 'condition' => 'SMC_CREDIT_PD.product_id = PRODUCT.product_id', + 'jointype' => 'INNER' + ) + ); + + $where_condition_array = array('SMC_CREDIT_PD.smc_credit_pd' => $smc_credit_pd); + $SMC_CREDIT_PD = $this->SMC_Credit_PD_Model->getJoinRecords($columns, $table, $joins, $where_condition_array); + log_message('ERROR', '#### Total Credit PD is ' . count($SMC_CREDIT_PD)); + $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); + $forms_data_to_be_get_direct_from_excel_sheet = array(3, 9, 10, 15); + // print_r($SMC_CREDIT_PD);die(); + if (count($SMC_CREDIT_PD) > 0) { + $all_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('smc_credit_pd' => $smc_credit_pd, 'isactive' => 1), SMC_CREDIT_PD_SECTION_DATA); + + $common_fields = array( + 'pdid' => $SMC_CREDIT_PD['fk_sales_pd_id'], + 'product' => $SMC_CREDIT_PD['abbr'], + 'caseno' => $SMC_CREDIT_PD['smc_credit_pd_sno'] + ); + foreach ($all_section_data as $sec_key => $section) { + $section_fields['section' . $section['section_id']] = $this->processSalesPDJSON($section); + } + $pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($SMC_CREDIT_PD['fk_sales_pd_id'], $SMC_CREDIT_PD['product_id'], null, null, 'REPORT'); + if (count($pd_section_data)) { + foreach ($pd_section_data as $key => $value) { + if (isset($value['json']) && $value['json'] != '') { + $filter_form_id[$key] = $value['fk_form_id']; + $CETAPP_creditPD_data[$value['form_name']] = $value['json']; + } else { + if (in_array($value['fk_form_id'], $forms_data_to_be_get_direct_from_excel_sheet)) { + $data_from_excel = $this->loadDataFromExcelBusiProcess($mater_details, $value['fk_form_id']); + $filter_form_id[$key] = $value['fk_form_id']; + $CETAPP_creditPD_data[$value['form_name']] = $data_from_excel; + } + } + } + } + + $photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('fk_smc_credit_pd' => $smc_credit_pd, 'img_name !=' => 'satellite', 'isactive' => 1), SALEPD_DOCS); + if (count($photograph_data) > 0) { + for ($i = 0; $i < count($photograph_data); $i++) { + $img_fields = $common_fields; + $img_fields['img_name'] = $photograph_data[$i]['img_name']; + $img_split = explode(',', $photograph_data[$i]['img']); + $img_fields['img'] = $img_split[1]; + cet_creditpd::pushwithcetphotographapi($img_fields, $i); + } + } + + if ($mater_details[0]['product_abbr'] == 'LFMP') { + $LFMP_KeyStackholders = $pd_section_data[5]['key_stakeholders']; + $temp_arr = []; + + for ($i = 0; $i < count($LFMP_KeyStackholders); $i++) { + $value = $LFMP_KeyStackholders[$i]; + if (isset($value["stakeholder_name0"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name0"], + "share_holding" => $value["share_holding0"], "vintage_in_current_biz" => $value["vintage_in_current_biz0"], + "total_work_exp" => $value["total_work_exp0"], "started_biz" => $value["started_biz0"], + "previous_experience_details" => (isset($value['previous_experience_details0']) ? $value['previous_experience_details0'] : '') + ); + } + if (isset($value["stakeholder_name1"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name1"], + "share_holding" => $value["share_holding1"], "vintage_in_current_biz" => $value["vintage_in_current_biz1"], + "total_work_exp" => $value["total_work_exp1"], "started_biz" => $value["started_biz1"], + "previous_experience_details" => (isset($value['previous_experience_details1']) ? $value['previous_experience_details1'] : '') + ); + } + if (isset($value["stakeholder_name2"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], + "stakeholder_name" => $value["stakeholder_name2"], "share_holding" => $value["share_holding2"], + "vintage_in_current_biz" => $value["vintage_in_current_biz2"], "total_work_exp" => $value["total_work_exp2"], "started_biz" => $value["started_biz2"], + "previous_experience_details" => (isset($value['previous_experience_details2']) ? $value['previous_experience_details2'] : '') + ); + } + } + $CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr; + } // ### LFMP key_stakeholders ends + if ((in_array(1, $filter_form_id)) && (in_array(21, $filter_form_id))) + // && (in_array(4,$filter_form_id))) + { + $officer_id = isset($mater_details[0]['fk_updatedby']) ? $mater_details[0]['fk_updatedby'] : ''; + $visit_date = isset($mater_details[0]['pd_visit_date']) ? $mater_details[0]['pd_visit_date'] : ''; + if (!empty($officer_id)) { + $officer_details = $this->SMC_Credit_PD_Model->selectCustomRecords(array('userid as officer_id', 'email', 'mobile_no', 'concat(first_name," ",last_name) as officer'), array('userid' => $officer_id), USERPROFILE); + if (!empty($officer_details)) { + foreach ($officer_details as $key => $value) { + $CETAPP_creditPD_data['Officer Details'] = $value; + $CETAPP_creditPD_data['Officer Details']['pd_visit_date'] = $visit_date; + } + } + } + } + cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data); + + $satellite_image = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id', 'img', 'img_name', 'isactive'), array('fk_smc_credit_pd_id' =>$smc_credit_pd, 'isactive' => 1, 'img_name=' => 'satellite'), SMC_CREDIT_PD_DOCS); + if (!empty($satellite_image)) { + $stt_fields = $common_fields; + $stt_fields['img_name'] = $satellite_image[0]['img_name']; + $stt_fields['img'] = $satellite_image[0]['img']; + cet_creditpd::pushwithcetphotographapi($stt_fields, 0); + } + + // + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Data Shared Successfully'; + $this->response($data, REST_Controller::HTTP_OK); + } else { + log_message('ERROR', '#### There is No Data Found relevant Credit PDID '); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'There is No Data Found relevant Credit PDID ! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + log_message('ERROR', '#### Can`t able Found the Credit PDID '); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Can`t able Found the Creditpd PDID ! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } public function listSMCCreditPD_get() { @@ -1529,12 +1672,6 @@ public function filterSalesPDList_post() { $view_data['applicant_details'] = $this->PD_Model->getApplicantsDetails($records['pd_id']); //$pd_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,'fk_pd_id' => $records['pd_id']),SMC_CREDIT_PD_SECTION_DATA,array(),'','fk_form_id','ASC'); $pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($records['pd_id'],$view_data['pd_master_details'][0]['fk_product_id'],null,null,'REPORT'); - //$common_fields = array('pdid'=>111, - // 'product'=>$view_data['pd_master_details'][0]['product_abbr'], - // 'caseno'=>'MWISE00840'); - $common_fields = array('pdid'=>$view_data['pd_master_details'][0]['pd_id'], - 'product'=>$view_data['pd_master_details'][0]['product_abbr'], - 'caseno'=>$view_data['pd_master_details'][0]['pd_sno']); // print_r($pd_section_data);die(); $forms_data_to_be_get_direct_from_excel_sheet = array(3,9,10,15); @@ -1553,8 +1690,6 @@ public function filterSalesPDList_post() { $filter_form_id[$key] = $value['fk_form_id']; // if($value['fk_form_id'] == 2){print_r($value['json']);die();} $view_data['pd_section_data'][$value['fk_form_id']] = $value['json']; - $CETAPP_creditPD_data[$value['form_name']] = $value['json']; - // $CETAPP_creditPD_data[$value['fk_form_id']] = $value['json']; } else { @@ -1565,9 +1700,6 @@ public function filterSalesPDList_post() { //print_r($data_from_excel);die(); $view_data['pd_section_data'][$value['fk_form_id']] = $data_from_excel; $filter_form_id[$key] = $value['fk_form_id']; - $CETAPP_creditPD_data[$value['form_name']] = $data_from_excel; - // $CETAPP_creditPD_data[$value['fk_form_id']]= $data_from_excel; - } } //die(); @@ -1578,21 +1710,6 @@ public function filterSalesPDList_post() { // print_r($view_data['pd_section_data'][15]);die(); $view_data['smc_images'] = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $records['pd_id'],'isactive' => 1,'img_name!=' => 'satellite'),SMC_CREDIT_PD_DOCS); $view_data['satellite'] = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $records['pd_id'],'isactive' => 1,'img_name=' => 'satellite'),SMC_CREDIT_PD_DOCS); - if(count($view_data['smc_images'])>0){ - for ($i = 0; $i < count($view_data['smc_images']); $i++){ - $img_fields = $common_fields; - $img_fields['img_name'] = $view_data['smc_images'][$i]['img_name']; - $img_split = explode( ',', $view_data['smc_images'][$i]['img']); - $img_fields['img'] = $img_split[1]; - // $img_fields[0]['img'] = $view_data['section9'][$i]['img']; - cet_creditpd::pushwithcetphotographapi($img_fields,$i); - }} - if(!empty($view_data['satellite'])){ - $stt_fields = $common_fields; - $stt_fields['img_name'] = $view_data['satellite'][0]['img_name']; - $stt_fields['img'] = $view_data['satellite'][0]['img']; - cet_creditpd::pushwithcetphotographapi($stt_fields,0); - } // print_r($view_data['smc_images']);die(); //print_r(count($view_data['smc_images']));die(); @@ -1664,26 +1781,7 @@ public function filterSalesPDList_post() { } } $view_data['pd_section_data'][5]['key_stakeholders'] = $temp_arr; - $CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr; - // $CETAPP_creditPD_data[5]['key_stakeholders'] = $temp_arr; }// ### LFMP key_stakeholders ends - // log_message('ERROR',"SUSEEN".json_encode($CETAPP_creditPD_data));die(); - if((in_array(1,$filter_form_id)) && (in_array(21,$filter_form_id))) - // && (in_array(4,$filter_form_id))) - { - $officer_id = isset($view_data['pd_master_details'][0]['fk_updatedby']) ? $view_data['pd_master_details'][0]['fk_updatedby'] : ''; - $visit_date = isset($view_data['pd_master_details'][0]['pd_visit_date']) ? $view_data['pd_master_details'][0]['pd_visit_date'] : ''; - if(!empty($officer_id)){ - $officer_details = $this->SMC_Credit_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer'),array('userid' => $officer_id),USERPROFILE); - if(!empty($officer_details)){ - foreach($officer_details as $key=>$value) { - $CETAPP_creditPD_data['Officer Details'] = $value; - $CETAPP_creditPD_data['Officer Details']['pd_visit_date'] = $visit_date; - } - } - } - } - cet_creditpd::pushwithcetcreditpdapi($common_fields,$CETAPP_creditPD_data); $view_data['report_attachments'] = (new report_attachments)->getSMCReportAttchments($records['pd_id'],$view_data['pd_master_details'][0]['random_string'],$view_data['pd_master_details']); From 427576591fe174362978198c01cf0ad29c9a18e0 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 2 Sep 2022 15:41:09 +0530 Subject: [PATCH 066/132] uploadCreditPDDataToCETApp : ps --- api/application/config/routes.php | 2 +- .../controllers/SMC_Credit_PD_Controller.php | 142 +++++++----------- 2 files changed, 55 insertions(+), 89 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 5c849cff..85415d7f 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -372,7 +372,7 @@ $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only deve $route['uploadSalesPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp'; $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; -$route['uploadCreditPDDataToCETApp/(:num)'] = 'Sales_PD_Controller/uploadCreditPDDataToCETApp'; +$route['uploadCreditPDDataToCETApp/(:num)'] = 'SMC_Credit_PD_Controller/uploadCreditPDDataToCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index a2377e69..018ff16d 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -271,42 +271,15 @@ class SMC_Credit_PD_Controller extends REST_Controller { { log_message('ERROR', '#### upload SMC Credit PDData To CETApp Called'); $smc_credit_pd = $this->uri->segment(2); - if (!empty($smc_credit_pd)) { - log_message('ERROR', '#### SMC Credit PD = ' . $smc_credit_pd); - $columns = array('SMC_CREDIT_PD.*', 'ENTITY.short_name', 'PRODUCT.abbr'); - $table = SMC_CREDIT_PD . ' as SMC_CREDIT_PD'; - $joins = array( - array( - 'table' => ENTITY . ' as ENTITY', - 'condition' => 'SMC_CREDIT_PD.lender_id = ENTITY.entity_id', - 'jointype' => 'INNER' - ), - array( - 'table' => PRODUCTS . ' as PRODUCT', - 'condition' => 'SMC_CREDIT_PD.product_id = PRODUCT.product_id', - 'jointype' => 'INNER' - ) - ); - - $where_condition_array = array('SMC_CREDIT_PD.smc_credit_pd' => $smc_credit_pd); - $SMC_CREDIT_PD = $this->SMC_Credit_PD_Model->getJoinRecords($columns, $table, $joins, $where_condition_array); - log_message('ERROR', '#### Total Credit PD is ' . count($SMC_CREDIT_PD)); - $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); + $mater_details = $this->PD_Model->getPDMasterDetails($smc_credit_pd); + $pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($smc_credit_pd,$mater_details[0]['fk_product_id'],null,null,'REPORT'); + log_message('ERROR', '#### Total Credit PD is ' . count($pd_section_data)); + if (!empty($pd_section_data)) { $forms_data_to_be_get_direct_from_excel_sheet = array(3, 9, 10, 15); - // print_r($SMC_CREDIT_PD);die(); - if (count($SMC_CREDIT_PD) > 0) { - $all_section_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('smc_credit_pd' => $smc_credit_pd, 'isactive' => 1), SMC_CREDIT_PD_SECTION_DATA); - - $common_fields = array( - 'pdid' => $SMC_CREDIT_PD['fk_sales_pd_id'], - 'product' => $SMC_CREDIT_PD['abbr'], - 'caseno' => $SMC_CREDIT_PD['smc_credit_pd_sno'] - ); - foreach ($all_section_data as $sec_key => $section) { - $section_fields['section' . $section['section_id']] = $this->processSalesPDJSON($section); - } - $pd_section_data = $this->SMC_Credit_PD_Model->getSMCTemplateForPD($SMC_CREDIT_PD['fk_sales_pd_id'], $SMC_CREDIT_PD['product_id'], null, null, 'REPORT'); - if (count($pd_section_data)) { + if (count($pd_section_data) > 0) { + $common_fields = array('pdid'=>$mater_details[0]['pd_id'], + 'product'=>$mater_details[0]['product_abbr'], + 'caseno'=>$mater_details[0]['pd_sno']); foreach ($pd_section_data as $key => $value) { if (isset($value['json']) && $value['json'] != '') { $filter_form_id[$key] = $value['fk_form_id']; @@ -319,51 +292,53 @@ class SMC_Credit_PD_Controller extends REST_Controller { } } } - } - - $photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), array('fk_smc_credit_pd' => $smc_credit_pd, 'img_name !=' => 'satellite', 'isactive' => 1), SALEPD_DOCS); - if (count($photograph_data) > 0) { - for ($i = 0; $i < count($photograph_data); $i++) { - $img_fields = $common_fields; - $img_fields['img_name'] = $photograph_data[$i]['img_name']; - $img_split = explode(',', $photograph_data[$i]['img']); - $img_fields['img'] = $img_split[1]; - cet_creditpd::pushwithcetphotographapi($img_fields, $i); - } - } - - if ($mater_details[0]['product_abbr'] == 'LFMP') { + $photograph_data = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $smc_credit_pd,'isactive' => 1,'img_name!=' => 'satellite'),SMC_CREDIT_PD_DOCS); + $satellite_image = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $smc_credit_pd,'isactive' => 1,'img_name=' => 'satellite'),SMC_CREDIT_PD_DOCS); + if(count($photograph_data)>0){ + for ($i = 0; $i < count($photograph_data); $i++){ + $img_fields = $common_fields; + $img_fields['img_name'] = $photograph_data[$i]['img_name']; + $img_split = explode( ',', $photograph_data[$i]['img']); + $img_fields['img'] = $img_split[1]; + cet_creditpd::pushwithcetphotographapi($img_fields,$i); + }} + if(!empty($satellite_image)){ + $stt_fields = $common_fields; + $stt_fields['img_name'] = $satellite_image[0]['img_name']; + $stt_fields['img'] = $satellite_image[0]['img']; + cet_creditpd::pushwithcetphotographapi($stt_fields,0); + } + if ($mater_details[0]['product_abbr'] == 'LFMP' && (array_key_exists("key_stakeholders",$pd_section_data[5])) ) { $LFMP_KeyStackholders = $pd_section_data[5]['key_stakeholders']; - $temp_arr = []; - - for ($i = 0; $i < count($LFMP_KeyStackholders); $i++) { - $value = $LFMP_KeyStackholders[$i]; - if (isset($value["stakeholder_name0"])) { - $temp_arr[] = array( - "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name0"], - "share_holding" => $value["share_holding0"], "vintage_in_current_biz" => $value["vintage_in_current_biz0"], - "total_work_exp" => $value["total_work_exp0"], "started_biz" => $value["started_biz0"], - "previous_experience_details" => (isset($value['previous_experience_details0']) ? $value['previous_experience_details0'] : '') - ); - } - if (isset($value["stakeholder_name1"])) { - $temp_arr[] = array( - "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name1"], - "share_holding" => $value["share_holding1"], "vintage_in_current_biz" => $value["vintage_in_current_biz1"], - "total_work_exp" => $value["total_work_exp1"], "started_biz" => $value["started_biz1"], - "previous_experience_details" => (isset($value['previous_experience_details1']) ? $value['previous_experience_details1'] : '') - ); - } - if (isset($value["stakeholder_name2"])) { - $temp_arr[] = array( - "company_name" => $value["company_name"], - "stakeholder_name" => $value["stakeholder_name2"], "share_holding" => $value["share_holding2"], - "vintage_in_current_biz" => $value["vintage_in_current_biz2"], "total_work_exp" => $value["total_work_exp2"], "started_biz" => $value["started_biz2"], - "previous_experience_details" => (isset($value['previous_experience_details2']) ? $value['previous_experience_details2'] : '') - ); - } - } - $CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr; + $temp_arr = []; + for ($i = 0; $i < count($LFMP_KeyStackholders); $i++) { + $value = $LFMP_KeyStackholders[$i]; + if (isset($value["stakeholder_name0"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name0"], + "share_holding" => $value["share_holding0"], "vintage_in_current_biz" => $value["vintage_in_current_biz0"], + "total_work_exp" => $value["total_work_exp0"], "started_biz" => $value["started_biz0"], + "previous_experience_details" => (isset($value['previous_experience_details0']) ? $value['previous_experience_details0'] : '') + ); + } + if (isset($value["stakeholder_name1"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], "stakeholder_name" => $value["stakeholder_name1"], + "share_holding" => $value["share_holding1"], "vintage_in_current_biz" => $value["vintage_in_current_biz1"], + "total_work_exp" => $value["total_work_exp1"], "started_biz" => $value["started_biz1"], + "previous_experience_details" => (isset($value['previous_experience_details1']) ? $value['previous_experience_details1'] : '') + ); + } + if (isset($value["stakeholder_name2"])) { + $temp_arr[] = array( + "company_name" => $value["company_name"], + "stakeholder_name" => $value["stakeholder_name2"], "share_holding" => $value["share_holding2"], + "vintage_in_current_biz" => $value["vintage_in_current_biz2"], "total_work_exp" => $value["total_work_exp2"], "started_biz" => $value["started_biz2"], + "previous_experience_details" => (isset($value['previous_experience_details2']) ? $value['previous_experience_details2'] : '') + ); + } + $CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr; + } } // ### LFMP key_stakeholders ends if ((in_array(1, $filter_form_id)) && (in_array(21, $filter_form_id))) // && (in_array(4,$filter_form_id))) @@ -382,15 +357,6 @@ class SMC_Credit_PD_Controller extends REST_Controller { } cet_creditpd::pushwithcetcreditpdapi($common_fields, $CETAPP_creditPD_data); - $satellite_image = $this->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id', 'img', 'img_name', 'isactive'), array('fk_smc_credit_pd_id' =>$smc_credit_pd, 'isactive' => 1, 'img_name=' => 'satellite'), SMC_CREDIT_PD_DOCS); - if (!empty($satellite_image)) { - $stt_fields = $common_fields; - $stt_fields['img_name'] = $satellite_image[0]['img_name']; - $stt_fields['img'] = $satellite_image[0]['img']; - cet_creditpd::pushwithcetphotographapi($stt_fields, 0); - } - - // $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'Data Shared Successfully'; From 3b8945983bbd435969f88847c2801c2a5519ce19 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Mon, 5 Sep 2022 13:44:30 +0530 Subject: [PATCH 067/132] fixes : pd --- api/application/helpers/cet_creditpd_helper.php | 8 ++++++-- api/application/helpers/pdalerts_helper.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/application/helpers/cet_creditpd_helper.php b/api/application/helpers/cet_creditpd_helper.php index c4e07112..9e5cc907 100644 --- a/api/application/helpers/cet_creditpd_helper.php +++ b/api/application/helpers/cet_creditpd_helper.php @@ -14,8 +14,12 @@ class CET_CREDITPD $key_check = array("Supplier details","Clients details","Stock details", "Neighbourhood Details", "Existing Loan Obligations","Business Assets"); for($i=0;$iaddBCC("sanjeev.p@venbainfotech.com"); } @@ -855,6 +857,7 @@ class PDALERTS $mail->Subject = $subject; $mail->Body = 'Dear Team ,

'.$arg["msg"]; $mail->AltBody = $arg["msg"]; + $mail->addBCC($arg["mail"]); if(!$mail->send()) { // $logger->error("Mailer Error:" ,array($mail->ErrorInfo)); From 74c81379b2aa1e8860563bf284e6c5faae4f8b2e Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 7 Sep 2022 05:31:38 +0000 Subject: [PATCH 068/132] printr_r removed FHFSL.php : ps --- api/application/views/sale_pd_templates/FHFSL.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api/application/views/sale_pd_templates/FHFSL.php b/api/application/views/sale_pd_templates/FHFSL.php index 37ef9737..4fcf1637 100644 --- a/api/application/views/sale_pd_templates/FHFSL.php +++ b/api/application/views/sale_pd_templates/FHFSL.php @@ -1,6 +1,5 @@ ↑'; $downarrow = ''; $dash = ' '; From c17736423de8c190e03c3bf3e5e84b46b06b029f Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 9 Sep 2022 09:37:31 +0530 Subject: [PATCH 069/132] Code committed : ps --- .../controllers/SMC_Credit_PD_Controller.php | 35 ++++++++++++++----- .../helpers/smc_creditpd_helper.php | 11 ++++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index 018ff16d..999da10b 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -767,7 +767,12 @@ class SMC_Credit_PD_Controller extends REST_Controller { $records['completed_date'] = date('Y-m-d H:i:s'); //echo 'final';die(); $id = $this->SMC_Credit_PD_Model->updateRecords($records,SMC_CREDIT_PD,array('smc_credit_pd' => $records['smc_credit_pd'])); - + log_message('ERROR','####COMPLETE SMC Credit PD = '.$records['smc_credit_pd']); + $random_string = $records['random_string']; + $ZIP = smc_creditpd::covertSMCImgs2ZIP($records['smc_credit_pd'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE ZIP = '.$ZIP); + $PDF = smc_creditpd::covertSMCImgs2PDF($records['smc_credit_pd'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE PDF = '.$PDF); //$this->prepareSalesPDReport($records['smc_credit_pd'],false); // sleep(10); // log_message('ERROR','####SALESPD AFTER 10 PREPARED REPORT'.$records['smc_credit_pd']); @@ -1114,7 +1119,8 @@ class SMC_Credit_PD_Controller extends REST_Controller { // } - +// updatepdstatus +// zip auto generate script public function testAPISalesPD_post() { //PDALERTS::sendSalesPDMail($this,32);die(); @@ -2022,12 +2028,18 @@ public function filterSalesPDList_post() { $this->load->helper('smc_creditpd'); $res_data = smc_creditpd::covertSMCImgs2ZIP($pdid,$random_string,array(),$regenerate); - - $response_data['dataStatus'] = true; - $response_data['status'] = REST_Controller::HTTP_OK; - $response_data['records'] = $res_data; + + if(!empty($res_data)){ + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $res_data; + } else { + $response_data['dataStatus'] = false; + $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; + $response_data['msg'] = 'NO Image Found'; + } $this->response($response_data,REST_Controller::HTTP_OK); - + } @@ -2043,12 +2055,17 @@ public function filterSalesPDList_post() { $regenerate = isset($records['regenerate']) ? $records['regenerate'] : 0; $res_data = smc_creditpd::covertSMCImgs2PDF($pdid,$random_string,array(),$regenerate); - + if(!empty($res_data)){ $response_data['dataStatus'] = true; $response_data['status'] = REST_Controller::HTTP_OK; $response_data['records'] = $res_data; - $this->response($response_data,REST_Controller::HTTP_OK); + } else { + $response_data['dataStatus'] = false; + $response_data['status'] = REST_Controller::HTTP_NOT_FOUND; + $response_data['msg'] = 'NO Image Found'; + } + $this->response($response_data,REST_Controller::HTTP_OK); } } diff --git a/api/application/helpers/smc_creditpd_helper.php b/api/application/helpers/smc_creditpd_helper.php index 5b04a3b4..65101a57 100644 --- a/api/application/helpers/smc_creditpd_helper.php +++ b/api/application/helpers/smc_creditpd_helper.php @@ -616,7 +616,7 @@ class smc_creditpd { $all_pd_images = $CI->PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1 ),SMC_CREDIT_PD_DOCS); - + if(count($all_pd_images)>0){ // $all_form_names = array('pd_form_id'=>19,'pd_form_name'=>"photograph"); // $form_name[19] = "photograph"; @@ -663,6 +663,7 @@ class smc_creditpd unlink($CI->external_path.'/pd_reports/'.$pdid.'/'.$temp_path); } return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + }else return ""; } } @@ -694,7 +695,8 @@ class smc_creditpd { $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); // $all_pd_images = $CI->SMC_Credit_PD_Model->selectCustomRecords(array('doc_id', 'fk_smc_credit_pd_id','img','img_name','isactive'),array('fk_smc_credit_pd_id' => $pdid,'isactive' => 1),SMC_CREDIT_PD_DOCS); - + if(count($all_pd_images)>0){ + $data_to_view['all_pd_images'] = $all_pd_images; $img_pdf_data = $CI->load->view('report_templates/PDSMCIMG_PDF',$data_to_view,true); //print_r($img_pdf_data);die(); @@ -718,7 +720,10 @@ class smc_creditpd } return $singed_uri = $CI->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+7 days'); + } + else return ""; + } - }} + } } ?> \ No newline at end of file From 44cc68da0aa28a8f6f92a8dc7687fe1be660c846 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 9 Sep 2022 22:13:51 +0530 Subject: [PATCH 070/132] Live Fixes 2 : ps --- api/application/controllers/PD_Controller.php | 14666 +++++++--------- .../controllers/SMC_Credit_PD_Controller.php | 11 +- .../helpers/smc_creditpd_helper.php | 2 +- 3 files changed, 6587 insertions(+), 8092 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 98327bd2..2236d5ea 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -1,11 +1,12 @@ array('Person met','18',0,0),'person_met_id' => array('Person met ID Proof','18',0,0),'address_proof_visited' => array('Address Proof','5',0,0),'name_board_seen' => array('Name Board Seen','13',0,0),'machinery_image' => array('Machinery Image','22',0,0),'gst_Regn_cert_pic' => array('GST Regn Cert','13',0,0),'pf_regn_pic' => array('PF Regn','13',0,0),'esic_regn_pic' => array('ESIC Regn','13',0,0),'export_import_cert_pic' => array('Export Import Cert','13',0,0),'factory_cert_pic' => array('Factory Cert','13',0,0),'shop_eat_act_cert_pic' => array('Shop Est Act Cert','13',0,0),'eb_bill_pic' => array('EB Bill','13',0,0),'practice_cert_pic' => array('Cert of Practice','13',0,0),'fire_noc_pic' => array('Fire NOC','13',0,0),'stock_image' => array('Stock image','11',1,1),'client_image' => array('Client Bills','2',1,1),'supplier_image' => array('Supplier Bills','1',1,1),'office_setup' => array('Office/Business Setup','13',1,1),'additional_photos' => array('Additional Photographs','13',1,1)); + private $photo_names = array('selfie_with_person_met' => array('Person met', '18', 0, 0), 'person_met_id' => array('Person met ID Proof', '18', 0, 0), 'address_proof_visited' => array('Address Proof', '5', 0, 0), 'name_board_seen' => array('Name Board Seen', '13', 0, 0), 'machinery_image' => array('Machinery Image', '22', 0, 0), 'gst_Regn_cert_pic' => array('GST Regn Cert', '13', 0, 0), 'pf_regn_pic' => array('PF Regn', '13', 0, 0), 'esic_regn_pic' => array('ESIC Regn', '13', 0, 0), 'export_import_cert_pic' => array('Export Import Cert', '13', 0, 0), 'factory_cert_pic' => array('Factory Cert', '13', 0, 0), 'shop_eat_act_cert_pic' => array('Shop Est Act Cert', '13', 0, 0), 'eb_bill_pic' => array('EB Bill', '13', 0, 0), 'practice_cert_pic' => array('Cert of Practice', '13', 0, 0), 'fire_noc_pic' => array('Fire NOC', '13', 0, 0), 'stock_image' => array('Stock image', '11', 1, 1), 'client_image' => array('Client Bills', '2', 1, 1), 'supplier_image' => array('Supplier Bills', '1', 1, 1), 'office_setup' => array('Office/Business Setup', '13', 1, 1), 'additional_photos' => array('Additional Photographs', '13', 1, 1)); private $existing_imges = array(); function __construct() { - // Construct the parent class + // Construct the parent class parent::__construct(); - $this->external_path = $this->config->item('external_data_path'); + $this->external_path = $this->config->item('external_data_path'); $this->load->model('PD_Model'); $this->load->library('AWS_S3'); @@ -39,110 +41,102 @@ class PD_Controller extends REST_Controller { $this->load->helper('satellite_image'); $this->load->library('pdfgenerator'); $this->load->helper('faceapi'); - //$this->load->library('excel'); $this->load->library('phpmailer_library'); } - public function base_get() { $base64_img = "data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV8AAF9fX8swMNgTAFlDOICAgPNSUnNWSMQ5MBAQEJE3QPIGAM9AQMqGcG9vb6MhJsEdGM8vLx8fH98AANIWAMuQeL8fABkTEPPQ0OM5OSYdGFl5jo+Pj/+pqcsTE78wMFNGQLYmID4dGPvd3UBAQJmTkP+8vH9QUK+vr8ZWSHpzcJMmILdwcLOGcHRQUHxwcK9PT9DQ0O/v70w5MLypoG8wKOuwsP/g4P/Q0IcwKEswKMl8aJ9fX2xjdOtGRs/Pz+Dg4GImIP8gIH0sKEAwKKmTiKZ8aB/f39Wsl+LFt8dgUE9PT5x5aHBwcP+AgP+WltdgYMyZfyywz78AAAAAAAD///8AAP9mZv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAKgALAAAAAA9AEQAAAj/AFEJHEiwoMGDCBMqXMiwocAbBww4nEhxoYkUpzJGrMixogkfGUNqlNixJEIDB0SqHGmyJSojM1bKZOmyop0gM3Oe2liTISKMOoPy7GnwY9CjIYcSRYm0aVKSLmE6nfq05QycVLPuhDrxBlCtYJUqNAq2bNWEBj6ZXRuyxZyDRtqwnXvkhACDV+euTeJm1Ki7A73qNWtFiF+/gA95Gly2CJLDhwEHMOUAAuOpLYDEgBxZ4GRTlC1fDnpkM+fOqD6DDj1aZpITp0dtGCDhr+fVuCu3zlg49ijaokTZTo27uG7Gjn2P+hI8+PDPERoUB318bWbfAJ5sUNFcuGRTYUqV/3ogfXp1rWlMc6awJjiAAd2fm4ogXjz56aypOoIde4OE5u/F9x199dlXnnGiHZWEYbGpsAEA3QXYnHwEFliKAgswgJ8LPeiUXGwedCAKABACCN+EA1pYIIYaFlcDhytd51sGAJbo3onOpajiihlO92KHGaUXGwWjUBChjSPiWJuOO/LYIm4v1tXfE6J4gCSJEZ7YgRYUNrkji9P55sF/ogxw5ZkSqIDaZBV6aSGYq/lGZplndkckZ98xoICbTcIJGQAZcNmdmUc210hs35nCyJ58fgmIKX5RQGOZowxaZwYA+JaoKQwswGijBV4C6SiTUmpphMspJx9unX4KaimjDv9aaXOEBteBqmuuxgEHoLX6Kqx+yXqqBANsgCtit4FWQAEkrNbpq7HSOmtwag5w57GrmlJBASEU18ADjUYb3ADTinIttsgSB1oJFfA63bduimuqKB1keqwUhoCSK374wbujvOSu4QG6UvxBRydcpKsav++Ca6G8A6Pr1x2kVMyHwsVxUALDq/krnrhPSOzXG1lUTIoffqGR7Goi2MAxbv6O2kEG56I7CSlRsEFKFVyovDJoIRTg7sugNRDGqCJzJgcKE0ywc0ELm6KBCCJo8DIPFeCWNGcyqNFE06ToAfV0HBRgxsvLThHn1oddQMrXj5DyAQgjEHSAJMWZwS3HPxT/QMbabI/iBCliMLEJKX2EEkomBAUCxRi42VDADxyTYDVogV+wSChqmKxEKCDAYFDFj4OmwbY7bDGdBhtrnTQYOigeChUmc1K3QTnAUfEgGFgAWt88hKA6aCRIXhxnQ1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw=="; - $output_file = APPPATH."/docs/temp_base64_image.png"; + $output_file = APPPATH . "/docs/temp_base64_image.png"; $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'); + $temp_file_name = $randomString . date('Y-m-d-H:i:s'); - $ifp = fopen( $output_file, 'wb' ); + $ifp = fopen($output_file, 'wb'); - // split the string on commas - // $data[ 0 ] == "data:image/png;base64" - // $data[ 1 ] == - $data = explode( ',', $base64_img ); + // split the string on commas + // $data[ 0 ] == "data:image/png;base64" + // $data[ 1 ] == + $data = explode(',', $base64_img); print_r($data); - // we could add validation here with ensuring count( $data ) > 1 - fwrite( $ifp, base64_decode( $data[ 1 ] ) ); + // we could add validation here with ensuring count( $data ) > 1 + fwrite($ifp, base64_decode($data[1])); - // clean up the file resource - fclose( $ifp ); + // clean up the file resource + fclose($ifp); - print_r($output_file); + print_r($output_file); $tempdoc = $output_file; - $tempdocname = $temp_file_name.'.png'; - $bucketname = LENDER_BUCKET_NAME_PREFIX.'1'; - $key = 'pd'.'1'.'/'.$tempdocname ; + $tempdocname = $temp_file_name . '.png'; + $bucketname = LENDER_BUCKET_NAME_PREFIX . '1'; + $key = 'pd' . '1' . '/' . $tempdocname; $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); print_r($s3result); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname); - // $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname); + // $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); } } /***********************Get get List Of Lenders Details for PD Trigger Page************************/ - + public function getListOfLenders_get() { - $fields = array('entity_id','full_name','short_name'); - $where_condition_array = array('isactive' => 1,'fk_entity_type_id' => 2); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITY,array(),'','full_name'); - if(count($result_data)) - { + $fields = array('entity_id', 'full_name', 'short_name'); + $where_condition_array = array('isactive' => 1, 'fk_entity_type_id' => 2); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENTITY, array(), '', 'full_name'); + if (count($result_data)) { - foreach($result_data as $key => $value) - { + foreach ($result_data as $key => $value) { $fields = array('*'); - $where_condition_array = array('isactive' => 1,'fk_entity_id' => $value['entity_id']); - $result_data[$key]['billing_address'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITYBILLING); + $where_condition_array = array('isactive' => 1, 'fk_entity_id' => $value['entity_id']); + $result_data[$key]['billing_address'] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENTITYBILLING); $fields = array('entity_lender_branch_id', 'branch_name'); - $where_condition_array = array('fk_entity_id' => $value['entity_id'],'isactive'=>1); - $result_data[$key]['branches'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITYLENDERBRANCH); - + $where_condition_array = array('fk_entity_id' => $value['entity_id'], 'isactive' => 1); + $result_data[$key]['branches'] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENTITYLENDERBRANCH); } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $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); - + $this->response($data, REST_Controller::HTTP_OK); } } /***********************Get get List Of Vendor Details for allocation************************/ - + public function getListOfvendors_get() { - $fields = array('entity_id','full_name','short_name'); - $where_condition_array = array('isactive' => 1,'fk_entity_type_id' => 3); - if($this->get('vendor_name')){$where_condition_array['full_name like'] = '%'.$this->get('vendor_name').'%';} + $fields = array('entity_id', 'full_name', 'short_name'); + $where_condition_array = array('isactive' => 1, 'fk_entity_type_id' => 3); + if ($this->get('vendor_name')) { + $where_condition_array['full_name like'] = '%' . $this->get('vendor_name') . '%'; + } //if($this->get('location')){$where_condition_array['location like'] = '%'.$this->get('vendor_name').'%';} //print_r($where_condition_array);die(); //die(); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITY); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENTITY); // if() // { - + // } //print_r($this->db->last_query()); - if(count($result_data)) - { + if (count($result_data)) { // foreach($result_data as $key => $value) // { @@ -158,141 +152,123 @@ class PD_Controller extends REST_Controller { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $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); - + $this->response($data, REST_Controller::HTTP_OK); } } /***********************Get get List Of Vendor Details for allocation************************/ - + public function getListVendorPDOfficers_get() { - $fk_entity_id = $this->uri->segment(2);//die(); - - $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','USERPROFILE.email','USERPROFILE.mobile_no','USERPROFILEROLES.user_role'); - $table = USERPROFILE.' as USERPROFILE'; - $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', - 'condition' =>'USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1 AND USERPROFILEROLES.user_role = 22', - 'jointype' => 'INNER')); - $where_condition_array = array('USERPROFILE.fk_entity_id' => $fk_entity_id); - $vendor_officer_details = $this->PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); - - if(count($vendor_officer_details)) - { + $fk_entity_id = $this->uri->segment(2); //die(); + + $columns = array('USERPROFILE.userid', 'concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name', 'USERPROFILE.email', 'USERPROFILE.mobile_no', 'USERPROFILEROLES.user_role'); + $table = USERPROFILE . ' as USERPROFILE'; + $joins = array(array( + 'table' => USERPROFILEROLES . ' as USERPROFILEROLES', + 'condition' => 'USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1 AND USERPROFILEROLES.user_role = 22', + 'jointype' => 'INNER' + )); + $where_condition_array = array('USERPROFILE.fk_entity_id' => $fk_entity_id); + $vendor_officer_details = $this->PD_Model->getJoinRecords($columns, $table, $joins, $where_condition_array); + + if (count($vendor_officer_details)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $vendor_officer_details; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Officers Found...!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } } - + /********************Get get List Of Products and SubProducts Name Details for PD Trigger Page*********/ - + public function getListOfProducts_get() { - $fields = array('product_id','name as product_name','abbr as product_abbr','prod_catagory'); + $fields = array('product_id', 'name as product_name', 'abbr as product_abbr', 'prod_catagory'); $where_condition_array = array('isactive' => 1); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PRODUCTS); - if(count($result_data)) - { - foreach($result_data as $key => $product) - { - $fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr','is_others'); - $where_condition_array = array('isactive' => 1,'fk_product_id' => $product['product_id']); - $subproducts = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS); - //array_push($result_data[$key],$subproducts); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PRODUCTS); + if (count($result_data)) { + foreach ($result_data as $key => $product) { + $fields = array('subproduct_id', 'name as subproduct_name', 'abbr as subproduct_abbr', 'is_others'); + $where_condition_array = array('isactive' => 1, 'fk_product_id' => $product['product_id']); + $subproducts = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, SUBPRODUCTS); + //array_push($result_data[$key],$subproducts); $result_data[$key]['subproducts'] = $subproducts; - } + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $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); - + $this->response($data, REST_Controller::HTTP_OK); } } - - + + /********************Get get List Of CustomerSegments Details for PD Trigger Page*********/ - + public function getListOfCustomerSegments_get() { - $fields = array('customer_segment_id','name as customer_segment','abbr'); + $fields = array('customer_segment_id', 'name as customer_segment', 'abbr'); $where_condition_array = array('isactive' => 1); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CUSTOMERSEGMENT); - if(count($result_data)) - { + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, CUSTOMERSEGMENT); + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $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); - + $this->response($data, REST_Controller::HTTP_OK); } } - + /********************Get get List Of Both PD Allocation Types and PD Types Details for PD Trigger Page*********/ - + public function getListOfPDAllocationTypes_get() { - $fields = array('pd_allocation_type_id','pd_allocation_type_name','pd_allocation_logic','default'); + $fields = array('pd_allocation_type_id', 'pd_allocation_type_name', 'pd_allocation_logic', 'default'); $where_condition_array = array('isactive' => 1); - $result_data['pd_allocation_type'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDALLOCATIONTYPE); - - $fields1 = array('pd_type_id','type_name'); + $result_data['pd_allocation_type'] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDALLOCATIONTYPE); + + $fields1 = array('pd_type_id', 'type_name'); $where_condition_array1 = array('isactive' => 1); - $result_data['pd_type'] = $this->PD_Model->selectCustomRecords($fields1,$where_condition_array1,PDTYPE); - if(count($result_data)) - { + $result_data['pd_type'] = $this->PD_Model->selectCustomRecords($fields1, $where_condition_array1, PDTYPE); + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $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); - + $this->response($data, REST_Controller::HTTP_OK); } } - - + + /********************Get get List Of States and Cities Name and Pincodes Details for PD Trigger Page*********/ - + public function getListOfStatesAndCities_post() { $records = $this->post('records'); @@ -300,20 +276,20 @@ class PD_Controller extends REST_Controller { // $fields = array('state_id','name as state_name','code'); // $where_condition_array = array('isactive' => 1); // $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE); - - $fields = array('city_id','name as city_name'); - $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid); - $cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); - //array_push($result_data[$key],$cities); + + $fields = array('city_id', 'name as city_name'); + $where_condition_array = array('isactive' => 1, 'fk_state_id' => $stateid); + $cities = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, CITY); + //array_push($result_data[$key],$cities); $result_data['cities'] = $cities; - // $fields = array('pincode_id','pincode'); - // $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid); - // $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE); - //echo "sds"; - $pincode = $this->db->DISTINCT()->SELECT('pincode,pincode_id')->FROM(PINCODE)->WHERE('fk_state_id',$stateid)->OR_WHERE('fk_state_id is null')->ORDER_BY('is_others')->GROUP_BY('pincode')->ORDER_BY('pincode')->GET()->result_array(); - //print_r($this->db->last_query()); + // $fields = array('pincode_id','pincode'); + // $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid); + // $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE); + //echo "sds"; + $pincode = $this->db->DISTINCT()->SELECT('pincode,pincode_id')->FROM(PINCODE)->WHERE('fk_state_id', $stateid)->OR_WHERE('fk_state_id is null')->ORDER_BY('is_others')->GROUP_BY('pincode')->ORDER_BY('pincode')->GET()->result_array(); + //print_r($this->db->last_query()); $result_data['pincode'] = $pincode; @@ -322,177 +298,157 @@ class PD_Controller extends REST_Controller { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - - - - + $this->response($data, REST_Controller::HTTP_OK); } - - + + //For RI form list display public function getStateCityNamesAndPincode_post() { - $records = $this->post('records'); + $records = $this->post('records'); - //get state name + //get state name $fields = array('name as state_name'); - $where_condition_array = array('isactive' => 1,'state_id' => $records['state_id']); - $state = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE); + $where_condition_array = array('isactive' => 1, 'state_id' => $records['state_id']); + $state = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, STATE); - //get city name + //get city name $fields = array('name as city_name'); - $where_condition_array = array('isactive' => 1,'city_id' => $records['city_id']); - $city = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); + $where_condition_array = array('isactive' => 1, 'city_id' => $records['city_id']); + $city = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, CITY); - //get pincode + //get pincode $fields = array('pincode'); - $where_condition_array = array('isactive' => 1,'pincode_id' => $records['pincode_id']); - $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE); + $where_condition_array = array('isactive' => 1, 'pincode_id' => $records['pincode_id']); + $pincode = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PINCODE); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('state_name' => $state[0]['state_name'],'city_name' => $city[0]['city_name'],'pincode' => $pincode[0]['pincode']); - $this->response($data,REST_Controller::HTTP_OK); + $data['records'] = array('state_name' => $state[0]['state_name'], 'city_name' => $city[0]['city_name'], 'pincode' => $pincode[0]['pincode']); + $this->response($data, REST_Controller::HTTP_OK); } /********************Get get List Of States and Cities Name only for Business form *********/ - + public function getListOfStatesCities_post() { $records = $this->post('records'); $stateid = $records['state_id']; - $fields = array('state_id','name as state_name','code'); + $fields = array('state_id', 'name as state_name', 'code'); $where_condition_array = array('isactive' => 1); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE); - - if(count($result_data)) - { - foreach($result_data as $key => $res) - { - // $fields = array('city_id','name as city_name'); - // $where_condition_array = array('isactive' => 1,'fk_state_id' => $res['state_id']); - // $cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); - //array_push($result_data[$key],$cities); - $cities = $this->db->DISTINCT()->SELECT('city_id,name as city_name')->FROM(CITY)->WHERE('fk_state_id',$res['state_id'])->OR_WHERE('fk_state_id is null')->ORDER_BY('fk_state_id,city_name')->GET()->result_array(); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, STATE); + + if (count($result_data)) { + foreach ($result_data as $key => $res) { + // $fields = array('city_id','name as city_name'); + // $where_condition_array = array('isactive' => 1,'fk_state_id' => $res['state_id']); + // $cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); + //array_push($result_data[$key],$cities); + $cities = $this->db->DISTINCT()->SELECT('city_id,name as city_name')->FROM(CITY)->WHERE('fk_state_id', $res['state_id'])->OR_WHERE('fk_state_id is null')->ORDER_BY('fk_state_id,city_name')->GET()->result_array(); $result_data[$key]['cities'] = $cities; - //print_r($this->db->last_query()); + //print_r($this->db->last_query()); - // $fields = array('pincode_id','pincode'); - // $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid); - // $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE); - // //array_push($result_data[$key],$cities); - // $result_data['pincode'] = $pincode; - - - } + // $fields = array('pincode_id','pincode'); + // $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid); + // $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE); + // //array_push($result_data[$key],$cities); + // $result_data['pincode'] = $pincode; + } } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - - - - + $this->response($data, REST_Controller::HTTP_OK); } - - - - - + + + + + /********For Save New PD while Trigger****/ - + public function triggerNewPD_post() { - - - $pd_details = json_decode($this->post('pd_details'),true); + + + $pd_details = json_decode($this->post('pd_details'), true); $pd_addtional_requirements = array(); $docs_to_be_collected = array(); unset($pd_details['createdon']); $addresses = array(); $company = array(); - if($this->post('addtional_requirements')) - { - $pd_addtional_requirements = json_decode($this->post('addtional_requirements'),true); - } - - if($this->post('docs_to_be_collected')) - { - $docs_to_be_collected = json_decode($this->post('docs_to_be_collected'),true); + if ($this->post('addtional_requirements')) { + $pd_addtional_requirements = json_decode($this->post('addtional_requirements'), true); } - if($this->post('addresses')) - { - $addresses = json_decode($this->post('addresses'),true); + if ($this->post('docs_to_be_collected')) { + $docs_to_be_collected = json_decode($this->post('docs_to_be_collected'), true); } - - if($this->post('company')) - { - $company = json_decode($this->post('company'),true); + + if ($this->post('addresses')) { + $addresses = json_decode($this->post('addresses'), true); } - $pd_applicant_details = json_decode($this->post('pd_applicant_details'),true); + + if ($this->post('company')) { + $company = json_decode($this->post('company'), true); + } + $pd_applicant_details = json_decode($this->post('pd_applicant_details'), true); $pd_document_titles = ""; - $pd_document_from_mobile = ""; - if($this->post('pd_document_titles')){ $pd_document_titles = json_decode($this->post('pd_document_titles'),true); } - - if($this->post('pd_document_from_mobile')){ $pd_document_from_mobile = json_decode($this->post('pd_document_from_mobile'),true); } - + $pd_document_from_mobile = ""; + if ($this->post('pd_document_titles')) { + $pd_document_titles = json_decode($this->post('pd_document_titles'), true); + } + + if ($this->post('pd_document_from_mobile')) { + $pd_document_from_mobile = json_decode($this->post('pd_document_from_mobile'), true); + } + $pd_documents = array(); - + $count = 0; /***********************CHOOSE PD TEMPALATE*********************/ - if($pd_details['pd_status'] == TRIGGERED) - { - + if ($pd_details['pd_status'] == TRIGGERED) { + $fields = array('fk_template_id'); - $where_condition_array = array('fk_lender_id'=>$pd_details['fk_lender_id'] ,'fk_product_id'=> $pd_details['fk_product_id'],'fk_customer_segment'=> $pd_details['fk_customer_segment'],'isactive' => 1); + $where_condition_array = array('fk_lender_id' => $pd_details['fk_lender_id'], 'fk_product_id' => $pd_details['fk_product_id'], 'fk_customer_segment' => $pd_details['fk_customer_segment'], 'isactive' => 1); $table = LENDERTEMPLATE; - $choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table); - - if(count($choosed_template_id))// CHOOSE FILTERED TEMPLATE// - { + $choosed_template_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, $table); - $pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id']; - } - else // CHOOSE GENERIC TEMPLATE// - { - //get customer segment abbrvations - $customer_segment_abbr = $this->PD_Model->selectCustomRecords(array('*'),array('customer_segment_id' => $pd_details['fk_customer_segment'],'isactive' => 1),CUSTOMERSEGMENT); - //print_r($this->db->last_query());die(); - $customer_segment_abbr = $customer_segment_abbr[0]['abbr']; - //echo $customer_segment_abbr; + if (count($choosed_template_id)) // CHOOSE FILTERED TEMPLATE// + { - if( !strcasecmp($customer_segment_abbr,'SAL'))// || !strcasecmp($customer_segment_abbr,'SAL-CHQ')) - { - //SAL - (CASH/CHQ) - $pd_details['fk_pd_template_id'] = 1; - } - else if( !strcasecmp($customer_segment_abbr,'SE-DI') || !strcasecmp($customer_segment_abbr,'SEP-DI') || !strcasecmp($customer_segment_abbr,'SEP_INDV')) - { - //* SENP/SEP - (DI) - $pd_details['fk_pd_template_id'] = 2; - } - else if( !strcasecmp($customer_segment_abbr,'SE-AI') || !strcasecmp($customer_segment_abbr,'SEP-AI') ) - { - //* SENP/SEP - (DI) - $pd_details['fk_pd_template_id'] = 3; - } - else if( !strcasecmp($customer_segment_abbr,'SE-RI')) - { - //* SENP/SEP - (RI) - $pd_details['fk_pd_template_id'] = 4; - } - } + $pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id']; + } else // CHOOSE GENERIC TEMPLATE// + { + //get customer segment abbrvations + $customer_segment_abbr = $this->PD_Model->selectCustomRecords(array('*'), array('customer_segment_id' => $pd_details['fk_customer_segment'], 'isactive' => 1), CUSTOMERSEGMENT); + //print_r($this->db->last_query());die(); + $customer_segment_abbr = $customer_segment_abbr[0]['abbr']; + //echo $customer_segment_abbr; + + if (!strcasecmp($customer_segment_abbr, 'SAL')) // || !strcasecmp($customer_segment_abbr,'SAL-CHQ')) + { + //SAL - (CASH/CHQ) + $pd_details['fk_pd_template_id'] = 1; + } else if (!strcasecmp($customer_segment_abbr, 'SE-DI') || !strcasecmp($customer_segment_abbr, 'SEP-DI') || !strcasecmp($customer_segment_abbr, 'SEP_INDV')) { + //* SENP/SEP - (DI) + $pd_details['fk_pd_template_id'] = 2; + } else if (!strcasecmp($customer_segment_abbr, 'SE-AI') || !strcasecmp($customer_segment_abbr, 'SEP-AI')) { + //* SENP/SEP - (DI) + $pd_details['fk_pd_template_id'] = 3; + } else if (!strcasecmp($customer_segment_abbr, 'SE-RI')) { + //* SENP/SEP - (RI) + $pd_details['fk_pd_template_id'] = 4; + } } + } - // /ie(); - /***********************PD ALLOCATION TYPE PROCESS **********/ + // /ie(); + /***********************PD ALLOCATION TYPE PROCESS **********/ // $pd_details['pd_status'] = TRIGGERED; // $pd_details['fk_pd_allocated_to'] = null; @@ -501,75 +457,74 @@ class PD_Controller extends REST_Controller { // //print_r($temp_city_id); // if(count($temp_city_id)) // { - // if(isset($temp_city_id[0]['team_type'])) - // { - // if($temp_city_id[0]['team_type'] == 0) // Allocate to Vendor - // { - // $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; - // $pd_details['pd_status'] = ALLOCATED_TO_PARTNER; - // $pd_details['fk_pd_allocated_to'] = null; - // } - // else //Allocate to SineEdge Team with allocation logics - // { - // //echo "SineEdge TEAm"; - // $local_pd_allocation_type = $pd_details['fk_pd_allocation_type']; - // if($local_pd_allocation_type == 1)// AUTO - Load Balance Allocation - // { + // if(isset($temp_city_id[0]['team_type'])) + // { + // if($temp_city_id[0]['team_type'] == 0) // Allocate to Vendor + // { + // $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; + // $pd_details['pd_status'] = ALLOCATED_TO_PARTNER; + // $pd_details['fk_pd_allocated_to'] = null; + // } + // else //Allocate to SineEdge Team with allocation logics + // { + // //echo "SineEdge TEAm"; + // $local_pd_allocation_type = $pd_details['fk_pd_allocation_type']; + // if($local_pd_allocation_type == 1)// AUTO - Load Balance Allocation + // { - // //echo "AUTO LOAD"; - // //select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED - // $fields = array('fk_user_id','allocated'); + // //echo "AUTO LOAD"; + // //select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED + // $fields = array('fk_user_id','allocated'); - // $where_condition_array = array('fk_pd_type_id' => $pd_details['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $pd_details['fk_customer_segment'],'fk_product_id' => $pd_details['fk_product_id'],'isactive' => 1); + // $where_condition_array = array('fk_pd_type_id' => $pd_details['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $pd_details['fk_customer_segment'],'fk_product_id' => $pd_details['fk_product_id'],'isactive' => 1); - // $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); - // //echo "PD OFF"; - // //print_r($list_of_pd_officers); - // $allocated_values = array_column($list_of_pd_officers,'allocated'); + // $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); + // //echo "PD OFF"; + // //print_r($list_of_pd_officers); + // $allocated_values = array_column($list_of_pd_officers,'allocated'); - // $min_allocated = min($allocated_values); - // $key = array_search($min_allocated,$allocated_values); - // $final_pd_officer_to_allocate = $list_of_pd_officers[$key]['fk_user_id']; + // $min_allocated = min($allocated_values); + // $key = array_search($min_allocated,$allocated_values); + // $final_pd_officer_to_allocate = $list_of_pd_officers[$key]['fk_user_id']; - // //For Random Allocaiton not in use - // // $key = mt_rand(0, count($list_of_pd_officers) - 1); - // // $final_pd_officer_to_allocate = isset($list_of_pd_officers[$key])? $list_of_pd_officers[$key]: null; + // //For Random Allocaiton not in use + // // $key = mt_rand(0, count($list_of_pd_officers) - 1); + // // $final_pd_officer_to_allocate = isset($list_of_pd_officers[$key])? $list_of_pd_officers[$key]: null; - // $pd_details['fk_pd_allocated_to'] = $final_pd_officer_to_allocate; - // $pd_details['pd_status'] = ALLOCATED; - // //echo "final".$final_pd_officer_to_allocate; + // $pd_details['fk_pd_allocated_to'] = $final_pd_officer_to_allocate; + // $pd_details['pd_status'] = ALLOCATED; + // //echo "final".$final_pd_officer_to_allocate; - // } - // else if($local_pd_allocation_type == 2) // AUTO - NEAREST Allocation - // { + // } + // else if($local_pd_allocation_type == 2) // AUTO - NEAREST Allocation + // { - // } - // else // Manual Allocation - // { - // // Do nothing, cause fk_pd_allocated_to value comes from front end. - // } - - // } - // }//End Of isset + // } + // else // Manual Allocation + // { + // // Do nothing, cause fk_pd_allocated_to value comes from front end. // } - /***********************END OF PD ALLOCATION TYPE AND PROCESS***********/ + // } + // }//End Of isset + // } - $pd_details['pd_date_of_initiation'] = date("Y-m-d H:i:s"); + /***********************END OF PD ALLOCATION TYPE AND PROCESS***********/ + + $pd_details['pd_date_of_initiation'] = date("Y-m-d H:i:s"); //Generate Random string - /************ASSIGN Random URL******************/ - $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; - /* $ch = curl_init(); + /************ASSIGN Random URL******************/ + $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; + /* $ch = curl_init(); $timeout = 5; $url = 'https://ssa.sineedge.com/ot/#/officertracking/'.$randomString; @@ -578,337 +533,295 @@ class PD_Controller extends REST_Controller { curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $tinyurl = curl_exec($ch); - curl_close($ch); */ - $pd_details['encrypted_url'] = $url; - //echo $tinyurl; - /************ASSIGN Random URL******************/ + curl_close($ch); */ + $pd_details['encrypted_url'] = $url; + //echo $tinyurl; + /************ASSIGN Random URL******************/ //End of Generate Random string - //implement SMC related stuffs - - if($pd_details['pd_status'] == TRIGGERED) + //implement SMC related stuffs + + if ($pd_details['pd_status'] == TRIGGERED) { + $pd_details = $this->smcStuffs($pd_details); + } + // echo 'final'; + // die(); + $pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : NULL; + + // $lender_id = ENVIRONMENT == 'production' ? 6 : 37; // IndusInd Bank Limited lender means notify enabled. + // if($pd_details['fk_lender_id'] == $lender_id){ + // // $pd_details['is_notify_enabled'] = isset($pd_details['is_notify_enabled']) ? (!is_null($pd_details['is_notify_enabled']) ? $pd_details['is_notify_enabled'] : 1) : 1; + // $pd_details['is_notify_enabled'] = 1; + // } + $pd_details['is_notify_enabled'] = isset($pd_details['is_notify_enabled']) ? (!is_null($pd_details['is_notify_enabled']) ? $pd_details['is_notify_enabled'] : 1) : 1; + + $pd_id = $this->PD_Model->saveRecords($pd_details, PDTRIGGER); + + + /***********************PD DOCUMENTS UPLOAD SECTION FROM WEB***********/ + if ($pd_id != null || $pd_id != '') { + + + // if it is SMC PD check excel file id , if not store address in smc address + // temprary table against pd id + if (!isset($pd_details[0]['excel_file_id'])) // && $pd_details[0]['excel_file_id'] != '') { - $pd_details = $this->smcStuffs($pd_details); + $this->saveSMCTempAddress($pd_id, $addresses); } - // echo 'final'; - // die(); - $pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : NULL; - - // $lender_id = ENVIRONMENT == 'production' ? 6 : 37; // IndusInd Bank Limited lender means notify enabled. - // if($pd_details['fk_lender_id'] == $lender_id){ - // // $pd_details['is_notify_enabled'] = isset($pd_details['is_notify_enabled']) ? (!is_null($pd_details['is_notify_enabled']) ? $pd_details['is_notify_enabled'] : 1) : 1; - // $pd_details['is_notify_enabled'] = 1; - // } - $pd_details['is_notify_enabled'] = isset($pd_details['is_notify_enabled']) ? (!is_null($pd_details['is_notify_enabled']) ? $pd_details['is_notify_enabled'] : 1) : 1; - - $pd_id = $this->PD_Model->saveRecords($pd_details,PDTRIGGER); - - - /***********************PD DOCUMENTS UPLOAD SECTION FROM WEB***********/ - if($pd_id != null || $pd_id != '') - { - - - // if it is SMC PD check excel file id , if not store address in smc address - // temprary table against pd id - if(!isset($pd_details[0]['excel_file_id']))// && $pd_details[0]['excel_file_id'] != '') - { - $this->saveSMCTempAddress($pd_id,$addresses); - } //If PD created sucessfully then create a externa folder named with pd_id - if(!file_exists($this->external_path.'/pd_reports/'.$pd_id)) - { - mkdir($this->external_path.'/pd_reports/'.$pd_id,0777); - } + if (!file_exists($this->external_path . '/pd_reports/' . $pd_id)) { + mkdir($this->external_path . '/pd_reports/' . $pd_id, 0777); + } - if(!empty($_FILES['pddocuments']) && !empty($pd_document_titles)) - { + if (!empty($_FILES['pddocuments']) && !empty($pd_document_titles)) { - foreach($pd_document_titles as $iter => $title) - { + foreach ($pd_document_titles as $iter => $title) { - $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; - $tempdocname = $_FILES['pddocuments']['name'][$iter]; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details['fk_lender_id']; - $key = 'pd'.$pd_id.'/'.$tempdocname ; - $sourcefile = $tempdoc; + $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; + $tempdocname = $_FILES['pddocuments']['name'][$iter]; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details['fk_lender_id']; + $key = 'pd' . $pd_id . '/' . $tempdocname; + $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - $record_data = array('fk_pd_id' => $pd_id,'img_type' => 3,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname); - $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - } + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + $record_data = array('fk_pd_id' => $pd_id, 'img_type' => 3, 'pd_document_title' => $title, 'pd_document_name' => $tempdocname); + $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + } + } + } + } - } - } - } - - /***********************END OF PD DOCUMENTS UPLOAD SECTION FROM WEB***********/ - if($pd_id != null || $pd_id != '') - { + /***********************END OF PD DOCUMENTS UPLOAD SECTION FROM WEB***********/ + if ($pd_id != null || $pd_id != '') { - if($pd_applicant_details != "" || $pd_applicant_details != null) - { - 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'])); - $pd_applicant_detail['company_name'] = trim(MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['company_name'])); - - $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); - if($co_applicant_id != null || $co_applicant_id != '') - { - $count = $count + 1; - } - } - } - } + if ($pd_applicant_details != "" || $pd_applicant_details != null) { + 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'])); + $pd_applicant_detail['company_name'] = trim(MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['company_name'])); - /***********************PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/ - if($pd_id != null || $pd_id != '') - { + $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail, PDAPPLICANTSDETAILS); + if ($co_applicant_id != null || $co_applicant_id != '') { + $count = $count + 1; + } + } + } + } - if(!empty($pd_document_from_mobile)) - { - $this->saveBase64Images($pd_id,null,null,null,$pd_document_from_mobile); + /***********************PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/ + if ($pd_id != null || $pd_id != '') { + + if (!empty($pd_document_from_mobile)) { + $this->saveBase64Images($pd_id, null, null, null, $pd_document_from_mobile); // foreach($pd_document_from_mobile as $iter => $doc) // { - // $temp_base64_string = $doc['image']; - // $title = $doc['Name']; - // $output_file = APPPATH."/docs/temp_base64_image.png"; + // $temp_base64_string = $doc['image']; + // $title = $doc['Name']; + // $output_file = APPPATH."/docs/temp_base64_image.png"; - // //Generate Random File Name - // $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').'.png'; + // //Generate Random File Name + // $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').'.png'; - // $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.$pd_details['fk_lender_id']; - // $key = 'pd'.$pd_id.'/'.$tempdocname ; - // $sourcefile = $tempdoc; + // $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.$pd_details['fk_lender_id']; + // $key = 'pd'.$pd_id.'/'.$tempdocname ; + // $sourcefile = $tempdoc; - // $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - // $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + // $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + // $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - // if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - // { - // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname); - // $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - // } + // if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + // { + // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname); + // $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); + // } // } - } - } - /***********************END OF PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/ + } + } + /***********************END OF PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/ - /****************ADDTIONAL REQUIREMENTS SECTION*******************************************/ - if($pd_id != null || $pd_id != '') - { - if(count($pd_addtional_requirements)) - { - foreach($pd_addtional_requirements as $pd_addtional_requirement_key => $pd_addtional_requirement) - { - if($pd_addtional_requirement['add_requirement'] != null) - { - $pd_addtional_requirement['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); - } - } - } + /****************ADDTIONAL REQUIREMENTS SECTION*******************************************/ + if ($pd_id != null || $pd_id != '') { + if (count($pd_addtional_requirements)) { + foreach ($pd_addtional_requirements as $pd_addtional_requirement_key => $pd_addtional_requirement) { + if ($pd_addtional_requirement['add_requirement'] != null) { + $pd_addtional_requirement['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($pd_addtional_requirement, PDADDTIONALREQUIREMENTS); + } + } + } - if(count($docs_to_be_collected)) - { - foreach($docs_to_be_collected as $docs_to_be_collected_key => $docs_to_be_collect) - { - if($docs_to_be_collect['doc_name'] != null) - { - $docs_to_be_collect['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($docs_to_be_collect,PDDOCSTOBECOLLECTED); - } - } - } + if (count($docs_to_be_collected)) { + foreach ($docs_to_be_collected as $docs_to_be_collected_key => $docs_to_be_collect) { + if ($docs_to_be_collect['doc_name'] != null) { + $docs_to_be_collect['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($docs_to_be_collect, PDDOCSTOBECOLLECTED); + } + } + } - $temp_address_id = null; - if(count($addresses)) - { + $temp_address_id = null; + if (count($addresses)) { - foreach($addresses as $address_key => $address) - { - $address['fk_pd_id'] = $pd_id; - $address['is_primary'] = count($addresses) == 1 ? 1:0; - $address['assigned_pd'] = count($addresses) == 1 ? $pd_id:null; - $address_id = $this->PD_Model->saveRecords($address,PDADDRESS); - if($address_key == 0) - { - $temp_address_id = $address_id; - } - } - - } + foreach ($addresses as $address_key => $address) { + $address['fk_pd_id'] = $pd_id; + $address['is_primary'] = count($addresses) == 1 ? 1 : 0; + $address['assigned_pd'] = count($addresses) == 1 ? $pd_id : null; + $address_id = $this->PD_Model->saveRecords($address, PDADDRESS); + if ($address_key == 0) { + $temp_address_id = $address_id; + } + } + } - //update parent pd id for same pd itself after PK generated - $temp = array('parent_pd_id' => $pd_id); - if(count($addresses) == 1) - { - $temp['fk_primary_address_id'] = $temp_address_id; - $temp['fk_address_id'] = $temp_address_id; - } - $where_condition_array = array('pd_id' => $pd_id); - $this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array); + //update parent pd id for same pd itself after PK generated + $temp = array('parent_pd_id' => $pd_id); + if (count($addresses) == 1) { + $temp['fk_primary_address_id'] = $temp_address_id; + $temp['fk_address_id'] = $temp_address_id; + } + $where_condition_array = array('pd_id' => $pd_id); + $this->PD_Model->updateRecords($temp, PDTRIGGER, $where_condition_array); - if(count($company)) - { - foreach($company as $company_key => $new_company) - { - $new_company['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($new_company,PDCOMPANY); - } - } - } + if (count($company)) { + foreach ($company as $company_key => $new_company) { + $new_company['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($new_company, PDCOMPANY); + } + } + } - /****************END OF ADDTIONAL REQUIREMENTS SECTION*******************************************/ + /****************END OF ADDTIONAL REQUIREMENTS SECTION*******************************************/ - //create gmeet link - // if($pd_id != null && $pd_id != '' && ($pd_details['fk_pd_type'] == 2 || $pd_details['fk_pd_type'] == 3)) - // { - // $this->createGmeetLink($pd_id); - // } + //create gmeet link + // if($pd_id != null && $pd_id != '' && ($pd_details['fk_pd_type'] == 2 || $pd_details['fk_pd_type'] == 3)) + // { + // $this->createGmeetLink($pd_id); + // } - if($pd_id != null || $pd_id != '' && $count != 0) - { + if ($pd_id != null || $pd_id != '' && $count != 0) { // CALL pdnotification Helper function to send pd alerts @ params pdid,pdstatus - $logger = MYLOG::logFunction(null,$pd_id); - $logger->info("NEW PD Trigged : ".$pd_id,array('ENV'=>ENVIRONMENT,'DATA' => $pd_details)); - PDALERTS::pdnotification($pd_id); + $logger = MYLOG::logFunction(null, $pd_id); + $logger->info("NEW PD Trigged : " . $pd_id, array('ENV' => ENVIRONMENT, 'DATA' => $pd_details)); + PDALERTS::pdnotification($pd_id); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pd_id; - $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); - } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pd_id; + $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 savePDAdditionalRequiremets_post() + { + $records = $this->post('records'); + //print_r($records);die(); + $pd_addtional_requirements = $records['addtional_requirements']; + $count = 0; + + if (count($pd_addtional_requirements)) { + foreach ($pd_addtional_requirements as $requirement_key => $pd_addtional_requirement) { + + + if ($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "") // && ($pd_addtional_requirement['add_requirement'] != null) ) + { + $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); + $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement, PDADDTIONALREQUIREMENTS, $where_condition_array); + if ($pk_id != "" || $pk_id != null) { + $count++; } - - public function savePDAdditionalRequiremets_post() - { - $records = $this->post('records'); - //print_r($records);die(); - $pd_addtional_requirements = $records['addtional_requirements']; - $count = 0; - - if(count($pd_addtional_requirements)) - { - foreach($pd_addtional_requirements as $requirement_key => $pd_addtional_requirement) - { - - - if($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "")// && ($pd_addtional_requirement['add_requirement'] != null) ) - { - $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); - $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS,$where_condition_array); - if($pk_id != "" || $pk_id != null){ $count++; } - } - else - { - if( $pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") - { - $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; - $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); - if($pk_id != "" || $pk_id != null){ $count++; } - } - } - } + } else { + if ($pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") { + $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; + $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement, PDADDTIONALREQUIREMENTS); + if ($pk_id != "" || $pk_id != null) { + $count++; } - if($count != 0 && $count == count($pd_addtional_requirements)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Some thing went wrong"; - $this->response($data,REST_Controller::HTTP_OK); - } - } + } + } + } + if ($count != 0 && $count == count($pd_addtional_requirements)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong"; + $this->response($data, REST_Controller::HTTP_OK); + } + } - public function savePDDocsToBeCollected_post() - { - $records = $this->post('records'); - $docs_to_be_collected = $records['docs_to_be_collected']; - $count = 0; - - if(count($docs_to_be_collected)) - { - foreach($docs_to_be_collected as $pd_doc_key => $pd_doc_requirement) - { - if($pd_doc_requirement['pd_doc_to_be_collect_id'] != null || $pd_doc_requirement['pd_doc_to_be_collect_id'] != "" && ($docs_to_be_collect['doc_name'] != null) ) - { - $where_condition_array = array('pd_doc_to_be_collect_id' => $pd_doc_requirement['pd_doc_to_be_collect_id']); - $pk_id = $this->PD_Model->updateRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED,$where_condition_array); - if($pk_id != "" || $pk_id != null){ $count++; } - } - else - { - if($pd_doc_requirement['doc_name'] != null) - { - $pd_doc_requirement['fk_pd_id'] = $records['pdid']; - $pk_id = $this->PD_Model->saveRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED); - if($pk_id != "" || $pk_id != null){ $count++; } - } - } - } - } - if($count != 0 && $count == count($docs_to_be_collected)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Some thing went wrong"; - $this->response($data,REST_Controller::HTTP_OK); - } + public function savePDDocsToBeCollected_post() + { + $records = $this->post('records'); + $docs_to_be_collected = $records['docs_to_be_collected']; + $count = 0; + if (count($docs_to_be_collected)) { + foreach ($docs_to_be_collected as $pd_doc_key => $pd_doc_requirement) { + if ($pd_doc_requirement['pd_doc_to_be_collect_id'] != null || $pd_doc_requirement['pd_doc_to_be_collect_id'] != "" && ($docs_to_be_collect['doc_name'] != null)) { + $where_condition_array = array('pd_doc_to_be_collect_id' => $pd_doc_requirement['pd_doc_to_be_collect_id']); + $pk_id = $this->PD_Model->updateRecords($pd_doc_requirement, PDDOCSTOBECOLLECTED, $where_condition_array); + if ($pk_id != "" || $pk_id != null) { + $count++; } + } else { + if ($pd_doc_requirement['doc_name'] != null) { + $pd_doc_requirement['fk_pd_id'] = $records['pdid']; + $pk_id = $this->PD_Model->saveRecords($pd_doc_requirement, PDDOCSTOBECOLLECTED); + if ($pk_id != "" || $pk_id != null) { + $count++; + } + } + } + } + } + if ($count != 0 && $count == count($docs_to_be_collected)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong"; + $this->response($data, REST_Controller::HTTP_OK); + } + } /* * @@ -916,61 +829,54 @@ class PD_Controller extends REST_Controller { */ public function updatePDMaster_post() { - $pd_details = []; + $pd_details = []; $exist_pd_details = []; clearstatcache(); $pd_details = $this->post('records'); //print_r($pd_details);die(); $pd_cancel_remark = ''; - log_message('ERROR',"UpdatePD Called"); + log_message('ERROR', "UpdatePD Called"); // log_message('ERROR',print_r($pd_details)); - if((isset($pd_details['pd_id']) && $pd_details['pd_id'] != "" ) && (isset($pd_details['random_string']) && $pd_details['random_string'] != " ")) - { - $logger = MYLOG::logFunction(null,$pd_details['pd_id']); + if ((isset($pd_details['pd_id']) && $pd_details['pd_id'] != "") && (isset($pd_details['random_string']) && $pd_details['random_string'] != " ")) { + $logger = MYLOG::logFunction(null, $pd_details['pd_id']); EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_details['pd_id']); $exist_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['pd_id']); - // print_r($pd_details); - // print_r($exist_pd_details); + // print_r($pd_details); + // print_r($exist_pd_details); - if(!file_exists($this->external_path.'/pd_reports/'.$pd_details['pd_id'])) - { - mkdir($this->external_path.'/pd_reports/'.$pd_details['pd_id'],0777); + if (!file_exists($this->external_path . '/pd_reports/' . $pd_details['pd_id'])) { + mkdir($this->external_path . '/pd_reports/' . $pd_details['pd_id'], 0777); } - if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == INITIATED) - { + if (isset($pd_details['pd_status']) && $pd_details['pd_status'] == INITIATED) { unset($pd_details['mobile_no']); unset($pd_details['firstName']); unset($pd_details['officerName']); $pd_details['initiate_location'] = isset($pd_details['link']) ? $pd_details['link'] : null;; unset($pd_details['link']); - } - if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == STARTED) - { + if (isset($pd_details['pd_status']) && $pd_details['pd_status'] == STARTED) { // echo 'STARTED'; - if($exist_pd_details[0]['fk_pd_type'] == 1) - { + if ($exist_pd_details[0]['fk_pd_type'] == 1) { $pd_details['start_location'] = $pd_details['link']; } - + unset($pd_details['link']); - $string2 = str_shuffle('1234567890'); - $OTP = substr($string2,0,6); - $msg = "OTP for starting your personal discussions with the verification officer is ".$OTP.".Pls share this only when the officer has reached your place in person."; + $string2 = str_shuffle('1234567890'); + $OTP = substr($string2, 0, 6); + $msg = "OTP for starting your personal discussions with the verification officer is " . $OTP . ".Pls share this only when the officer has reached your place in person."; $no = (string)$pd_details['mobile_no']; unset($pd_details['mobile_no']); - $pd_details['OTP'] = $OTP; - //$pd_details['OTP'] = '123456'; + $pd_details['OTP'] = $OTP; + //$pd_details['OTP'] = '123456'; - // $client = new \GuzzleHttp\Client(); - // $response = $client->post($url); - if($exist_pd_details[0]['is_otp_enabled'] == 1) - { - SMS_GUPSHUP::sendSMS($msg,$no,array('pd_id' => $pd_details['pd_id'],'status' => 'STARTED','msg' => 'Started OTP msg from PD controlller')); + // $client = new \GuzzleHttp\Client(); + // $response = $client->post($url); + if ($exist_pd_details[0]['is_otp_enabled'] == 1) { + SMS_GUPSHUP::sendSMS($msg, $no, array('pd_id' => $pd_details['pd_id'], 'status' => 'STARTED', 'msg' => 'Started OTP msg from PD controlller')); } // if($exist_pd_details[0]['fk_pd_type'] == 3) @@ -980,127 +886,121 @@ class PD_Controller extends REST_Controller { // SMS_GUPSHUP::sendSMS($msg,$no,array('pd_id' => $exist_pd_details[0]['pd_id'],'status' => 'STARTED','msg' => 'Cus Link from PD controlller')); // } - }// started if condition closed here. + } // started if condition closed here. // die(); - if(isset($pd_details['pd_status']) && (($pd_details['pd_status'] == COMPLETED) || ($pd_details['pd_status'] == ADD_ON_PENDING)) ) - { + if (isset($pd_details['pd_status']) && (($pd_details['pd_status'] == COMPLETED) || ($pd_details['pd_status'] == ADD_ON_PENDING))) { - if($pd_details['pd_status'] == COMPLETED) - { - $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); + if ($pd_details['pd_status'] == COMPLETED) { + // $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); $pd_details['completed_on'] = date('Y-m-d H:i:s'); - log_message('ERROR',"In PD Controller @ line no : 992 (When Completed status means calling to Make FaceBoundingBox fns below"); + log_message('ERROR', "In PD Controller @ line no : 992 (When Completed status means calling to Make FaceBoundingBox fns below"); $this->toMakeFaceBoundingBox($exist_pd_details); + if(isset($pd_details['is_this_smc_pd']) && $pd_details['is_this_smc_pd'] == 1 && $pd_details['pd_status'] == COMPLETED){ + $this->load->helper('smc_creditpd'); + if(isset($pd_details['random_string'])){ + $random_string = $pd_details['random_string']; + }else{ + $random_string = $this->PD_Model->selectCustomRecords(array('random_string'),array('pd_id' => $pd_details['pd_id']),PDTRIGGER); + $random_string = $random_string[0]['random_string'];} + + $ZIP = smc_creditpd::covertSMCImgs2ZIP($pd_details['pd_id'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE ZIP = '.$ZIP); + $PDF = smc_creditpd::covertSMCImgs2PDF($pd_details['pd_id'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE PDF = '.$PDF); + unset($pd_details['is_this_smc_pd']); + } + } - if(array_key_exists('link',$pd_details)) - { + if (array_key_exists('link', $pd_details)) { $pd_details['complete_location'] = isset($pd_details['link']) ? $pd_details['link'] : null; unset($pd_details['link']); } - - if($pd_details['pd_status'] == COMPLETED){ - if(($exist_pd_details[0]['pd_status'] != COMPLETED) && ($exist_pd_details[0]['pd_status'] != QC_COMPLETED)){ - if($exist_pd_details[0]['fk_pd_type'] != 2 && (!isset($pd_details['is_revert_status']))) - { - $pd_details['pd_visit_date'] = date('Y-m-d H:i:s'); - } - } + + if ($pd_details['pd_status'] == COMPLETED) { + if (($exist_pd_details[0]['pd_status'] != COMPLETED) && ($exist_pd_details[0]['pd_status'] != QC_COMPLETED)) { + if ($exist_pd_details[0]['fk_pd_type'] != 2 && (!isset($pd_details['is_revert_status']))) { + $pd_details['pd_visit_date'] = date('Y-m-d H:i:s'); + } + } } // else{ // $pd_details['pd_visit_date'] = $exist_pd_details[0]['pd_visit_date']; // } unset($pd_details['is_revert_status']); - //get satellite image blob and store it in DB + //get satellite image blob and store it in DB //$pd_details['satellite_image_base64_blob'] = $this->getSatelliteImage($pd_details['pd_id']); - if($exist_pd_details[0]['fk_pd_type'] == 1) - { + if ($exist_pd_details[0]['fk_pd_type'] == 1) { $pd_details['satellite_image_base64_blob'] = satellite_image::getSatelliteImage($pd_details['pd_id']); } - //die(); - //If it is Addtional PD ,then update 'COMPLETE' status for primary and all other addtional PD's - if($exist_pd_details[0]['is_child'] == 1) - { - //echo "child"; + //die(); + //If it is Addtional PD ,then update 'COMPLETE' status for primary and all other addtional PD's + if ($exist_pd_details[0]['is_child'] == 1) { + //echo "child"; $all_pd_id = array(); - //get all associated PD ID's from address table + //get all associated PD ID's from address table $all_associated_addresses = $this->PD_Model->getPDAddress($exist_pd_details[0]['parent_pd_id']); - //print_r($all_associated_addresses); - if(count($all_associated_addresses)) - { - foreach($all_associated_addresses as $address) - { - if($address['assigned_pd'] != $pd_details['pd_id']) - { - $all_pd_id[] = array('pd_id' => $address['assigned_pd'],'pd_status' => COMPLETED, 'fk_updatedby' => $pd_details['fk_updatedby']); + //print_r($all_associated_addresses); + if (count($all_associated_addresses)) { + foreach ($all_associated_addresses as $address) { + if ($address['assigned_pd'] != $pd_details['pd_id']) { + $all_pd_id[] = array('pd_id' => $address['assigned_pd'], 'pd_status' => COMPLETED, 'fk_updatedby' => $pd_details['fk_updatedby']); } - } + } } - //print_r($all_pd_id); - foreach($all_pd_id as $single_pd) - { - $this->PD_Model->updateRecords($single_pd,PDTRIGGER,array('pd_id' => $single_pd['pd_id'])); + //print_r($all_pd_id); + foreach ($all_pd_id as $single_pd) { + $this->PD_Model->updateRecords($single_pd, PDTRIGGER, array('pd_id' => $single_pd['pd_id'])); } - - - } - //print_r($pd_details); + //print_r($pd_details); } - //die(); - if((isset($pd_details['pd_status']) && $pd_details['pd_status'] == QC_COMPLETED)) - { - $pd_details['is_cus_link_disabled'] = 1; + //die(); + if ((isset($pd_details['pd_status']) && $pd_details['pd_status'] == QC_COMPLETED)) { + $pd_details['is_cus_link_disabled'] = 1; - //call delete google calender event - $this->deleteCalenderEvent($exist_pd_details[0]['gmeet_id']); + //call delete google calender event + $this->deleteCalenderEvent($exist_pd_details[0]['gmeet_id']); + } - } - - if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == TRIGGERED || $pd_details['pd_status'] == INITIATED || $pd_details['pd_status'] == INPROGRESS)) - { + if (isset($pd_details['pd_status']) && ($pd_details['pd_status'] == TRIGGERED || $pd_details['pd_status'] == INITIATED || $pd_details['pd_status'] == INPROGRESS)) { /***********************CHOOSE PD TEMPALATE*********************/ $pd_details['fk_pd_template_id'] = $this->assignPDTempalate($pd_details['pd_id']); - //echo $pd_details['fk_pd_template_id']; - + //echo $pd_details['fk_pd_template_id']; + } /*********************** vendor status if it is allocated to partner*********************/ - if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == ALLOCATED_TO_FIA )) - { + if (isset($pd_details['pd_status']) && ($pd_details['pd_status'] == ALLOCATED_TO_FIA)) { $pd_details['vendor_status'] = TRIGGERED; } - //die(); + //die(); $primary_address_id = null; - - if( $exist_pd_details[0]['fk_primary_address_id'] == null && $exist_pd_details[0]['is_child'] == 0)//Master PD only + + if ($exist_pd_details[0]['fk_primary_address_id'] == null && $exist_pd_details[0]['is_child'] == 0) //Master PD only { - $primary_address_id = isset($pd_details['fk_primary_address_id'])?$pd_details['fk_primary_address_id']:null; + $primary_address_id = isset($pd_details['fk_primary_address_id']) ? $pd_details['fk_primary_address_id'] : null; $pd_details['fk_address_id'] = $primary_address_id; } - - - if( $exist_pd_details[0]['is_child'] == 0) - { - if(isset($pd_details['parent_pd_id']) && ($pd_details['parent_pd_id'] == null || $pd_details['parent_pd_id'] == "")) - { + + + if ($exist_pd_details[0]['is_child'] == 0) { + if (isset($pd_details['parent_pd_id']) && ($pd_details['parent_pd_id'] == null || $pd_details['parent_pd_id'] == "")) { $pd_details['parent_pd_id'] = $exist_pd_details[0]['pd_id'] != "" || $exist_pd_details[0]['pd_id'] != null ? $exist_pd_details[0]['pd_id'] : $pd_details['pd_id']; } } - + // Before update if this is ssmart pd, then when vevndor status is completed but still pd status changing between to allocated or scheduling then keep //main pd status as in progress - if($exist_pd_details[0]['fk_pd_type'] == 2 && $exist_pd_details[0]['pd_status'] == INPROGRESS && $exist_pd_details[0]['vendor_status'] == COMPLETED && isset($pd_details['pd_status']) && ($pd_details['pd_status'] == ALLOCATED || $pd_details['pd_status'] == SCHEDULED)) - { + if ($exist_pd_details[0]['fk_pd_type'] == 2 && $exist_pd_details[0]['pd_status'] == INPROGRESS && $exist_pd_details[0]['vendor_status'] == COMPLETED && isset($pd_details['pd_status']) && ($pd_details['pd_status'] == ALLOCATED || $pd_details['pd_status'] == SCHEDULED)) { $pd_details['pd_status'] == INPROGRESS; } - - if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == CANCELLED )) - { + + if (isset($pd_details['pd_status']) && ($pd_details['pd_status'] == CANCELLED)) { $pd_details['cancel_pd_remark'] = $pd_details['remark']; unset($pd_details['remark']); } @@ -1108,333 +1008,294 @@ class PD_Controller extends REST_Controller { //if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == BOUNCED || $pd_details['pd_status'] == TRIGGERED) //{ - //implement smc related stuffs - $pd_details = $this->smcStuffs($pd_details,$exist_pd_details); + //implement smc related stuffs + $pd_details = $this->smcStuffs($pd_details, $exist_pd_details); //} // echo 'after'; // print_r($pd_details); // die(); - - $temp_data = $this->PD_Model->selectCustomRecords(array('pd_agency_id','fk_lender_id'),array('pd_id' => $pd_details['pd_id']),PDTRIGGER); - $agency_id = isset($pd_details['pd_agency_id']) ? $pd_details['pd_agency_id'] : $temp_data[0]['pd_agency_id']; - $mwise_lender_id = (ENVIRONMENT == 'production' ? 7 : 35); - $current_lender_id = (isset($pd_details['fk_lender_id']) && $pd_details['fk_lender_id'] != '' ? $pd_details['fk_lender_id'] : $temp_data[0]['fk_lender_id']); - $is_mwise_lender = ( $current_lender_id == $mwise_lender_id ? true : false); - $this->load->model('User_Management_Model'); - $user_details = $this->User_Management_Model->getUserDetails($pd_details['fk_updatedby']); - $role = $user_details['data'][0]['user_role']; - - if($is_mwise_lender && (!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0) && ($pd_details['pd_status'] == "TRIGGERED") && ($role == 30)){ + + $temp_data = $this->PD_Model->selectCustomRecords(array('pd_agency_id', 'fk_lender_id'), array('pd_id' => $pd_details['pd_id']), PDTRIGGER); + $agency_id = isset($pd_details['pd_agency_id']) ? $pd_details['pd_agency_id'] : $temp_data[0]['pd_agency_id']; + $mwise_lender_id = (ENVIRONMENT == 'production' ? 7 : 35); + $current_lender_id = (isset($pd_details['fk_lender_id']) && $pd_details['fk_lender_id'] != '' ? $pd_details['fk_lender_id'] : $temp_data[0]['fk_lender_id']); + $is_mwise_lender = ($current_lender_id == $mwise_lender_id ? true : false); + $this->load->model('User_Management_Model'); + $user_details = $this->User_Management_Model->getUserDetails($pd_details['fk_updatedby']); + $role = $user_details['data'][0]['user_role']; + + if ($is_mwise_lender && (!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0) && ($pd_details['pd_status'] == "TRIGGERED") && ($role == 30)) { $pd_details['vendor_status'] = null; $pd_details['pd_agency_id'] = null; $pd_details['pd_status'] = $pd_details['pd_status']; - } - - if($is_mwise_lender && (!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0) && ($pd_details['pd_status'] != "TRIGGERED" || $pd_details['pd_status'] != "QC_COMPLETED")) - { + } + + if ($is_mwise_lender && (!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0) && ($pd_details['pd_status'] != "TRIGGERED" || $pd_details['pd_status'] != "QC_COMPLETED")) { //newly implemented - if(($pd_details['pd_status'] == "CANCELLED") && ($role == 27 || $role == 26 || $role == 30)){ + if (($pd_details['pd_status'] == "CANCELLED") && ($role == 27 || $role == 26 || $role == 30)) { $pd_details['vendor_status'] = null; $pd_details['pd_agency_id'] = null; $pd_details['pd_status'] = $pd_details['pd_status']; - } - else{ - $pd_details['vendor_status'] = $pd_details['pd_status']; - $pd_details['pd_status'] = ALLOCATED_TO_FIA;} - } - - + } else { + $pd_details['vendor_status'] = $pd_details['pd_status']; + $pd_details['pd_status'] = ALLOCATED_TO_FIA; + } + } - $where_condition_array = array('pd_id' => $pd_details['pd_id'],'random_string' => $pd_details['random_string']); - $pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array); + + + $where_condition_array = array('pd_id' => $pd_details['pd_id'], 'random_string' => $pd_details['random_string']); + $pd_id_modified = $this->PD_Model->updateRecords($pd_details, PDTRIGGER, $where_condition_array); // print_r($this->db->last_query()); - + //update pd cancel remrks if any - if($pd_cancel_remark) - { - $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_details['pd_id'],'remark' => $pd_cancel_remark,'createdby' => $pd_details['fk_updatedby'],),PDREMARKS); + if ($pd_cancel_remark) { + $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_details['pd_id'], 'remark' => $pd_cancel_remark, 'createdby' => $pd_details['fk_updatedby'],), PDREMARKS); } //Update Address table,if primary address choosed - if($primary_address_id != null) - { - + if ($primary_address_id != null) { + $where_condition_array = array('pd_address_id' => $primary_address_id); - $temp_data = array('is_primary' => 1,'assigned_pd' => $pd_details['pd_id']); + $temp_data = array('is_primary' => 1, 'assigned_pd' => $pd_details['pd_id']); - $id = $this->PD_Model->updateRecords($temp_data,PDADDRESS,$where_condition_array); + $id = $this->PD_Model->updateRecords($temp_data, PDADDRESS, $where_condition_array); } - - - if($pd_id_modified != null || $pd_id_modified != '' && $count != 0) - { - $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $pd_details,'Pre-Status' => $exist_pd_details[0]['pd_status'],'Current_status' => isset($pd_details['pd_status']) ? $pd_details['pd_status'] : '')); - if(isset($pd_details['pd_status'])) { PDALERTS::pdnotification($pd_details['pd_id']); } + if ($pd_id_modified != null || $pd_id_modified != '' && $count != 0) { + + $logger->info("PD UPDATED", array('ENV' => ENVIRONMENT, 'DATA' => $pd_details, 'Pre-Status' => $exist_pd_details[0]['pd_status'], 'Current_status' => isset($pd_details['pd_status']) ? $pd_details['pd_status'] : '')); + + if (isset($pd_details['pd_status'])) { + PDALERTS::pdnotification($pd_details['pd_id']); + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - }//end of normal PD - else//#################### Handle Addtional PD - { - //echo 'else'; - if(($pd_details['parent_pd_id'] != "" || $pd_details['parent_pd_id'] != null) && - (($pd_details['fk_customer_segment'] != "" || $pd_details['fk_customer_segment'] != null)) && - (($pd_details['fk_address_id'] != "" || $pd_details['fk_address_id'] != null)) && - (($pd_details['pd_status'] != "" || $pd_details['pd_status'] != null)) && - (($pd_details['fk_updatedby'] != "" || $pd_details['fk_updatedby'] != null)) ) + } //end of normal PD + else //#################### Handle Addtional PD { - //GET PArent PD Details - $parent_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['parent_pd_id']); - - if(count($parent_pd_details)) - { - $newpd['fk_lender_id'] = $parent_pd_details[0]['fk_lender_id']; - $newpd['pd_date_of_initiation'] = date('Y-m-d H-i-s'); - $newpd['fk_entity_billing_id'] = $parent_pd_details[0]['fk_entity_billing_id']; - $newpd['lender_applicant_id'] = $parent_pd_details[0]['lender_applicant_id']; - $newpd['fk_product_id'] = $parent_pd_details[0]['fk_product_id']; - $newpd['fk_subproduct_id'] = $parent_pd_details[0]['fk_subproduct_id']; - $newpd['fk_pd_type'] = $parent_pd_details[0]['fk_pd_type']; - $newpd['pd_branch_id'] = $parent_pd_details[0]['pd_branch_id']; - $newpd['is_child'] = 1; - $newpd['loan_amount'] = $parent_pd_details[0]['loan_amount']; - $newpd['fk_pd_allocated_to'] = $parent_pd_details[0]['fk_pd_allocated_to']; - - $newpd['pd_status'] = $pd_details['pd_status']; - $newpd['fk_updatedby'] = $pd_details['fk_updatedby']; - $newpd['fk_customer_segment'] = $pd_details['fk_customer_segment']; - $newpd['fk_address_id'] = $pd_details['fk_address_id']; - $newpd['parent_pd_id'] = $pd_details['parent_pd_id']; + //echo 'else'; + if (($pd_details['parent_pd_id'] != "" || $pd_details['parent_pd_id'] != null) && + (($pd_details['fk_customer_segment'] != "" || $pd_details['fk_customer_segment'] != null)) && + (($pd_details['fk_address_id'] != "" || $pd_details['fk_address_id'] != null)) && + (($pd_details['pd_status'] != "" || $pd_details['pd_status'] != null)) && + (($pd_details['fk_updatedby'] != "" || $pd_details['fk_updatedby'] != null)) + ) { + //GET PArent PD Details + $parent_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['parent_pd_id']); - //Generate Random string + if (count($parent_pd_details)) { + $newpd['fk_lender_id'] = $parent_pd_details[0]['fk_lender_id']; + $newpd['pd_date_of_initiation'] = date('Y-m-d H-i-s'); + $newpd['fk_entity_billing_id'] = $parent_pd_details[0]['fk_entity_billing_id']; + $newpd['lender_applicant_id'] = $parent_pd_details[0]['lender_applicant_id']; + $newpd['fk_product_id'] = $parent_pd_details[0]['fk_product_id']; + $newpd['fk_subproduct_id'] = $parent_pd_details[0]['fk_subproduct_id']; + $newpd['fk_pd_type'] = $parent_pd_details[0]['fk_pd_type']; + $newpd['pd_branch_id'] = $parent_pd_details[0]['pd_branch_id']; + $newpd['is_child'] = 1; + $newpd['loan_amount'] = $parent_pd_details[0]['loan_amount']; + $newpd['fk_pd_allocated_to'] = $parent_pd_details[0]['fk_pd_allocated_to']; + + $newpd['pd_status'] = $pd_details['pd_status']; + $newpd['fk_updatedby'] = $pd_details['fk_updatedby']; + $newpd['fk_customer_segment'] = $pd_details['fk_customer_segment']; + $newpd['fk_address_id'] = $pd_details['fk_address_id']; + $newpd['parent_pd_id'] = $pd_details['parent_pd_id']; + + //Generate Random string + + /************ASSIGN Random URL******************/ + $newpd['random_string'] = $parent_pd_details[0]['random_string']; + $url = OFFICER_TRACKING_URL . $randomString; + $newpd['encrypted_url'] = $url; + + + $newpd['fk_pd_template_id'] = $this->assignPDTempalate(array('lender' => $newpd['fk_lender_id'], 'product' => $newpd['fk_product_id'], 'customer_segment' => $newpd['fk_customer_segment'])); + //print_r($newpd);die(); + + $pd_id = $this->PD_Model->saveRecords($newpd, PDTRIGGER); + if ($pd_id != "" || $pd_id != null) { + + + if (!file_exists($this->external_path . '/pd_reports/' . $pd_id)) { + mkdir($this->external_path . '/pd_reports/' . $pd_id, 0777); + } + //update Applicant details + $fields = array('pd_co_applicant_id' => $pd_details['pd_co_applicant_id'], 'mobile_no' => $pd_details['mobile_no']); + $where_condition_array = array('additional_pd_id' => $pd_id); + $this->PD_Model->updateRecords($fields, PDAPPLICANTSDETAILS, $where_condition_array); + + //update Assiged PD to Address Table + $where_condition_array = array('pd_address_id' => $newpd['fk_address_id']); + $temp_data = array('assigned_pd' => $pd_id); + $id = $this->PD_Model->updateRecords($temp_data, PDADDRESS, $where_condition_array); + + + $logger = MYLOG::logFunction(null, $pd_id); + $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED AND TEMPLATED ID - " . $newpd['fk_pd_template_id'] . " CHOOSED", array('ENV' => ENVIRONMENT, 'Parent-PDID' => $newpd['parent_pd_id'], 'Addresss ID' => $newpd['fk_address_id'], 'PDID' => $pd_id, 'PD Type' => "Addtional PD", 'Current_status' => $newpd['pd_status'])); - /************ASSIGN Random URL******************/ - $newpd['random_string'] = $parent_pd_details[0]['random_string']; - $url = OFFICER_TRACKING_URL.$randomString; - $newpd['encrypted_url'] = $url; - - - $newpd['fk_pd_template_id'] = $this->assignPDTempalate(array('lender' => $newpd['fk_lender_id'],'product' => $newpd['fk_product_id'],'customer_segment' => $newpd['fk_customer_segment'])); - //print_r($newpd);die(); - - $pd_id = $this->PD_Model->saveRecords($newpd,PDTRIGGER); - if($pd_id != "" || $pd_id != null) - { - - if(!file_exists($this->external_path.'/pd_reports/'.$pd_id)) - { - mkdir($this->external_path.'/pd_reports/'.$pd_id,0777); - } - //update Applicant details - $fields = array('pd_co_applicant_id'=>$pd_details['pd_co_applicant_id'],'mobile_no' => $pd_details['mobile_no']); - $where_condition_array = array('additional_pd_id' => $pd_id); - $this->PD_Model->updateRecords($fields,PDAPPLICANTSDETAILS,$where_condition_array); - - //update Assiged PD to Address Table - $where_condition_array = array('pd_address_id' => $newpd['fk_address_id']); - $temp_data = array('assigned_pd' => $pd_id); - $id = $this->PD_Model->updateRecords($temp_data,PDADDRESS,$where_condition_array); - - $logger = MYLOG::logFunction(null,$pd_id); - $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED AND TEMPLATED ID - ".$newpd['fk_pd_template_id']." CHOOSED",array('ENV'=>ENVIRONMENT,'Parent-PDID' => $newpd['parent_pd_id'],'Addresss ID'=>$newpd['fk_address_id'] ,'PDID' => $pd_id,'PD Type' => "Addtional PD",'Current_status' => $newpd['pd_status'])); - - - //PDALERTS::pdnotification($newpd['pd_id']); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pd_id; - $data['msg'] = "Addtional PD Created!"; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pd_id; + $data['msg'] = "Addtional PD Created!"; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong. Try later!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong. Try later!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Parent PD Details Not available!'; + $this->response($data, REST_Controller::HTTP_OK); } - - - } - else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Parent PD Details Not available!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['msg'] = 'Addtional PD :- ParentPD ID,Customer Segment, Address,, PD Status, Created by Required!'; + $this->response($data, REST_Controller::HTTP_OK); } } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Addtional PD :- ParentPD ID,Customer Segment, Address,, PD Status, Created by Required!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } -} - //While PD Completion stage, send lenth of PD address -public function getPDCompleteDetails_post() -{ - - - $records = $this->post('records'); - $pdid = $records['pd_id']; - $pd_master_detials = $this->PD_Model->getPDMasterDetails($pdid); - - $address_count = $this->db->SELECT('count(*) as count')->FROM(PDADDRESS.' as PDADDRESS')->WHERE('PDADDRESS.fk_pd_id',$pd_master_detials[0]['parent_pd_id'])->WHERE('assigned_pd is null')->WHERE('PDADDRESS.isactive',1)->GET()->result_array(); - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('address_count' => (int)$address_count[0]['count']); - $this->response($data,REST_Controller::HTTP_OK); - -} - -public function assignPDTempalate($data) -{ - - //print_r($data); - $customer_segment_abbr = ''; - $res_array = array(); - if(!is_array($data)) - { - $logger = MYLOG::logFunction(null,$data); - $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED",array('ENV'=>ENVIRONMENT,'DATA' => $data)); - // $fields = array('fk_lender_id','fk_product_id','fk_customer_segment','pd_status'); - // $where_condition_array = array('pd_id' => $data); - $res_array = $this->PD_Model->getPDMasterDetails($data); - $customer_segment_abbr = $res_array[0]['customer_segment_abbr']; - } - - $templateid = null; - $fields = array('fk_template_id'); - $where_condition_array = array(); - //print_r($res_array[0]['fk_customer_segment']);die(); - if(!is_array($data)) - { - $where_condition_array = array('fk_lender_id'=>$res_array[0]['fk_lender_id'] ,'fk_product_id'=> $res_array[0]['fk_product_id'],'fk_customer_segment'=> $res_array[0]['fk_customer_segment'],'isactive' => 1); - //$customer_segment_abbr = $this->PD_Model->selectCustomRecords(array('*'),array('customer_segment_id' => $res_array[0]['fk_customer_segment'], 'isactive' => 1),CUSTOMERSEGMENT); - //$customer_segment_abbr = $customer_segment_abbr[0]['abbr']; - //print_r($customer_segment_abbr); - - } - else + public function getPDCompleteDetails_post() { - //print_r('else'); - $logger = MYLOG::logFunction(null,$data['pd_id']); - $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED",array('ENV'=>ENVIRONMENT,'DATA' => $data)); - $where_condition_array = array('fk_lender_id'=>$data['lender'] ,'fk_product_id'=> $data['product'],'fk_customer_segment'=> $data['customer_segment'],'isactive' => 1); + + + $records = $this->post('records'); + $pdid = $records['pd_id']; + $pd_master_detials = $this->PD_Model->getPDMasterDetails($pdid); + + $address_count = $this->db->SELECT('count(*) as count')->FROM(PDADDRESS . ' as PDADDRESS')->WHERE('PDADDRESS.fk_pd_id', $pd_master_detials[0]['parent_pd_id'])->WHERE('assigned_pd is null')->WHERE('PDADDRESS.isactive', 1)->GET()->result_array(); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('address_count' => (int)$address_count[0]['count']); + $this->response($data, REST_Controller::HTTP_OK); + } + + public function assignPDTempalate($data) + { + + //print_r($data); + $customer_segment_abbr = ''; + $res_array = array(); + if (!is_array($data)) { + $logger = MYLOG::logFunction(null, $data); + $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED", array('ENV' => ENVIRONMENT, 'DATA' => $data)); + // $fields = array('fk_lender_id','fk_product_id','fk_customer_segment','pd_status'); + // $where_condition_array = array('pd_id' => $data); + $res_array = $this->PD_Model->getPDMasterDetails($data); + $customer_segment_abbr = $res_array[0]['customer_segment_abbr']; + } + + $templateid = null; + $fields = array('fk_template_id'); + $where_condition_array = array(); + //print_r($res_array[0]['fk_customer_segment']);die(); + if (!is_array($data)) { + $where_condition_array = array('fk_lender_id' => $res_array[0]['fk_lender_id'], 'fk_product_id' => $res_array[0]['fk_product_id'], 'fk_customer_segment' => $res_array[0]['fk_customer_segment'], 'isactive' => 1); + //$customer_segment_abbr = $this->PD_Model->selectCustomRecords(array('*'),array('customer_segment_id' => $res_array[0]['fk_customer_segment'], 'isactive' => 1),CUSTOMERSEGMENT); + //$customer_segment_abbr = $customer_segment_abbr[0]['abbr']; + //print_r($customer_segment_abbr); + + } else { + //print_r('else'); + $logger = MYLOG::logFunction(null, $data['pd_id']); + $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED", array('ENV' => ENVIRONMENT, 'DATA' => $data)); + $where_condition_array = array('fk_lender_id' => $data['lender'], 'fk_product_id' => $data['product'], 'fk_customer_segment' => $data['customer_segment'], 'isactive' => 1); + } + + + $table = LENDERTEMPLATE; + + $choosed_template_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, $table); + + if (count($choosed_template_id)) // CHOOSE FILTERED TEMPLATE// + { + $templateid = $choosed_template_id[0]['fk_template_id']; + } else // CHOOSE GENERIC TEMPLATE// + { + //echo "CHOOSE GENERIC "; + + if (!strcasecmp($customer_segment_abbr, 'SAL')) // || !strcasecmp($customer_segment_abbr,'SAL-CHQ')) + { + //SAL - (CASH/CHQ) + $templateid = 1; + } else if (!strcasecmp($customer_segment_abbr, 'SE-DI') || !strcasecmp($customer_segment_abbr, 'SEP-DI') || !strcasecmp($customer_segment_abbr, 'SEP_INDV')) { + //* SENP/SEP - (DI) + $templateid = 2; + } else if (!strcasecmp($customer_segment_abbr, 'SE-AI') || !strcasecmp($customer_segment_abbr, 'SEP-AI')) { + //* SENP/SEP - (DI) + $templateid = 3; + } else if (!strcasecmp($customer_segment_abbr, 'SE-RI')) { + //* SENP/SEP - (RI) + $templateid = 4; + } + } + // echo $templateid;die(); + return $templateid; } - $table = LENDERTEMPLATE; + public function updatePDAddress_post() + { + $records = $this->post('records'); - $choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table); + $count = 0; + foreach ($records as $key => $value) { + unset($value['stateSearch']); + unset($value['citySearch']); + unset($value['pinSearch']); + if (count($records) == 1) { + $value['is_primary'] = 1; + } - if(count($choosed_template_id))// CHOOSE FILTERED TEMPLATE// - { - $templateid = $choosed_template_id[0]['fk_template_id']; + if ($value['pd_address_id'] != "" || $value['pd_address_id'] != null) { + $where_condition_array = array('pd_address_id' => $value['pd_address_id']); + $id = $this->PD_Model->updateRecords($value, PDADDRESS, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + } else { + $id = $this->PD_Model->saveRecords($value, PDADDRESS); + if ($id != "" || $id != null) { + $count++; + } + } + } - } - else // CHOOSE GENERIC TEMPLATE// - { - //echo "CHOOSE GENERIC "; - - if( !strcasecmp($customer_segment_abbr,'SAL') ) // || !strcasecmp($customer_segment_abbr,'SAL-CHQ')) - { - //SAL - (CASH/CHQ) - $templateid = 1; - } - else if( !strcasecmp($customer_segment_abbr,'SE-DI') || !strcasecmp($customer_segment_abbr,'SEP-DI') || !strcasecmp($customer_segment_abbr,'SEP_INDV')) - { - //* SENP/SEP - (DI) - $templateid = 2; - } - else if( !strcasecmp($customer_segment_abbr,'SE-AI') || !strcasecmp($customer_segment_abbr,'SEP-AI') ) - { - //* SENP/SEP - (DI) - $templateid = 3; - } - else if( !strcasecmp($customer_segment_abbr,'SE-RI')) - { - //* SENP/SEP - (RI) - $templateid = 4; - } - } - // echo $templateid;die(); - return $templateid; - - - - - } - - - public function updatePDAddress_post() - { - $records = $this->post('records'); - - $count = 0; - foreach($records as $key => $value) - { - unset($value['stateSearch']); - unset($value['citySearch']); - unset($value['pinSearch']); - if(count($records) == 1) - { - $value['is_primary'] = 1; - } - - if($value['pd_address_id'] != "" || $value['pd_address_id'] != null) - { - $where_condition_array = array('pd_address_id' => $value['pd_address_id']); - $id = $this->PD_Model->updateRecords($value,PDADDRESS,$where_condition_array); - if($id != "" || $id != null){ $count++; } - } - else - { - $id = $this->PD_Model->saveRecords($value,PDADDRESS); - if($id != "" || $id != null){ $count++; } - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } /** * Pd Discussion OTP Checking function @@ -1446,58 +1307,51 @@ public function assignPDTempalate($data) $pdotp = $this->post('records'); $pdotpStatus = 0; - if(!array_key_exists('reason',$pdotp)) - { + if (!array_key_exists('reason', $pdotp)) { $pdotpStatus = $this->PD_Model->checkotp($pdotp); $updatePd['pd_id'] = $pdotp['pd_id']; $updatePd['pd_status'] = INPROGRESS; $updatePd['is_otp_done'] = 1; $updatePd['fk_updatedby'] = $pdotp['fk_updatedby']; //$updatePd['updatedon'] = date('Y-m-d h:i:00'); - - if($pdotpStatus != 0 || $pdotpStatus != '' && count($pdotpStatus) != 0) - { + + if ($pdotpStatus != 0 || $pdotpStatus != '' && count($pdotpStatus) != 0) { $where_condition_array = array('pd_id' => $pdotp['pd_id']); - $pd_id_modified = $this->PD_Model->updateRecords($updatePd,PDTRIGGER,$where_condition_array); + $pd_id_modified = $this->PD_Model->updateRecords($updatePd, PDTRIGGER, $where_condition_array); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { - //echo "WITHOUT OTP CALLED"; + } else { + //echo "WITHOUT OTP CALLED"; $updatePd['pd_id'] = $pdotp['pd_id']; $updatePd['pd_status'] = INPROGRESS; $updatePd['is_otp_done'] = 0; $updatePd['otp_reject_reason'] = $pdotp['reason']; $updatePd['otp_reject_other_reason'] = $pdotp['other_reason']; - //$updatePd['updatedon'] = date('Y-m-d h:m:00'); + //$updatePd['updatedon'] = date('Y-m-d h:m:00'); $updatePd['fk_updatedby'] = $pdotp['fk_updatedby']; $where_condition_array = array('pd_id' => $pdotp['pd_id']); - $pd_id_modified = $this->PD_Model->updateRecords($updatePd,PDTRIGGER,$where_condition_array); + $pd_id_modified = $this->PD_Model->updateRecords($updatePd, PDTRIGGER, $where_condition_array); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - + /* * *Update PD trigger Applicats Details(Web app only) from PD trigger Edit/view page @@ -1508,47 +1362,37 @@ public function assignPDTempalate($data) $count = 0; $pd_id = 0; //print_r($this->post());die(); - foreach($pd_applicant_details as $pd_applicant_detail) - { + foreach ($pd_applicant_details as $pd_applicant_detail) { $pd_applicant_detail['applicant_name'] = trim($pd_applicant_detail['applicant_name']); $pd_applicant_detail['company_name'] = trim(MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['company_name'])); - if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "") - { - //$pd_id = $pd_applicant_detail['fk_pd_id']; + if ($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "") { + //$pd_id = $pd_applicant_detail['fk_pd_id']; $where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']); - $co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array); - if($co_applicant_id != null || $co_applicant_id != '') - { + $co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail, PDAPPLICANTSDETAILS, $where_condition_array); + if ($co_applicant_id != null || $co_applicant_id != '') { $count = $count + 1; } - } - else - { - //$pd_applicant_detail['fk_pd_id'] = $pd_id; - $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); - if($co_applicant_id != null || $co_applicant_id != '') - { + } else { + //$pd_applicant_detail['fk_pd_id'] = $pd_id; + $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail, PDAPPLICANTSDETAILS); + if ($co_applicant_id != null || $co_applicant_id != '') { $count = $count + 1; } } } - if($count != 0 && count($pd_applicant_details) == $count) - { + if ($count != 0 && count($pd_applicant_details) == $count) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - + /* * *delete single PD Document - delete form table entry and S3 obj @@ -1556,108 +1400,91 @@ public function assignPDTempalate($data) public function deletePDDoc_post() { $pd_document_details = $this->post('pd_document_details'); - - if(count($pd_document_details)) - { - //Select lender_id userin pdid + + if (count($pd_document_details)) { + //Select lender_id userin pdid $pdid = $pd_document_details[0]['fk_pd_id']; $fields = array('fk_lender_id'); $where_condition_array = array('pd_id' => $pdid); - $lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - - $bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id']; - $key = 'pd'.$pd_document_details[0]['fk_pd_id'].'/'.$pd_document_details[0]['pd_document_name']; - $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); + $lender_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); - //delete old entry - $modified = $this->db->where('pd_document_id',$pdid)->$this->db->delete(PDDOCUMENTS); - if($modified) - { + $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + $key = 'pd' . $pd_document_details[0]['fk_pd_id'] . '/' . $pd_document_details[0]['pd_document_name']; + $this->aws_s3->deleteSingleObjFromBucket($bucketname, $key); + + //delete old entry + $modified = $this->db->where('pd_document_id', $pdid)->$this->db->delete(PDDOCUMENTS); + if ($modified) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - } - } - + /* * *Update PD Documents details from PD Trigger(Web application only) edit/view page */ public function updatePDDocs_post() { - - - $pd_document_titles = json_decode($this->post('pd_document_titles'),true); - if(count($pd_document_titles)) - { + + + $pd_document_titles = json_decode($this->post('pd_document_titles'), true); + if (count($pd_document_titles)) { //Get Lender id from PD Master $pdid = $pd_document_titles[0]['fk_pd_id']; $fields = array('fk_lender_id'); $where_condition_array = array('pd_id' => $pdid); - $lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - foreach($pd_document_titles as $iter => $doc) - { - if($doc['pd_document_id'] != null || $doc['pd_document_id'] != '') - { + $lender_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); + foreach ($pd_document_titles as $iter => $doc) { + if ($doc['pd_document_id'] != null || $doc['pd_document_id'] != '') { $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; $tempdocname = $_FILES['pddocuments']['name'][$iter]; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id']; - $key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + $key = 'pd' . $doc['fk_pd_id'] . '/' . $tempdocname; $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - //delete old doc from s3 bucket_data + //delete old doc from s3 bucket_data $fields = array('pd_document_name'); $where_condition_array1 = array('pd_document_id' => $doc['pd_document_id']); - $old_doc_name = $this->PD_Model->selectCustomRecords($fields,$where_condition_array1,PDDOCUMENTS); + $old_doc_name = $this->PD_Model->selectCustomRecords($fields, $where_condition_array1, PDDOCUMENTS); - if($old_doc_name != "" || $old_doc_name != null) - { - $key = 'pd'.$doc['fk_pd_id'].'/'.$old_doc_name[0]['pd_document_name']; - $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); + if ($old_doc_name != "" || $old_doc_name != null) { + $key = 'pd' . $doc['fk_pd_id'] . '/' . $old_doc_name[0]['pd_document_name']; + $this->aws_s3->deleteSingleObjFromBucket($bucketname, $key); } - //Update entry in PD Doc table - $record_data = array('pd_document_name'=>$tempdocname); + //Update entry in PD Doc table + $record_data = array('pd_document_name' => $tempdocname); $where_condition_array = array('pd_document_id' => $doc['pd_document_id']); - $this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array); + $this->PD_Model->updateRecords($record_data, PDDOCUMENTS, $where_condition_array); } + } else { - - } - else - { - $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; $tempdocname = $_FILES['pddocuments']['name'][$iter]; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id; - $key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id; + $key = 'pd' . $doc['fk_pd_id'] . '/' . $tempdocname; $sourcefile = $tempdoc; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>$doc['pd_document_title'],'pd_document_name'=>$tempdocname); - $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + $record_data = array('fk_pd_id' => $pdid, 'pd_document_title' => $doc['pd_document_title'], 'pd_document_name' => $tempdocname); + $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); } } } @@ -1666,13 +1493,12 @@ public function assignPDTempalate($data) $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } } - - - + + + /* *Allocate PD to Some PD officer */ @@ -1684,34 +1510,32 @@ public function assignPDTempalate($data) //{ // $records['pd_agency_id'] =isset($records['pd_agency_id']) ? $records['pd_agency_id'] : null; - $fields = array('fk_lender_id','pd_agency_id'); - $where_condition_array = array('pd_id'=>$records['pd_id']); - $lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $fields = array('fk_lender_id', 'pd_agency_id'); + $where_condition_array = array('pd_id' => $records['pd_id']); + $lender_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //SMC lender id MWISE in live and demo // IF Condition - PD AGENCY ID means SMC VENDOR FLOW - if(isset($records['pd_agency_id'])){ + if (isset($records['pd_agency_id'])) { // IF Condition - using PDID get the lender and mapped with SMC_lender_id macthed means Vendor status dynamically assigned // {"records":{"pd_id":"2795","fk_pd_allocated_to":"383","pd_agency_id":"2","fk_updatedby":"395"}} - if($smc_lender_id == $lender_id[0]['fk_lender_id'] && isset($records['pd_agency_id']) && $records['pd_agency_id'] != null){ - $records['vendor_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED ; //Here vendor_status is dynamic (ALLOCATED,SCHEDULED,COMPLETED like that) + if ($smc_lender_id == $lender_id[0]['fk_lender_id'] && isset($records['pd_agency_id']) && $records['pd_agency_id'] != null) { + $records['vendor_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED; //Here vendor_status is dynamic (ALLOCATED,SCHEDULED,COMPLETED like that) //Mail - SMC Vendor. - if($records['vendor_status'] == ALLOCATED){ - $records['pd_status'] = ALLOCATED_TO_FIA; + if ($records['vendor_status'] == ALLOCATED) { + $records['pd_status'] = ALLOCATED_TO_FIA; } } - } - else{ - //Normal FLOW - $records['pd_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED; - if(isset($records['pd_status']) && ($records['pd_status'] == ALLOCATED_TO_FIA )) - { - $records['vendor_status'] = TRIGGERED; - } + } else { + //Normal FLOW + $records['pd_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED; + if (isset($records['pd_status']) && ($records['pd_status'] == ALLOCATED_TO_FIA)) { + $records['vendor_status'] = TRIGGERED; + } } // if($smc_lender_id != $lender_id[0]['fk_lender_id']){ // $records['pd_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED ; - // } + // } // IF Condition - using PDID get the lender and mapped with SMC_lender_id macthed means Vendor status dynamically assigned // if($smc_lender_id == $lender_id[0]['fk_lender_id'] && isset($records['pd_agency_id']) && $records['pd_agency_id'] != null){ // $records['vendor_status'] = isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED ; //Here vendor_status is dynamic (ALLOCATED,SCHEDULED,COMPLETED like that) @@ -1724,37 +1548,33 @@ public function assignPDTempalate($data) // } //} // $where_condition_array = array('pd_id' => $records['pd_id']); - $pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array); - + $pd_id_modified = $this->PD_Model->updateRecords($records, PDTRIGGER, $where_condition_array); + // $where_condition_array = array('fk_user_id' => $records['fk_pd_allocated_to']); // $temp_array = array(''); // $pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array); - - if($pd_id_modified != "" || $pd_id_modified != null) - { - $logger = MYLOG::logFunction(null,$records['pd_id']); - $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'TRIGGERED','Current_status' => isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED)); + + if ($pd_id_modified != "" || $pd_id_modified != null) { + $logger = MYLOG::logFunction(null, $records['pd_id']); + $logger->info("PD UPDATED", array('ENV' => ENVIRONMENT, 'DATA' => $records, 'Pre-Status' => 'TRIGGERED', 'Current_status' => isset($records['pd_status']) ? $records['pd_status'] : ALLOCATED)); PDALERTS::pdnotification($records['pd_id']); - if(isset($records['pd_agency_id']) && $records['vendor_status'] == ALLOCATED){ - PDALERTS::sendMWcreditPDMail($this,$records,1); - PDALERTS::sendMWcreditPDMail($this,$records,2); - } + if (isset($records['pd_agency_id']) && $records['vendor_status'] == ALLOCATED) { + PDALERTS::sendMWcreditPDMail($this, $records, 1); + PDALERTS::sendMWcreditPDMail($this, $records, 2); + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Not Updated! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - - + + /* *Schedule PD by PD officer(only on Manual Schedule) */ @@ -1762,387 +1582,340 @@ public function assignPDTempalate($data) { $records = $this->post('records'); //print_r($records['app_client']);die(); - if($records['schedule_time'] != "" || $records['schedule_time'] != null) - { + if ($records['schedule_time'] != "" || $records['schedule_time'] != null) { //$id = $this->PD_Model->saveRecords($records,PDSCHEDULE); - + $where_condition_array = array('pd_id' => $records['fk_pd_id']); - $temp_array = array('fk_updatedby'=>$records['fk_scheduled_by'],'scheduled_on'=>$records['schedule_time']); - - if(isset($records['app_client']) && $records['app_client'] == 3) - { + $temp_array = array('fk_updatedby' => $records['fk_scheduled_by'], 'scheduled_on' => $records['schedule_time']); + + if (isset($records['app_client']) && $records['app_client'] == 3) { $temp_array['vendor_status'] = SCHEDULED; - } - else - { + } else { $temp_array['pd_status'] = SCHEDULED; - } + } //print_r($temp_array);die(); - $pd_id_modified = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + $pd_id_modified = $this->PD_Model->updateRecords($temp_array, PDTRIGGER, $where_condition_array); - // /******* Code Snippt for Save Template Category Weightage info to PD category Info*/ - // $fields = array('fk_pd_template_id'); - // $where_condition_array = array('pd_id'=>$records['fk_pd_id']); - // $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + // /******* Code Snippt for Save Template Category Weightage info to PD category Info*/ + // $fields = array('fk_pd_template_id'); + // $where_condition_array = array('pd_id'=>$records['fk_pd_id']); + // $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - // if(count($res_array)) - // { - // $fields = array('fk_pd_template_id'); - // $where_condition_array = array('pd_id'=>$records['fk_pd_id']); - // $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + // if(count($res_array)) + // { + // $fields = array('fk_pd_template_id'); + // $where_condition_array = array('pd_id'=>$records['fk_pd_id']); + // $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - // if(count($res_array)) - // { - // $template_id = $res_array[0]['fk_pd_template_id']; + // if(count($res_array)) + // { + // $template_id = $res_array[0]['fk_pd_template_id']; - // $fields = array('fk_question_category_id','weightage'); - // $where_condition_array = array('fk_template_id'=>$template_id); - // $template_categories = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATECATEGORYWEIGHTAGE); + // $fields = array('fk_question_category_id','weightage'); + // $where_condition_array = array('fk_template_id'=>$template_id); + // $template_categories = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATECATEGORYWEIGHTAGE); - // foreach($template_categories as $key => $category) - // { - // $temp_data = array('fk_pd_id'=>$records['fk_pd_id'],'fk_category_id'=>$category['fk_question_category_id'],'pd_category_weightage'=>$category['weightage']); - // $this->PD_Model->saveRecords($temp_data,PDCATEGORYWEIGHTAGE); - // } - // } - // } + // foreach($template_categories as $key => $category) + // { + // $temp_data = array('fk_pd_id'=>$records['fk_pd_id'],'fk_category_id'=>$category['fk_question_category_id'],'pd_category_weightage'=>$category['weightage']); + // $this->PD_Model->saveRecords($temp_data,PDCATEGORYWEIGHTAGE); + // } + // } + // } /******* End of Code Snippt Save Template Category Weightage info to PD category Info*/ - if($pd_id_modified != "" || $pd_id_modified != null) - { + if ($pd_id_modified != "" || $pd_id_modified != null) { PDALERTS::pdnotification($records['fk_pd_id']); $logger = MYLOG::logFunction(); - $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'NA','Current_status' => SCHEDULED)); + $logger->info("PD UPDATED", array('ENV' => ENVIRONMENT, 'DATA' => $records, 'Pre-Status' => 'NA', 'Current_status' => SCHEDULED)); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Not Updated! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - - } - - + + /* *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'); //1.Get LenderID and CityID by using pdid - $fields = array('fk_lender_id','fk_city','fk_pd_type','fk_product_id','fk_customer_segment'); - $where_condition_array = array('pd_id'=>$pdid); - $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $fields = array('fk_lender_id', 'fk_city', 'fk_pd_type', 'fk_product_id', 'fk_customer_segment'); + $where_condition_array = array('pd_id' => $pdid); + $res_array = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); //print_r($res_array); //2.Get Team ID based on Lender ID - if(count($res_array)) - { - $where_condition_array = array('lender_id' => $res_array[0]['fk_lender_id'],'city_id' =>$res_array[0]['fk_city'] ,'cs_id' =>$res_array[0]['fk_customer_segment'] ,'product_id' =>$res_array[0]['fk_product_id']); - $temp_city_id = $this->PD_Model->selectRecords(PDTEAM_CTY_PRODUCT_CS_COMBINATIONS,$where_condition_array,$limit=0,$offset=0); - //print_r($temp_city_id);die(); - if(count($temp_city_id)) - { - if(isset($temp_city_id[0]['team_type'])) - { - if($temp_city_id[0]['team_type'] == 0) // Allocate to Vendor - { - // $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; - // $pd_details['fk_pd_allocated_to'] = ALLOCATED_TO_PARTNER; - - } - else //Allocate to SineEdge Team with allocation logics - { - - //select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED - $fields = array('fk_user_id','fk_pd_type_id'); + if (count($res_array)) { + $where_condition_array = array('lender_id' => $res_array[0]['fk_lender_id'], 'city_id' => $res_array[0]['fk_city'], 'cs_id' => $res_array[0]['fk_customer_segment'], 'product_id' => $res_array[0]['fk_product_id']); + $temp_city_id = $this->PD_Model->selectRecords(PDTEAM_CTY_PRODUCT_CS_COMBINATIONS, $where_condition_array, $limit = 0, $offset = 0); + //print_r($temp_city_id);die(); + if (count($temp_city_id)) { + if (isset($temp_city_id[0]['team_type'])) { + if ($temp_city_id[0]['team_type'] == 0) // Allocate to Vendor + { + // $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; + // $pd_details['fk_pd_allocated_to'] = ALLOCATED_TO_PARTNER; - $where_condition_array = array('fk_team_id' => $temp_city_id[0]['pdteam_id'],'isactive' => 1); - - $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); - - if(count($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'); - $this->db->FROM(USERPROFILE.' as USERPROFILE'); - $this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']); - $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]['count'] = 0; - - $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.lender_applicant_id,ENTITY.short_name'); - $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); - $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); - $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT'); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT'); - $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); - - $this->db->OR_GROUP_START(); - $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); - $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->GROUP_END(); - if($pdofficer['fk_pd_type_id'] == 1) - { - $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); - } - else - { - $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); - } - $pd_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - if(count($pd_count)){ - $list_of_pd_officers[$key]['pd_details'] = $pd_count; - $list_of_pd_officers[$key]['count'] =count($pd_count); } - - // Get Profile Pic from S3 - - $bucket_name = PROFILE_PICTURE_BUCKET_NAME; - $profilepics3path = 'sineedge/'.$names[0]['profilepic']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); - $list_of_pd_officers[$key]['profile_url'] = $singed_uri; - } - } - // Get Central PD Officers List - $central_pd_officers = array(); - if($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3) - { - $this->db->SELECT('USERPROFILE.userid as fk_user_id,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('ROLES.role_id',2); - $central_pd_officers = $this->db->GET()->result_array(); - //print_r($central_pd_officers); - if(count($central_pd_officers)) - { - foreach($central_pd_officers as $k => $central_pd_officer) - { - - //Get PD Details assigned to Central Officers - $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.lender_applicant_id,ENTITY.short_name'); - $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); - $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); - $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT'); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT'); - $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); - - $this->db->OR_GROUP_START(); - $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); - $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->GROUP_END(); - $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); - $pd_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - $central_pd_officers[$k]['count'] = 0; - if(count($pd_count)){ - $central_pd_officers[$k]['pd_details'] = $pd_count; - $central_pd_officers[$k]['count'] = count($pd_count); } - //End Get PD Details assigned to Central Officers - - - $bucket_name = PROFILE_PICTURE_BUCKET_NAME; - $profilepics3path = 'sineedge/'.$central_pd_officer['profilepic']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); - $central_pd_officers[$k]['profile_url'] = $singed_uri; - } - } - } - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Officers Records Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - - - } - } - - - - - } - else // Find Officers in General Team - { - - - - //echo 'Find General Team ID';die(); - $fields = array('pdteam_id'); - $where_condition_array = array('team_name' => "General"); - $general_team_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTEAM); - // print_r($general_team_id);die(); - if(count($general_team_id)) + } else //Allocate to SineEdge Team with allocation logics { + //select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED + $fields = array('fk_user_id', 'fk_pd_type_id'); - $fields = array('fk_user_id','fk_pd_type_id'); - $where_condition_array = array('fk_team_id' => $general_team_id[0]['pdteam_id'],'isactive' => 1); - $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS); - if(count($list_of_pd_officers)) - { - foreach($list_of_pd_officers as $key => $pdofficer) - { + $where_condition_array = array('fk_team_id' => $temp_city_id[0]['pdteam_id'], 'isactive' => 1); + + $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDOFFICIERSDETAILS); + + if (count($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'); - $this->db->FROM(USERPROFILE.' as USERPROFILE'); - $this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']); + $this->db->FROM(USERPROFILE . ' as USERPROFILE'); + $this->db->WHERE('USERPROFILE.userid', $pdofficer['fk_user_id']); $names = $this->db->GET()->result_array(); + if (count($names)) { - 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]['count'] = 0; $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.lender_applicant_id,ENTITY.short_name'); - $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); - $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); - $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT'); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT'); + $this->db->FROM(PDTRIGGER . ' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', 'PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); + $this->db->JOIN(PDTYPE . ' as PDTYPE', 'PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); + $this->db->JOIN(STATE . ' as STATE', 'PDTRIGGER.fk_state = STATE.state_id ', 'LEFT'); + $this->db->JOIN(CITY . ' as CITY', 'PDTRIGGER.fk_city = CITY.city_id', 'LEFT'); + $this->db->JOIN(ENTITY . ' as ENTITY', 'PDTRIGGER.fk_lender_id = ENTITY.entity_id', 'LEFT'); + $this->db->OR_GROUP_START(); - $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); - $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); + $this->db->OR_WHERE('PDTRIGGER.pd_status', SCHEDULED); + $this->db->OR_WHERE('PDTRIGGER.pd_status', INPROGRESS); + $this->db->OR_WHERE('PDTRIGGER.pd_status', ALLOCATED); $this->db->GROUP_END(); - if($pdofficer['fk_pd_type_id'] == 1) - { - $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); - } - else - { - $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); + if ($pdofficer['fk_pd_type_id'] == 1) { + $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to', $pdofficer['fk_user_id']); + } else { + $this->db->WHERE('PDTRIGGER.executive_id', $pdofficer['fk_user_id']); } $pd_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - if(count($pd_count)){ + //print_r($this->db->last_query()); + if (count($pd_count)) { $list_of_pd_officers[$key]['pd_details'] = $pd_count; - $list_of_pd_officers[$key]['count'] =count($pd_count); + $list_of_pd_officers[$key]['count'] = count($pd_count); } - // Get Profile Pic from S3 + // Get Profile Pic from S3 $bucket_name = PROFILE_PICTURE_BUCKET_NAME; - $profilepics3path = 'sineedge/'.$names[0]['profilepic']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); + $profilepics3path = 'sineedge/' . $names[0]['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '+10 minutes'); $list_of_pd_officers[$key]['profile_url'] = $singed_uri; - - } } - - // Get Central PD Officers List + // Get Central PD Officers List $central_pd_officers = array(); - if($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3) - { + if ($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3) { $this->db->SELECT('USERPROFILE.userid as fk_user_id,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('ROLES.role_id',2); + $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(); + //print_r($central_pd_officers); + if (count($central_pd_officers)) { + foreach ($central_pd_officers as $k => $central_pd_officer) { - if(count($central_pd_officers)) - { - foreach($central_pd_officers as $k => $central_pd_officer) - { - - - //Get PD Details assigned to Central Officers - $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode'); - $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); - $this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); - $this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT'); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT'); + //Get PD Details assigned to Central Officers + $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.lender_applicant_id,ENTITY.short_name'); + $this->db->FROM(PDTRIGGER . ' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', 'PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); + $this->db->JOIN(PDTYPE . ' as PDTYPE', 'PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); + $this->db->JOIN(STATE . ' as STATE', 'PDTRIGGER.fk_state = STATE.state_id ', 'LEFT'); + $this->db->JOIN(CITY . ' as CITY', 'PDTRIGGER.fk_city = CITY.city_id', 'LEFT'); + $this->db->JOIN(ENTITY . ' as ENTITY', 'PDTRIGGER.fk_lender_id = ENTITY.entity_id', 'LEFT'); $this->db->OR_GROUP_START(); - $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); - $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); + $this->db->OR_WHERE('PDTRIGGER.pd_status', SCHEDULED); + $this->db->OR_WHERE('PDTRIGGER.pd_status', INPROGRESS); + $this->db->OR_WHERE('PDTRIGGER.pd_status', ALLOCATED); $this->db->GROUP_END(); - $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); + $this->db->WHERE('PDTRIGGER.central_pd_officer_id', $central_pd_officer['fk_user_id']); $pd_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); + //print_r($this->db->last_query()); $central_pd_officers[$k]['count'] = 0; - if(count($pd_count)){ + if (count($pd_count)) { $central_pd_officers[$k]['pd_details'] = $pd_count; - $central_pd_officers[$k]['count'] = count($pd_count); } - //End Get PD Details assigned to Central Officers - - - $bucket_name = PROFILE_PICTURE_BUCKET_NAME; - $profilepics3path = 'sineedge/'.$central_pd_officer['profilepic']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); - $central_pd_officers[$k]['profile_url'] = $singed_uri; + $central_pd_officers[$k]['count'] = count($pd_count); } + //End Get PD Details assigned to Central Officers + + + $bucket_name = PROFILE_PICTURE_BUCKET_NAME; + $profilepics3path = 'sineedge/' . $central_pd_officer['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '+10 minutes'); + $central_pd_officers[$k]['profile_url'] = $singed_uri; } } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); - $this->response($data,REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Officers Records Not Found in General Team!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pdofficers' => $list_of_pd_officers, 'centralpdofficers' => $central_pd_officers); + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'General Team Not Found'; - $this->response($data,REST_Controller::HTTP_OK); + $data['msg'] = 'Officers Records Not Found!'; + $this->response($data, REST_Controller::HTTP_OK); } } } - else - { + } else // Find Officers in General Team + { + + + + //echo 'Find General Team ID';die(); + $fields = array('pdteam_id'); + $where_condition_array = array('team_name' => "General"); + $general_team_id = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTEAM); + // print_r($general_team_id);die(); + if (count($general_team_id)) { + + + $fields = array('fk_user_id', 'fk_pd_type_id'); + $where_condition_array = array('fk_team_id' => $general_team_id[0]['pdteam_id'], 'isactive' => 1); + $list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDOFFICIERSDETAILS); + if (count($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'); + $this->db->FROM(USERPROFILE . ' as USERPROFILE'); + $this->db->WHERE('USERPROFILE.userid', $pdofficer['fk_user_id']); + $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]['count'] = 0; + + $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.lender_applicant_id,ENTITY.short_name'); + $this->db->FROM(PDTRIGGER . ' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', 'PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); + $this->db->JOIN(PDTYPE . ' as PDTYPE', 'PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); + $this->db->JOIN(STATE . ' as STATE', 'PDTRIGGER.fk_state = STATE.state_id ', 'LEFT'); + $this->db->JOIN(CITY . ' as CITY', 'PDTRIGGER.fk_city = CITY.city_id', 'LEFT'); + $this->db->OR_GROUP_START(); + $this->db->OR_WHERE('PDTRIGGER.pd_status', SCHEDULED); + $this->db->OR_WHERE('PDTRIGGER.pd_status', INPROGRESS); + $this->db->OR_WHERE('PDTRIGGER.pd_status', ALLOCATED); + $this->db->JOIN(ENTITY . ' as ENTITY', 'PDTRIGGER.fk_lender_id = ENTITY.entity_id', 'LEFT'); + $this->db->GROUP_END(); + if ($pdofficer['fk_pd_type_id'] == 1) { + $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to', $pdofficer['fk_user_id']); + } else { + $this->db->WHERE('PDTRIGGER.executive_id', $pdofficer['fk_user_id']); + } + $pd_count = $this->db->GET()->result_array(); + //print_r($this->db->last_query()); + if (count($pd_count)) { + $list_of_pd_officers[$key]['pd_details'] = $pd_count; + $list_of_pd_officers[$key]['count'] = count($pd_count); + } + + // Get Profile Pic from S3 + + $bucket_name = PROFILE_PICTURE_BUCKET_NAME; + $profilepics3path = 'sineedge/' . $names[0]['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '+10 minutes'); + $list_of_pd_officers[$key]['profile_url'] = $singed_uri; + } + } + + // Get Central PD Officers List + $central_pd_officers = array(); + if ($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3) { + $this->db->SELECT('USERPROFILE.userid as fk_user_id,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('ROLES.role_id', 2); + $central_pd_officers = $this->db->GET()->result_array(); + + if (count($central_pd_officers)) { + foreach ($central_pd_officers as $k => $central_pd_officer) { + + + //Get PD Details assigned to Central Officers + $this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode'); + $this->db->FROM(PDTRIGGER . ' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', 'PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); + $this->db->JOIN(PDTYPE . ' as PDTYPE', 'PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1'); + $this->db->JOIN(STATE . ' as STATE', 'PDTRIGGER.fk_state = STATE.state_id ', 'LEFT'); + $this->db->JOIN(CITY . ' as CITY', 'PDTRIGGER.fk_city = CITY.city_id', 'LEFT'); + + $this->db->OR_GROUP_START(); + $this->db->OR_WHERE('PDTRIGGER.pd_status', SCHEDULED); + $this->db->OR_WHERE('PDTRIGGER.pd_status', INPROGRESS); + $this->db->OR_WHERE('PDTRIGGER.pd_status', ALLOCATED); + $this->db->GROUP_END(); + $this->db->WHERE('PDTRIGGER.central_pd_officer_id', $central_pd_officer['fk_user_id']); + $pd_count = $this->db->GET()->result_array(); + //print_r($this->db->last_query()); + $central_pd_officers[$k]['count'] = 0; + if (count($pd_count)) { + $central_pd_officers[$k]['pd_details'] = $pd_count; + $central_pd_officers[$k]['count'] = count($pd_count); + } + //End Get PD Details assigned to Central Officers + + + $bucket_name = PROFILE_PICTURE_BUCKET_NAME; + $profilepics3path = 'sineedge/' . $central_pd_officer['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '+10 minutes'); + $central_pd_officers[$k]['profile_url'] = $singed_uri; + } + } + } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pdofficers' => $list_of_pd_officers, 'centralpdofficers' => $central_pd_officers); + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Officers Records Not Found in General Team!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'PD Master Records Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['msg'] = 'General Team Not Found'; + $this->response($data, REST_Controller::HTTP_OK); } } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'PD Master Records Not Found!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } /* PD_Triggerd and PD_Co_Applocants Details only for Listing Page @param page/offset @@ -2150,218 +1923,238 @@ public function assignPDTempalate($data) @param sorting order(ASC/DESC) @param cid for category_id for filter question with category wise. */ - public function listLessPDDetails_get() - { + public function listLessPDDetails_get() + { - //print_r($_GET);die(); - //check empty query params - $this->checkEmptyQueryParams($_GET); - $page = 0;$limit = 1000;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate =""; - $lenderid = "";$status="";$lender_details = array(); - $pdagencyid = "";$vendor_pdofficer = "";$user_type = "";$createdby="";$client=""; - if($this->get('page')) { $page = $this->get('page'); } - if($this->get('limit')){ $limit = $this->get('limit'); } - if($this->get('sort')) { $sort = $this->get('sort'); } - if($this->get('pdofficerid')) { $pdofficerid = $this->get('pdofficerid'); } - if($this->get('pdagencyid')) { $pdagencyid = $this->get('pdagencyid'); } - if($this->get('vendor_pdofficer')) { $vendor_pdofficer = $this->get('vendor_pdofficer'); } - if($this->get('datetype')) { $datetype = $this->get('datetype'); } - if($this->get('fdate')) { $fdate = $this->get('fdate'); } - if($this->get('tdate')) { $tdate = $this->get('tdate'); } - if($this->get('status')) { $status = $this->get('status'); } - if($this->get('user_type')) { $user_type = $this->get('user_type'); } - if($this->get('client')) { $client = $this->get('client'); } - $is_smc_vendor = $this->get('is_smc_vendor') ? $this->get('is_smc_vendor') : null; - - //if lender id exists, then make custom filter for only SMC usage - if($this->get('createdby')) { $createdby = $this->get('createdby'); } - if($this->get('lenderid')) - { - $lenderid = $this->get('lenderid'); - $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo - if($lenderid == $smc_lender_id) - { - - // $this->load->model('User_Management_Model'); - // $user_details = $this->User_Management_Model->getUserDetails($createdby); - // if($user_details['data'][0]['user_role'] == 26)//Credit Manager - // { - // $pdofficerid = $createdby; - - // } - // else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager - // { - // $lender_details = array('city' => $user_details['data'][0]['fk_city']); - - // } - $createdby = ''; - - } - - // $lender_details = $this->getLenderHierarchyForPDListing($lenderid); - - } - // die(); - $result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status,$lender_details,$pdagencyid,$vendor_pdofficer,$user_type,$createdby,$client,$is_smc_vendor); - // echo count($result_data['data']);die(); - if($result_data['data_status'] == true) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data['data']; - $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); - } - + //print_r($_GET);die(); + //check empty query params + $this->checkEmptyQueryParams($_GET); + $page = 0; + $limit = 1000; + $sort = 'DESC'; + $pdofficerid = ""; + $datetype = ""; + $fdate = ""; + $tdate = ""; + $lenderid = ""; + $status = ""; + $lender_details = array(); + $pdagencyid = ""; + $vendor_pdofficer = ""; + $user_type = ""; + $createdby = ""; + $client = ""; + if ($this->get('page')) { + $page = $this->get('page'); } + if ($this->get('limit')) { + $limit = $this->get('limit'); + } + if ($this->get('sort')) { + $sort = $this->get('sort'); + } + if ($this->get('pdofficerid')) { + $pdofficerid = $this->get('pdofficerid'); + } + if ($this->get('pdagencyid')) { + $pdagencyid = $this->get('pdagencyid'); + } + if ($this->get('vendor_pdofficer')) { + $vendor_pdofficer = $this->get('vendor_pdofficer'); + } + if ($this->get('datetype')) { + $datetype = $this->get('datetype'); + } + if ($this->get('fdate')) { + $fdate = $this->get('fdate'); + } + if ($this->get('tdate')) { + $tdate = $this->get('tdate'); + } + if ($this->get('status')) { + $status = $this->get('status'); + } + if ($this->get('user_type')) { + $user_type = $this->get('user_type'); + } + if ($this->get('client')) { + $client = $this->get('client'); + } + $is_smc_vendor = $this->get('is_smc_vendor') ? $this->get('is_smc_vendor') : null; + + //if lender id exists, then make custom filter for only SMC usage + if ($this->get('createdby')) { + $createdby = $this->get('createdby'); + } + if ($this->get('lenderid')) { + $lenderid = $this->get('lenderid'); + $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo + if ($lenderid == $smc_lender_id) { + + // $this->load->model('User_Management_Model'); + // $user_details = $this->User_Management_Model->getUserDetails($createdby); + // if($user_details['data'][0]['user_role'] == 26)//Credit Manager + // { + // $pdofficerid = $createdby; + + // } + // else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager + // { + // $lender_details = array('city' => $user_details['data'][0]['fk_city']); + + // } + $createdby = ''; + } + + // $lender_details = $this->getLenderHierarchyForPDListing($lenderid); + + } + // die(); + $result_data = $this->PD_Model->listLessPDDetails($page, $limit, $sort, $pdofficerid, $datetype, $fdate, $tdate, $lenderid, $status, $lender_details, $pdagencyid, $vendor_pdofficer, $user_type, $createdby, $client, $is_smc_vendor); + // echo count($result_data['data']);die(); + if ($result_data['data_status'] == true) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data['data']; + $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); + } + } - function checkEmptyQueryParams($arr) - { - if(count($arr)) - { - foreach ($arr as $key => $value) - { - if(!$value) - { - - //exit('CATUTION'); - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_UNPROCESSABLE_ENTITY; - $data['msg'] = 'Unprocessable Params'; - $this->response($data,REST_Controller::HTTP_OK); - } + function checkEmptyQueryParams($arr) + { + if (count($arr)) { + foreach ($arr as $key => $value) { + if (!$value) { + + //exit('CATUTION'); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_UNPROCESSABLE_ENTITY; + $data['msg'] = 'Unprocessable Params'; + $this->response($data, REST_Controller::HTTP_OK); } } } - // PD listing based on lender role hierarchy - function getLenderHierarchyForPDListing($lender_user_id) - { - //get role of lender_user_id` - $user_role_details = $this->PD_Model->getLenderHierarchyForPDListing($lender_user_id); - //print_r($user_role_details);die(); - if(count($user_role_details)) - { - $role_id = $user_role_details[0]['user_role']; - switch($role_id) - { - case 11:// National Sales Head - case 12:// National Credit Head - //Get all PD's which were triggered in this entity id - return array('entity' => $user_role_details[0]['fk_entity_id']); - case 13:// Zonal Sales Head - case 14:// Zonal Credit Head - //Get all cities id's from m_entity_region_mapping table using region_id / zone id - $temp_array = $this->PD_Model->selectCustomRecords(array('fk_city_id'),array('fk_region_id' => $user_role_details[0]['fk_region_id']),ENTITYREGION); - //Get all PD's which were triggered in this entity id and city id's in current zone - //$citiesInCurrentZone = array(10,20); - $citiesInCurrentZone = array(); - if(count($temp_array)) - { - foreach ($temp_array as $key => $value) { $citiesInCurrentZone = array_merge($citiesInCurrentZone,array($value['fk_city_id'])); } - } - return array('entity' => $user_role_details[0]['fk_entity_id'],'zone' => $citiesInCurrentZone); - case 15://Area Sales Head - case 16://Area Credit Head - //Get all PD's which were triggered in this entity id and city id's in current zone - return array('entity' => $user_role_details[0]['fk_entity_id'],'state' => $user_role_details[0]['fk_state']); - case 17://City Sales Head - case 18://City Credit Head - //Get all PD's which were triggered in this entity id and current city - return array('entity' => $user_role_details[0]['fk_entity_id'],'city' => $user_role_details[0]['fk_city']); - case 19://Branch Sales - case 20://Branch Credit - //Get all PD's which were triggered in this entity id and current lender user id - return array('entity' => $user_role_details[0]['fk_entity_id'],'lender_credit_person' => $lender_user_id); - default: - return array(); - } + } + // PD listing based on lender role hierarchy + function getLenderHierarchyForPDListing($lender_user_id) + { + //get role of lender_user_id` + $user_role_details = $this->PD_Model->getLenderHierarchyForPDListing($lender_user_id); + //print_r($user_role_details);die(); + if (count($user_role_details)) { + $role_id = $user_role_details[0]['user_role']; + switch ($role_id) { + case 11: // National Sales Head + case 12: // National Credit Head + //Get all PD's which were triggered in this entity id + return array('entity' => $user_role_details[0]['fk_entity_id']); + case 13: // Zonal Sales Head + case 14: // Zonal Credit Head + //Get all cities id's from m_entity_region_mapping table using region_id / zone id + $temp_array = $this->PD_Model->selectCustomRecords(array('fk_city_id'), array('fk_region_id' => $user_role_details[0]['fk_region_id']), ENTITYREGION); + //Get all PD's which were triggered in this entity id and city id's in current zone + //$citiesInCurrentZone = array(10,20); + $citiesInCurrentZone = array(); + if (count($temp_array)) { + foreach ($temp_array as $key => $value) { + $citiesInCurrentZone = array_merge($citiesInCurrentZone, array($value['fk_city_id'])); + } + } + return array('entity' => $user_role_details[0]['fk_entity_id'], 'zone' => $citiesInCurrentZone); + case 15: //Area Sales Head + case 16: //Area Credit Head + //Get all PD's which were triggered in this entity id and city id's in current zone + return array('entity' => $user_role_details[0]['fk_entity_id'], 'state' => $user_role_details[0]['fk_state']); + case 17: //City Sales Head + case 18: //City Credit Head + //Get all PD's which were triggered in this entity id and current city + return array('entity' => $user_role_details[0]['fk_entity_id'], 'city' => $user_role_details[0]['fk_city']); + case 19: //Branch Sales + case 20: //Branch Credit + //Get all PD's which were triggered in this entity id and current lender user id + return array('entity' => $user_role_details[0]['fk_entity_id'], 'lender_credit_person' => $lender_user_id); + default: + return array(); } } + } - public function filterPDList_post() - { + public function filterPDList_post() + { //echo "Hi"; - $records = $this->post('records'); + $records = $this->post('records'); //print_r($this->post('records'));die(); - $pd_type = $records['pd_type']; + $pd_type = $records['pd_type']; //print_r($records);die(); - $pd_status = $records['pd_status']; - $pd_from_date = $records['pd_from_date']; - $pd_to_date = $records['pd_to_date']; - $pd_city = $records['pd_city']; - $pd_products = $records['pd_products']; - $pd_lender = $records['pd_lender']; - $pd_applicant_name = strtolower($records['pd_name']); - $pd_applicant_lender_ref = strtolower($records['pd_applicant_id']); - $pd_officer_name = isset($records['pd_officer']) ? $records['pd_officer'] : null ; - $pd_officer_id = isset($records['pd_officer_id']) ? $records['pd_officer_id'] : null ; - $include_archive = isset($records['is_include_archived']) ? $records['is_include_archived'] : null; - $pd_agency_id = isset($records['pd_agency_id']) ? $records['pd_agency_id'] : null; - $vendor_pdofficer = isset($records['vendor_pdofficer']) ? $records['vendor_pdofficer'] : null; - $user_type = isset($records['user_type']) ? $records['user_type'] : null; - $createdby = $records['createdby']; - // echo "B4 date_type ".$records['date_type']." and my return type is ".gettype($records['date_type'])."\n"; - $date_type = isset($records['date_type']) ? (int)$records['date_type'] : null; - // echo "After date_type ".$date_type." and my return type is ".gettype($date_type)."\n"; - $client = isset($records['client']) ? $records['client'] : null; - // $smc_agency_id = isset($records['smc_agency_id']) ? $records['smc_agency_id'] : null; - $is_smc_vendor = isset($records['is_smc_vendor']) ? $records['is_smc_vendor'] : null; - - $lender_details = array(); - //if lender id exists, then make custom filter for only SMC usage - - if($pd_lender) - { - $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo - if($pd_lender == $smc_lender_id) - { - $createdby = ''; - // $this->load->model('User_Management_Model'); - // $user_details = $this->User_Management_Model->getUserDetails($createdby); - // if($user_details['data'][0]['user_role'] == 26)//Credit Manager - // { - // $pd_officer_id = $createdby; - - // } - // else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager - // { - // $pd_city = array( $user_details['data'][0]['fk_city'] ); - - // } - + $pd_status = $records['pd_status']; + $pd_from_date = $records['pd_from_date']; + $pd_to_date = $records['pd_to_date']; + $pd_city = $records['pd_city']; + $pd_products = $records['pd_products']; + $pd_lender = $records['pd_lender']; + $pd_applicant_name = strtolower($records['pd_name']); + $pd_applicant_lender_ref = strtolower($records['pd_applicant_id']); + $pd_officer_name = isset($records['pd_officer']) ? $records['pd_officer'] : null; + $pd_officer_id = isset($records['pd_officer_id']) ? $records['pd_officer_id'] : null; + $include_archive = isset($records['is_include_archived']) ? $records['is_include_archived'] : null; + $pd_agency_id = isset($records['pd_agency_id']) ? $records['pd_agency_id'] : null; + $vendor_pdofficer = isset($records['vendor_pdofficer']) ? $records['vendor_pdofficer'] : null; + $user_type = isset($records['user_type']) ? $records['user_type'] : null; + $createdby = $records['createdby']; + // echo "B4 date_type ".$records['date_type']." and my return type is ".gettype($records['date_type'])."\n"; + $date_type = isset($records['date_type']) ? (int)$records['date_type'] : null; + // echo "After date_type ".$date_type." and my return type is ".gettype($date_type)."\n"; + $client = isset($records['client']) ? $records['client'] : null; + // $smc_agency_id = isset($records['smc_agency_id']) ? $records['smc_agency_id'] : null; + $is_smc_vendor = isset($records['is_smc_vendor']) ? $records['is_smc_vendor'] : null; - } + $lender_details = array(); + //if lender id exists, then make custom filter for only SMC usage + + if ($pd_lender) { + $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo + if ($pd_lender == $smc_lender_id) { + $createdby = ''; + // $this->load->model('User_Management_Model'); + // $user_details = $this->User_Management_Model->getUserDetails($createdby); + // if($user_details['data'][0]['user_role'] == 26)//Credit Manager + // { + // $pd_officer_id = $createdby; + + // } + // else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager + // { + // $pd_city = array( $user_details['data'][0]['fk_city'] ); + + // } - // $lender_details = $this->getLenderHierarchyForPDListing($lenderid); - - } - $result_data = $this->PD_Model->PDListwithGlobalFilters($pd_type,$pd_status,$pd_from_date,$pd_to_date,$pd_city,$pd_products,$pd_lender,$pd_applicant_name,$pd_applicant_lender_ref,$pd_officer_name,$include_archive,$pd_officer_id,$pd_agency_id,$vendor_pdofficer,$user_type,$createdby,$date_type,$client,$is_smc_vendor); - - if(count($result_data)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $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); - } + // $lender_details = $this->getLenderHierarchyForPDListing($lenderid); + } + $result_data = $this->PD_Model->PDListwithGlobalFilters($pd_type, $pd_status, $pd_from_date, $pd_to_date, $pd_city, $pd_products, $pd_lender, $pd_applicant_name, $pd_applicant_lender_ref, $pd_officer_name, $include_archive, $pd_officer_id, $pd_agency_id, $vendor_pdofficer, $user_type, $createdby, $date_type, $client, $is_smc_vendor); + + if (count($result_data)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $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); + } + } + /* * Get Full PD Details like all applicant's details, all PD related documents, PD Template and * answersd questions,PD History details. @@ -2371,81 +2164,74 @@ public function assignPDTempalate($data) $pdid = $this->post('pdid'); $random_string = $this->post('random_string'); // Get All PD Masters Details - $result_data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid,$random_string); + $result_data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid, $random_string); //Get All existing PD details of same applicants $result_data['exist_pd_details'] = $this->PD_Model->getExistPDdetails($pdid); - + // Get All Applicant's Details $result_data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); - + // Get All PD Related Documents - $result_data['pd_documnets'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,1); + $result_data['pd_documnets'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, 1); //Get All PD Template and It's Question with Answers $result_data['pd_question_answer'] = $this->PD_Model->getPDQuestionAnswers($pdid); - + //Get All PD Address $result_data['pd_address'] = $this->PD_Model->getPDAddress($pdid); - + //Get All PD COmpanies $result_data['pd_company'] = $this->PD_Model->getPDCompany($pdid); - + //Get Addtional Requirements details $result_data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); - + //Get Docs to be collected array $result_data['docs_to_be_collected'] = $this->PD_Model->getDocsToBeCollected($pdid); - - if($result_data['pd_master_details'][0]['fk_pd_type'] == 2 && !$result_data['pd_master_details'][0]['is_vendor_visit_disabled']) //smart pd get vendor forms status + + if ($result_data['pd_master_details'][0]['fk_pd_type'] == 2 && !$result_data['pd_master_details'][0]['is_vendor_visit_disabled']) //smart pd get vendor forms status { - $result_data['vendor_form_status'] = $this->PD_Model->getVendorFormStatus($pdid,$result_data['pd_master_details']); + $result_data['vendor_form_status'] = $this->PD_Model->getVendorFormStatus($pdid, $result_data['pd_master_details']); } - + //Get All PD Logs $result_data['pd_logs'] = $this->PD_Model->getPDLogs($pdid); //print_r($result_data['pd_logs']);die(); - if(count($result_data['pd_logs']) && isset($result_data['pd_logs']['last_status_update_date'])) - { + if (count($result_data['pd_logs']) && isset($result_data['pd_logs']['last_status_update_date'])) { $result_data['pd_master_details'][0]['maser_updatedon'] = $result_data['pd_master_details'][0]['updatedon']; - $result_data['pd_master_details'][0]['updatedon'] = DATE_FORMAT(date_create_from_format("Y-m-d H:i:s",$result_data['pd_logs']['last_status_update_date']),"d/m/Y h:i:s a"); + $result_data['pd_master_details'][0]['updatedon'] = DATE_FORMAT(date_create_from_format("Y-m-d H:i:s", $result_data['pd_logs']['last_status_update_date']), "d/m/Y h:i:s a"); } //print_r($result_data['pd_master_details']);die(); $applicant_msg = ''; $pd_docs_msg = ''; $pd_question_answer_msg = ''; $pd_logs_msg = ''; - - if(!count($result_data['applicants_details'])) - { + + if (!count($result_data['applicants_details'])) { $applicant_msg = 'Applicant Details Not Found'; } - - if(!count($result_data['pd_documnets'])) - { + + if (!count($result_data['pd_documnets'])) { $pd_docs_msg = 'Documents Not Found'; } - - if(!count($result_data['pd_question_answer'])) - { + + if (!count($result_data['pd_question_answer'])) { $pd_question_answer_msg = 'PD Details Not Found'; } - - if(!count($result_data['pd_logs']['master']) || !count($result_data['pd_logs']['child'])) - { + + if (!count($result_data['pd_logs']['master']) || !count($result_data['pd_logs']['child'])) { $pd_logs_msg = 'PD Logs Not Found'; } - + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $data['msg'] = array('applicant_msg'=>$applicant_msg,'pd_docs_msg'=>$pd_docs_msg,'pd_question_answer_msg'=>$pd_question_answer_msg,'pd_logs_msg'=>$pd_logs_msg); - $this->response($data,REST_Controller::HTTP_OK); - - + $data['msg'] = array('applicant_msg' => $applicant_msg, 'pd_docs_msg' => $pd_docs_msg, 'pd_question_answer_msg' => $pd_question_answer_msg, 'pd_logs_msg' => $pd_logs_msg); + $this->response($data, REST_Controller::HTTP_OK); } - + /******** for Load Whole PD Template for PD Screen @param template_id***************/ public function loadFullTemplate_get() { @@ -2453,40 +2239,42 @@ public function assignPDTempalate($data) $client = ""; $random_string = ""; $api = ""; - - if($this->get('pd_id')) { $pd_id = $this->get('pd_id'); } - if($this->get('client')) { $client = $this->get('client'); } - if($this->get('random_string')) { $random_string = $this->get('random_string'); } - if($this->get('api')) { $api = $this->get('api'); } - if($pd_id != "" || $pd_id != null) - { - - $template_details = $this->PD_Model->getTemplateForPD($pd_id,$client,$random_string,$api); - if(count($template_details)) - { + if ($this->get('pd_id')) { + $pd_id = $this->get('pd_id'); + } + if ($this->get('client')) { + $client = $this->get('client'); + } + if ($this->get('random_string')) { + $random_string = $this->get('random_string'); + } + if ($this->get('api')) { + $api = $this->get('api'); + } + + if ($pd_id != "" || $pd_id != null) { + + $template_details = $this->PD_Model->getTemplateForPD($pd_id, $client, $random_string, $api); + if (count($template_details)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $template_details; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Template Not for PD ID'.$pd_id; - $this->response($data,REST_Controller::HTTP_OK); + $data['msg'] = 'Template Not for PD ID' . $pd_id; + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_BAD_REQUEST; $data['msg'] = 'No Param Available'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } - + /******** Save Multiple/Single PD qustions ********/ public function saveActualPDQuestions_post() { @@ -2499,245 +2287,211 @@ public function assignPDTempalate($data) $answer_count = ""; $images_array = array(); $answers_array = array(); - - foreach($records as $record_key => $record) - { - - if($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null) - { - if($record['answers'] != "" || $record['answers'] != null) - { + foreach ($records as $record_key => $record) { + + if ($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null) { + + if ($record['answers'] != "" || $record['answers'] != null) { $answers_array = $record['answers']; unset($record['answers']); } - if($record['images'] != "" || $record['images'] != null) - { + if ($record['images'] != "" || $record['images'] != null) { $images_array = $record['images']; unset($record['images']); } $where_condition_array = array('pd_detail_id' => $record['pd_detail_id']); - $pd_detail_id = $this->PD_Model->updateRecords($record,PDDETAIL,$where_condition_array); - + $pd_detail_id = $this->PD_Model->updateRecords($record, PDDETAIL, $where_condition_array); + // ANSWERS SAVE - pd_detail_answer_id, fk_pd_id, fk_pd_detail_id, pd_answer_id, pd_answer, pd_answer_weightage, pd_answer_remark - if(count($answers_array)) - { - - - //Deactivate Old Answers + if (count($answers_array)) { + + + //Deactivate Old Answers $fields = array('pd_detail_answer_id'); - $where_condition_array = array('fk_pd_id' => $record['fk_pd_id'],'fk_pd_detail_id' => $record['pd_detail_id']); - $old_answers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDANSWER); - foreach($old_answers as $old) - { - $where_condition_array = array('pd_detail_answer_id'=>$old['pd_detail_answer_id']); + $where_condition_array = array('fk_pd_id' => $record['fk_pd_id'], 'fk_pd_detail_id' => $record['pd_detail_id']); + $old_answers = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDANSWER); + foreach ($old_answers as $old) { + $where_condition_array = array('pd_detail_answer_id' => $old['pd_detail_answer_id']); $temp_array = array('isactive' => 0); - $pd_detail_answer_id = $this->PD_Model->updateRecords($temp_array,PDANSWER,$where_condition_array); + $pd_detail_answer_id = $this->PD_Model->updateRecords($temp_array, PDANSWER, $where_condition_array); } - foreach($answers_array as $answer_key => $answer) - { - if($answer['pd_detail_answer_id'] == "" || $answer['pd_detail_answer_id'] == null) - { + foreach ($answers_array as $answer_key => $answer) { + if ($answer['pd_detail_answer_id'] == "" || $answer['pd_detail_answer_id'] == null) { - //INsert New Answers + //INsert New Answers $answer['fk_pd_detail_id'] = $record['pd_detail_id']; - $pd_detail_answer_id = $this->PD_Model->saveRecords($answer,PDANSWER); - if($pd_detail_answer_id != "" || $pd_detail_answer_id != null){ $answer_count++; } - - } - else - { - // Update Current Answer - $where_condition_array = array('pd_detail_answer_id'=>$answer['pd_detail_answer_id']); + $pd_detail_answer_id = $this->PD_Model->saveRecords($answer, PDANSWER); + if ($pd_detail_answer_id != "" || $pd_detail_answer_id != null) { + $answer_count++; + } + } else { + // Update Current Answer + $where_condition_array = array('pd_detail_answer_id' => $answer['pd_detail_answer_id']); $answer['isactive'] = 1; - $pd_detail_answer_id = $this->PD_Model->updateRecords($answer,PDANSWER,$where_condition_array); - if($pd_detail_answer_id != "" || $pd_detail_answer_id != null){ $answer_count++; } + $pd_detail_answer_id = $this->PD_Model->updateRecords($answer, PDANSWER, $where_condition_array); + if ($pd_detail_answer_id != "" || $pd_detail_answer_id != null) { + $answer_count++; + } } - } } - + //IMAGES SAVE - pd_document_id, fk_pd_id, fk_pd_detail_id, pd_document_title, pd_document_name, createdon, fk_createdby, updatedon, fk_updatedby - if(count($images_array)) - { - foreach($images_array as $image_key => $image) - { + if (count($images_array)) { + foreach ($images_array as $image_key => $image) { - //Get Lender ID - $sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"]; + //Get Lender ID + $sql = 'SELECT fk_lender_id FROM ' . PDTRIGGER . ' WHERE pd_id =' . $record["fk_pd_id"]; $lender_id = $this->db->query($sql)->result_array(); $temp_base64_string = $image['pd_document_name']; $title = $image['pd_document_title']; - $output_file = APPPATH."/docs/temp_base64_image.jpeg"; + $output_file = APPPATH . "/docs/temp_base64_image.jpeg"; - //Generate Random File Name + //Generate Random File Name $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').'.jpeg'; + $temp_file_name = $randomString . date('Y-m-d-H-i-s') . '.jpeg'; - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); + $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.$lender_id[0]['fk_lender_id']; - $key = 'pd'.$record['fk_pd_id'].'/'.$tempdocname ; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + $key = 'pd' . $record['fk_pd_id'] . '/' . $tempdocname; $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $image['pd_document_name'] = $tempdocname; $image['fk_pd_detail_id'] = $record['pd_detail_id']; $image['fk_pd_id'] = $record['fk_pd_id']; - $pd_document_id = $this->PD_Model->saveRecords($image,PDDOCUMENTS); - if($pd_document_id != "" || $pd_document_id != null){ $image_count++; } - + $pd_document_id = $this->PD_Model->saveRecords($image, PDDOCUMENTS); + if ($pd_document_id != "" || $pd_document_id != null) { + $image_count++; + } } - } } - - if(($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count) - { + + if (($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - - } - else - { + } else { - - if($record['answers'] != "" || $record['answers'] != null) - { + + if ($record['answers'] != "" || $record['answers'] != null) { $answers_array = $record['answers']; unset($record['answers']); } - if($record['images'] != "" || $record['images'] != null) - { + if ($record['images'] != "" || $record['images'] != null) { $images_array = $record['images']; unset($record['images']); } - //print_r($record);die(); - $pd_detail_id = $this->PD_Model->saveRecords($record,PDDETAIL); - + //print_r($record);die(); + $pd_detail_id = $this->PD_Model->saveRecords($record, PDDETAIL); + // ANSWERS SAVE - pd_detail_answer_id, fk_pd_id, fk_pd_detail_id, pd_answer_id, pd_answer, pd_answer_weightage, pd_answer_remark - if(count($answers_array)) - { - foreach($answers_array as $answer_key => $answer) - { + if (count($answers_array)) { + foreach ($answers_array as $answer_key => $answer) { $answer['fk_pd_detail_id'] = $pd_detail_id; - $pd_detail_answer_id = $this->PD_Model->saveRecords($answer,PDANSWER); - if($pd_detail_answer_id != "" || $pd_detail_answer_id != null){ $answer_count++; } + $pd_detail_answer_id = $this->PD_Model->saveRecords($answer, PDANSWER); + if ($pd_detail_answer_id != "" || $pd_detail_answer_id != null) { + $answer_count++; + } } } - + //IMAGES SAVE - pd_document_id, fk_pd_id, fk_pd_detail_id, pd_document_title, pd_document_name, createdon, fk_createdby, updatedon, fk_updatedby - if(count($images_array)) - { - foreach($images_array as $image_key => $image) - { + if (count($images_array)) { + foreach ($images_array as $image_key => $image) { - //Get Lender ID - $sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"]; + //Get Lender ID + $sql = 'SELECT fk_lender_id FROM ' . PDTRIGGER . ' WHERE pd_id =' . $record["fk_pd_id"]; $lender_id = $this->db->query($sql)->result_array(); $temp_base64_string = $image['pd_document_name']; $title = $image['pd_document_title']; - $output_file = APPPATH."/docs/temp_base64_image.jpeg"; + $output_file = APPPATH . "/docs/temp_base64_image.jpeg"; - //Generate Random File Name + //Generate Random File Name $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').'.jpeg'; + $temp_file_name = $randomString . date('Y-m-d-H-i-s') . '.jpeg'; - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); + $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.$lender_id[0]['fk_lender_id']; - $key = 'pd'.$record['fk_pd_id'].'/'.$tempdocname ; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + $key = 'pd' . $record['fk_pd_id'] . '/' . $tempdocname; $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $image['pd_document_name'] = $tempdocname; $image['fk_pd_detail_id'] = $record['pd_detail_id']; $image['fk_pd_id'] = $record['fk_pd_id']; - $pd_document_id = $this->PD_Model->saveRecords($image,PDDOCUMENTS); - if($pd_document_id != "" || $pd_document_id != null){ $image_count++; } - + $pd_document_id = $this->PD_Model->saveRecords($image, PDDOCUMENTS); + if ($pd_document_id != "" || $pd_document_id != null) { + $image_count++; + } } - } } - - if(($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count) - { + + if (($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $pd_detail_id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } - - - } - - - - - } - + /************** Get Answers for PD @params question_id, pd_id, template_id, category_id**************/ public function getAnswersForPD_post() { @@ -2746,41 +2500,37 @@ public function assignPDTempalate($data) $template_id = $this->post('template_id'); $category_id = $this->post('category_id'); - $answers = $this->PD_Model->getAnswersForPD($question_id,$pd_id,$template_id,$category_id); - - if(count($answers)) - { + $answers = $this->PD_Model->getAnswersForPD($question_id, $pd_id, $template_id, $category_id); + + if (count($answers)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $answers; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - - - - + + + + public function savePDFormDetailsJSON_post() { //ini_set('max_execution_time', 60); //$this->load->helper('INLINEPHOTOTRANSFORM'); - + // $size = mb_strlen(json_encode($this->post('records'), JSON_NUMERIC_CHECK), '8bit'); // echo $size; // die(); $records = $this->post('records'); $pdid = $records['pdid']; $formid = $records['formid']; - $templateid = isset($records['template_id'])?$records['template_id']:null; + $templateid = isset($records['template_id']) ? $records['template_id'] : null; $createdby = $records['fk_createdby']; $company_id = null; $processed_json = null; @@ -2790,35 +2540,33 @@ public function assignPDTempalate($data) $parent_form_index = null; $parent_forms = $this->config->item('parent_forms'); $additional_pd_id = $pdid; - - $custom_log_info = '###Payload Size - '. (int) $_SERVER['CONTENT_LENGTH'].' ###savePDFormDetailsJSON Function Called - PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - $logger = MYLOG::logFunction(null,$pdid); + $custom_log_info = '###Payload Size - ' . (int) $_SERVER['CONTENT_LENGTH'] . ' ###savePDFormDetailsJSON Function Called - PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + + $logger = MYLOG::logFunction(null, $pdid); $log_info_array['pdid'] = $pdid; $log_info_array['formid'] = $formid; $log_info_array['payload_size'] = (int) $_SERVER['CONTENT_LENGTH']; $log_info_array['payload_data'] = json_encode($records); - $logger->info("SAVE FORM JSON FUNCTION CALLED - ENV (".ENVIRONMENT.")",$log_info_array);//die(); + $logger->info("SAVE FORM JSON FUNCTION CALLED - ENV (" . ENVIRONMENT . ")", $log_info_array); //die(); ///die(); //$inline_forms_photo_status_check = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid),T_PD_INLINE_PHOTO_FORM_STATUS); - // print_r($inline_forms_photo_status_check); - // echo count($inline_forms_photo_status_check); - - if($pdid != $parent_pdid) - { - $parent_form_index = array_search($formid,$parent_forms); + // print_r($inline_forms_photo_status_check); + // echo count($inline_forms_photo_status_check); + + if ($pdid != $parent_pdid) { + $parent_form_index = array_search($formid, $parent_forms); $pdid = $parent_form_index != null ? $parent_pdid : $pdid; $records['pdid'] = $pdid; } - + // print_r($records); // die(); - if(isset($records['company_id'])) - { - $company_id = $records['company_id']; + if (isset($records['company_id'])) { + $company_id = $records['company_id']; } - + //Save Any New Applicants Details From General Form // if($formid == 18) // { @@ -2832,20 +2580,18 @@ public function assignPDTempalate($data) // } - if($formid == 10) - { + if ($formid == 10) { $this->updateSubProductFromLoanDetailsForm($records); - $custom_log_info = '###updateSubProductFromLoanDetailsForm Function Called PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); + $custom_log_info = '###updateSubProductFromLoanDetailsForm Function Called PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); } - //From Business form save Employee Salary as Business Expenses - if($formid == 13) - { - + //From Business form save Employee Salary as Business Expenses + if ($formid == 13) { + $this->saveEmpSalaryAsBusinessExpensesFromBusinessForm($records); - $custom_log_info = '###saveEmpSalaryAsBusinessExpensesFromBusinessForm Function Called PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); + $custom_log_info = '###saveEmpSalaryAsBusinessExpensesFromBusinessForm Function Called PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); // if(count($inline_forms_photo_status_check) && $inline_forms_photo_status_check[0]['is_business_photo_saved'] != 1) // { @@ -2854,1934 +2600,1673 @@ public function assignPDTempalate($data) // } } - if($formid == 22) - { - $this->saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records); - $custom_log_info = '###saveAssetRentAsBusinessExpensesFromBusinessAssestForm Function Called PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - } - - - $fields = array('isactive' => 0); - $where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid); - if($company_id != null) - { - $where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid,'company_id' => $company_id); + if ($formid == 22) { + $this->saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records); + $custom_log_info = '###saveAssetRentAsBusinessExpensesFromBusinessAssestForm Function Called PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); } - if($rental_count_id != null) - { + + $fields = array('isactive' => 0); + $where_condition_array = array('fk_form_id' => $formid, 'fk_pd_id' => $pdid); + if ($company_id != null) { + $where_condition_array = array('fk_form_id' => $formid, 'fk_pd_id' => $pdid, 'company_id' => $company_id); + } + + if ($rental_count_id != null) { $where_condition_array['rental_count_id'] = $rental_count_id; } - $id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array); - $custom_log_info = '###OLD Entries Deactivated PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - + $id = $this->PD_Model->updateRecords($fields, PDFORMDETAILSJSON, $where_condition_array); + $custom_log_info = '###OLD Entries Deactivated PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + /*****Call Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA******/ - if(PROCESSJSON == true) - { - switch($formid) - { - case 1: - $processed_json = GETPROCESSEDJSON::convertSupplierForm($records,$formid); - break; + if (PROCESSJSON == true) { + switch ($formid) { + case 1: + $processed_json = GETPROCESSEDJSON::convertSupplierForm($records, $formid); + break; - case 2: - $processed_json = GETPROCESSEDJSON::convertClientForm($records,$formid); - break; - case 4: - $processed_json = GETPROCESSEDJSON::convertOtherAssetForm($records,$formid); - //$processed_json = $records; - break; - case 5: - $processed_json = GETPROCESSEDJSON::convertAddressForm($records,$formid); - break; + case 2: + $processed_json = GETPROCESSEDJSON::convertClientForm($records, $formid); + break; + case 4: + $processed_json = GETPROCESSEDJSON::convertOtherAssetForm($records, $formid); + //$processed_json = $records; + break; + case 5: + $processed_json = GETPROCESSEDJSON::convertAddressForm($records, $formid); + break; case 6: - $processed_json = GETPROCESSEDJSON::convertOtherFamilyDetailsForm($records,$formid); - break; + $processed_json = GETPROCESSEDJSON::convertOtherFamilyDetailsForm($records, $formid); + break; case 8: - $processed_json = GETPROCESSEDJSON::convertExistingLoanDetailsForm($records,$formid); - break; - case 7: - $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); - break; - case 9: - $processed_json = GETPROCESSEDJSON::convertOtherIncomeDetailsForm($records,$formid); - break; - case 10: - $processed_json = GETPROCESSEDJSON::convertLoanDetailsForm($records,$formid); - break; + $processed_json = GETPROCESSEDJSON::convertExistingLoanDetailsForm($records, $formid); + break; + case 7: + $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records, $formid); + break; + case 9: + $processed_json = GETPROCESSEDJSON::convertOtherIncomeDetailsForm($records, $formid); + break; + case 10: + $processed_json = GETPROCESSEDJSON::convertLoanDetailsForm($records, $formid); + break; - case 11: //In Stock UOM Only - also coming Text - right now No need to convert. - $processed_json = GETPROCESSEDJSON::convertStockDetailsForm($records,$formid); + case 11: //In Stock UOM Only - also coming Text - right now No need to convert. + $processed_json = GETPROCESSEDJSON::convertStockDetailsForm($records, $formid); //print_r($processed_json);die(); - break; - case 12: - $processed_json = GETPROCESSEDJSON::convertEmploymetForm($records,$formid); - break; + break; + case 12: + $processed_json = GETPROCESSEDJSON::convertEmploymetForm($records, $formid); + break; - case 14: // There is no master Data in Financial Form - $processed_json = $records; - break; + case 14: // There is no master Data in Financial Form + $processed_json = $records; + break; - case 13: - $processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records,$formid); - break; - case 15: - $processed_json = $records; - break; - case 17: - $processed_json = GETPROCESSEDJSON::convertRentalIncomeDetailsForm($records,$formid); - break; - case 18: - $processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records,$formid); - break; + case 13: + $processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records, $formid); + break; + case 15: + $processed_json = $records; + break; + case 17: + $processed_json = GETPROCESSEDJSON::convertRentalIncomeDetailsForm($records, $formid); + break; + case 18: + $processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records, $formid); + break; - case 19: - $processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records,$formid); - break; - case 20: - $processed_json = GETPROCESSEDJSON::convertFinalRemarksForm($records,$formid); - break; + case 19: + $processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records, $formid); + break; + case 20: + $processed_json = GETPROCESSEDJSON::convertFinalRemarksForm($records, $formid); + break; - // Buiness Banking Form - case 21: - $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); - break; + // Buiness Banking Form + case 21: + $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records, $formid); + break; - case 22: - $processed_json = GETPROCESSEDJSON::convertBusinessAssetsForm($records,$formid); - break; - case 23: - $processed_json = $records; - break; + case 22: + $processed_json = GETPROCESSEDJSON::convertBusinessAssetsForm($records, $formid); + break; + case 23: + $processed_json = $records; + break; - case 24: - $processed_json = GETPROCESSEDJSON::convertCreditManagerQueriesForm($records,$formid); - $records['docs_to_be_sighted'] = isset($processed_json['docs_to_be_sighted']) ? $processed_json['docs_to_be_sighted'] : null; - unset($processed_json['docs_to_be_sighted']); + case 24: + $processed_json = GETPROCESSEDJSON::convertCreditManagerQueriesForm($records, $formid); + $records['docs_to_be_sighted'] = isset($processed_json['docs_to_be_sighted']) ? $processed_json['docs_to_be_sighted'] : null; + unset($processed_json['docs_to_be_sighted']); - //default: + //default: //echo "Something Wrong! Form ID did not match, Contact System Administrator"; + } } - } - $custom_log_info = '###Processed JSON Function Executed PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); + $custom_log_info = '###Processed JSON Function Executed PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); - /*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/ + /*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/ - unset($records['pdid']); - unset($records['formid']); - unset($records['fk_createdby']); - unset($records['company_id']); - unset($records['parent_pdid']); + unset($records['pdid']); + unset($records['formid']); + unset($records['fk_createdby']); + unset($records['company_id']); + unset($records['parent_pdid']); //unset($records['rental_count_id']); - $records = json_encode($records); - if($processed_json != null) - { - $processed_json = json_encode($processed_json); - } - - - $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id,'template_id'=>$templateid); - // $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id); - - $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON); - - $logger->info("SAVE FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); - if($id != "" || $id != null) - { - // Update form dummy entry against Additional PD common form ID to avoid every time fetch data from additional PD forms - scenarios like exist loan obligations, other family details - - // if($formid == 4)//other asset - here this should happen for only if it is additional PD. - // { - // $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$additional_pd_id,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id); - // $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON); - // } - // End Of update Additional Entry - if($temp_array['fk_form_id'] == 25) //vendor form id - { - $custom_log_info = '### Disable all forms VENDOR_FORMS_STATUS to zero - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - $this->PD_Model->updateRecords(array('form_status' => 0),VENDORFORMSTATUS,array('fk_pd_id' => $pdid)); + $records = json_encode($records); + if ($processed_json != null) { + $processed_json = json_encode($processed_json); } - $custom_log_info = '### JSON Saved Successfully PDID - ('. $pdid.' - '. $formid.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); + + $temp_array = array('fk_form_id' => $formid, 'company_id' => $company_id, 'fk_pd_id' => $pdid, 'fk_createdby' => $createdby, 'json' => $records, 'processed_json' => $processed_json, 'rental_count_id' => $rental_count_id, 'template_id' => $templateid); + // $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id); + + $id = $this->PD_Model->saveRecords($temp_array, PDFORMDETAILSJSON); + + $logger->info("SAVE FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); + if ($id != "" || $id != null) { + // Update form dummy entry against Additional PD common form ID to avoid every time fetch data from additional PD forms - scenarios like exist loan obligations, other family details + + // if($formid == 4)//other asset - here this should happen for only if it is additional PD. + // { + // $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$additional_pd_id,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id); + // $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON); + // } + // End Of update Additional Entry + if ($temp_array['fk_form_id'] == 25) //vendor form id + { + $custom_log_info = '### Disable all forms VENDOR_FORMS_STATUS to zero - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + $this->PD_Model->updateRecords(array('form_status' => 0), VENDORFORMSTATUS, array('fk_pd_id' => $pdid)); + } + $custom_log_info = '### JSON Saved Successfully PDID - (' . $pdid . ' - ' . $formid . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later..!'; + $this->response($data, REST_Controller::HTTP_OK); + } } - else + + + public function getPDFormDetailsJSON_post() { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later..!'; - $this->response($data,REST_Controller::HTTP_OK); - } -} - - -public function getPDFormDetailsJSON_post() -{ - $pd_id = $this->post('pd_id'); $pd_form_id = $this->post('pd_form_id'); - $parent_pd_id = $this->post('parent_pdid');// ? $this->post('parent_pd_id') : null; - $company_id = $this->post('company_id') ? $this->post('company_id') : null; - $parent_form_index = null; - $parent_forms = $this->config->item('parent_forms'); - $is_addtional_pd = 0; - $additional_pd_id = null; + $parent_pd_id = $this->post('parent_pdid'); // ? $this->post('parent_pd_id') : null; + $company_id = $this->post('company_id') ? $this->post('company_id') : null; + $parent_form_index = null; + $parent_forms = $this->config->item('parent_forms'); + $is_addtional_pd = 0; + $additional_pd_id = null; - $custom_log_info = '###getPDFormDetailsJSON Function Executed PDID - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); + $custom_log_info = '###getPDFormDetailsJSON Function Executed PDID - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); // echo "getPDFormDetails".$custom_log_info;die(); - log_message('ERROR',$custom_log_info); + log_message('ERROR', $custom_log_info); - if($pd_id != $parent_pd_id) - { - $is_addtional_pd = 1; - // list of common forms for addtional PD (Other Assets,Family Details,Banking Details of Individuals,Existing Loan Obligations,Other Income Details,Loan Details,Final Remarks Form) - $parent_form_index = array_search($pd_form_id,$parent_forms); - $additional_pd_id = $pd_id; - $pd_id = $parent_form_index != null ? $parent_pd_id : $pd_id; + if ($pd_id != $parent_pd_id) { + $is_addtional_pd = 1; + // list of common forms for addtional PD (Other Assets,Family Details,Banking Details of Individuals,Existing Loan Obligations,Other Income Details,Loan Details,Final Remarks Form) + $parent_form_index = array_search($pd_form_id, $parent_forms); + $additional_pd_id = $pd_id; + $pd_id = $parent_form_index != null ? $parent_pd_id : $pd_id; + } + $logger = MYLOG::logFunction(null, $pd_id); + $log_info_array['pdid'] = $pd_id; + $log_info_array['formid'] = $pd_form_id; + $logger->info("GET FORM JSON FUNCTION CALLED - ENV (" . ENVIRONMENT . ")", $log_info_array); - } - $logger = MYLOG::logFunction(null,$pd_id); - $log_info_array['pdid'] = $pd_id; - $log_info_array['formid'] = $pd_form_id; - $logger->info("GET FORM JSON FUNCTION CALLED - ENV (".ENVIRONMENT.")",$log_info_array); + if ($pd_form_id == 18) { - if($pd_form_id == 18) - { + $fields = array('json'); + $where_condition_array = array('fk_pd_id' => $pd_id, 'fk_form_id' => $pd_form_id, 'isactive' => 1); + $form_count = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + //print_r($form_count); + if (!count($form_count)) { + //echo "dsjsbsdj"; + $fields = array('json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => $pd_form_id, 'fk_pd_id' => $parent_pd_id); + $rec = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); - $fields = array('json'); - $where_condition_array = array('fk_pd_id' => $pd_id,'fk_form_id' =>$pd_form_id , 'isactive' => 1); - $form_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - //print_r($form_count); - if(!count($form_count)) - { - //echo "dsjsbsdj"; - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>$pd_form_id,'fk_pd_id'=>$parent_pd_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + if (count($rec)) { + $temp_json = $this->renewGeneralFormForAddtionalPD($rec[0]['json']); + $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); - if(count($rec)) - { - $temp_json = $this->renewGeneralFormForAddtionalPD($rec[0]['json']); - $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); + $custom_log_info = '###renewGeneralFormForAddtionalPD Function Called (ADDItional PD ) - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); - $custom_log_info = '###renewGeneralFormForAddtionalPD Function Called (ADDItional PD ) - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $temp_json; + $this->response($data, REST_Controller::HTTP_OK); + } + } + } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $temp_json; - $this->response($data,REST_Controller::HTTP_OK); - } - } - } - - - - if($is_addtional_pd == 1 && $pd_form_id == 5)//address form && ($parent_pd_id != $pd_id) - { - $fields = array('json'); - $where_condition_array = array('fk_pd_id' => $pd_id,'fk_form_id' =>$pd_form_id , 'isactive' => 1); - $form_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + if ($is_addtional_pd == 1 && $pd_form_id == 5) //address form && ($parent_pd_id != $pd_id) + { - if(count($form_count)) - { - $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); + $fields = array('json'); + $where_condition_array = array('fk_pd_id' => $pd_id, 'fk_form_id' => $pd_form_id, 'isactive' => 1); + $form_count = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); - $custom_log_info = '###Return Response FROM GET PD FORM JSON - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); + if (count($form_count)) { + $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = json_decode($form_count[0]['json']); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - //echo "get address details from address form"; - $fields = array('*'); - $where_condition_array = array('assigned_pd' => $pd_id); - $assigned_address = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDADDRESS); - if(count($assigned_address)) - { - $temp_address = $assigned_address[0]; - //print_r($temp_address); - //construct address form jsn format here - $address = array(); - $address[] = array('address' => $temp_address['addressline1'],'address_type' => "",'address_type_others' => '','state'=>$temp_address['fk_state'],'city'=>$temp_address['fk_city'],'citySearch' =>'','stateSearch'=>'','citySearch'=>'','pinSearch' => '','pincode'=>$temp_address['pincode'],'pincode_others' => '','locality' => '','locality_others'=>'','pd_location' => '','comment_locality' => '','estimated_area' => '','uom' => '','uom_others'=>''); + $custom_log_info = '###Return Response FROM GET PD FORM JSON - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); - $records['addresses'] = $address; - $records['address_form_remark'] = ''; - $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = json_decode($form_count[0]['json']); + $this->response($data, REST_Controller::HTTP_OK); + } else { + //echo "get address details from address form"; + $fields = array('*'); + $where_condition_array = array('assigned_pd' => $pd_id); + $assigned_address = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDADDRESS); + if (count($assigned_address)) { + $temp_address = $assigned_address[0]; + //print_r($temp_address); + //construct address form jsn format here + $address = array(); + $address[] = array('address' => $temp_address['addressline1'], 'address_type' => "", 'address_type_others' => '', 'state' => $temp_address['fk_state'], 'city' => $temp_address['fk_city'], 'citySearch' => '', 'stateSearch' => '', 'citySearch' => '', 'pinSearch' => '', 'pincode' => $temp_address['pincode'], 'pincode_others' => '', 'locality' => '', 'locality_others' => '', 'pd_location' => '', 'comment_locality' => '', 'estimated_area' => '', 'uom' => '', 'uom_others' => ''); - $custom_log_info = '###Return Response FROM GET PD FORM JSON (ADDRESS FORM ADDITIONAL PD) - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $records; - $this->response($data,REST_Controller::HTTP_OK); + $records['addresses'] = $address; + $records['address_form_remark'] = ''; + $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); - } - } - } - + $custom_log_info = '###Return Response FROM GET PD FORM JSON (ADDRESS FORM ADDITIONAL PD) - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>$pd_form_id,'fk_pd_id'=>$pd_id); - //print_r($where_condition_array); - if($company_id != null) - { - $where_condition_array = array('fk_form_id'=>$pd_form_id,'fk_pd_id'=>$pd_id,'company_id' => $company_id,'isactive' => 1); - } - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $records; + $this->response($data, REST_Controller::HTTP_OK); + } + } + } + + + $fields = array('json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => $pd_form_id, 'fk_pd_id' => $pd_id); + //print_r($where_condition_array); + if ($company_id != null) { + $where_condition_array = array('fk_form_id' => $pd_form_id, 'fk_pd_id' => $pd_id, 'company_id' => $company_id, 'isactive' => 1); + } + $rec = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); // echo "I have"; // print_r($rec);die(); - if(isset($rec[0]['json'])) - { - $temp_rec = json_decode($rec[0]['json'],true); - - if(($temp_rec)) - { - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - if($pd_form_id == 18) //General form - { - $custom_log_info = '###Get General FOrm IMG AWS urls & attach into JSON Function Called - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id,18,null,null,null); - - foreach($temp_rec['individuals'] as $g_key => $g_value) - { - //print_r( $g_value); + if (isset($rec[0]['json'])) { + $temp_rec = json_decode($rec[0]['json'], true); - if($g_value['is_person_met'] == true) - { - - - if(count($result_data)) - { - foreach($result_data as $img_key => $img_value) - { - //$temp_rec['individuals'][$g_key]['is_person_met_pic'] = ""; - //$temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = ""; - $applicant_name = trim($g_value['applicant_name']); - if( !strcasecmp($applicant_name,trim($img_value['pd_document_title']))) - { - $temp_rec['individuals'][$g_key]['is_person_met_pic'] = $img_value['doc_url']; - //echo 'SAME-'.$applicant_name.'-'.trim($img_value['pd_document_title']); - //echo $img_value['doc_url'];die(); - } - - if( !strcasecmp(($applicant_name.'-id_proof'),trim($img_value['pd_document_title'])) ) - { - $temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = $img_value['doc_url']; - } - } - } - } - else - { - $temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = ""; - $temp_rec['individuals'][$g_key]['is_person_met_pic'] = ""; - } - } - //print_r($temp_rec);die(); - $rec[0]['json'] = json_encode($temp_rec); - $custom_log_info = '###Get General FOrm IMG AWS urls & attach into JSON Function End - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - } - - - - if($pd_form_id == 13 ) //ABout Business form - { - - $custom_log_info = '###Get Business IMG AWS urls & attach into JSON Function Called - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - - $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id,13,$company_id,null,null,null,'report'); - - foreach($result_data as $b_key => $b_value) - { - if($b_value['pd_document_title'] == 'shop_eat_act_cert_pic') - { - $temp_rec['shop_eat_act_cert_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'gst_Regn_cert_pic') - { - $temp_rec['gst_Regn_cert_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'pf_regn_pic') - { - $temp_rec['pf_regn_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'esic_regn_pic') - { - $temp_rec['esic_regn_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'export_import_cert_pic') - { - $temp_rec['export_import_cert_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'factory_cert_pic') - { - $temp_rec['factory_cert_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'practice_cert_pic') - { - $temp_rec['practice_cert_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'fire_noc_pic') - { - $temp_rec['fire_noc_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'eb_bill_pic') - { - $temp_rec['eb_bill_pic'] = $b_value['doc_url']; - } - - - if(isset($temp_rec['documents']) && count($temp_rec['documents'])) - { - $temp_iter = $temp_rec['documents']; - - foreach ($temp_iter as $key => $value) { - - if( !strcasecmp($value['document'],trim($b_value['pd_document_title'])) && $value['document_pic']) - { - $temp_rec['documents'][$key]['document_pic'] = $b_value['doc_url']; - //unset($temp_iter[$key]); - //print_r($temp_iter); - break; - - } - // else - // { - // $temp_rec['documents'][$key]['document_pic'] = false; - // } - - } - } - } - //die(); - $rec[0]['json'] = json_encode($temp_rec); - $custom_log_info = '###Get Business IMG AWS urls & attach into JSON Function End - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - } - - if($pd_form_id == 12 ) //Employeement - { - - $custom_log_info = '###Get EMployee IMG AWS urls & attach into JSON Function Called - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - - $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id,12,null,null,null,null,'report'); - - foreach($result_data as $b_key => $b_value) - { - if($b_value['pd_document_title'] == 'attendance_seen_pic') - { - $temp_rec['attendance_seen_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'sal_reg_seen_pic') - { - $temp_rec['sal_reg_seen_pic'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'name_board_img') - { - $temp_rec['name_board_img'] = $b_value['doc_url']; - } - if($b_value['pd_document_title'] == 'id_card_image') - { - $temp_rec['id_card_image'] = $b_value['doc_url']; - } - - } - //die(); - $rec[0]['json'] = json_encode($temp_rec); - $custom_log_info = '###Get Employeement IMG AWS urls & attach into JSON Function End - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - } - } - - - } - // print_r($rec);die(); - // if(count($rec)) - // { - // if($pd_form_id == 8 && $is_addtional_pd == 1) - // { - // //echo "add"; - // $additional_count = $this->PD_Model->selectCustomRecords(array('*'),array('fk_form_id'=>8,'fk_pd_id'=>$additional_pd_id,'company_id' => $company_id,'isactive' => 1),PDFORMDETAILSJSON); - // if(!count($additional_count)) - // { - - // //get addtional PD business and other assets details and attach it with existing loan Obligation From(Parent PD existing Loan JSON Details). - // $json = $this->getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($rec[0]['json'],$pd_id,$additional_pd_id,$company_id); - - // $data['dataStatus'] = true; - // $data['status'] = REST_Controller::HTTP_OK; - // $data['records'] = $json; - // $this->response($data,REST_Controller::HTTP_OK); - // } - // } - // } - - - if(count($rec)) - { - $json = null; - if($pd_form_id == 17) - { - - foreach($rec as $r) - { - - $json[] = json_decode($r['json'],true); - } - } - else if($pd_form_id == 24) //// common form credit managers specific queries - { - $json = $this->getDocsToBeSightedImagesS3URL( json_decode($rec[0]['json'],true),$pd_id ); - } - else - { - $json = json_decode($rec[0]['json']); - } - - $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); - - $custom_log_info = '###Return Response FROM GET PD FORM JSON - ('. $pd_id.' - '. $pd_form_id.') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $json; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (".ENVIRONMENT.")",$log_info_array); - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Data Available'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - } - - //get documents to be sight form images S3 url's and fetch it to frond end form - function getDocsToBeSightedImagesS3URL( $credit_manager_form_data,$pd_id ) - { - $pd_documnets = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'fk_form_id' => 24),PDDOCUMENTS); + if (($temp_rec)) { $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - if(count($pd_documnets)) + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + if ($pd_form_id == 18) //General form { - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - //echo $bucketname; - //print_r($credit_manager_form_data);die(); - foreach ($pd_documnets as $doc_key => $doc_value) { + $custom_log_info = '###Get General FOrm IMG AWS urls & attach into JSON Function Called - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id, 18, null, null, null); - if(is_array($credit_manager_form_data['docs_to_be_sighted']) && count($credit_manager_form_data['docs_to_be_sighted'])) - { - foreach ($credit_manager_form_data['docs_to_be_sighted'] as $docs_to_be_sighted_key => $docs_to_be_sighted_value) - { - if(isset($docs_to_be_sighted_value['img']) && $docs_to_be_sighted_value['img'] == $doc_value['pd_document_id']) - { - $key = 'pd'.$pd_id.'/'.$doc_value['pd_document_name']; - //echo $key;die(); - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - //echo $doc_value['pd_document_id'] .'********'.$singed_uri.'*******'; - $credit_manager_form_data['docs_to_be_sighted'][$docs_to_be_sighted_key]['img'] = $singed_uri; + foreach ($temp_rec['individuals'] as $g_key => $g_value) { + //print_r( $g_value); + if ($g_value['is_person_met'] == true) { + + + if (count($result_data)) { + foreach ($result_data as $img_key => $img_value) { + //$temp_rec['individuals'][$g_key]['is_person_met_pic'] = ""; + //$temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = ""; + $applicant_name = trim($g_value['applicant_name']); + if (!strcasecmp($applicant_name, trim($img_value['pd_document_title']))) { + $temp_rec['individuals'][$g_key]['is_person_met_pic'] = $img_value['doc_url']; + //echo 'SAME-'.$applicant_name.'-'.trim($img_value['pd_document_title']); + //echo $img_value['doc_url'];die(); + } + + if (!strcasecmp(($applicant_name . '-id_proof'), trim($img_value['pd_document_title']))) { + $temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = $img_value['doc_url']; + } } } + } else { + $temp_rec['individuals'][$g_key]['is_person_met_id_proof'] = ""; + $temp_rec['individuals'][$g_key]['is_person_met_pic'] = ""; + } + } + //print_r($temp_rec);die(); + $rec[0]['json'] = json_encode($temp_rec); + $custom_log_info = '###Get General FOrm IMG AWS urls & attach into JSON Function End - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + } + + + + if ($pd_form_id == 13) //ABout Business form + { + + $custom_log_info = '###Get Business IMG AWS urls & attach into JSON Function Called - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + + $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id, 13, $company_id, null, null, null, 'report'); + + foreach ($result_data as $b_key => $b_value) { + if ($b_value['pd_document_title'] == 'shop_eat_act_cert_pic') { + $temp_rec['shop_eat_act_cert_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'gst_Regn_cert_pic') { + $temp_rec['gst_Regn_cert_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'pf_regn_pic') { + $temp_rec['pf_regn_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'esic_regn_pic') { + $temp_rec['esic_regn_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'export_import_cert_pic') { + $temp_rec['export_import_cert_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'factory_cert_pic') { + $temp_rec['factory_cert_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'practice_cert_pic') { + $temp_rec['practice_cert_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'fire_noc_pic') { + $temp_rec['fire_noc_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'eb_bill_pic') { + $temp_rec['eb_bill_pic'] = $b_value['doc_url']; + } + + + if (isset($temp_rec['documents']) && count($temp_rec['documents'])) { + $temp_iter = $temp_rec['documents']; + + foreach ($temp_iter as $key => $value) { + + if (!strcasecmp($value['document'], trim($b_value['pd_document_title'])) && $value['document_pic']) { + $temp_rec['documents'][$key]['document_pic'] = $b_value['doc_url']; + //unset($temp_iter[$key]); + //print_r($temp_iter); + break; + } + // else + // { + // $temp_rec['documents'][$key]['document_pic'] = false; + // } + + } } } + //die(); + $rec[0]['json'] = json_encode($temp_rec); + $custom_log_info = '###Get Business IMG AWS urls & attach into JSON Function End - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); } - return $credit_manager_form_data; + + if ($pd_form_id == 12) //Employeement + { + + $custom_log_info = '###Get EMployee IMG AWS urls & attach into JSON Function Called - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + + $result_data = $this->PD_Model->getSignedPDDocsURL($pd_id, 12, null, null, null, null, 'report'); + + foreach ($result_data as $b_key => $b_value) { + if ($b_value['pd_document_title'] == 'attendance_seen_pic') { + $temp_rec['attendance_seen_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'sal_reg_seen_pic') { + $temp_rec['sal_reg_seen_pic'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'name_board_img') { + $temp_rec['name_board_img'] = $b_value['doc_url']; + } + if ($b_value['pd_document_title'] == 'id_card_image') { + $temp_rec['id_card_image'] = $b_value['doc_url']; + } + } + //die(); + $rec[0]['json'] = json_encode($temp_rec); + $custom_log_info = '###Get Employeement IMG AWS urls & attach into JSON Function End - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + } + } + } + // print_r($rec);die(); + // if(count($rec)) + // { + // if($pd_form_id == 8 && $is_addtional_pd == 1) + // { + // //echo "add"; + // $additional_count = $this->PD_Model->selectCustomRecords(array('*'),array('fk_form_id'=>8,'fk_pd_id'=>$additional_pd_id,'company_id' => $company_id,'isactive' => 1),PDFORMDETAILSJSON); + // if(!count($additional_count)) + // { + + // //get addtional PD business and other assets details and attach it with existing loan Obligation From(Parent PD existing Loan JSON Details). + // $json = $this->getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($rec[0]['json'],$pd_id,$additional_pd_id,$company_id); + + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['records'] = $json; + // $this->response($data,REST_Controller::HTTP_OK); + // } + // } + // } + + + if (count($rec)) { + $json = null; + if ($pd_form_id == 17) { + + foreach ($rec as $r) { + + $json[] = json_decode($r['json'], true); + } + } else if ($pd_form_id == 24) //// common form credit managers specific queries + { + $json = $this->getDocsToBeSightedImagesS3URL(json_decode($rec[0]['json'], true), $pd_id); + } else { + $json = json_decode($rec[0]['json']); } + $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); - public function getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($parentpd_existing_loan_details,$pd_id,$additional_pd_id,$company_id = null) - { - $parentpd_existing_loan_details = json_decode($parentpd_existing_loan_details,true); - //echo 'getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets'; - //Get Other Assets - $fields = array('json','processed_json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>4,'fk_pd_id'=>$pd_id); - $other_assests = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - - - //Get Business Assets - $fields = array('json','processed_json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>22,'fk_pd_id'=>$additional_pd_id); + $custom_log_info = '###Return Response FROM GET PD FORM JSON - (' . $pd_id . ' - ' . $pd_form_id . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); - if($company_id != null) - { - $where_condition_array['company_id'] = $company_id; - } - $business_assests = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $json; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $logger->info("GET FORM JSON FUNCTION RESPONSE - ENV (" . ENVIRONMENT . ")", $log_info_array); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Data Available'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - if(count($other_assests)) - { - $other_assests = json_decode($other_assests[0]['json'],true); - //print_r($other_assests); - foreach($other_assests['assets_details'] as $other_assest) - { + //get documents to be sight form images S3 url's and fetch it to frond end form + function getDocsToBeSightedImagesS3URL($credit_manager_form_data, $pd_id) + { + $pd_documnets = $this->PD_Model->selectCustomRecords(array('*'), array('fk_pd_id' => $pd_id, 'fk_form_id' => 24), PDDOCUMENTS); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + if (count($pd_documnets)) { + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + //echo $bucketname; + //print_r($credit_manager_form_data);die(); + foreach ($pd_documnets as $doc_key => $doc_value) { - if($other_assest['emi'] == 'yes') - { - $converted_data = $this->convertOtherAssetAsExistingLoanParams($other_assest); - //print_r($converted_data); - $parentpd_existing_loan_details['loan_details'][] = $converted_data; - } - - } - - - } - - if(count($business_assests)) - { - $business_assests = json_decode($business_assests[0]['json'],true); - //print_r($other_assests); - - if(isset($business_assests['business_assets_for_address'])) - { - if($business_assests['business_assets_for_address'][0]['business_emi'] == 'yes') - { - $data['loan_amount'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $data['current_balance_tenure'] = ""; - $data['elapsed_tenure'] = ""; - $data['label'] = $business_assests['business_assets_for_address'][0]['address_label']; - $parentpd_existing_loan_details['loan_details'][] = $data; + if (is_array($credit_manager_form_data['docs_to_be_sighted']) && count($credit_manager_form_data['docs_to_be_sighted'])) { + foreach ($credit_manager_form_data['docs_to_be_sighted'] as $docs_to_be_sighted_key => $docs_to_be_sighted_value) { + if (isset($docs_to_be_sighted_value['img']) && $docs_to_be_sighted_value['img'] == $doc_value['pd_document_id']) { + $key = 'pd' . $pd_id . '/' . $doc_value['pd_document_name']; + //echo $key;die(); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes'); + //echo $doc_value['pd_document_id'] .'********'.$singed_uri.'*******'; + $credit_manager_form_data['docs_to_be_sighted'][$docs_to_be_sighted_key]['img'] = $singed_uri; } } - foreach($business_assests['business_assets_details'] as $business_assest) - { - if($business_assest['business_emi'] == 'yes') - { - $converted_data = $this->convertBusinessAssetAsExistingLoanParams($business_assest); - - $parentpd_existing_loan_details['loan_details'][] = $converted_data; - } - - } - - - } - - - return $parentpd_existing_loan_details; } + } + return $credit_manager_form_data; + } - function convertBusinessAssetAsExistingLoanParams($business_assest) - { - $data['loan_amount'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $data['current_balance_tenure'] = ""; - $data['elapsed_tenure'] = ""; - $label = null; - $fields = array('*'); - $where_condition_array = array('isactive' => 1); - $investment_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,INVESTMENTTYPE); + public function getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($parentpd_existing_loan_details, $pd_id, $additional_pd_id, $company_id = null) + { + $parentpd_existing_loan_details = json_decode($parentpd_existing_loan_details, true); + //echo 'getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets'; + //Get Other Assets + $fields = array('json', 'processed_json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 4, 'fk_pd_id' => $pd_id); + $other_assests = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); - $fields = array('*'); - $where_condition_array = array('isactive' => 1); - $property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES); + + //Get Business Assets + $fields = array('json', 'processed_json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 22, 'fk_pd_id' => $additional_pd_id); + + if ($company_id != null) { + $where_condition_array['company_id'] = $company_id; + } + $business_assests = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + + if (count($other_assests)) { + $other_assests = json_decode($other_assests[0]['json'], true); + //print_r($other_assests); + foreach ($other_assests['assets_details'] as $other_assest) { + + if ($other_assest['emi'] == 'yes') { + $converted_data = $this->convertOtherAssetAsExistingLoanParams($other_assest); + //print_r($converted_data); + $parentpd_existing_loan_details['loan_details'][] = $converted_data; + } + } + } + + if (count($business_assests)) { + $business_assests = json_decode($business_assests[0]['json'], true); + //print_r($other_assests); + + if (isset($business_assests['business_assets_for_address'])) { + if ($business_assests['business_assets_for_address'][0]['business_emi'] == 'yes') { + $data['loan_amount'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $data['current_balance_tenure'] = ""; + $data['elapsed_tenure'] = ""; + $data['label'] = $business_assests['business_assets_for_address'][0]['address_label']; + $parentpd_existing_loan_details['loan_details'][] = $data; + } + } + foreach ($business_assests['business_assets_details'] as $business_assest) { + if ($business_assest['business_emi'] == 'yes') { + $converted_data = $this->convertBusinessAssetAsExistingLoanParams($business_assest); + + $parentpd_existing_loan_details['loan_details'][] = $converted_data; + } + } + } + + + return $parentpd_existing_loan_details; + } + + function convertBusinessAssetAsExistingLoanParams($business_assest) + { + $data['loan_amount'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $data['current_balance_tenure'] = ""; + $data['elapsed_tenure'] = ""; + $label = null; + + $fields = array('*'); + $where_condition_array = array('isactive' => 1); + $investment_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, INVESTMENTTYPE); + + $fields = array('*'); + $where_condition_array = array('isactive' => 1); + $property_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PROPERTIES); // print_r($investment_types); - //print_r($other_assest); - switch($business_assest['business_assets_mode']) - { - case 7 : - $label = $business_assest['business_name_of_the_owner'][0]['name'].' - Investments ('. $investment_types[ ($business_assest['details'][0]['investments_type'] - 1) ]['name'] .')'; - break; + //print_r($other_assest); + switch ($business_assest['business_assets_mode']) { + case 7: + $label = $business_assest['business_name_of_the_owner'][0]['name'] . ' - Investments (' . $investment_types[($business_assest['details'][0]['investments_type'] - 1)]['name'] . ')'; + break; - case 4 : - $label = $business_assest['business_name_of_the_owner'][0]['name'].' - Equipment & Machinary ('. ($business_assest['details'][0]['equipment_manufacturing_description']) .')'; - break; + case 4: + $label = $business_assest['business_name_of_the_owner'][0]['name'] . ' - Equipment & Machinary (' . ($business_assest['details'][0]['equipment_manufacturing_description']) . ')'; + break; - case 6 : - $label = $business_assest['business_name_of_the_owner'][0]['name'].' - Life Insurance Policy'; - break; + case 6: + $label = $business_assest['business_name_of_the_owner'][0]['name'] . ' - Life Insurance Policy'; + break; - case 2 : - $label = $business_assest['business_name_of_the_owner'][0]['name'].' - Property ('. ($property_types[ $business_assest['details'][0]['property_type'] - 1]['name']) .')'; - break; - } - $data['label'] = $label; - return $data; - } + case 2: + $label = $business_assest['business_name_of_the_owner'][0]['name'] . ' - Property (' . ($property_types[$business_assest['details'][0]['property_type'] - 1]['name']) . ')'; + break; + } + $data['label'] = $label; + return $data; + } - function convertOtherAssetAsExistingLoanParams($other_assest) - { - //echo 'convertOtherAssetAsExistingLoanParams'; - $data['loan_amount'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $data['current_balance_tenure'] = ""; - $data['elapsed_tenure'] = ""; - $label = null; + function convertOtherAssetAsExistingLoanParams($other_assest) + { + //echo 'convertOtherAssetAsExistingLoanParams'; + $data['loan_amount'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $data['current_balance_tenure'] = ""; + $data['elapsed_tenure'] = ""; + $label = null; - $fields = array('*'); - $where_condition_array = array('isactive' => 1); - $investment_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,INVESTMENTTYPE); + $fields = array('*'); + $where_condition_array = array('isactive' => 1); + $investment_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, INVESTMENTTYPE); - $fields = array('*'); - $where_condition_array = array('isactive' => 1); - $property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES); + $fields = array('*'); + $where_condition_array = array('isactive' => 1); + $property_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PROPERTIES); // print_r($investment_types); - //print_r($other_assest); - switch($other_assest['assets_mode']) - { - case 7 : - $label = $other_assest['name_of_the_owner'][0]['name'].' - Investments ('. $investment_types[ ($other_assest['details'][0]['investments_type'] - 1) ]['name'] .')'; - break; + //print_r($other_assest); + switch ($other_assest['assets_mode']) { + case 7: + $label = $other_assest['name_of_the_owner'][0]['name'] . ' - Investments (' . $investment_types[($other_assest['details'][0]['investments_type'] - 1)]['name'] . ')'; + break; - case 4 : - $label = $other_assest['name_of_the_owner'][0]['name'].' - Equipment & Machinary ('. ($other_assest['details'][0]['equipment_manufacturing_description']) .')'; - break; + case 4: + $label = $other_assest['name_of_the_owner'][0]['name'] . ' - Equipment & Machinary (' . ($other_assest['details'][0]['equipment_manufacturing_description']) . ')'; + break; - case 6 : - $label = $other_assest['name_of_the_owner'][0]['name'].' - Life Insurance Policy'; - break; + case 6: + $label = $other_assest['name_of_the_owner'][0]['name'] . ' - Life Insurance Policy'; + break; - case 2 : - $label = $other_assest['name_of_the_owner'][0]['name'].' - Property ('. ($property_types[ $other_assest['details'][0]['property_type'] - 1]['name']) .')'; - break; + case 2: + $label = $other_assest['name_of_the_owner'][0]['name'] . ' - Property (' . ($property_types[$other_assest['details'][0]['property_type'] - 1]['name']) . ')'; + break; - //case - } - $data['label'] = $label; - return $data; - } + //case + } + $data['label'] = $label; + return $data; + } - public function renewGeneralFormForAddtionalPD($json) - { + public function renewGeneralFormForAddtionalPD($json) + { //echo 'renewGeneralFormForAddtionalPD'; - $json = json_decode($json,true); - if(array_key_exists('individuals',$json)) - { - foreach($json['individuals'] as $individual_key => $individual) - { - $json['individuals'][$individual_key]['is_person_met'] = false; - } - } - - if(array_key_exists('companies',$json)) - { - foreach($json['companies'] as $company_key => $compnay) - { - //print_r($company); - $json['companies'][$company_key]['is_company_applicant'] = false; - $json['companies'][$company_key]['business_entity_type'] = null; - $json['companies'][$company_key]['business_years'] = ""; - $json['companies'][$company_key]['business_month'] = ""; - $json['companies'][$company_key]['business_date_object'] = ""; - //$json['companies'][$company_key]['business_date_object'] = ""; - } - } - $json['company_with_relationships'][] = array('applicant_name' => "",'company_relationship' => '','relation_to_company' => ""); - $json['general_remark'] = ""; - - return (($json)); - + $json = json_decode($json, true); + if (array_key_exists('individuals', $json)) { + foreach ($json['individuals'] as $individual_key => $individual) { + $json['individuals'][$individual_key]['is_person_met'] = false; } + } - public function downloadExcel_get() - { - $this->excel->setActiveSheetIndex(0)->mergeCells('F3:M3'); - $this->excel->getActiveSheet()->setTitle('Material Master'); - $this->excel->getActiveSheet()->setCellValue('F3', 'SIDDHARTH INDUSTRIES Material Master'); - $filename = 'MaterialMaster'.'.xls'; //save our workbook as this file name - header('Content-Type: application/vnd.ms-excel'); //mime type - header('Access-Control-Expose-Headers:Content-Disposition'); //mime type - header('Content-Disposition: attachment;filename="' . $filename . '"'); //tell browser what's the file name - header('Cache-Control: max-age=0'); //no cache - $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); - if (ob_get_contents()) ob_end_clean(); - ob_start(); - $objWriter->save('php://output'); - } + if (array_key_exists('companies', $json)) { + foreach ($json['companies'] as $company_key => $compnay) { + //print_r($company); + $json['companies'][$company_key]['is_company_applicant'] = false; + $json['companies'][$company_key]['business_entity_type'] = null; + $json['companies'][$company_key]['business_years'] = ""; + $json['companies'][$company_key]['business_month'] = ""; + $json['companies'][$company_key]['business_date_object'] = ""; + //$json['companies'][$company_key]['business_date_object'] = ""; + } + } + $json['company_with_relationships'][] = array('applicant_name' => "", 'company_relationship' => '', 'relation_to_company' => ""); + $json['general_remark'] = ""; + + return (($json)); + } + + public function downloadExcel_get() + { + $this->excel->setActiveSheetIndex(0)->mergeCells('F3:M3'); + $this->excel->getActiveSheet()->setTitle('Material Master'); + $this->excel->getActiveSheet()->setCellValue('F3', 'SIDDHARTH INDUSTRIES Material Master'); + $filename = 'MaterialMaster' . '.xls'; //save our workbook as this file name + header('Content-Type: application/vnd.ms-excel'); //mime type + header('Access-Control-Expose-Headers:Content-Disposition'); //mime type + header('Content-Disposition: attachment;filename="' . $filename . '"'); //tell browser what's the file name + header('Cache-Control: max-age=0'); //no cache + $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); + if (ob_get_contents()) ob_end_clean(); + ob_start(); + $objWriter->save('php://output'); + } //Save Co applicants details from General Form - public function saveCoApplicantsFromGeneralInfoForm($records) - { + public function saveCoApplicantsFromGeneralInfoForm($records) + { //print_r($records);die(); - if(count($records['individuals'])) - { - //echo 'saveCoApplicantsFromGeneralInfoForm'; - $exist_applicants = $this->PD_Model->getApplicantsDetails($records['pdid']); - //print_r($exist_applicants); - //echo "Yes"; - $index_of_new_applicants = array(); - foreach($records['individuals'] as $applicant_key => $new_applicant) - { - $count = 0; + if (count($records['individuals'])) { + //echo 'saveCoApplicantsFromGeneralInfoForm'; + $exist_applicants = $this->PD_Model->getApplicantsDetails($records['pdid']); + //print_r($exist_applicants); + //echo "Yes"; + $index_of_new_applicants = array(); + foreach ($records['individuals'] as $applicant_key => $new_applicant) { + $count = 0; - if($new_applicant['is_new'] == true && ($new_applicant['is_applicant'] == true || $new_applicant['is_person_met'] == true)) - { + if ($new_applicant['is_new'] == true && ($new_applicant['is_applicant'] == true || $new_applicant['is_person_met'] == true)) { - $current_temp_id = $new_applicant['pd_co_applicant_id']; - $temp_array = array(); - if($new_applicant['is_person_met'] == true) - { - $temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>3,'applicant_title_name'=>$new_applicant['applicant_title_name']); - } + $current_temp_id = $new_applicant['pd_co_applicant_id']; + $temp_array = array(); + if ($new_applicant['is_person_met'] == true) { + $temp_array = array('fk_pd_id' => $records['pdid'], 'applicant_name' => $new_applicant['applicant_name'], 'applicant_type' => 3, 'applicant_title_name' => $new_applicant['applicant_title_name']); + } - if($new_applicant['is_applicant'] == true) - { - $temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>0,'applicant_title_name'=>$new_applicant['applicant_title_name']); - } - $new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array,PDAPPLICANTSDETAILS); + if ($new_applicant['is_applicant'] == true) { + $temp_array = array('fk_pd_id' => $records['pdid'], 'applicant_name' => $new_applicant['applicant_name'], 'applicant_type' => 0, 'applicant_title_name' => $new_applicant['applicant_title_name']); + } + $new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array, PDAPPLICANTSDETAILS); - if($new_co_appliacant_id != null || $new_co_appliacant_id != "") - { - $records['individuals'][$applicant_key]['pd_co_applicant_id'] = $new_co_appliacant_id; - $records['individuals'][$applicant_key]['is_new'] = false; + if ($new_co_appliacant_id != null || $new_co_appliacant_id != "") { + $records['individuals'][$applicant_key]['pd_co_applicant_id'] = $new_co_appliacant_id; + $records['individuals'][$applicant_key]['is_new'] = false; - if(array_key_exists('persons_with_relationships',$records)) - { - foreach($records['persons_with_relationships'] as $persons_with_relationship_key => $persons_with_relationship) - { - if($persons_with_relationship['pd_co_applicant_id'] == $current_temp_id) - { - $records['persons_with_relationships'][$persons_with_relationship_key]['pd_co_applicant_id'] = $new_co_appliacant_id; - } + if (array_key_exists('persons_with_relationships', $records)) { + foreach ($records['persons_with_relationships'] as $persons_with_relationship_key => $persons_with_relationship) { + if ($persons_with_relationship['pd_co_applicant_id'] == $current_temp_id) { + $records['persons_with_relationships'][$persons_with_relationship_key]['pd_co_applicant_id'] = $new_co_appliacant_id; + } - if($persons_with_relationship['relation_to'] == $current_temp_id) - { - $records['persons_with_relationships'][$persons_with_relationship_key]['relation_to'] = $new_co_appliacant_id; - } - } - } + if ($persons_with_relationship['relation_to'] == $current_temp_id) { + $records['persons_with_relationships'][$persons_with_relationship_key]['relation_to'] = $new_co_appliacant_id; + } + } + } - if(array_key_exists('company_with_relationships',$records)) - { - foreach($records['company_with_relationships'] as $company_with_relationship_key => $company_with_relationship) - { - if($company_with_relationship['applicant_name'] == $current_temp_id) - { - $records['company_with_relationships'][$company_with_relationship_key]['applicant_name'] = $new_co_appliacant_id; - } + if (array_key_exists('company_with_relationships', $records)) { + foreach ($records['company_with_relationships'] as $company_with_relationship_key => $company_with_relationship) { + if ($company_with_relationship['applicant_name'] == $current_temp_id) { + $records['company_with_relationships'][$company_with_relationship_key]['applicant_name'] = $new_co_appliacant_id; + } + } + } - } - } + /*################### LOGGING #########################*/ + $logger = MYLOG::logFunction(null, $records['pdid']); + $temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; + $logger->info("APPLICANT ADDED FROM GENERAL FORM - ENV (" . ENVIRONMENT . ")", $temp_array); - /*################### LOGGING #########################*/ - $logger = MYLOG::logFunction(null,$records['pdid']); - $temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; - $logger->info("APPLICANT ADDED FROM GENERAL FORM - ENV (".ENVIRONMENT.")",$temp_array); + /*################### LOGGING #########################*/ + } + } + // if($new_applicant['is_new'] == false) + // { - /*################### LOGGING #########################*/ + // $temp_array = array(); + // $where_condition_array = array('pd_co_applicant_id'=>$new_applicant['pd_co_applicant_id']); + // if($new_applicant['is_person_met'] == true) + // { + // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>3,'applicant_title_name'=>$new_applicant['applicant_title_name']); + // } - } + // if($new_applicant['is_applicant'] == true) + // { + // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>0,'applicant_title_name'=>$new_applicant['applicant_title_name']); + // } + // if($new_applicant['is_main_applicant'] == true) + // { + // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>1,'applicant_title_name'=>$new_applicant['applicant_title_name']); + // } + // $new_co_appliacant_id = $this->PD_Model->updateRecords($temp_array,PDAPPLICANTSDETAILS,$where_condition_array); + // if($new_co_appliacant_id != "" || $new_co_appliacant_id != null) + // { + // /*################### LOGGING #########################*/ - } + // $logger = MYLOG::logFunction(); + // $temp_array['pd_co_applicant_id'] = $new_applicant['pd_co_applicant_id']; + // $logger->info("APPLICANT EDITED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$temp_array); - // if($new_applicant['is_new'] == false) - // { - // $temp_array = array(); - // $where_condition_array = array('pd_co_applicant_id'=>$new_applicant['pd_co_applicant_id']); - // if($new_applicant['is_person_met'] == true) - // { - // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>3,'applicant_title_name'=>$new_applicant['applicant_title_name']); - // } - // if($new_applicant['is_applicant'] == true) - // { - // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>0,'applicant_title_name'=>$new_applicant['applicant_title_name']); - // } - // if($new_applicant['is_main_applicant'] == true) - // { - // $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>1,'applicant_title_name'=>$new_applicant['applicant_title_name']); - // } - // $new_co_appliacant_id = $this->PD_Model->updateRecords($temp_array,PDAPPLICANTSDETAILS,$where_condition_array); - // if($new_co_appliacant_id != "" || $new_co_appliacant_id != null) - // { - // /*################### LOGGING #########################*/ + // /*################### LOGGING #########################*/ - // $logger = MYLOG::logFunction(); - // $temp_array['pd_co_applicant_id'] = $new_applicant['pd_co_applicant_id']; - // $logger->info("APPLICANT EDITED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$temp_array); + // } + // } + if (array_key_exists('is_active', $new_applicant)) { + if ($new_applicant['is_active'] == false) { + $rows_afftecd = $this->db->where('pd_co_applicant_id', $new_applicant['pd_co_applicant_id'])->delete(PDAPPLICANTSDETAILS); + if ($rows_afftecd != "" && $rows_afftecd != null) { + /*################### LOGGING #########################*/ + $logger = MYLOG::logFunction(null, $records['pdid']); + $logger->info("APPLICANT DELETED FROM GENERAL FORM ENV (" . ENVIRONMENT . ")", $new_applicant); - // /*################### LOGGING #########################*/ - // } - // } - if(array_key_exists('is_active',$new_applicant)) - { - if($new_applicant['is_active'] == false) - { - $rows_afftecd = $this->db->where('pd_co_applicant_id',$new_applicant['pd_co_applicant_id'])->delete(PDAPPLICANTSDETAILS); - if($rows_afftecd != "" && $rows_afftecd != null) - { - /*################### LOGGING #########################*/ - $logger = MYLOG::logFunction(null,$records['pdid']); - $logger->info("APPLICANT DELETED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$new_applicant); + /*################### LOGGING #########################*/ + } + } + } + } + foreach ($records['companies'] as $company_key => $company) { + if ($company['is_company_applicant'] == true && $company['is_new'] == true) { + $temp_array = array('fk_pd_id' => $records['pdid'], 'applicant_name' => $company['company_name'], 'applicant_type' => 2, 'applicant_title_name' => $company['company_messrs_name']); + $new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array, PDAPPLICANTSDETAILS); + $records['companies'][$company_key]['is_new'] = false; + $records['companies'][$company_key]['pd_co_applicant_id'] = $new_co_appliacant_id; - /*################### LOGGING #########################*/ - } - } - } + /*################### LOGGING #########################*/ + $logger = MYLOG::logFunction(null, $records['pdid']); + $temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; + $logger->info("COMPANY ADDED AS APPLICANT FROM GENERAL FORM ENV (" . ENVIRONMENT . ")", $temp_array); - } - foreach($records['companies'] as $company_key => $company) - { + /*################### LOGGING #########################*/ + } - if($company['is_company_applicant'] == true && $company['is_new'] == true) - { + if (array_key_exists('is_active', $company)) { + if ($company['is_active'] == false && $company['is_company_applicant'] == true) { - $temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$company['company_name'],'applicant_type'=>2,'applicant_title_name'=>$company['company_messrs_name']); - $new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array,PDAPPLICANTSDETAILS); - $records['companies'][$company_key]['is_new'] = false; - $records['companies'][$company_key]['pd_co_applicant_id'] = $new_co_appliacant_id; + $rows_afftecd = $this->db->where('applicant_name', $company['company_name'])->where('fk_pd_id', $records['pdid'])->delete(PDAPPLICANTSDETAILS); - /*################### LOGGING #########################*/ + if ($rows_afftecd != "" || $rows_afftecd != null) { + /*################### LOGGING #########################*/ - $logger = MYLOG::logFunction(null,$records['pdid']); - $temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; - $logger->info("COMPANY ADDED AS APPLICANT FROM GENERAL FORM ENV (".ENVIRONMENT.")",$temp_array); + $logger = MYLOG::logFunction(null, $records['pdid']); + //$temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; + $logger->info("COMPANY(APPLICANT) DELETED FROM GENERAL FORM ENV (" . ENVIRONMENT . ")", $company); + /*################### LOGGING #########################*/ + } + } + } + } + } - /*################### LOGGING #########################*/ + return $records; + } - } + public function getAssessedIncome_post() + { + $pd_id = $this->post('pd_id'); + $pd_form_id = $this->post('pd_form_id'); + $company_id = $this->post('company_id') ? $this->post('company_id') : null; - if(array_key_exists('is_active',$company)) - { - if($company['is_active'] == false && $company['is_company_applicant'] == true) - { + $result_array = $this->PD_Model->getAssessedIncome($pd_id, $company_id); - - $rows_afftecd = $this->db->where('applicant_name',$company['company_name'])->where('fk_pd_id',$records['pdid'])->delete(PDAPPLICANTSDETAILS); - - - if($rows_afftecd != "" || $rows_afftecd != null) - { - /*################### LOGGING #########################*/ - - $logger = MYLOG::logFunction(null,$records['pdid']); - //$temp_array['pd_co_applicant_id'] = $new_co_appliacant_id; - $logger->info("COMPANY(APPLICANT) DELETED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$company); - - - - - - /*################### LOGGING #########################*/ - } - - } - } - } - } - - return $records; - - - } - - public function getAssessedIncome_post() - { - $pd_id = $this->post('pd_id'); - $pd_form_id = $this->post('pd_form_id'); - $company_id = $this->post('company_id') ? $this->post('company_id') : null; - - $result_array = $this->PD_Model->getAssessedIncome($pd_id,$company_id); - - $result_array['final_data'] = array(); - $fine = $this->calculateAssessedIncome($pd_id,$company_id); + $result_array['final_data'] = array(); + $fine = $this->calculateAssessedIncome($pd_id, $company_id); //print_r($fine);die(); //print_r($fine);die(); - if($fine != null) - { - $fine['purchase_declared_by_customer'] = $result_array['purchase_declared_by_customer']; - $fine['sales_revenue_details'] = $result_array['sales_calculated_by_itemwise']; - $fine['other_business_income_details'] = $result_array['othre_business_income']; - $fine['purchase_details'] = $result_array['purchase_details']; + if ($fine != null) { + $fine['purchase_declared_by_customer'] = $result_array['purchase_declared_by_customer']; + $fine['sales_revenue_details'] = $result_array['sales_calculated_by_itemwise']; + $fine['other_business_income_details'] = $result_array['othre_business_income']; + $fine['purchase_details'] = $result_array['purchase_details']; //$fine['purchase_billwise'] = $result_array['purchase_billwise']; - $fine['business_expense_details'] = $result_array['business_expenses']; - $fine['house_hold_expense_details'] = $result_array['house_hold_expenses']; + $fine['business_expense_details'] = $result_array['business_expenses']; + $fine['house_hold_expense_details'] = $result_array['house_hold_expenses']; - $result_array['final_data'][] = $fine; - } + $result_array['final_data'][] = $fine; + } - if(count($result_array['sales_declared_by_customer']) == 0 && count($result_array['sales_calculated_by_itemwise']) == 0 && count($result_array['purchase_details']) == 0 && count($result_array['purchase_declared_by_customer']) == 0 && count($result_array['business_expenses']) == 0 && count($result_array['house_hold_expenses']) == 0 && count($result_array['gross_profit_calculation_type']) == 0) - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_array; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_array; - $this->response($data,REST_Controller::HTTP_OK); - } - } + if (count($result_array['sales_declared_by_customer']) == 0 && count($result_array['sales_calculated_by_itemwise']) == 0 && count($result_array['purchase_details']) == 0 && count($result_array['purchase_declared_by_customer']) == 0 && count($result_array['business_expenses']) == 0 && count($result_array['house_hold_expenses']) == 0 && count($result_array['gross_profit_calculation_type']) == 0) { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_array; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_array; + $this->response($data, REST_Controller::HTTP_OK); + } + } - public function saveAssessedIncomeSalesDeclaredByCustomer_post() - { - $records = $this->post('records'); - $pk = ""; - if($records['sdc_id'] != null || $records['sdc_id'] != "") - { + public function saveAssessedIncomeSalesDeclaredByCustomer_post() + { + $records = $this->post('records'); + $pk = ""; + if ($records['sdc_id'] != null || $records['sdc_id'] != "") { - $where_condition_array = array('sdc_id'=>$records['sdc_id']); - $pk = $this->PD_Model->updateRecords($records,SALESDECLAREDBYCUSTOMER,$where_condition_array); - } - else - { - $pk = $this->PD_Model->saveRecords($records,SALESDECLAREDBYCUSTOMER); - } + $where_condition_array = array('sdc_id' => $records['sdc_id']); + $pk = $this->PD_Model->updateRecords($records, SALESDECLAREDBYCUSTOMER, $where_condition_array); + } else { + $pk = $this->PD_Model->saveRecords($records, SALESDECLAREDBYCUSTOMER); + } - if($pk != "" || $pk != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pk; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } + if ($pk != "" || $pk != null) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pk; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - } + public function saveAssessedIncomePurchaseDeclaredByCustomer_post() + { + $records = $this->post('records'); + $pk = ""; + if ($records['pdc_id'] != null || $records['pdc_id'] != "") { - public function saveAssessedIncomePurchaseDeclaredByCustomer_post() - { - $records = $this->post('records'); - $pk = ""; - if($records['pdc_id'] != null || $records['pdc_id'] != "") - { + $where_condition_array = array('pdc_id' => $records['pdc_id']); + $pk = $this->PD_Model->updateRecords($records, PURCHASEDECLAREDBYCUSTOMER, $where_condition_array); + } else { + $pk = $this->PD_Model->saveRecords($records, PURCHASEDECLAREDBYCUSTOMER); + } - $where_condition_array = array('pdc_id'=>$records['pdc_id']); - $pk = $this->PD_Model->updateRecords($records,PURCHASEDECLAREDBYCUSTOMER,$where_condition_array); - } - else - { - $pk = $this->PD_Model->saveRecords($records,PURCHASEDECLAREDBYCUSTOMER); - } + if ($pk != "" || $pk != null) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pk; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - if($pk != "" || $pk != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pk; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } + public function saveOtherBusinessIncome_post() + { + $records = $this->post('records'); + $count = 0; + foreach ($records as $rec_key => $record) { + if ($record['pd_business_income_id'] != null || $record['pd_business_income_id'] != "") { + $where_condition_array = array('pd_business_income_id' => $record['pd_business_income_id']); + $id = $this->PD_Model->updateRecords($record, PDBUSINESSINCOME, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + } else { + $id = $this->PD_Model->saveRecords($record, PDBUSINESSINCOME); + if ($id != "" || $id != null) { + $count++; + } + } + } + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - } + public function saveAssessedIncomeSalesCalculatedByItemwise_post() + { + $records = $this->post('records'); + $count = 0; + foreach ($records as $rec_key => $record) { - public function saveOtherBusinessIncome_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['pd_business_income_id'] != null || $record['pd_business_income_id'] != "") - { - $where_condition_array = array('pd_business_income_id'=>$record['pd_business_income_id']); - $id = $this->PD_Model->updateRecords($record,PDBUSINESSINCOME,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDBUSINESSINCOME); - if($id != "" || $id != null){$count++;} - } - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - } - - public function saveAssessedIncomeSalesCalculatedByItemwise_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - - $child_data = array(); - if(array_key_exists('child',$record)) - { - $child_data = $record['child']; - unset($record['child']); - } + $child_data = array(); + if (array_key_exists('child', $record)) { + $child_data = $record['child']; + unset($record['child']); + } - if($record['sci_id'] != null || $record['sci_id'] != "") - { - $where_condition_array = array('sci_id'=>$record['sci_id']); - $id = $this->PD_Model->updateRecords($record,SALESCALCULATEDBYITEMWISE,$where_condition_array); - if($id != "" || $id != null){$count++;} - if($record['sales_type'] == 3) - { - foreach($child_data as $ckey => $child) - { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { - $child['fk_sci_id'] = $record['sci_id']; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } - } - } - } - else - { - $id = $this->PD_Model->saveRecords($record,SALESCALCULATEDBYITEMWISE); - if($id != "" || $id != null){$count++;} + if ($record['sci_id'] != null || $record['sci_id'] != "") { + $where_condition_array = array('sci_id' => $record['sci_id']); + $id = $this->PD_Model->updateRecords($record, SALESCALCULATEDBYITEMWISE, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + if ($record['sales_type'] == 3) { + foreach ($child_data as $ckey => $child) { + if ($child['simc_id'] != "" || $child['simc_id'] != null) { + $where_condition_array = array('simc_id' => $child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child, SALESITEMMONTHWISECHILD, $where_condition_array); + } else { + if (($child['sales_date'] != null || $child['sales_date'] != "")) { + $child['fk_sci_id'] = $record['sci_id']; + $child_id = $this->PD_Model->saveRecords($child, SALESITEMMONTHWISECHILD); + } + } + } + } + } else { + $id = $this->PD_Model->saveRecords($record, SALESCALCULATEDBYITEMWISE); + if ($id != "" || $id != null) { + $count++; + } - if($record['sales_type'] == 3) - { - foreach($child_data as $ckey => $child) - { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { - $child['fk_sci_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } - } - } - } + if ($record['sales_type'] == 3) { + foreach ($child_data as $ckey => $child) { + if ($child['simc_id'] != "" || $child['simc_id'] != null) { + $where_condition_array = array('simc_id' => $child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child, SALESITEMMONTHWISECHILD, $where_condition_array); + } else { + if (($child['sales_date'] != null || $child['sales_date'] != "")) { + $child['fk_sci_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child, SALESITEMMONTHWISECHILD); + } + } + } + } + } + } + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } + public function saveAssessedIncomePurchaseDetails_post() + { + $records = $this->post('records'); + $count = 0; + foreach ($records as $rec_key => $record) { + $child_data = ""; + if (array_key_exists('child', $record)) { + $child_data = $record['child']; + unset($record['child']); + } - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } + if ($record['purchase_id'] != null || $record['purchase_id'] != "") { + $where_condition_array = array('purchase_id' => $record['purchase_id']); + $id = $this->PD_Model->updateRecords($record, PDPURCHASEDETAILS, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + if ($record['purchase_type'] == 3) { + if ($id != "" || $id != null) { - public function saveAssessedIncomePurchaseDetails_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - $child_data = ""; - if(array_key_exists('child',$record)) - { - $child_data = $record['child']; - unset($record['child']); - } + foreach ($child_data as $ckey => $child) { + if ($child['pbwc_id'] != "" || $child['pbwc_id'] != null) { + $where_condition_array = array('pbwc_id' => $child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child, PDPURCHASEBILLWISECHILD, $where_condition_array); + } else { + $child['fk_purchase_id'] = $record['purchase_id']; + $child_id = $this->PD_Model->saveRecords($child, PDPURCHASEBILLWISECHILD); + } + } + } + } + } else { + $id = $this->PD_Model->saveRecords($record, PDPURCHASEDETAILS); + if ($id != "" || $id != null) { + $count++; + } + if ($record['purchase_type'] == 3) { + if ($id != "" || $id != null) { - if($record['purchase_id'] != null || $record['purchase_id'] != "") - { - $where_condition_array = array('purchase_id'=>$record['purchase_id']); - $id = $this->PD_Model->updateRecords($record,PDPURCHASEDETAILS,$where_condition_array); - if($id != "" || $id != null){$count++;} - if($record['purchase_type'] == 3) - { - if($id != "" || $id != null) - { + foreach ($child_data as $ckey => $child) { + if ($child['pbwc_id'] != "" || $child['pbwc_id'] != null) { + $where_condition_array = array('pbwc_id' => $child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child, PDPURCHASEBILLWISECHILD, $where_condition_array); + } else { + $child['fk_purchase_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child, PDPURCHASEBILLWISECHILD); + } + } + } + } + } + } + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - foreach($child_data as $ckey => $child) - { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { - $child['fk_purchase_id'] = $record['purchase_id']; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); - } - } - } - } + public function saveAssessedIncomeBusinessExpenses_post() + { + $records = $this->post('records'); + $count = 0; + foreach ($records as $rec_key => $record) { + if ($record['pd_expense_id'] != null || $record['pd_expense_id'] != "") { + $where_condition_array = array('pd_expense_id' => $record['pd_expense_id']); + $id = $this->PD_Model->updateRecords($record, PDBUSINESSEXPENSES, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + } else { + $id = $this->PD_Model->saveRecords($record, PDBUSINESSEXPENSES); + if ($id != "" || $id != null) { + $count++; + } + } + } - } - else - { - $id = $this->PD_Model->saveRecords($record,PDPURCHASEDETAILS); - if($id != "" || $id != null){$count++;} - if($record['purchase_type'] == 3) - { - if($id != "" || $id != null) - { + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } - foreach($child_data as $ckey => $child) - { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { - $child['fk_purchase_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); - } - } - } - } - } - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } + public function saveAssessedIncomeHouseholdExpenses_post() + { + $records = $this->post('records'); + $count = 0; + foreach ($records as $rec_key => $record) { + if ($record['household_expense_id'] != null || $record['household_expense_id'] != "") { + $where_condition_array = array('household_expense_id' => $record['household_expense_id']); + $id = $this->PD_Model->updateRecords($record, PDHOUSEHOLDEXPENSES, $where_condition_array); + if ($id != "" || $id != null) { + $count++; + } + } else { + $id = $this->PD_Model->saveRecords($record, PDHOUSEHOLDEXPENSES); + if ($id != "" || $id != null) { + $count++; + } + } + } - public function saveAssessedIncomeBusinessExpenses_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['pd_expense_id'] != null || $record['pd_expense_id'] != "") - { - $where_condition_array = array('pd_expense_id'=>$record['pd_expense_id']); - $id = $this->PD_Model->updateRecords($record,PDBUSINESSEXPENSES,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDBUSINESSEXPENSES); - if($id != "" || $id != null){$count++;} - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function saveAssessedIncomeHouseholdExpenses_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['household_expense_id'] != null || $record['household_expense_id'] != "") - { - $where_condition_array = array('household_expense_id'=>$record['household_expense_id']); - $id = $this->PD_Model->updateRecords($record,PDHOUSEHOLDEXPENSES,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDHOUSEHOLDEXPENSES); - if($id != "" || $id != null){$count++;} - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } + if ($count == count($records)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } /*************NOT IN USE***********NOT IN USE*************************NOT IN USE************ - *************NOT IN USE*********NOT IN USE*****************NOT IN USE***********************/ - public function saveAssessedIncomeMonthwiseItems($item)//SALESITEMMONTHWISECHILD - NOT IN USE + *************NOT IN USE*********NOT IN USE*****************NOT IN USE***********************/ + public function saveAssessedIncomeMonthwiseItems($item) //SALESITEMMONTHWISECHILD - NOT IN USE { //$records = $this->post('records'); $record = $item; $count = 0; //foreach($records as $key => $record) //{ - //$record['sales_type'] + //$record['sales_type'] $child_data = array(); - if(array_key_exists('child',$record)) - { + if (array_key_exists('child', $record)) { $child_data = $record['child']; unset($record['child']); } $id = ""; - //Remove other than DB fields - if(array_key_exists('margin_final_value',$record)) - { - $record['margin_value'] = $record['margin_final_value']; + //Remove other than DB fields + if (array_key_exists('margin_final_value', $record)) { + $record['margin_value'] = $record['margin_final_value']; unset($record['margin_final_value']); } - // array_key_exists('sales_qty', $record) ? unset($record['sales_qty']) : ''; - // array_key_exists('fk_uom_id', $record) ? unset($record['fk_uom_id']) : ''; - // array_key_exists('rate_per_unit', $record) ? unset($record['rate_per_unit']) : ''; - // array_key_exists('fk_frequency_id', $record) ? unset($record['fk_frequency_id']) : ''; - // array_key_exists('annual_sale_value', $record) ? unset($record['annual_sale_value']) : ''; - // array_key_exists('margin_per_uom', $record) ? unset($record['margin_per_uom']) : ''; + // array_key_exists('sales_qty', $record) ? unset($record['sales_qty']) : ''; + // array_key_exists('fk_uom_id', $record) ? unset($record['fk_uom_id']) : ''; + // array_key_exists('rate_per_unit', $record) ? unset($record['rate_per_unit']) : ''; + // array_key_exists('fk_frequency_id', $record) ? unset($record['fk_frequency_id']) : ''; + // array_key_exists('annual_sale_value', $record) ? unset($record['annual_sale_value']) : ''; + // array_key_exists('margin_per_uom', $record) ? unset($record['margin_per_uom']) : ''; - // CURD Operations - if($record['sim_id'] != null || $record['sim_id'] != "" ) - { - $where_condition_array = array('sim_id'=>$record['sim_id']); - $id = $this->PD_Model->updateRecords($record,SALESITEMMONTHWISE,$where_condition_array); - if($id != "" || $id != null) - { + // CURD Operations + if ($record['sim_id'] != null || $record['sim_id'] != "") { + $where_condition_array = array('sim_id' => $record['sim_id']); + $id = $this->PD_Model->updateRecords($record, SALESITEMMONTHWISE, $where_condition_array); + if ($id != "" || $id != null) { $count++; - foreach($child_data as $ckey => $child) - { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { + foreach ($child_data as $ckey => $child) { + if ($child['simc_id'] != "" || $child['simc_id'] != null) { + $where_condition_array = array('simc_id' => $child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child, SALESITEMMONTHWISECHILD, $where_condition_array); + } else { + if (($child['sales_date'] != null || $child['sales_date'] != "")) { $child['fk_sim_id'] = $record['sim_id']; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + $child_id = $this->PD_Model->saveRecords($child, SALESITEMMONTHWISECHILD); } } } } + } else { - } - else - { - - $id = $this->PD_Model->saveRecords($record,SALESITEMMONTHWISE); - if($id != "" || $id != null) - { + $id = $this->PD_Model->saveRecords($record, SALESITEMMONTHWISE); + if ($id != "" || $id != null) { $count++; - foreach($child_data as $ckey => $child) - { - if((($child['sales_date'] != null || $child['sales_date'] != ""))) - { - //echo 'true'; + foreach ($child_data as $ckey => $child) { + if ((($child['sales_date'] != null || $child['sales_date'] != ""))) { + //echo 'true'; $child['fk_sim_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + $child_id = $this->PD_Model->saveRecords($child, SALESITEMMONTHWISECHILD); } } } - } //} - - if($id != "") - { - return 1; + + if ($id != "") { + return 1; } } - + //Save Purcahse Items billwise - NOT IN USE - public function saveAssessedIncomePurchaseBillwise_post()//SALESITEMMONTHWISECHILD - NOT IN USE + public function saveAssessedIncomePurchaseBillwise_post() //SALESITEMMONTHWISECHILD - NOT IN USE { $records = $this->post('records'); $count = 0; - foreach($records as $key => $record) - { + foreach ($records as $key => $record) { $child_data = array(); - if(array_key_exists('child',$record)) - { + if (array_key_exists('child', $record)) { $child_data = $record['child']; unset($record['child']); } $id = ""; - if($record['pbw_id'] != null || $record['pbw_id'] != "") - { - $where_condition_array = array('pbw_id'=>$record['pbw_id']); - $id = $this->PD_Model->updateRecords($record,PDPURCHASEBILLWISE,$where_condition_array); - if($id != "" || $id != null) - { + if ($record['pbw_id'] != null || $record['pbw_id'] != "") { + $where_condition_array = array('pbw_id' => $record['pbw_id']); + $id = $this->PD_Model->updateRecords($record, PDPURCHASEBILLWISE, $where_condition_array); + if ($id != "" || $id != null) { $count++; - foreach($child_data as $ckey => $child) - { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { + foreach ($child_data as $ckey => $child) { + if ($child['pbwc_id'] != "" || $child['pbwc_id'] != null) { + $where_condition_array = array('pbwc_id' => $child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child, PDPURCHASEBILLWISECHILD, $where_condition_array); + } else { $child['fk_pbw_id'] = $record['pbw_id']; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + $child_id = $this->PD_Model->saveRecords($child, PDPURCHASEBILLWISECHILD); } } } - - } - else - { - $id = $this->PD_Model->saveRecords($record,PDPURCHASEBILLWISE); - if($id != "" || $id != null) - { + } else { + $id = $this->PD_Model->saveRecords($record, PDPURCHASEBILLWISE); + if ($id != "" || $id != null) { $count++; - foreach($child_data as $ckey => $child) - { + foreach ($child_data as $ckey => $child) { $child['fk_pbw_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + $child_id = $this->PD_Model->saveRecords($child, PDPURCHASEBILLWISECHILD); } } } } - - if($count == count($records)) - { + + if ($count == count($records)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } - - + + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function getFinalPDReportQuestions_post() { $pd_id = $this->post('pd_id'); $random_string = $this->post('random_string'); - + $final_data_to_response = array(); $final_data_to_response['question_answers']['general_questions'] = ""; - - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); + + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id, $random_string); $final_data_to_response = $pd_master_details[0]; $final_data_to_response['pd_applicant_details'] = $this->PD_Model->getApplicantsDetails($pd_id); - + //Get Template id $fields = array('fk_pd_template_id'); $where_condition_array = array('pd_id' => $pd_id); - $template_details = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); + $template_details = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); $template_id = null; - if(count($template_details)) - { + if (count($template_details)) { $template_id = $template_details[0]['fk_pd_template_id']; } - + // Get all assigned pd forms associated with this pd from template_forms table - if($template_id == null) - { - $columns = array('TEMPLATEFORMS.form_id','PDFORMS.pd_form_name'); - $table = TEMPLATEFORMS.' as TEMPLATEFORMS'; - $joins = array(array('table' => PDFORMS. ' as PDFORMS', - 'condition' =>'TEMPLATEFORMS.form_id = PDFORMS.pd_form_id AND TEMPLATEFORMS.isactive = 1', - 'jointype' => 'INNER')); + if ($template_id == null) { + $columns = array('TEMPLATEFORMS.form_id', 'PDFORMS.pd_form_name'); + $table = TEMPLATEFORMS . ' as TEMPLATEFORMS'; + $joins = array(array( + 'table' => PDFORMS . ' as PDFORMS', + 'condition' => 'TEMPLATEFORMS.form_id = PDFORMS.pd_form_id AND TEMPLATEFORMS.isactive = 1', + 'jointype' => 'INNER' + )); $where_condition_array = array('fk_template_id' => $template_id); - $template_form_details = $this->PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,'PDFORMS.pd_form_order'); + $template_form_details = $this->PD_Model->getJoinRecords($columns, $table, $joins, $where_condition_array, 'PDFORMS.pd_form_order'); //print_r($template_form_details); - if(count($template_form_details)) - { + if (count($template_form_details)) { $temp_array = ""; - foreach($template_form_details as $template_key => $template_form_detail) - { - $pd_form_raw_data = $this->PD_Model->getPDFormDetailsWithScoring($pd_id,$template_form_detail['form_id']); - + foreach ($template_form_details as $template_key => $template_form_detail) { + $pd_form_raw_data = $this->PD_Model->getPDFormDetailsWithScoring($pd_id, $template_form_detail['form_id']); + //$pd_form_raw_data_with_score = $this->calculatePDScore($pd_form_raw_data); - $transformed_data = $this->transformKeyPairToQuestionAnswers($pd_form_raw_data,$template_form_detail['form_id']); - - - $final_data_to_response['question_answers']['form_details'][] = array('name' =>[$template_form_detail['pd_form_name']],'details' => $transformed_data); - + $transformed_data = $this->transformKeyPairToQuestionAnswers($pd_form_raw_data, $template_form_detail['form_id']); + + + $final_data_to_response['question_answers']['form_details'][] = array('name' => [$template_form_detail['pd_form_name']], 'details' => $transformed_data); + //$final_data_to_response['question_answers']['form_details'] = array_merge($final_data_to_response['question_answers']['form_details'],array('name' =>[$template_form_detail['pd_form_name']],'details' => $transformed_data)); - - + + } } - } - + $final_data_to_response['question_answers']['general_questions'] = array(); //$final_data_to_response['question_answers']['form_details'] = array(); - + $object = new stdClass(); - foreach($final_data_to_response as $key => $value) - { + foreach ($final_data_to_response as $key => $value) { $object->$key = $value; } - if(count($final_data_to_response)) - { + if (count($final_data_to_response)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $final_data_to_response; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - - - } - - - + + + /********************************************************************************************* - *********************************************************************************************/ - public function transformKeyPairToQuestionAnswers($pd_form_raw_data,$form_id) + *********************************************************************************************/ + public function transformKeyPairToQuestionAnswers($pd_form_raw_data, $form_id) { //field name array holds - field name of each masters table $master_tables_field_names = $this->config->item('master_tables_field_names'); - + $master_tables_pkid = $this->config->item('master_tables_pkid'); - + //Get Question Key Mapping masters $fields = array('question', 'key', 'ismaster', 'master_name'); - $where_condition_array = array('fk_form_id' => $form_id,'isactive' => 1); - $question_key_master_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONKEYMAPPING); + $where_condition_array = array('fk_form_id' => $form_id, 'isactive' => 1); + $question_key_master_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, QUESTIONKEYMAPPING); //print_r($pd_form_raw_data);die(); $current_question_array = array(); - if(count($pd_form_raw_data)) - { - foreach($pd_form_raw_data as $raw_key => $raw_data) - { + if (count($pd_form_raw_data)) { + foreach ($pd_form_raw_data as $raw_key => $raw_data) { $que_key = $raw_data['column_name']; - if($que_key != null || $que_key != "") - { - foreach($question_key_master_data as $master_key => $master) - { - if($master['key'] == $que_key) - { - if($master['ismaster'] != 1) - { - $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$raw_data['column_value'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); - } - else - { + if ($que_key != null || $que_key != "") { + foreach ($question_key_master_data as $master_key => $master) { + if ($master['key'] == $que_key) { + if ($master['ismaster'] != 1) { + $current_question_array[] = array('category_id' => $raw_data['fk_category_id'], 'category_name' => $raw_data['category_name'], 'category_weightage' => $raw_data['category_weightage'], 'question_weightage' => $raw_data['question_weightage'], 'answer_score' => $raw_data['score'], 'max_score' => $raw_data['max_score'], 'question' => $master['question'], 'answer' => $raw_data['column_value'], 'actual_score' => $raw_data['actual_score'], 'exact_score' => $raw_data['exact_score']); + } else { $table = constant($master['master_name']); - $temp_fields = array($master_tables_field_names[$master['master_name']].' as name'); + $temp_fields = array($master_tables_field_names[$master['master_name']] . ' as name'); $where_condition_array = array($master_tables_pkid[$master['master_name']] => $raw_data['column_value']); - $result_data = $this->PD_Model->selectCustomRecords($temp_fields,$where_condition_array,$table); - if(count($result_data)) - { - //print_r($result_data); - $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$result_data[0]['name'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); + $result_data = $this->PD_Model->selectCustomRecords($temp_fields, $where_condition_array, $table); + if (count($result_data)) { + //print_r($result_data); + $current_question_array[] = array('category_id' => $raw_data['fk_category_id'], 'category_name' => $raw_data['category_name'], 'category_weightage' => $raw_data['category_weightage'], 'question_weightage' => $raw_data['question_weightage'], 'answer_score' => $raw_data['score'], 'max_score' => $raw_data['max_score'], 'question' => $master['question'], 'answer' => $result_data[0]['name'], 'actual_score' => $raw_data['actual_score'], 'exact_score' => $raw_data['exact_score']); } - // + // } } } } } } - - return $current_question_array ; - - + return $current_question_array; } - - + + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function saveAssessedIncomeCalculateMode_post() { $records = $this->post('records'); $id = 0; - if($records['calc_type_id'] != "" || $records['calc_type_id'] != null) - { - + if ($records['calc_type_id'] != "" || $records['calc_type_id'] != null) { + $where_condition_array = array("calc_type_id" => $records['calc_type_id']); - $id = $this->PD_Model->updateRecords($records,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE,$where_condition_array); + $id = $this->PD_Model->updateRecords($records, PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE, $where_condition_array); + } else { + + $id = $this->PD_Model->saveRecords($records, PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); } - else - { - - $id = $this->PD_Model->saveRecords($records,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); - } - - if($id != 0) - { + + if ($id != 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - + $this->response($data, REST_Controller::HTTP_OK); + } } - - + + /********************************************************************************************* - *********************************************************************************************/ - public function calculateAssessedIncome($pd_id,$company_id) + *********************************************************************************************/ + public function calculateAssessedIncome($pd_id, $company_id) { - - + + $overall_summary_report = array(); $overall_summary_report['sales_calculated_by_itemwise'] = null; - + $overall_summary_report['sales_declared_by_customer'] = null; - + $sales_declared_by_customer = array(); $sales_declared_by_customer_flag = 0; - + $sales_calculated_by_itemwise = array(); $sales_calculated_by_itemwise_flag = 0; - - + + $purchases = array(); $purchases_flag = 0; $purchase_declared_by_customer = array(); $purchase_declared_by_customer_flag = 0; - + $business_expenses = array(); $business_expenses_flag = 0; - + $household_expenses = array(); $household_expenses_flag = 0; - + $other_business_income = array(); $other_business_income_flag = 0; - + $overall_purchase_total = 0; $overall_business_expenses_total = 0; $overall_other_business_income_total = 0; $overall_household_total = 0; $net_profit = 0; $final_sales_avg_value = 0; - + //Get all Master Details - $result_array = $this->PD_Model->getAssessedIncome($pd_id,$company_id); - + $result_array = $this->PD_Model->getAssessedIncome($pd_id, $company_id); + $sales_declared_by_customer = $result_array['sales_declared_by_customer']; $sales_calculated_by_itemwise = $result_array['sales_calculated_by_itemwise']; - + $purchases = $result_array['purchase_details']; $purchase_declared_by_customer = $result_array['purchase_declared_by_customer']; - + $business_expenses = $result_array['business_expenses']; $other_business_income = $result_array['othre_business_income']; $household_expenses = $result_array['house_hold_expenses']; $gross_profit_calculation_type = $result_array['gross_profit_calculation_type']; $othre_business_income = $result_array['othre_business_income']; - if(count($sales_declared_by_customer)){$sales_declared_by_customer_flag = 1;} - if(count($sales_calculated_by_itemwise)){$sales_calculated_by_itemwise_flag = 1;} - + if (count($sales_declared_by_customer)) { + $sales_declared_by_customer_flag = 1; + } + if (count($sales_calculated_by_itemwise)) { + $sales_calculated_by_itemwise_flag = 1; + } - if(count($purchases)){ $purchases_flag = 1;} + + if (count($purchases)) { + $purchases_flag = 1; + } //echo $sales_calculated_by_itemwise_flag.$purchases_flag; - if(count($purchase_declared_by_customer)){$purchase_declared_by_customer_flag = 1;} - if(count($business_expenses)){$business_expenses_flag = 1;} - if(count($household_expenses)){$household_expenses_flag = 1;} - if(count($other_business_income)){$other_business_income_flag = 1;} - - + if (count($purchase_declared_by_customer)) { + $purchase_declared_by_customer_flag = 1; + } + if (count($business_expenses)) { + $business_expenses_flag = 1; + } + if (count($household_expenses)) { + $household_expenses_flag = 1; + } + if (count($other_business_income)) { + $other_business_income_flag = 1; + } + + // if(($business_expenses_flag == 1) && ($sales_declared_by_customer_flag == 1 || $purchase_declared_by_customer_flag) || ($sales_calculated_by_itemwise_flag == 1 || $purchases_flag == 1)) - if($gross_profit_calculation_type[0]['is_completed']) - { + if ($gross_profit_calculation_type[0]['is_completed']) { $total_sales_itemwise = 0; $sales_monthwise = array(); - + $total_sales_monthwise = 0; $total_sales_declared_by_customer = 0; - - foreach($other_business_income as $other_business_key => $other_business) - { + + foreach ($other_business_income as $other_business_key => $other_business) { $overall_other_business_income_total = $overall_other_business_income_total + $other_business['annual_income_value']; } - - - - foreach($business_expenses as $business_key => $business_expense) - { + + + + foreach ($business_expenses as $business_key => $business_expense) { $overall_business_expenses_total = $overall_business_expenses_total + $business_expense['annual_expenses_value']; } - - foreach($household_expenses as $household_key => $household_expense) - { + + foreach ($household_expenses as $household_key => $household_expense) { $overall_household_total = $overall_household_total + $household_expense['annual_expense_value']; } - - if($purchases_flag != 0) - { - - - foreach($purchases as $purchase_key => $purchase) - { + + if ($purchases_flag != 0) { + + + foreach ($purchases as $purchase_key => $purchase) { $overall_purchase_total += $purchase['annual_purchase_value']; } - } - - - if($sales_calculated_by_itemwise_flag == 1 ) - { - - $temp_purchases = 0; - $temp_netprofit = 0; - $temp_grossprofit = 0; - $temp_netmargin = 0; - $month_total = 0; - $i = 0; - foreach($sales_calculated_by_itemwise as $itemwise_key => $item) - { - $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; - $temp_netprofit = $temp_netprofit + $item['margin_final_value']; - - } - $total_sales_monthwise = 0; - - - //calculatin part - if($gross_profit_calculation_type[0]['mode'] == 1) - { + if ($sales_calculated_by_itemwise_flag == 1) { - $temp_purchases = $overall_purchase_total; - $temp_grossprofit = ($total_sales_itemwise + $total_sales_monthwise) - $temp_purchases; - $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - - if($temp_netprofit != 0 && ($total_sales_itemwise + $total_sales_monthwise) != 0) - { - $temp_netmargin = ($temp_netprofit/ ($total_sales_itemwise + $total_sales_monthwise)) * 100; - } - else - { - $temp_netmargin = 0; - } - } - else - { - - // This one changes as per 15/03/2019 Excel Review changes - $temp_grossprofit = $temp_netprofit;// + $overall_business_expenses_total; - $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - $temp_purchases = ($total_sales_itemwise + $total_sales_monthwise) - $temp_grossprofit; - if($temp_netprofit != 0 && ( $total_sales_itemwise + $total_sales_monthwise) != 0 ){ - $temp_netmargin = ($temp_netprofit/( $total_sales_itemwise + $total_sales_monthwise) * 100); - } - else { $temp_netmargin = 0;} - } - - $overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise + $total_sales_monthwise); - ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases,2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases); - $overall_summary_report['sales_calculated_by_itemwise']['grossprofit'] = round($temp_grossprofit); - $overall_summary_report['sales_calculated_by_itemwise']['business_expenses'] = round($overall_business_expenses_total); - $overall_summary_report['sales_calculated_by_itemwise']['netprofit'] = round($temp_netprofit); - $overall_summary_report['sales_calculated_by_itemwise']['house_hold_expenses'] = round($overall_household_total); - $overall_summary_report['sales_calculated_by_itemwise']['disposable_income'] = round($temp_netprofit - $overall_household_total); - $overall_summary_report['sales_calculated_by_itemwise']['netmargin'] = round($temp_netmargin,2); + + $temp_purchases = 0; + $temp_netprofit = 0; + $temp_grossprofit = 0; + $temp_netmargin = 0; + $month_total = 0; + $i = 0; + foreach ($sales_calculated_by_itemwise as $itemwise_key => $item) { + + $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; + $temp_netprofit = $temp_netprofit + $item['margin_final_value']; + } + $total_sales_monthwise = 0; + + + //calculatin part + if ($gross_profit_calculation_type[0]['mode'] == 1) { + + $temp_purchases = $overall_purchase_total; + $temp_grossprofit = ($total_sales_itemwise + $total_sales_monthwise) - $temp_purchases; + $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; + + if ($temp_netprofit != 0 && ($total_sales_itemwise + $total_sales_monthwise) != 0) { + $temp_netmargin = ($temp_netprofit / ($total_sales_itemwise + $total_sales_monthwise)) * 100; + } else { + $temp_netmargin = 0; + } + } else { + + // This one changes as per 15/03/2019 Excel Review changes + $temp_grossprofit = $temp_netprofit; // + $overall_business_expenses_total; + $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; + $temp_purchases = ($total_sales_itemwise + $total_sales_monthwise) - $temp_grossprofit; + if ($temp_netprofit != 0 && ($total_sales_itemwise + $total_sales_monthwise) != 0) { + $temp_netmargin = ($temp_netprofit / ($total_sales_itemwise + $total_sales_monthwise) * 100); + } else { + $temp_netmargin = 0; + } + } + + $overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise + $total_sales_monthwise); + ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases, 2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases); + $overall_summary_report['sales_calculated_by_itemwise']['grossprofit'] = round($temp_grossprofit); + $overall_summary_report['sales_calculated_by_itemwise']['business_expenses'] = round($overall_business_expenses_total); + $overall_summary_report['sales_calculated_by_itemwise']['netprofit'] = round($temp_netprofit); + $overall_summary_report['sales_calculated_by_itemwise']['house_hold_expenses'] = round($overall_household_total); + $overall_summary_report['sales_calculated_by_itemwise']['disposable_income'] = round($temp_netprofit - $overall_household_total); + $overall_summary_report['sales_calculated_by_itemwise']['netmargin'] = round($temp_netmargin, 2); } - - if($sales_declared_by_customer_flag == 1) - { - + + if ($sales_declared_by_customer_flag == 1) { + $temp_purchases = 0; $temp_netprofit = 0; $temp_grossprofit = 0; $temp_netmargin = 0; $total_sales_declared_by_customer = $sales_declared_by_customer[0]['sales_declared_by_customer']; - + $temp_netprofit = $sales_declared_by_customer[0]['margin_value']; - - if($gross_profit_calculation_type[0]['mode'] == 1) - { + + if ($gross_profit_calculation_type[0]['mode'] == 1) { $total_purchase_declared_by_customer = $purchase_declared_by_customer[0]['purchase_declared_by_customer']; $temp_purchases = $total_purchase_declared_by_customer; $temp_grossprofit = $total_sales_declared_by_customer - $temp_purchases; $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - $temp_netmargin = $total_sales_declared_by_customer > 0 ?($temp_netprofit/$total_sales_declared_by_customer) * 100 : 0; - } - else - { + $temp_netmargin = $total_sales_declared_by_customer > 0 ? ($temp_netprofit / $total_sales_declared_by_customer) * 100 : 0; + } else { $temp_grossprofit = $temp_netprofit + $overall_business_expenses_total; $temp_purchases = $total_sales_declared_by_customer - $temp_grossprofit; - $temp_netmargin = $total_sales_declared_by_customer > 0 ?($temp_netprofit/$total_sales_declared_by_customer) * 100 : 0; + $temp_netmargin = $total_sales_declared_by_customer > 0 ? ($temp_netprofit / $total_sales_declared_by_customer) * 100 : 0; } - + $overall_summary_report['sales_declared_by_customer']['sales_revenue'] = round($total_sales_declared_by_customer); ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_declared_by_customer']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_declared_by_customer']['cost_of_goods_sold'] = round($temp_purchases); $overall_summary_report['sales_declared_by_customer']['grossprofit'] = round($temp_grossprofit); @@ -4789,64 +4274,60 @@ public function getPDFormDetailsJSON_post() $overall_summary_report['sales_declared_by_customer']['netprofit'] = round($temp_netprofit); $overall_summary_report['sales_declared_by_customer']['house_hold_expenses'] = round($overall_household_total); $overall_summary_report['sales_declared_by_customer']['disposable_income'] = round($temp_netprofit - $overall_household_total); - $overall_summary_report['sales_declared_by_customer']['netmargin'] = round($temp_netmargin,2); + $overall_summary_report['sales_declared_by_customer']['netmargin'] = round($temp_netmargin, 2); } - - - $temp_sales_array = array(); - - if(isset($overall_summary_report['sales_declared_by_customer']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_declared_by_customer']['sales_revenue'])); } - //if(isset($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])); } - if(isset($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])); } - - - $temp_netmargin_array = array(); - - if(isset($overall_summary_report['sales_declared_by_customer']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_declared_by_customer']['netprofit'])); } - //if(isset($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])); } - if(isset($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])); } - - if(count($temp_sales_array)) - { - $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = round(array_sum($temp_sales_array) / count($temp_sales_array)); - } - else - { - $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = 0.0; - } - - if(count($temp_netmargin_array)) - { + + $temp_sales_array = array(); + + if (isset($overall_summary_report['sales_declared_by_customer']['sales_revenue'])) { + $temp_sales_array = array_merge($temp_sales_array, array($overall_summary_report['sales_declared_by_customer']['sales_revenue'])); + } + //if(isset($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])); } + if (isset($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])) { + $temp_sales_array = array_merge($temp_sales_array, array($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])); + } + + + $temp_netmargin_array = array(); + + if (isset($overall_summary_report['sales_declared_by_customer']['netprofit'])) { + $temp_netmargin_array = array_merge($temp_netmargin_array, array($overall_summary_report['sales_declared_by_customer']['netprofit'])); + } + //if(isset($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])); } + if (isset($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])) { + $temp_netmargin_array = array_merge($temp_netmargin_array, array($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])); + } + + if (count($temp_sales_array)) { + $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = round(array_sum($temp_sales_array) / count($temp_sales_array)); + } else { + $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = 0.0; + } + + + if (count($temp_netmargin_array)) { $overall_summary_report['consolidated_report']['consolidated_nerprofit'] = round(array_sum($temp_netmargin_array) / count($temp_netmargin_array)); + } else { + $overall_summary_report['consolidated_report']['consolidated_nerprofit'] = 0.0; } - else - { - $overall_summary_report['consolidated_report']['consolidated_nerprofit'] = 0.0; - } - - if($overall_summary_report['consolidated_report']['consolidated_nerprofit'] != 0 && $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] != 0) - { - $overall_summary_report['consolidated_report']['consolidated_nermagin'] = round((($overall_summary_report['consolidated_report']['consolidated_nerprofit']/$overall_summary_report['consolidated_report']['consolidated_sales_revenue'])*100),2); - } - else - { + + if ($overall_summary_report['consolidated_report']['consolidated_nerprofit'] != 0 && $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] != 0) { + $overall_summary_report['consolidated_report']['consolidated_nermagin'] = round((($overall_summary_report['consolidated_report']['consolidated_nerprofit'] / $overall_summary_report['consolidated_report']['consolidated_sales_revenue']) * 100), 2); + } else { $overall_summary_report['consolidated_report']['consolidated_nermagin'] = 0; } - + return ($overall_summary_report); - } - else - { - + } else { + return null; } - } - - + + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function getLatestPDReportBlob_post() { $records = $this->post('records'); @@ -4854,51 +4335,38 @@ public function getPDFormDetailsJSON_post() $records = $records['pd_id']; $pdid = $records['startId']; $version_id = $records['version_id']; - + $version_no = ""; - - if(is_numeric(substr($version_id,-7,3))) - { - $version_no = substr($version_id,-7,3); - - } - else if(is_numeric(substr($version_id,-6,2))) - { - $version_no = substr($version_id,-6,2); - - }else if(is_numeric(substr($version_id,-5,1))) - { - $version_no = substr($version_id,-5,1); - } - else - { + + if (is_numeric(substr($version_id, -7, 3))) { + $version_no = substr($version_id, -7, 3); + } else if (is_numeric(substr($version_id, -6, 2))) { + $version_no = substr($version_id, -6, 2); + } else if (is_numeric(substr($version_id, -5, 1))) { + $version_no = substr($version_id, -5, 1); + } else { $version_no = 1; } - + $fields = array('content'); - $where_condition_array = array('fk_pd_id'=>$pdid,'version_no'=>$version_no); - $result_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDREPORTSVERSIONBLOB); - if(count($result_array)) - { + $where_condition_array = array('fk_pd_id' => $pdid, 'version_no' => $version_no); + $result_array = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDREPORTSVERSIONBLOB); + if (count($result_array)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_array; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Data Available'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } - } - + /********************************************************************************************* - *********************************************************************************************/ - + *********************************************************************************************/ + //Generate Report AS PDF public function generatePDReportPDF_post() { @@ -4910,27 +4378,24 @@ public function getPDFormDetailsJSON_post() $is_qc_edited = 0; //echo "step1.Function Entered"; $this->load->helper('report_attachments'); - - - if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + + + if (!file_exists($this->external_path . '/pd_reports/' . $pdid)) { + mkdir($this->external_path . '/pd_reports/' . $pdid, 0777); } - $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid,$random_string); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid, $random_string); // print_r($pd_master_details); // var_dump($pd_master_details[0]['is_img_pdf_created']); // check img zip link, img pdf link and vide links - if(!$pd_master_details[0]['is_img_pdf_created']) - { - $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Image PDF'.', ') : 'Image PDF, '; + if (!$pd_master_details[0]['is_img_pdf_created']) { + $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Image PDF' . ', ') : 'Image PDF, '; } - if(!$pd_master_details[0]['is_zip_created']) - { - $data['msg'] = isset($data['msg']) ? ($data['msg'] . 'Image ZIP'.', ') : 'Image ZIP, '; + if (!$pd_master_details[0]['is_zip_created']) { + $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); @@ -4941,229 +4406,215 @@ public function getPDFormDetailsJSON_post() // } // print_r($data); // echo strrpos($data['msg'], ','); - if(isset($data['msg']) && $data['msg'] != '') - { - $data['msg'] = substr_replace($data['msg'],'',-2); - if(strrpos($data['msg'], ',')) { $data['msg'] = substr_replace($data['msg'],' and ', strrpos($data['msg'], ','),2); } + if (isset($data['msg']) && $data['msg'] != '') { + $data['msg'] = substr_replace($data['msg'], '', -2); + if (strrpos($data['msg'], ',')) { + $data['msg'] = substr_replace($data['msg'], ' and ', strrpos($data['msg'], ','), 2); + } $data['msg'] = ('The following item(s) yet to be complete :- ' . $data['msg']); $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; $main_applicant_name = $pd_master_details[0]['main_applicant']; - $pdf_name = 'PD_Report_'.$main_applicant_name; - - $key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'.pdf'; - $newkey = 'pd'.$pdid.'/pd_reports/'.$pdf_name.'.pdf'; - - - if($pd_master_details[0]['is_qc_edited']) - { - $is_qc_edited = $pd_master_details[0]['is_qc_edited']; + $pdf_name = 'PD_Report_' . $main_applicant_name; + + $key = 'pd' . $pdid . '/pd_reports/' . $main_applicant_name . '.pdf'; + $newkey = 'pd' . $pdid . '/pd_reports/' . $pdf_name . '.pdf'; + + + if ($pd_master_details[0]['is_qc_edited']) { + $is_qc_edited = $pd_master_details[0]['is_qc_edited']; } - - if($is_qc_edited == 1 || $is_qc_edited == 2) - { - //Get Latest PD Report Html file and convert it into PDF + + if ($is_qc_edited == 1 || $is_qc_edited == 2) { + //Get Latest PD Report Html file and convert it into PDF $latest_pd_report_html_file_name = $pd_master_details[0]['pd_report_html_filename']; - $latest_pd_report_html_file_path = $this->external_path.'/pd_reports/'.$pdid.'/'.$latest_pd_report_html_file_name.'.html'; + $latest_pd_report_html_file_path = $this->external_path . '/pd_reports/' . $pdid . '/' . $latest_pd_report_html_file_name . '.html'; $temp = file_get_contents($latest_pd_report_html_file_path); - //Replace Span tags from HTML File + //Replace Span tags from HTML File - $total_replaces = substr_count($temp,'');for($i = 0 ;$i < $total_replaces;$i++) - { - $start_pos = strpos($temp,''); + $total_replaces = substr_count($temp, ''); + for ($i = 0; $i < $total_replaces; $i++) { + $start_pos = strpos($temp, ''); - $end_pos = strpos($temp, '', strpos($temp,'')); + $end_pos = strpos($temp, '', strpos($temp, '')); $end_pos = $end_pos + 14; - //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; + //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; - $temp = substr_replace($temp,'',$start_pos,($end_pos - $start_pos)); + $temp = substr_replace($temp, '', $start_pos, ($end_pos - $start_pos)); - $temp = substr_replace($temp,'',strpos($temp,''),(strlen(''))); - + $temp = substr_replace($temp, '', strpos($temp, ''), (strlen(''))); } - //End Of Replace Span tags from HTML File + //End Of Replace Span tags from HTML File - //Get attachment links and embed here... + //Get attachment links and embed here... //get img pdf - $report_attachments = (new report_attachments)->getReportAttchments($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details); - $temp = substr_replace($temp,$report_attachments,strpos($temp,''),0); - //End Get attachment links + $report_attachments = (new report_attachments)->getReportAttchments($pd_master_details[0]['pd_id'], $pd_master_details[0]['random_string'], $pd_master_details); + $temp = substr_replace($temp, $report_attachments, strpos($temp, ''), 0); + //End Get attachment links // echo $temp; // die(); - //PDF Gen using DOM PDF - $pdf_doc = $this->pdfgenerator->generate($temp, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //End of PDF Gen using DOM PDF - $output_file2 = $this->external_path."/pd_reports/". $pdid ."/sample.pdf"; + //PDF Gen using DOM PDF + $pdf_doc = $this->pdfgenerator->generate($temp, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file2 = $this->external_path . "/pd_reports/" . $pdid . "/sample.pdf"; $bytes = file_put_contents($output_file2, $pdf_doc); // echo $output_file2; // die(); - if(file_put_contents($output_file2, $pdf_doc)) - { + if (file_put_contents($output_file2, $pdf_doc)) { $sourcefile = $output_file2; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$newkey,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - //print_r($s3result); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - //$result_array[0]['content'] + $bucket_data = array('bucket_name' => $bucketname, 'key' => $newkey, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + //$result_array[0]['content'] $where_condition_array = array("pd_id" => $pdid); $temp_array['is_qc_edited'] = 0; - $id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + $id = $this->PD_Model->updateRecords($temp_array, PDTRIGGER, $where_condition_array); - //call all reports functionality and send it. + //call all reports functionality and send it. // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'30 minutes'); - $headers = @get_headers($_uri); - if($headers && strpos( $headers[0], '200')) { - $singed_uri = $_uri; - }else { + $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '30 minutes'); + $headers = @get_headers($_uri); + if ($headers && strpos($headers[0], '200')) { + $singed_uri = $_uri; + } else { - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$newkey,'30 minutes'); - } + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $newkey, '30 minutes'); + } - if($id != null || $id != "" ) - { + if ($id != null || $id != "") { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $singed_uri; - //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - }else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else //If Qc not edited pull PDF uri from S3 + } else //If Qc not edited pull PDF uri from S3 { - - // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - $headers = @get_headers($_uri); - if($headers && strpos( $headers[0], '200')) { - $singed_uri = $_uri; - }else { - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$newkey,'+30 minutes'); - } - if($singed_uri != null || $singed_uri != "" ) - { + // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + $_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes'); + $headers = @get_headers($_uri); + if ($headers && strpos($headers[0], '200')) { + $singed_uri = $_uri; + } else { + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $newkey, '+30 minutes'); + } + + if ($singed_uri != null || $singed_uri != "") { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $singed_uri; - //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } - - }//funcion end + } //funcion end - //Generate Report as HTML File + //Generate Report as HTML File public function generatePDReport_post() { $records = $this->post('records'); $pdid = $records['pd_id']; $fk_createdby = $records['fk_createdby']; $random_string = $records['random_string']; - - if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + + if (!file_exists($this->external_path . '/pd_reports/' . $pdid)) { + mkdir($this->external_path . '/pd_reports/' . $pdid, 0777); } - $data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid,$random_string); + $data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid, $random_string); // print_r($data['pd_master_details']);die; $data['pd_master_details'][0]['pd_report_generated_date'] = date('d/m/Y g:i:s A'); - + // if($data['pd_master_details'][0]['lender_short_name'] == 'CHFPL' && ($data['pd_master_details'][0]['product_abbr'] == 'LAP' || $data['pd_master_details'][0]['product_abbr'] == 'NRPL')) // { - + // $clix_lender_id = ENVIRONMENT == 'production' ? 5 : 16; //clix lender id based on env // $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $clix_lender_id)); - + // } // else // { $pd_type = $data['pd_master_details'][0]['fk_pd_type'] == 3 ? 3 : 1; - $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => ($data['pd_master_details'][0]['sub_entity_id'] ? $data['pd_master_details'][0]['sub_entity_id'] : $data['pd_master_details'][0]['fk_lender_id']),'fk_pd_type' => $pd_type)); + $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER, array('fk_entity_id' => ($data['pd_master_details'][0]['sub_entity_id'] ? $data['pd_master_details'][0]['sub_entity_id'] : $data['pd_master_details'][0]['fk_lender_id']), 'fk_pd_type' => $pd_type)); //} $entity_geo_location = $this->PD_Model->getEntityAddr($data['pd_master_details'][0]['fk_lender_id']); // print_r($entity_geo_location);die(); - if($entity_geo_location != 0){ + if ($entity_geo_location != 0) { $pd_location = $data['pd_master_details'][0]['start_location']; - $data['distances'] = satellite_image::getdistancematrix($entity_geo_location,$pd_location); - }else{ $data['distances'] = ""; } + $data['distances'] = satellite_image::getdistancematrix($entity_geo_location, $pd_location); + } else { + $data['distances'] = ""; + } //$data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $data['pd_master_details'][0]['fk_lender_id'])); $data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); $data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); $data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly($pdid); - + //$data['dsc_cards'] = $this->getDetailedScoreCardChart( $data['pd_score'] ); $data['assessed_income_details'] = $this->getAssessedIncomeForPDReport($pdid); - if($data['pd_master_details'][0]['is_score_card_enabled'] != 0 && ($data['pd_master_details'][0]['customer_segment_abbr'] != "SAL" && $data['pd_master_details'][0]['customer_segment_abbr'] != "SE-RI")) - { + if ($data['pd_master_details'][0]['is_score_card_enabled'] != 0 && ($data['pd_master_details'][0]['customer_segment_abbr'] != "SAL" && $data['pd_master_details'][0]['customer_segment_abbr'] != "SE-RI")) { $data['pd_score'] = $this->calculateScore($pdid); - $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],1) : 0; + $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'], 1) : 0; //echo $score_for_chart; - + //GET phantom script from DB - $phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => PHANTOMJSSCRIPT_LOCATION),SCRIPTS); - + $phantom_script = $this->PD_Model->selectCustomRecords(array('*'), array('script_name' => PHANTOMJSSCRIPT_LOCATION), SCRIPTS); + $exact_script = $phantom_script[0]['script_content']; //print_r($exact_script); - $apppath = str_replace('\\','/',$this->external_path.'/pd_reports/'.$pdid); - $exact_script = str_replace('{{APPPATH}}',$apppath,$exact_script); - $exact_script = str_replace('{{place_score_here}}',$score_for_chart,$exact_script); + $apppath = str_replace('\\', '/', $this->external_path . '/pd_reports/' . $pdid); + $exact_script = str_replace('{{APPPATH}}', $apppath, $exact_script); + $exact_script = str_replace('{{place_score_here}}', $score_for_chart, $exact_script); //print_r($exact_script);die(); - - + + //GENERATE CHART PART - file_put_contents(APPPATH.'/views/js/phantomchart.js',$exact_script,LOCK_EX); - - $str = 'phantomjs '.APPPATH.'/views/js/phantomchart.js'; - exec($str,$ou); + file_put_contents(APPPATH . '/views/js/phantomchart.js', $exact_script, LOCK_EX); + + $str = 'phantomjs ' . APPPATH . '/views/js/phantomchart.js'; + exec($str, $ou); exec('phantom.exit();'); - + //print_r($ou); - - $chart_img_path = $this->external_path.'/pd_reports/'. $pdid .'/chart.png'; + + $chart_img_path = $this->external_path . '/pd_reports/' . $pdid . '/chart.png'; $type = pathinfo($chart_img_path, PATHINFO_EXTENSION); $chart_img_content = file_get_contents($chart_img_path); $base64_pdscore_chart_url = 'data:image/' . $type . ';base64,' . base64_encode($chart_img_content); @@ -5172,185 +4623,148 @@ public function getPDFormDetailsJSON_post() // echo $data['base64_pdscore_chart_url']; //die(); //END OF GENERATE CHART PART - - - - - //GET ALL PROCESSED JSON - for($i = 1;$i<=30;$i++) - { + + + + + //GET ALL PROCESSED JSON + for ($i = 1; $i <= 30; $i++) { $fields = array('processed_json'); - if($i == 25) { $fields = array('json'); } - $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i); - $data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); + if ($i == 25) { + $fields = array('json'); + } + $where_condition_array = array('isactive' => 1, 'fk_pd_id' => $pdid, 'fk_form_id' => $i); + $data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON, array(), '', 'company_id', 'ASC'); $fields2 = array('*'); - $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i,null,null,null,'report'); + $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid, $i, null, null, null, 'report'); } - + //Get Common Images - if($data['pd_master_details'][0]['customer_segment_abbr'] == "SAL" && $data['pd_master_details'][0]['fk_pd_type'] != 3) - { - $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,null,null,'report'); - } - else - { - $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,'common',null,'report'); - } - // echo "i ahve image"; - // print_r($data['pd_images']);die(); + if ($data['pd_master_details'][0]['customer_segment_abbr'] == "SAL" && $data['pd_master_details'][0]['fk_pd_type'] != 3) { + $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, null, null, 'report'); + } else { + $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, 'common', null, 'report'); + } + // echo "i ahve image"; + // print_r($data['pd_images']);die(); $t = 'DEFAULT DATA'; // if(!count($add_on_pd)) // { - - if($data['pd_master_details'][0]['fk_pd_type'] == 1) //Full PD - { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) - { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') - { - $t = $this->load->view('report_templates/JSONTOREPORT_RI',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL',$data,true); - } - } - else if($data['pd_master_details'][0]['fk_pd_type'] == 2) - { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) - { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') - { - $t = $this->load->view('report_templates/JSONTOREPORT_RI_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL_SMARTPD',$data,true); - } - } - else if($data['pd_master_details'][0]['fk_pd_type'] == 3) //Tele PD - { + if ($data['pd_master_details'][0]['fk_pd_type'] == 1) //Full PD + { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) - { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_TELE_PD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL_TELE_PD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') - { - $t = $this->load->view('report_templates/JSONTOREPORT_RI_TELE_PD',$data,true); - - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_TELE_PD',$data,true); - - } + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + { + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL', $data, true); } + } else if ($data['pd_master_details'][0]['fk_pd_type'] == 2) { + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + { + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL_SMARTPD', $data, true); + } + } else if ($data['pd_master_details'][0]['fk_pd_type'] == 3) //Tele PD + { + + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + { + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_TELE_PD', $data, true); + } + } // } // else // { // $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_ADDON',$data,true); // } - - + + $pd_report_time = date('Y-m-d-H-i-s'); - $pd_report_store = $this->external_path.'/pd_reports/'.$pdid.'/'.$pd_report_time.'.html'; - $is_write_done = file_put_contents($pd_report_store,$t); - - if($is_write_done) - { - - //$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time),PDTRIGGER,array('pd_id' => $pdid)); + $pd_report_store = $this->external_path . '/pd_reports/' . $pdid . '/' . $pd_report_time . '.html'; + $is_write_done = file_put_contents($pd_report_store, $t); + + if ($is_write_done) { + + //$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time),PDTRIGGER,array('pd_id' => $pdid)); $where_condition_array = array("pd_id" => $pdid); - $temp_array = array('is_original_report_created'=>1,'pd_report_html_filename' => $pd_report_time,'pd_report_generated_date' => date('Y-m-d H:i:s'),'is_qc_edited' => 2); + $temp_array = array('is_original_report_created' => 1, 'pd_report_html_filename' => $pd_report_time, 'pd_report_generated_date' => date('Y-m-d H:i:s'), 'is_qc_edited' => 2); - $id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + $id = $this->PD_Model->updateRecords($temp_array, PDTRIGGER, $where_condition_array); $response_data['dataStatus'] = true; $response_data['status'] = REST_Controller::HTTP_OK; $response_data['msg'] = 'Report Generated Sucessfully..!'; - $this->response($response_data,REST_Controller::HTTP_OK); - - } - else - { + $this->response($response_data, REST_Controller::HTTP_OK); + } else { $response_data['dataStatus'] = false; $response_data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $response_data['msg'] = 'Something went wrong..!'; - $this->response($response_data,REST_Controller::HTTP_OK); - - } - + $this->response($response_data, REST_Controller::HTTP_OK); + } } - - public function archivePDImages_post() + + public function archivePDImages_post() { $records = $this->post('records'); $pdid = $records['pd_id']; $random_string = $records['random_string']; $regenerate = isset($records['regenerate']) ? $records['regenerate'] : 0; $this->load->helper('photo_zip_creator'); - $res_data = (new photo_zip_creator)->covertImgs2ZIP($pdid,$random_string,array(),$regenerate); - - $response_data['dataStatus'] = true; - $response_data['status'] = REST_Controller::HTTP_OK; - $response_data['records'] = $res_data; - $this->response($response_data,REST_Controller::HTTP_OK); - - + $res_data = (new photo_zip_creator)->covertImgs2ZIP($pdid, $random_string, array(), $regenerate); + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $res_data; + $this->response($response_data, REST_Controller::HTTP_OK); } - public function imgPDFDownload_post() + public function imgPDFDownload_post() { $records = $this->post('records'); $this->load->helper('photo_pdf_converter'); - + $pdid = $records['pd_id']; $random_string = $records['random_string']; $regenerate = isset($records['regenerate']) ? $records['regenerate'] : 0; - - $res_data = (new photo_pdf_converter)->covertImgs2PDF($pdid,$random_string,array(),$regenerate); - - $response_data['dataStatus'] = true; - $response_data['status'] = REST_Controller::HTTP_OK; - $response_data['records'] = $res_data; - $this->response($response_data,REST_Controller::HTTP_OK); - + $res_data = (new photo_pdf_converter)->covertImgs2PDF($pdid, $random_string, array(), $regenerate); + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $res_data; + $this->response($response_data, REST_Controller::HTTP_OK); } - - - + + + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function saveNewVersionOfPDReport_post() { - - + + $records = $this->post('records'); $pdid = $records['pd_id']; $blob = $records['content']; @@ -5360,349 +4774,294 @@ public function getPDFormDetailsJSON_post() $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); $main_applicant_name = $pd_master_details[0]['main_applicant']; //print_r($pd_master_details); - + //update BLOB in pd trigger Table $latest_version = $pd_master_details[0]['pd_report_latest_version']; $where_condition_array = array('pd_id' => $pdid); - $temp_array = array('pd_report_latest_version_blob' => $blob,'fk_updatedby' => $fk_updatedby); - $mas_id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); - - + $temp_array = array('pd_report_latest_version_blob' => $blob, 'fk_updatedby' => $fk_updatedby); + $mas_id = $this->PD_Model->updateRecords($temp_array, PDTRIGGER, $where_condition_array); + + //store BLOB in t_pd_reports_version_blob Table //$latest_version = $pd_master_details[0]['pd_report_latest_version'] + 1; //$where_condition_array = array('pd_id' => $pdid); - $temp_array_one = array('content' => $blob,'fk_updatedby'=>$fk_updatedby); - $where_condition_array = array('fk_pd_id' => $pdid,'version_no' => $latest_version); - $id = $this->PD_Model->updateRecords($temp_array_one,PDREPORTSVERSIONBLOB,$where_condition_array); - - //convert BLOB as html then pdf then store it s3. - $output_file = APPPATH."/docs/temp.html"; - $ifp = fopen( $output_file, 'wb' ); - //fwrite( $ifp, $original_template ); - fwrite( $ifp, $blob ); - fclose( $ifp ); - //print_r($output_file); - $file= file_get_contents($output_file); - $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //print_r($pdf_doc); - + $temp_array_one = array('content' => $blob, 'fk_updatedby' => $fk_updatedby); + $where_condition_array = array('fk_pd_id' => $pdid, 'version_no' => $latest_version); + $id = $this->PD_Model->updateRecords($temp_array_one, PDREPORTSVERSIONBLOB, $where_condition_array); - $output_file2 = APPPATH."/docs/sample.pdf"; - if(file_put_contents($output_file2, $pdf_doc)) - { - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'_version'.$latest_version.'.pdf'; + //convert BLOB as html then pdf then store it s3. + $output_file = APPPATH . "/docs/temp.html"; + $ifp = fopen($output_file, 'wb'); + //fwrite( $ifp, $original_template ); + fwrite($ifp, $blob); + fclose($ifp); + //print_r($output_file); + $file = file_get_contents($output_file); + $pdf_doc = $this->pdfgenerator->generate($file, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); + //print_r($pdf_doc); + + + $output_file2 = APPPATH . "/docs/sample.pdf"; + if (file_put_contents($output_file2, $pdf_doc)) { + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + $key = 'pd' . $pdid . '/pd_reports/' . $main_applicant_name . '_version' . $latest_version . '.pdf'; $sourcefile = $output_file2; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - //print_r($s3result); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid); - if($id != null || $id != "" ) - { + $urls = $this->getALLPDReportsSingedURLs($bucketname, $key, $pdid); + if ($id != null || $id != "") { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $urls; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } + } - //End of convert BLOB as html then pdf then store it s3. + //End of convert BLOB as html then pdf then store it s3. } - - - } - + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function getListOfPDReportVersions_post() { $records = $this->post('records'); - + $pdid = $records['pd_id']; - - + + //Get PD Master Details $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); $main_applicant_name = $pd_master_details[0]['main_applicant']; $lender_id = $pd_master_details[0]['fk_lender_id']; - - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; - $key = 'pd'.$pdid.'/pd_reports'; + + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $lender_id; + $key = 'pd' . $pdid . '/pd_reports'; //$key = 'pd'.$pdid; - $urls = $this->getALLPDReportsSingedURLs($bucket_name,$key,$pdid); - - if(count($urls)) - { + $urls = $this->getALLPDReportsSingedURLs($bucket_name, $key, $pdid); + + if (count($urls)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pdstatus' => $pd_master_details[0]['pd_status'],'reports_urls' => $urls); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $data['records'] = array('pdstatus' => $pd_master_details[0]['pd_status'], 'reports_urls' => $urls); + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'PD Report Not Generated'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - - - } - - - /********************************************************************************************* - *********************************************************************************************/ - public function getALLPDReportsSingedURLs($bucket_name,$key,$pdid) - { - - //Get Blob version - $fields = array('version_no','concat(USERPROFILE.first_name,USERPROFILE.last_name) as createdby','DATE_FORMAT(PDREPORTSVERSIONBLOB.createdon,"%d %b %Y at %h:%i:%s %p") as createdon','PDREPORTSVERSIONBLOB.fk_createdby'); - $where_condition_array = array('fk_pd_id'=>$pdid); - $table = PDREPORTSVERSIONBLOB.' as PDREPORTSVERSIONBLOB'; - $joins = array( array('table' => USERPROFILE. ' as USERPROFILE', - 'condition' =>'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid', - 'jointype' => 'INNER') - ); - + + /********************************************************************************************* + *********************************************************************************************/ + public function getALLPDReportsSingedURLs($bucket_name, $key, $pdid) + { + + //Get Blob version + $fields = array('version_no', 'concat(USERPROFILE.first_name,USERPROFILE.last_name) as createdby', 'DATE_FORMAT(PDREPORTSVERSIONBLOB.createdon,"%d %b %Y at %h:%i:%s %p") as createdon', 'PDREPORTSVERSIONBLOB.fk_createdby'); + $where_condition_array = array('fk_pd_id' => $pdid); + $table = PDREPORTSVERSIONBLOB . ' as PDREPORTSVERSIONBLOB'; + $joins = array( + array( + 'table' => USERPROFILE . ' as USERPROFILE', + 'condition' => 'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid', + 'jointype' => 'INNER' + ) + + ); + //Get Max No of blob version - $max_version = $this->db->SELECT('MAX(version_no) as max_version')->FROM(PDREPORTSVERSIONBLOB)->WHERE('fk_pd_id',$pdid)->GET()->result_array(); - - $blob_versions = $this->PD_Model->getJoinRecords($fields,$table,$joins,$where_condition_array); - + $max_version = $this->db->SELECT('MAX(version_no) as max_version')->FROM(PDREPORTSVERSIONBLOB)->WHERE('fk_pd_id', $pdid)->GET()->result_array(); + + $blob_versions = $this->PD_Model->getJoinRecords($fields, $table, $joins, $where_condition_array); + //print_r($max_version); - $all_objects = $this->aws_s3->getAllObjectsInaBucket($bucket_name,$key); + $all_objects = $this->aws_s3->getAllObjectsInaBucket($bucket_name, $key); $uri = array(); - foreach($all_objects as $obj) - { - //print_r($obj); + foreach ($all_objects as $obj) { + //print_r($obj); $uri[]['doc_name'] = $obj['Key']; } - //print_r($uri); - if(count($uri)) - { + //print_r($uri); + if (count($uri)) { - foreach($uri as $uri_key => $url) - { - $uri[$uri_key]['doc_uri'] = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$url['doc_name'],$time = '3600 seconds'); - //echo $key; - $uri[$uri_key]['doc_name'] = str_replace($key.'/',"",$uri[$uri_key]['doc_name']); + foreach ($uri as $uri_key => $url) { + $uri[$uri_key]['doc_uri'] = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $url['doc_name'], $time = '3600 seconds'); + //echo $key; + $uri[$uri_key]['doc_name'] = str_replace($key . '/', "", $uri[$uri_key]['doc_name']); - //find version no from file + //find version no from file $version_no = 0; - if(is_numeric(substr($uri[$uri_key]['doc_name'],-7,3))) - { - $version_no = substr($uri[$uri_key]['doc_name'],-7,3); - - } - else if(is_numeric(substr($uri[$uri_key]['doc_name'],-6,2))) - { - $version_no = substr($uri[$uri_key]['doc_name'],-6,2); - - }else if(is_numeric(substr($uri[$uri_key]['doc_name'],-5,1))) - { - $version_no = substr($uri[$uri_key]['doc_name'],-5,1); + if (is_numeric(substr($uri[$uri_key]['doc_name'], -7, 3))) { + $version_no = substr($uri[$uri_key]['doc_name'], -7, 3); + } else if (is_numeric(substr($uri[$uri_key]['doc_name'], -6, 2))) { + $version_no = substr($uri[$uri_key]['doc_name'], -6, 2); + } else if (is_numeric(substr($uri[$uri_key]['doc_name'], -5, 1))) { + $version_no = substr($uri[$uri_key]['doc_name'], -5, 1); } $uri[$uri_key]['version'] = (int)$version_no; - if(count($blob_versions)) - { - foreach($blob_versions as $blob_key => $blob) - { - if($blob['version_no'] == $version_no) - { + if (count($blob_versions)) { + foreach ($blob_versions as $blob_key => $blob) { + if ($blob['version_no'] == $version_no) { $uri[$uri_key]['createdby'] = $blob['createdby']; $uri[$uri_key]['createdon'] = $blob['createdon']; } $uri[$uri_key]['is_latest'] = 0; - if(($blob['version_no'] == $max_version[0]['max_version']) &&($version_no == $max_version[0]['max_version'])) - { + if (($blob['version_no'] == $max_version[0]['max_version']) && ($version_no == $max_version[0]['max_version'])) { $uri[$uri_key]['is_latest'] = 1; } } } - // if($uri_key == (count($uri)-1)) - // { - // $uri[$uri_key]['is_latest'] = 1; - // }else - // { - // $uri[$uri_key]['is_latest'] = 0; - // } + // if($uri_key == (count($uri)-1)) + // { + // $uri[$uri_key]['is_latest'] = 1; + // }else + // { + // $uri[$uri_key]['is_latest'] = 0; + // } } } return $uri; - } - - + + /********************************************************************************************* - *********************************************************************************************/ + *********************************************************************************************/ public function getTypeOfActivetyFromBusinessForm_post() { - + $records = $this->post('records'); $pdid = $records['pd_id']; - + // $fields = array('column_name', 'column_value'); // $where_condition_array = array('column_name'=>'type_of_activity','isactive'=>1,'fk_form_id'=>13,'fk_pd_id'=>$pdid); // $or_where_total = array(array('column_name'=>'profession_name')); // $result_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILS,$or_where_total); - - $this->db->SELECT('column_name,column_value'); - $this->db->FROM(PDFORMDETAILS); - $this->db->WHERE('isactive',1); - $this->db->WHERE('fk_form_id',13); - $this->db->WHERE('fk_pd_id',$pdid); + + $this->db->SELECT('column_name,column_value'); + $this->db->FROM(PDFORMDETAILS); + $this->db->WHERE('isactive', 1); + $this->db->WHERE('fk_form_id', 13); + $this->db->WHERE('fk_pd_id', $pdid); $this->db->GROUP_START(); - $this->db->OR_WHERE('column_name','type_of_activity_id'); - $this->db->OR_WHERE('column_name','profession_name'); + $this->db->OR_WHERE('column_name', 'type_of_activity_id'); + $this->db->OR_WHERE('column_name', 'profession_name'); $this->db->GROUP_END(); $result_array = $this->db->GET()->result_array(); //print_r($result_array);die(); - - if(count($result_array)) - { + + if (count($result_array)) { $final_data = array(); - foreach($result_array as $res_key => $res) - { - if($res['column_name'] == 'profession_name') - { + foreach ($result_array as $res_key => $res) { + if ($res['column_name'] == 'profession_name') { $final_data['profession_name'] = $res['column_value']; + } else { + if (count($result_array) > 0) { + $final_data['type_of_activity'][] = $res['column_value']; + } } - else - { - if(count($result_array) > 0){ - $final_data['type_of_activity'][] = $res['column_value'];} - } - } + } //print_r($final_data); - if(array_key_exists('type_of_activity',$final_data)) - { - foreach($final_data['type_of_activity'] as $f_key => $f_value) - { - $fields = array('name'); - $where_condition_array = array('type_of_activity_id'=>$f_value,'isactive'=>1); - $result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TYPEOFACTIVITY); - $final_data['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value,'name' =>$result[0]['name']); - - } + if (array_key_exists('type_of_activity', $final_data)) { + foreach ($final_data['type_of_activity'] as $f_key => $f_value) { + $fields = array('name'); + $where_condition_array = array('type_of_activity_id' => $f_value, 'isactive' => 1); + $result = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, TYPEOFACTIVITY); + $final_data['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value, 'name' => $result[0]['name']); } + } - if(count($final_data)) - { - //Get Products from Business Form - $fields_pro = array('iter_column_name','column_value'); - $where_condition_array_pro = array('column_name'=>'main_products','isactive'=>1,'fk_pd_id' => $pdid, 'fk_form_id'=> 13); - $prodcuts = $this->PD_Model->selectCustomRecords($fields_pro,$where_condition_array_pro,PDFORMDETAILS); + if (count($final_data)) { + //Get Products from Business Form + $fields_pro = array('iter_column_name', 'column_value'); + $where_condition_array_pro = array('column_name' => 'main_products', 'isactive' => 1, 'fk_pd_id' => $pdid, 'fk_form_id' => 13); + $prodcuts = $this->PD_Model->selectCustomRecords($fields_pro, $where_condition_array_pro, PDFORMDETAILS); //print_r($prodcuts);die(); - if(array_key_exists('type_of_activity',$final_data)) - { - foreach($final_data['type_of_activity'] as $activity_key => $activity) - { + if (array_key_exists('type_of_activity', $final_data)) { + foreach ($final_data['type_of_activity'] as $activity_key => $activity) { //print_r($activity); - if($activity['type_of_activity_id'] == 1) - { - $temp = array(); - foreach($prodcuts as $product_key => $product) - { + if ($activity['type_of_activity_id'] == 1) { + $temp = array(); + foreach ($prodcuts as $product_key => $product) { - if($product['iter_column_name'] == 'manufacturing_activity_details') - { - $temp[] = array('id' => $product_key,'name' => $product['column_value']); - } + if ($product['iter_column_name'] == 'manufacturing_activity_details') { + $temp[] = array('id' => $product_key, 'name' => $product['column_value']); } - $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; } - else if($activity['type_of_activity_id'] == 2)//Retail trading + $final_data['type_of_activity'][$activity_key]['prodcuts'] = $temp; + } else if ($activity['type_of_activity_id'] == 2) //Retail trading { $temp = array(); - foreach($prodcuts as $product_key => $product) - { - - if($product['iter_column_name'] == 'retail_trading__activity_details') - { - $temp[] = array('id' => $product_key,'name' => $product['column_value']); + foreach ($prodcuts as $product_key => $product) { + + if ($product['iter_column_name'] == 'retail_trading__activity_details') { + $temp[] = array('id' => $product_key, 'name' => $product['column_value']); } } - $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; - } - else if($activity['type_of_activity_id'] == 3)//Wholesale Trade wholesale_trading_activity_details + $final_data['type_of_activity'][$activity_key]['prodcuts'] = $temp; + } else if ($activity['type_of_activity_id'] == 3) //Wholesale Trade wholesale_trading_activity_details { $temp = array(); - foreach($prodcuts as $product_key => $product) - { - - if($product['iter_column_name'] == 'wholesale_trading_activity_details') - { - $temp[] = array('id' => $product_key,'name' => $product['column_value']); + foreach ($prodcuts as $product_key => $product) { + + if ($product['iter_column_name'] == 'wholesale_trading_activity_details') { + $temp[] = array('id' => $product_key, 'name' => $product['column_value']); } } - $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; - } - else//Service Provider + $final_data['type_of_activity'][$activity_key]['prodcuts'] = $temp; + } else //Service Provider { $temp = array(); - foreach($prodcuts as $product_key => $product) - { - - if($product['iter_column_name'] == 'wholesale_trading_activity_details') - { - $temp[] = array('id' => $product_key,'name' => $product['column_value']); + foreach ($prodcuts as $product_key => $product) { + + if ($product['iter_column_name'] == 'wholesale_trading_activity_details') { + $temp[] = array('id' => $product_key, 'name' => $product['column_value']); } } - $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; + $final_data['type_of_activity'][$activity_key]['prodcuts'] = $temp; } - } } - //Response + //Response $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $final_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = "Fill Business Details First/ No Data Available!"; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - - }else{ + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = "Fill Business Details First/ No Data Available!"; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - } - + public function getTypeOfActivetyFromBusinessJSON_post() { $records = $this->post('records'); @@ -5710,240 +5069,187 @@ public function getPDFormDetailsJSON_post() $company_id = $records['company_id']; $final_array = array(); $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>13,'fk_pd_id'=>$pd_id,'company_id' => $company_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 13, 'fk_pd_id' => $pd_id, 'company_id' => $company_id); + $rec = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); //print_r($this->db->last_query()); //print_r($rec); - if(count($rec)) - { - $temp_data = json_decode($rec[0]['json'],true); + if (count($rec)) { + $temp_data = json_decode($rec[0]['json'], true); // print_r($temp_data); - // $final_array['profession_name'] = $temp_data['profession_name']; - // $final_array['profession_name_other'] = ""; - // if(array_key_exists('profession_name_other',$temp_data)) - // { - // $final_array['profession_name_other'] = $temp_data['profession_name_other']; - // } + // $final_array['profession_name'] = $temp_data['profession_name']; + // $final_array['profession_name_other'] = ""; + // if(array_key_exists('profession_name_other',$temp_data)) + // { + // $final_array['profession_name_other'] = $temp_data['profession_name_other']; + // } $final_array['type_of_activity'] = $temp_data['select_business_activity_type']; - foreach($final_array['type_of_activity'] as $f_key => $f_value) - { + foreach ($final_array['type_of_activity'] as $f_key => $f_value) { $fields = array('name'); - $where_condition_array = array('type_of_activity_id'=>$f_value['type_of_activity_id'],'isactive'=>1); - $result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TYPEOFACTIVITY); - $final_array['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value['type_of_activity_id'],'name' =>$result[0]['name']); - - if($f_value['type_of_activity_id'] == 2) - { - if(array_key_exists('manufacturing_activity_details',$temp_data)) - { + $where_condition_array = array('type_of_activity_id' => $f_value['type_of_activity_id'], 'isactive' => 1); + $result = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, TYPEOFACTIVITY); + $final_array['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value['type_of_activity_id'], 'name' => $result[0]['name']); + + if ($f_value['type_of_activity_id'] == 2) { + if (array_key_exists('manufacturing_activity_details', $temp_data)) { $temp = array(); - foreach($temp_data['manufacturing_activity_details'] as $product_key => $product) - { - $temp[] = array('id' => $product_key,'name' => $product['main_products']); + foreach ($temp_data['manufacturing_activity_details'] as $product_key => $product) { + $temp[] = array('id' => $product_key, 'name' => $product['main_products']); } - $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; + $final_array['type_of_activity'][$f_key]['prodcuts'] = $temp; } - } - else if($f_value['type_of_activity_id'] == 3)//Retail trading - { - if(array_key_exists('retail_trading_activity_details',$temp_data)) - { - $temp = array(); - foreach($temp_data['retail_trading_activity_details'] as $product_key => $product) - { - $temp[] = array('id' => $product_key,'name' => $product['main_products']); - } - $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; - } - } - else if($f_value['type_of_activity_id'] == 4)//Wholesale Trade wholesale_trading_activity_details - { - $temp = array(); - foreach($temp_data['wholesale_trading_activity_details'] as $product_key => $product) - { - - $temp[] = array('id' => $product_key,'name' => $product['main_products']); - } - $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; - } - else if($f_value['type_of_activity_id'] == 5)//Service Provider - { - $temp = array(); - foreach($temp_data['service_provider_activity_details'] as $product_key => $product) - { - - $temp[] = array('id' => $product_key,'name' => $product['main_products']); - - } - $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; - } - } - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $final_array; - $this->response($data,REST_Controller::HTTP_OK); - - } - else + } else if ($f_value['type_of_activity_id'] == 3) //Retail trading { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Fill Business Form First! / No Company Found at this ID $company_id!"; - $this->response($data,REST_Controller::HTTP_OK); + if (array_key_exists('retail_trading_activity_details', $temp_data)) { + $temp = array(); + foreach ($temp_data['retail_trading_activity_details'] as $product_key => $product) { + $temp[] = array('id' => $product_key, 'name' => $product['main_products']); + } + $final_array['type_of_activity'][$f_key]['prodcuts'] = $temp; + } + } else if ($f_value['type_of_activity_id'] == 4) //Wholesale Trade wholesale_trading_activity_details + { + $temp = array(); + foreach ($temp_data['wholesale_trading_activity_details'] as $product_key => $product) { + $temp[] = array('id' => $product_key, 'name' => $product['main_products']); + } + $final_array['type_of_activity'][$f_key]['prodcuts'] = $temp; + } else if ($f_value['type_of_activity_id'] == 5) //Service Provider + { + $temp = array(); + foreach ($temp_data['service_provider_activity_details'] as $product_key => $product) { + + $temp[] = array('id' => $product_key, 'name' => $product['main_products']); + } + $final_array['type_of_activity'][$f_key]['prodcuts'] = $temp; } - - - - } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $final_array; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Fill Business Form First! / No Company Found at this ID $company_id!"; + $this->response($data, REST_Controller::HTTP_OK); + } + } + /********************************************************************************************* - *********************************************************************************************/ - + *********************************************************************************************/ + public function swapOlderPDReporttoLatest_post() { $records = $this->post('records'); - + $pdid = $records['pd_id']; - + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); $main_applicant_name = $pd_master_details[0]['main_applicant']; $doc_name = $records['doc_name']; $fk_createdby = $records['fk_createdby']; - + $version_no = ""; - - if(is_numeric(substr($doc_name,-7,3))) - { - $version_no = substr($doc_name,-7,3); - - } - else if(is_numeric(substr($doc_name,-6,2))) - { - $version_no = substr($doc_name,-6,2); - - }else if(is_numeric(substr($doc_name,-5,1))) - { - $version_no = substr($doc_name,-5,1); - } - else - { + + if (is_numeric(substr($doc_name, -7, 3))) { + $version_no = substr($doc_name, -7, 3); + } else if (is_numeric(substr($doc_name, -6, 2))) { + $version_no = substr($doc_name, -6, 2); + } else if (is_numeric(substr($doc_name, -5, 1))) { + $version_no = substr($doc_name, -5, 1); + } else { $version_no = 1; } - - //Get Latest Version from PD Master Table - //$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); - //Get Blob from blob table + //Get Latest Version from PD Master Table + //$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + + //Get Blob from blob table $fields = array('content'); - $where_condition_array = array('fk_pd_id'=>$pdid,'version_no'=>$version_no); - $result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDREPORTSVERSIONBLOB); + $where_condition_array = array('fk_pd_id' => $pdid, 'version_no' => $version_no); + $result = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDREPORTSVERSIONBLOB); - if(count($result)) - { - $temp_array = array('content' => $result[0]['content'],'fk_pd_id'=> $pdid,'fk_createdby'=>$fk_createdby,'version_no' => ($pd_master_details[0]['pd_report_latest_version'] + 1)); - $id = $this->PD_Model->saveRecords($temp_array,PDREPORTSVERSIONBLOB); + if (count($result)) { + $temp_array = array('content' => $result[0]['content'], 'fk_pd_id' => $pdid, 'fk_createdby' => $fk_createdby, 'version_no' => ($pd_master_details[0]['pd_report_latest_version'] + 1)); + $id = $this->PD_Model->saveRecords($temp_array, PDREPORTSVERSIONBLOB); - if($id != null || $id != "") - { - $temp_array = array('pd_report_latest_version_blob' => $result[0]['content'],'pd_report_latest_version' => ($pd_master_details[0]['pd_report_latest_version'] + 1)); + if ($id != null || $id != "") { + $temp_array = array('pd_report_latest_version_blob' => $result[0]['content'], 'pd_report_latest_version' => ($pd_master_details[0]['pd_report_latest_version'] + 1)); - $where_condition_array = array('pd_id'=>$pdid); - $master_result = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); + $where_condition_array = array('pd_id' => $pdid); + $master_result = $this->PD_Model->updateRecords($temp_array, PDTRIGGER, $where_condition_array); - if($master_result != null || $master_result != "") - { - //do doc renegerate things here..... + if ($master_result != null || $master_result != "") { + //do doc renegerate things here..... - $output_file = APPPATH."/docs/temp.html"; - $ifp = fopen( $output_file, 'wb' ); - //fwrite( $ifp, $original_template ); - fwrite( $ifp, $result[0]['content'] ); - fclose( $ifp ); - //print_r($output_file); - $file= file_get_contents($output_file); - $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //print_r($pdf_doc); + $output_file = APPPATH . "/docs/temp.html"; + $ifp = fopen($output_file, 'wb'); + //fwrite( $ifp, $original_template ); + fwrite($ifp, $result[0]['content']); + fclose($ifp); + //print_r($output_file); + $file = file_get_contents($output_file); + $pdf_doc = $this->pdfgenerator->generate($file, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); + //print_r($pdf_doc); - $output_file2 = APPPATH."/docs/sample.pdf"; - if(file_put_contents($output_file2, $pdf_doc)) - { - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'_version'.($pd_master_details[0]['pd_report_latest_version'] + 1).'.pdf'; + $output_file2 = APPPATH . "/docs/sample.pdf"; + if (file_put_contents($output_file2, $pdf_doc)) { + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + $key = 'pd' . $pdid . '/pd_reports/' . $main_applicant_name . '_version' . ($pd_master_details[0]['pd_report_latest_version'] + 1) . '.pdf'; $sourcefile = $output_file2; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - - $urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid); - if($id != null || $id != "" ) - { + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + + $urls = $this->getALLPDReportsSingedURLs($bucketname, $key, $pdid); + if ($id != null || $id != "") { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $urls; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } - } - - - - - - - - } - else - { + } + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Version Not Updated in Master Table! Contact System Admin'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Version Not Updated!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'No older Version Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - - } - + /********************************************************************************************* - *********************************************************************************************/ - - + *********************************************************************************************/ + + public function smartyTestFunction_post() { - - - $this->smarty->assign('title','Test Title'); + + + $this->smarty->assign('title', 'Test Title'); $this->smarty->assign('description', 'Test Description'); //$this->smarty->display('index.tpl'); $data['pdif'] = '10'; @@ -5952,63 +5258,60 @@ public function getPDFormDetailsJSON_post() $data['lender_name'] = 'HDFC'; $data['product'] = 'Home Loan'; $data['type_of_activity'] = 'Manufacturing'; - $data['applicants'] = array(array('name' => 'Rajesh Kumar','age' => '56'),array('name' => 'santhosh Kumar','age' => '45')); + $data['applicants'] = array(array('name' => 'Rajesh Kumar', 'age' => '56'), array('name' => 'santhosh Kumar', 'age' => '45')); $this->smarty->assign("FirstName", array("John", "Mary", "James", "Henry")); - $fin = $this->smarty->view('index.tpl' , $data); - + $fin = $this->smarty->view('index.tpl', $data); + // echo "CON"; print_r($fin); - + // $temp_array = array('content' => $fin,'fk_pd_id'=> 555); - // $id = $this->PD_Model->saveRecords($temp_array,PDREPORTSVERSIONBLOB); + // $id = $this->PD_Model->saveRecords($temp_array,PDREPORTSVERSIONBLOB); - // $data['dataStatus'] = true; - // $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - // $data['msg'] = $fin; - // $this->response($data,REST_Controller::HTTP_OK); + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + // $data['msg'] = $fin; + // $this->response($data,REST_Controller::HTTP_OK); - $output_file = APPPATH."/docs/temp.html"; - $ifp = fopen( $output_file, 'wb' ); - //fwrite( $ifp, $original_template ); - fwrite( $ifp, $fin ); - fclose( $ifp ); - //print_r($output_file); - $file= file_get_contents($output_file); - $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //print_r($pdf_doc); - + $output_file = APPPATH . "/docs/temp.html"; + $ifp = fopen($output_file, 'wb'); + //fwrite( $ifp, $original_template ); + fwrite($ifp, $fin); + fclose($ifp); + //print_r($output_file); + $file = file_get_contents($output_file); + $pdf_doc = $this->pdfgenerator->generate($file, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); + //print_r($pdf_doc); - $output_file2 = APPPATH."/docs/sample.pdf"; + + $output_file2 = APPPATH . "/docs/sample.pdf"; echo file_put_contents($output_file2, $pdf_doc); - - } - + // Not in use**************moved to helper file function getSatelliteImage($pd_id) { $pdid = $pd_id; - $logger = MYLOG::logFunction(null,$pdid); + $logger = MYLOG::logFunction(null, $pdid); - if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + if (!file_exists($this->external_path . '/pd_reports/' . $pdid)) { + mkdir($this->external_path . '/pd_reports/' . $pdid, 0777); } $pdmas = $this->PD_Model->getPDMasterDetails($pdid); //print_r($pdmas); //load satellite script from db //$satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomsatellite_local'),SCRIPTS); - - $satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => SATELLITE_IMAGE_LOCATION),SCRIPTS); + + $satellite_script_from_db = $this->PD_Model->selectCustomRecords(array('*'), array('script_name' => SATELLITE_IMAGE_LOCATION), SCRIPTS); $satellite_script = $satellite_script_from_db[0]['script_content']; - - + + //Get Address Data - - // $address = preg_replace("/[\n\r]/","",$pdmas[0]['addressline1']); - + + // $address = preg_replace("/[\n\r]/","",$pdmas[0]['addressline1']); + //$address = $address.','.$pdmas[0]['city_name'].','.$pdmas[0]['state_name']; - + //Replacing space with + symbol // $address =str_replace(' ','+',$address); // $address =str_replace('\n','',$address); @@ -6017,76 +5320,69 @@ public function getPDFormDetailsJSON_post() // $address =str_replace(PHP_EOL,'',$address); $geo_location = $pdmas[0]['start_location']; $google_map_static_api_key = GOOGLE_STATIC_MAP_API_KEY; - - + + //Replacing Place holders - - $apppath = str_replace('\\','/',$this->external_path.'/pd_reports/'.$pdid); - $satellite_script = str_replace('{{APPPATH}}',$apppath,$satellite_script); - $satellite_script = str_replace('{{ADDRESS}}',$geo_location,$satellite_script); - $satellite_script = str_replace('{{GEOLOCATION}}',$geo_location,$satellite_script); - $satellite_script = str_replace('{{API_KEY}}',$google_map_static_api_key,$satellite_script); + + $apppath = str_replace('\\', '/', $this->external_path . '/pd_reports/' . $pdid); + $satellite_script = str_replace('{{APPPATH}}', $apppath, $satellite_script); + $satellite_script = str_replace('{{ADDRESS}}', $geo_location, $satellite_script); + $satellite_script = str_replace('{{GEOLOCATION}}', $geo_location, $satellite_script); + $satellite_script = str_replace('{{API_KEY}}', $google_map_static_api_key, $satellite_script); //echo $satellite_script;die(); - - file_put_contents(APPPATH.'/views/js/phantomsatellite.js',$satellite_script); - + + file_put_contents(APPPATH . '/views/js/phantomsatellite.js', $satellite_script); + //call& execute phantom script - $str = 'phantomjs '.APPPATH.'/views/js/phantomsatellite.js'; - exec($str,$ou); + $str = 'phantomjs ' . APPPATH . '/views/js/phantomsatellite.js'; + exec($str, $ou); exec('phantom.exit();'); - - + + // //convert as base 64 image. - $satellite_image_png_path = $this->external_path.'/pd_reports/'. $pdid .'/satellite.png'; + $satellite_image_png_path = $this->external_path . '/pd_reports/' . $pdid . '/satellite.png'; $pd_details = $this->PD_Model->getPDMasterDetails($pdid); - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; - $key = 'pd'.$pdid.'/'.'satellite.png'; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$this->external_path.'/pd_reports/'.$pdid.'/satellite.png'); + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details[0]['fk_lender_id']; + $key = 'pd' . $pdid . '/' . 'satellite.png'; + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $this->external_path . '/pd_reports/' . $pdid . '/satellite.png'); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - $this->PD_Model->updateRecords(array('isactive' => 0),PDDOCUMENTS,array('pd_document_title' => 'satellite','fk_pd_id' => $pd_id)); - $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>'satellite','pd_document_name'=>'satellite.png','fk_form_id'=>null,'rental_count_id' => null,'location' => null); - $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - - $custom_log_info = '###CUSTOM DEBUG SATELLITE IMAGE STORED IN S3 DONE - '. $id; - log_message('ERROR',$custom_log_info); + $this->PD_Model->updateRecords(array('isactive' => 0), PDDOCUMENTS, array('pd_document_title' => 'satellite', 'fk_pd_id' => $pd_id)); + $record_data = array('fk_pd_id' => $pdid, 'pd_document_title' => 'satellite', 'pd_document_name' => 'satellite.png', 'fk_form_id' => null, 'rental_count_id' => null, 'location' => null); + $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); - + $custom_log_info = '###CUSTOM DEBUG SATELLITE IMAGE STORED IN S3 DONE - ' . $id; + log_message('ERROR', $custom_log_info); } - // $type = pathinfo($satellite_image_png_path, PATHINFO_EXTENSION); + // $type = pathinfo($satellite_image_png_path, PATHINFO_EXTENSION); // $satellite_img_content = file_get_contents($satellite_image_png_path); // $base64_pdscore_chart_url = 'data:image/' . $type . ';base64,' . base64_encode($satellite_img_content); - + //generate log - $logger->info("Generate Satellite Called in (".ENVIRONMENT.")",array('script' => $satellite_script,'script_output' => $ou)); + $logger->info("Generate Satellite Called in (" . ENVIRONMENT . ")", array('script' => $satellite_script, 'script_output' => $ou)); //return $base64_pdscore_chart_url; - + } - + function getDetailedScoreCardChart($score) { $business_score['business'] = ($score['business']); $general_score['general'] = ($score['general']); - foreach($business_score['business'] as $bsk => $score) - { - if((!($bsk == 'cerificates')) && (!strcasecmp($score['answer'],'not applicable'))) - { + foreach ($business_score['business'] as $bsk => $score) { + if ((!($bsk == 'cerificates')) && (!strcasecmp($score['answer'], 'not applicable'))) { unset($business_score['business'][$bsk]); } } - foreach($general_score['general'] as $gsk => $g_score) - { - if(($gsk == 'neibourhood_check_as_per_pd_officer') && (!strcasecmp($g_score['answer'],'Could not verify'))) - { + foreach ($general_score['general'] as $gsk => $g_score) { + if (($gsk == 'neibourhood_check_as_per_pd_officer') && (!strcasecmp($g_score['answer'], 'Could not verify'))) { unset($general_score['general'][$gsk]); } } @@ -6094,128 +5390,121 @@ public function getPDFormDetailsJSON_post() $business_score['business'] = array_reverse($business_score['business']); $general_score['general'] = array_reverse($general_score['general']); - // print_r($general_score['general']); - // print_r($business_score['business']); + // print_r($general_score['general']); + // print_r($business_score['business']); - // die(); + // die(); $data = array(); $img_name = ''; - - for($i = 1;$i < 3;$i++) - { - - // Incase running from local windows - //$dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantom_dsc_local'),SCRIPTS); - $dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => DETAILED_SCORE_CARD_IMAGE_LOCATION),SCRIPTS); + for ($i = 1; $i < 3; $i++) { + + // Incase running from local windows + //$dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantom_dsc_local'),SCRIPTS); + + $dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'), array('script_name' => DETAILED_SCORE_CARD_IMAGE_LOCATION), SCRIPTS); + + if (count($dsc_script_from_db)) { - if(count($dsc_script_from_db)) - { - $dsc_script_from_db = $dsc_script_from_db[0]['script_content']; - //print_r($dsc_script_from_db); + //print_r($dsc_script_from_db); $html_content = ""; - if($i == 1){ $html_content = $this->load->view('business_scorecard',$business_score,true); } + if ($i == 1) { + $html_content = $this->load->view('business_scorecard', $business_score, true); + } else if ($i == 2) { + $html_content = $this->load->view('general_scorecard', $general_score, true); + } + //print_r($html_content); + $apppath = str_replace('\\', '/', APPPATH); + $dsc_script_from_db = str_replace('{{APPPATH}}', $apppath, $dsc_script_from_db); + $dsc_script_from_db = str_replace('{{html_content}}', $html_content, $dsc_script_from_db); + $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}', 'dsc_business', $dsc_script_from_db) : str_replace('{{img_name}}', 'dsc_general', $dsc_script_from_db); + //print_r($dsc_script_from_db);die(); + //$logger = MYLOG::logFunction(); + //$logger->info('Score Card Graphical Representation called',array('card_type' => $i,'script' => $dsc_script_from_db)); + //echo $dsc_script_from_db; + //echo "*************"; + file_put_contents(APPPATH . '/views/js/phantomdsc.js', $dsc_script_from_db); - else if($i == 2) { $html_content = $this->load->view('general_scorecard',$general_score,true);} - //print_r($html_content); - $apppath = str_replace('\\','/',APPPATH); - $dsc_script_from_db = str_replace('{{APPPATH}}',$apppath,$dsc_script_from_db); - $dsc_script_from_db = str_replace('{{html_content}}',$html_content,$dsc_script_from_db); - $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}','dsc_business',$dsc_script_from_db) : str_replace('{{img_name}}','dsc_general',$dsc_script_from_db); - //print_r($dsc_script_from_db);die(); - //$logger = MYLOG::logFunction(); - //$logger->info('Score Card Graphical Representation called',array('card_type' => $i,'script' => $dsc_script_from_db)); - //echo $dsc_script_from_db; - //echo "*************"; - file_put_contents(APPPATH.'/views/js/phantomdsc.js',$dsc_script_from_db); - - //call& execute phantom script - $str = 'phantomjs '.APPPATH.'/views/js/phantomdsc.js'; - exec($str,$ou); + //call& execute phantom script + $str = 'phantomjs ' . APPPATH . '/views/js/phantomdsc.js'; + exec($str, $ou); exec('phantom.exit();'); - // //convert as base 64 image. - $dsc_image_png_path = $i == 1 ? APPPATH.'/views/report_templates/dsc_business.png' : APPPATH.'/views/report_templates/dsc_general.png'; + // //convert as base 64 image. + $dsc_image_png_path = $i == 1 ? APPPATH . '/views/report_templates/dsc_business.png' : APPPATH . '/views/report_templates/dsc_general.png'; $type = pathinfo($dsc_image_png_path, PATHINFO_EXTENSION); $dsc_img_content = file_get_contents($dsc_image_png_path); $base64_dsc_url = 'data:image/' . $type . ';base64,' . base64_encode($dsc_img_content); - if($i == 1){ $data['base64_dsc_business'] = $base64_dsc_url; } - else if($i == 2){ $data['base64_dsc_general'] = $base64_dsc_url; } - - } - else - { + if ($i == 1) { + $data['base64_dsc_business'] = $base64_dsc_url; + } else if ($i == 2) { + $data['base64_dsc_general'] = $base64_dsc_url; + } + } else { //$logger->error('SCORE CARD SCRIPT NOT FOUND'); } } - + // print_r($data); // die(); return $data; - - } function getAssessedIncomeForPDReport($pdid) { - - $assessed_config_details = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid),PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + + $assessed_config_details = $this->PD_Model->selectCustomRecords(array('*'), array('fk_pd_id' => $pdid), PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); $data = array(); - if(count($assessed_config_details)) - { - foreach($assessed_config_details as $ai) - { - $data[ $ai['company_id'] ]['core_details'] = $this->PD_Model->getAssessedIncome($pdid,$ai['company_id']); - - $data[ $ai['company_id'] ]['summary_details'] = $this->calculateAssessedIncome($pdid,$ai['company_id']); + if (count($assessed_config_details)) { + foreach ($assessed_config_details as $ai) { + $data[$ai['company_id']]['core_details'] = $this->PD_Model->getAssessedIncome($pdid, $ai['company_id']); + + $data[$ai['company_id']]['summary_details'] = $this->calculateAssessedIncome($pdid, $ai['company_id']); } return $data; + } else { + return null; } - else - { - return null; - } - - } + } - function demo($var) { + function demo($var) + { - echo " Before try block"; - try { + echo " Before try block"; + try { $try = 'THis is declared in side try block'; - echo "\n Inside try block"; + echo "\n Inside try block"; - // If var is zero then only if will be executed - if($var == 0) - { + // If var is zero then only if will be executed + if ($var == 0) { - // If var is zero then only exception is thrown - throw new Exception('Number is zero.'); + // If var is zero then only exception is thrown + throw new Exception('Number is zero.'); - // This line will never be executed - echo "\n After throw (It will never be executed)"; - } - } + // This line will never be executed + echo "\n After throw (It will never be executed)"; + } + } - // Catch block will be executed only - // When Exception has been thrown by try block - catch(Exception $e) { - echo "\n Exception Caught", $e->getMessage(); - echo "\n Exception Caught", $e->getLine(); - echo "\n Exception Caught", $e->getFile(); + // Catch block will be executed only + // When Exception has been thrown by try block + catch (Exception $e) { + echo "\n Exception Caught", $e->getMessage(); + echo "\n Exception Caught", $e->getLine(); + echo "\n Exception Caught", $e->getFile(); echo $try; - } + } - // This line will be executed whether - // Exception has been thrown or not - echo "\n After catch (will be always executed)"; - } + // This line will be executed whether + // Exception has been thrown or not + echo "\n After catch (will be always executed)"; + } public function codeigniterViewTest_post() { @@ -6223,19 +5512,19 @@ public function getPDFormDetailsJSON_post() // echo "i am here"; // exit(); // $host = getenv('DB_HOST'); -// echo $this->config->item('new_db_variable'); -// echo MY_CONSTANT; -// die(); -// // $this->load->library('myspreadsheet'); -// //print_r($myspreadsheet);die(); -// $spreadsheet = $this->myspreadsheet->getMySpreadSheet(); -// // print_r($sheet);die(); -// $sheet = $spreadsheet->getActiveSheet(); -// $sheet->setCellValue('A1', 'Hello World !'); + // echo $this->config->item('new_db_variable'); + // echo MY_CONSTANT; + // die(); + // // $this->load->library('myspreadsheet'); + // //print_r($myspreadsheet);die(); + // $spreadsheet = $this->myspreadsheet->getMySpreadSheet(); + // // print_r($sheet);die(); + // $sheet = $spreadsheet->getActiveSheet(); + // $sheet->setCellValue('A1', 'Hello World !'); -// $writer = $this->myspreadsheet->getXlsx($spreadsheet); -// $writer->save('hello world.xlsx'); -// die(); + // $writer = $this->myspreadsheet->getXlsx($spreadsheet); + // $writer->save('hello world.xlsx'); + // die(); // echo 'HI'; // die(); // $records = $this->post('records'); @@ -6248,24 +5537,24 @@ public function getPDFormDetailsJSON_post() //print_r($res); //PDALERTS::pdnotification(1797); // $this->aws_cognito->adminSetUserPassword('prashant.unjia@yahoo.com'); - + // echo 'Hi'; // die(); - + //$this->dupAssessedIncomeInfo(1192,9999,1);die(); //print_r($this->aws_s3->getAllObjectsInaBucket('test-lender1','pd114'));die(); //print_r($this->aws_s3->dupSinglePDImages('test-lender24','pd1247','pd1247dup'));die(); //satellite_image::getSatelliteImage(1704);die(); //echo $this->assignPDTempalate(1325);die(); //$this->getSatelliteImage(342);die();//velmurugan.s@venbainfotech.com -// PDALERTS::sendSalesPDMail($this,2);die(); + // PDALERTS::sendSalesPDMail($this,2);die(); //$this->load->helper('applicantname_grabber'); // print_r(APPLICANTNAME_GRABBER::getLatestApplicantsName(1390));die(); //satellite_image::getSatelliteImage(1442);die(); // $this->load->helper('push_notification'); // PUSH_NOTIFICATION::notifyWeb("fJJeUjCWSSs:APA91bHJIHVBJ4KuBbz5sEQSTXG171KpUyraekuejPedkCVrFrULvh8R8JmIHZlovA3QJogr007Yv6IN0Bhja_oBScMBFS2MAWAyPOWLDwsY-OeoPbOx8vzNalvJ7yt0jcB_atJcTbAD","The New PD 255 has been triggered...",array());die(); // print_r($this->db->error());die(); - //$s3result= $this->aws_s3->uploadFileToS3Bucket(array('bucket_name' =>'xmldatatest007' ,'key' => 'packages/tourone.xml','sourcefile' => 'C:\xampp\htdocs\XMLTOARRAY\mydata.xml',));die(); + //$s3result= $this->aws_s3->uploadFileToS3Bucket(array('bucket_name' =>'xmldatatest007' ,'key' => 'packages/tourone.xml','sourcefile' => 'C:\xampp\htdocs\XMLTOARRAY\mydata.xml',));die(); //$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI('xmldatatest007','packages/tourone.xml','+1 minutes'); //echo $singed_uri; // $new = simplexml_load_string(file_get_contents($singed_uri)); @@ -6278,12 +5567,11 @@ public function getPDFormDetailsJSON_post() //$external_path = $this->config->item('external_data_path'); - if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0761); + if (!file_exists($this->external_path . '/pd_reports/' . $pdid)) { + mkdir($this->external_path . '/pd_reports/' . $pdid, 0761); } // echo "finally"; -// exit(); + // exit(); // $this->load->helper('DIFFCHECK'); // $old_version = $this->external_path.'/pd_reports/'.$pdid.'/a.html'; @@ -6298,9 +5586,9 @@ public function getPDFormDetailsJSON_post() // } //DIFFCHECK::checkDiff($old_version,$new_version); - //xdiff_file_diff($old_version, $new_version, $this->external_path.'/pd_reports/'.$pdid.'/my_script.diff', 2); - //die(); - // $this->getSatelliteImage($pdid);die(); + //xdiff_file_diff($old_version, $new_version, $this->external_path.'/pd_reports/'.$pdid.'/my_script.diff', 2); + //die(); + // $this->getSatelliteImage($pdid);die(); // for($i = 900;$i <= 1500;$i++) // { // //echo $this->external_path.'/pd_reports/'.$i; @@ -6321,11 +5609,11 @@ public function getPDFormDetailsJSON_post() // { // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>'satellite','pd_document_name'=>'satellite.png','fk_form_id'=>null,'is_show_report' =>$is_show_report,'rental_count_id' => null,'location' => null); - - + + // $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - + // $custom_log_info = '###CUSTOM DEBUG IMAGE S3 DONE - '. $id; // log_message('ERROR',$custom_log_info); @@ -6336,10 +5624,10 @@ public function getPDFormDetailsJSON_post() // die(); //$this->external_path.'/pd_reports/'. $pdid .'/satellite.png'; //die(); - // $pd_string = 'PD accessed-'.$pdid; - // MYLOG::logFunction(null,$pdid)->info($pd_string,array('data' => 'Test LOg info')); - // MYLOG::logFunction()->warning($pd_string,array('data' => 'Test LOg warn')); - // MYLOG::logFunction()->error($pd_string,array('data' => 'Test LOg error')); + // $pd_string = 'PD accessed-'.$pdid; + // MYLOG::logFunction(null,$pdid)->info($pd_string,array('data' => 'Test LOg info')); + // MYLOG::logFunction()->warning($pd_string,array('data' => 'Test LOg warn')); + // MYLOG::logFunction()->error($pd_string,array('data' => 'Test LOg error')); // $this->load->helper('push_notification'); // PUSH_NOTIFICATION::notifyWeb('eT3F2YlSOsU:APA91bEoK7w-_yaoWK8NUYsYwL1gAfIShm70K5t8IrHjiZAw-oNKOOL09bfgfthBoA4EFoVot17Y9ZOhWxO-B3oKVoQdYxUq6JsAdrOwmPTO-9-mJ61zBcifg34EiiUmdnrAQDt7E90t','Test Msg from test api',array()); // PDALERTS::pdnotification(1247); @@ -6347,9 +5635,9 @@ public function getPDFormDetailsJSON_post() //$this->demo(5); //$this->demo(0); - - - + + + // // $sql = "SELECT email FROM sineedgeprod.m_user_profile where email like '%imgc%'"; // $u = $this->db->query($sql)->result_array(); @@ -6357,22 +5645,21 @@ public function getPDFormDetailsJSON_post() // die(); // foreach($u as $v) // { - //$this->aws_cognito->adminSetUserPassword('harshita.nadigatla@imgc.com'); + //$this->aws_cognito->adminSetUserPassword('harshita.nadigatla@imgc.com'); // } //die(); $is_regenerate = 0; - if(isset($records['regenerate'])) - { - $is_regenerate = 1; + if (isset($records['regenerate'])) { + $is_regenerate = 1; } //print_r($records); - $add_on_pd = $this->PD_Model->selectCustomRecords(array('pd_id'),array('parent_pd_id' => $pdid,'is_child' => 1),PDTRIGGER); + $add_on_pd = $this->PD_Model->selectCustomRecords(array('pd_id'), array('parent_pd_id' => $pdid, 'is_child' => 1), PDTRIGGER); + + - - $data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid); $data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); // print_r($data['pd_master_details']);die(); @@ -6388,226 +5675,195 @@ public function getPDFormDetailsJSON_post() // } // else // { - // echo 'NOR'; - // print_r($data['pd_master_details']);die(); - $entity_geo_location = $this->PD_Model->getEntityAddr($data['pd_master_details'][0]['fk_lender_id']); - if($entity_geo_location != 0){ - $pd_location = $data['pd_master_details'][0]['start_location']; - $data['distances'] = satellite_image::getdistancematrix($entity_geo_location,$pd_location); - }else{ $data['distances'] = ""; } - $pd_type = $data['pd_master_details'][0]['fk_pd_type'] == 3 ? 3 : 1; - $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => ($data['pd_master_details'][0]['sub_entity_id'] ? $data['pd_master_details'][0]['sub_entity_id'] : $data['pd_master_details'][0]['fk_lender_id']),'fk_pd_type' => $pd_type)); + // echo 'NOR'; + // print_r($data['pd_master_details']);die(); + $entity_geo_location = $this->PD_Model->getEntityAddr($data['pd_master_details'][0]['fk_lender_id']); + if ($entity_geo_location != 0) { + $pd_location = $data['pd_master_details'][0]['start_location']; + $data['distances'] = satellite_image::getdistancematrix($entity_geo_location, $pd_location); + } else { + $data['distances'] = ""; + } + $pd_type = $data['pd_master_details'][0]['fk_pd_type'] == 3 ? 3 : 1; + $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER, array('fk_entity_id' => ($data['pd_master_details'][0]['sub_entity_id'] ? $data['pd_master_details'][0]['sub_entity_id'] : $data['pd_master_details'][0]['fk_lender_id']), 'fk_pd_type' => $pd_type)); //} //print_r($data['lender_disclaimer']);die(); //$GLOBALS['footer_lender_disclaimer'] = $data['lender_disclaimer'][0]['type'] == 2 ? $data['lender_disclaimer'][0]['disclaimer'] : (isset($data['lender_disclaimer'][1]) && $$data['lender_disclaimer'][1]['type'] == 2 ? $$data['lender_disclaimer'][1]['disclaimer'] : ''); $data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); $data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly(); - + // print_r($data['pd_score']); // die(); $data['assessed_income_details'] = $this->getAssessedIncomeForPDReport($pdid); - - //print_r($data['pd_master_details'][0]['is_score_card_enabled']);die(); + + //print_r($data['pd_master_details'][0]['is_score_card_enabled']);die(); // echo "**************************"; //$data['dsc_cards'] = $this->getDetailedScoreCardChart( $data['pd_score'] ); - if($data['pd_master_details'][0]['is_score_card_enabled'] == 1 && ($data['pd_master_details'][0]['customer_segment_abbr'] != "SAL" && $data['pd_master_details'][0]['customer_segment_abbr'] != "SE-RI"))// && $data['pd_master_details'][0]['customer_segment_abbr'] != "SAL-CHQ")) //&& ($data['pd_master_details'][0]['customer_segment_abbr'] != '')) + if ($data['pd_master_details'][0]['is_score_card_enabled'] == 1 && ($data['pd_master_details'][0]['customer_segment_abbr'] != "SAL" && $data['pd_master_details'][0]['customer_segment_abbr'] != "SE-RI")) // && $data['pd_master_details'][0]['customer_segment_abbr'] != "SAL-CHQ")) //&& ($data['pd_master_details'][0]['customer_segment_abbr'] != '')) { //echo $data['pd_master_details'][0]['is_score_card_enabled'].'-'.$data['pd_master_details'][0]['customer_segment_abbr'];die(); $data['pd_score'] = $this->calculateScore($pdid); - $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],1) : 0; - //echo $score_for_chart;die(); - - //GET phantom script from DB - $phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomjs_local'),SCRIPTS); + $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'], 1) : 0; + //echo $score_for_chart;die(); + + //GET phantom script from DB + $phantom_script = $this->PD_Model->selectCustomRecords(array('*'), array('script_name' => 'phantomjs_local'), SCRIPTS); $exact_script = $phantom_script[0]['script_content']; - //print_r($exact_script); + //print_r($exact_script); - $apppath = str_replace('\\','/',$this->external_path.'/pd_reports/'.$pdid); - $exact_script = str_replace('{{APPPATH}}',$apppath,$exact_script); - $exact_script = str_replace('{{place_score_here}}',$score_for_chart,$exact_script); - - //print_r($exact_script);die(); - //GENERATE CHART PART + $apppath = str_replace('\\', '/', $this->external_path . '/pd_reports/' . $pdid); + $exact_script = str_replace('{{APPPATH}}', $apppath, $exact_script); + $exact_script = str_replace('{{place_score_here}}', $score_for_chart, $exact_script); - file_put_contents(APPPATH.'/views/js/phantomchart.js',$exact_script,LOCK_EX); + //print_r($exact_script);die(); + //GENERATE CHART PART - $str = 'phantomjs '.APPPATH.'/views/js/phantomchart.js'; + file_put_contents(APPPATH . '/views/js/phantomchart.js', $exact_script, LOCK_EX); + + $str = 'phantomjs ' . APPPATH . '/views/js/phantomchart.js'; // exec($str,$ou); // exec('phantom.exit();'); - //print_r($ou); + //print_r($ou); - $chart_img_path = $this->external_path.'/pd_reports/'. $pdid .'/chart.png'; + $chart_img_path = $this->external_path . '/pd_reports/' . $pdid . '/chart.png'; $type = pathinfo($chart_img_path, PATHINFO_EXTENSION); $chart_img_content = file_get_contents($chart_img_path); $base64_pdscore_chart_url = 'data:image/' . $type . ';base64,' . base64_encode($chart_img_content); $data['base64_pdscore_chart_url'] = $base64_pdscore_chart_url; - //echo $data['base64_pdscore_chart_url']; + //echo $data['base64_pdscore_chart_url']; - //GENERATE CHART PART + //GENERATE CHART PART } //die(); - //GET ALL PROCESSED JSON - for($i = 1;$i<=30;$i++) - { + //GET ALL PROCESSED JSON + for ($i = 1; $i <= 30; $i++) { $fields = array('processed_json'); - if($i == 25) { $fields = array('json'); } - $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i); + if ($i == 25) { + $fields = array('json'); + } + $where_condition_array = array('isactive' => 1, 'fk_pd_id' => $pdid, 'fk_form_id' => $i); - $data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); + $data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON, array(), '', 'company_id', 'ASC'); $fields2 = array('*'); - $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i,null,null,null,'report'); - + $data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid, $i, null, null, null, 'report'); - // $this->getPDImages_post``($fields2,array('fk_pd_id'=>$pdid,'fk_form_id' => $i),PDDOCUMENTS,array(),'','company_id','ASC'); - // print_r($this->db->last_query()); + + // $this->getPDImages_post``($fields2,array('fk_pd_id'=>$pdid,'fk_form_id' => $i),PDDOCUMENTS,array(),'','company_id','ASC'); + // print_r($this->db->last_query()); } //print_r(json_decode($data['pd_processed_forms'][25][0]['json'],true));die(); - //echo $data['pd_master_details'][0]['customer_segment_abbr'].$data['pd_master_details'][0]['fk_pd_type']; + //echo $data['pd_master_details'][0]['customer_segment_abbr'].$data['pd_master_details'][0]['fk_pd_type']; // $data['pd_master_details'][0]['fk_pd_type'] = 3; - if($data['pd_master_details'][0]['customer_segment_abbr'] == "SAL" && $data['pd_master_details'][0]['fk_pd_type'] != 3)// && $data['pd_master_details'][0]['fk_pd_type'] != 1) - { - $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,null,null,'report'); - } - else - { - $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,'common',null,'report'); - - } - // echo "i ahve image"; - // print_r($data['pd_images']);die(); - // die(); + if ($data['pd_master_details'][0]['customer_segment_abbr'] == "SAL" && $data['pd_master_details'][0]['fk_pd_type'] != 3) // && $data['pd_master_details'][0]['fk_pd_type'] != 1) + { + $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, null, null, 'report'); + } else { + $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid, null, null, 'common', null, 'report'); + } + // echo "i ahve image"; + // print_r($data['pd_images']);die(); + // die(); //print_r(json_decode($data['pd_processed_forms'][24][0]['processed_json']));//die(); -// $it = array_filter($data['pd_images'][11],function($d){ if($d['company_id'] == 2){ echo $d['company_id'].'TRUE';return 1;}else {echo $d['company_id'].'FALSE'; return 0;} }); -// print_r($it); -// die(); //print_r(json_decode($data['pd_processed_forms'][14][0]['processed_json'],true)); - // die(); + // $it = array_filter($data['pd_images'][11],function($d){ if($d['company_id'] == 2){ echo $d['company_id'].'TRUE';return 1;}else {echo $d['company_id'].'FALSE'; return 0;} }); + // print_r($it); + // die(); //print_r(json_decode($data['pd_processed_forms'][14][0]['processed_json'],true)); + // die(); //echo "*******************************************"; //get add on forms and images - if(count($add_on_pd)) - { + if (count($add_on_pd)) { $data['add_on_pd_forms'] = array(); $data['add_on_pd_images'] = array(); $data['add_on_pd_master_details'] = array(); - $add_on_forms = array(18,5,19,1,2,22,23,1,11); // - foreach ($add_on_pd as $add_on_pd_key => $add_on_pd_value) - { - foreach ($add_on_forms as $add_on_forms_key => $add_on_forms_value) - { - - $fields = array('processed_json'); - $where_condition_array = array('isactive' => 1,'fk_pd_id'=>$add_on_pd_value['pd_id'],'fk_form_id' => $add_on_forms_value); + $add_on_forms = array(18, 5, 19, 1, 2, 22, 23, 1, 11); // + foreach ($add_on_pd as $add_on_pd_key => $add_on_pd_value) { + foreach ($add_on_forms as $add_on_forms_key => $add_on_forms_value) { - $data['add_on_pd_forms'][$add_on_pd_value['pd_id']][$add_on_forms_value] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC'); + $fields = array('processed_json'); + $where_condition_array = array('isactive' => 1, 'fk_pd_id' => $add_on_pd_value['pd_id'], 'fk_form_id' => $add_on_forms_value); + + $data['add_on_pd_forms'][$add_on_pd_value['pd_id']][$add_on_forms_value] = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON, array(), '', 'company_id', 'ASC'); $fields2 = array('*'); - $data['add_on_pd_images'][$add_on_pd_value['pd_id']][$add_on_forms_value] = $this->PD_Model->getSignedPDDocsURL($add_on_pd_value['pd_id'],$add_on_forms_value,null,null,null,'report'); + $data['add_on_pd_images'][$add_on_pd_value['pd_id']][$add_on_forms_value] = $this->PD_Model->getSignedPDDocsURL($add_on_pd_value['pd_id'], $add_on_forms_value, null, null, null, 'report'); $data['add_on_pd_master_details'][$add_on_pd_value['pd_id']] = $this->PD_Model->getPDMasterDetails($pdid); - } - + } } } - // print_r($data['add_on_pd_images']); - // die(); + // print_r($data['add_on_pd_images']); + // die(); $t = ""; - if(!count($add_on_pd)) - { - - if($data['pd_master_details'][0]['fk_pd_type'] == 1 ) - { + if (!count($add_on_pd)) { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + if ($data['pd_master_details'][0]['fk_pd_type'] == 1) { + + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX',$data,true); + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL', $data, true); } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') + } else if ($data['pd_master_details'][0]['fk_pd_type'] == 2) { + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) { - $t = $this->load->view('report_templates/JSONTOREPORT_RI',$data,true); + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_SMARTPD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL_SMARTPD', $data, true); } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL',$data,true); - } - } - else if($data['pd_master_details'][0]['fk_pd_type'] == 2) + } else if ($data['pd_master_details'][0]['fk_pd_type'] == 3) //Tele PD { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + if ($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE')) // && $data['pd_master_details'][0]['product_abbr'] == 'BL')) { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') - { - $t = $this->load->view('report_templates/JSONTOREPORT_RI_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_SMARTPD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL_SMARTPD',$data,true); + $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') { + $t = $this->load->view('report_templates/JSONTOREPORT_SAL_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') { + $t = $this->load->view('report_templates/JSONTOREPORT_RI_TELE_PD', $data, true); + } else if ($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_TELE_PD', $data, true); } } - else if($data['pd_master_details'][0]['fk_pd_type'] == 3) //Tele PD - { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MWISE'))// && $data['pd_master_details'][0]['product_abbr'] == 'BL')) - { - $t = $this->load->view('report_templates/JSONTOREPORT_CLIX_TELE_PD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SAL') - { - $t = $this->load->view('report_templates/JSONTOREPORT_SAL_TELE_PD',$data,true); - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-RI') - { - $t = $this->load->view('report_templates/JSONTOREPORT_RI_TELE_PD',$data,true); - - } - else if($data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-DI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SE-AI' || $data['pd_master_details'][0]['customer_segment_abbr'] == 'SEP_INDV') - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_TELE_PD',$data,true); - - } - } - } - else - { - $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_ADDON',$data,true); + } else { + $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_ADDON', $data, true); } //$t = $this->load->view('temp_html.html',null,true); + echo $data['pd_master_details'][0]['customer_segment_abbr']; + echo $data['pd_master_details'][0]['fk_pd_type']; echo $t; - + die(); - - $total_replaces = substr_count($t,''); - for($i = 0 ;$i < $total_replaces;$i++) - { - $start_pos = strpos($t,''); - $end_pos = strpos($t, '', strpos($t,'')); + $total_replaces = substr_count($t, ''); + for ($i = 0; $i < $total_replaces; $i++) { + $start_pos = strpos($t, ''); + + $end_pos = strpos($t, '', strpos($t, '')); $end_pos = $end_pos + 14; - //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; + //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; - $t = substr_replace($t,'',$start_pos,($end_pos - $start_pos)); - - $t = substr_replace($t,'',strpos($t,''),(strlen(''))); + $t = substr_replace($t, '', $start_pos, ($end_pos - $start_pos)); + $t = substr_replace($t, '', strpos($t, ''), (strlen(''))); } //echo $t;die(); - + //$t = file_get_contents($this->external_path ."/pd_reports/" . $pdid . "/sample.html"); // $start_pos = strpos($t,''); // $end_pos = $start_pos + 10; @@ -6617,24 +5873,23 @@ public function getPDFormDetailsJSON_post() //file_put_contents($this->external_path ."/pd_reports/" . $pdid . "/sample2.html",$t); //PDF Gen using DOM PDF //$this->pdfgenerator->setEncryption('test1234'); - $pdf_doc = $this->pdfgenerator->generate($t, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + $pdf_doc = $this->pdfgenerator->generate($t, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF - $output_file2 = $this->external_path ."/pd_reports/" . $pdid . "/sample.pdf"; + $output_file2 = $this->external_path . "/pd_reports/" . $pdid . "/sample.pdf"; $ti = file_put_contents($output_file2, $pdf_doc); echo $output_file2; - echo $ti;die(); + echo $ti; + die(); $dat['dataStatus'] = true; $dat['status'] = REST_Controller::HTTP_OK; $dat['records'] = $ti; - $this->response($dat,REST_Controller::HTTP_OK); - - - + $this->response($dat, REST_Controller::HTTP_OK); } - public function notify_get(){ + public function notify_get() + { PDALERTS::pdnotification(2854); } - + public function calculatePDScore($data) { @@ -6642,579 +5897,470 @@ public function getPDFormDetailsJSON_post() $actual_score = 0; $exact_score = 0; - foreach($pd_form_raw_data as $raw_key => $raw_data) - { + foreach ($pd_form_raw_data as $raw_key => $raw_data) { - if($raw_data['category_weightage'] != '' && $raw_data['question_weightage'] != '' && $raw_data['score'] != '' && $raw_data['max_score'] != '') - { + if ($raw_data['category_weightage'] != '' && $raw_data['question_weightage'] != '' && $raw_data['score'] != '' && $raw_data['max_score'] != '') { - $pd_form_raw_data[$raw_key]['actual_score'] = (($raw_data['category_weightage']/100) * ($raw_data['question_weightage']/100) * $raw_data['max_score']); - $pd_form_raw_data[$raw_key]['exact_score'] = (($raw_data['category_weightage']/100) * ($raw_data['question_weightage']/100) * $raw_data['score']); + $pd_form_raw_data[$raw_key]['actual_score'] = (($raw_data['category_weightage'] / 100) * ($raw_data['question_weightage'] / 100) * $raw_data['max_score']); + $pd_form_raw_data[$raw_key]['exact_score'] = (($raw_data['category_weightage'] / 100) * ($raw_data['question_weightage'] / 100) * $raw_data['score']); - // $actual_score = $actual_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['max_score']); - // $exact_score = $exact_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['score']); + // $actual_score = $actual_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['max_score']); + // $exact_score = $exact_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['score']); - } - else - { + } else { $pd_form_raw_data[$raw_key]['actual_score'] = null; $pd_form_raw_data[$raw_key]['exact_score'] = null; } } return $pd_form_raw_data; - - - } - + public function getQCLenderRemarks_post() { $records = $this->post('records'); $pdid = $records['pd_id']; $fields = array(); - if($records['flag'] == 'QC') - { - $fields = array('qc_feedback','qc_rating','pd_status'); - } - else if($records['flag'] == 'LENDER') - { - $fields = array('lender_remarks','lender_rating','pd_status'); - } - else if($records['flag'] == 'QC_REMARKS') - { - $fields = array('qc_remarks','pd_status'); - } - else if($records['flag'] == 'OFFICER_REMARKS') - { + if ($records['flag'] == 'QC') { + $fields = array('qc_feedback', 'qc_rating', 'pd_status'); + } else if ($records['flag'] == 'LENDER') { + $fields = array('lender_remarks', 'lender_rating', 'pd_status'); + } else if ($records['flag'] == 'QC_REMARKS') { + $fields = array('qc_remarks', 'pd_status'); + } else if ($records['flag'] == 'OFFICER_REMARKS') { $fields = array('pd_qc_note'); - } - else if($records['flag'] == 'ALL_REMARKS')// Get All Other remarks from pd remarks table + } else if ($records['flag'] == 'ALL_REMARKS') // Get All Other remarks from pd remarks table { - - $this->db->SELECT('PDREMARKS.remark,DATE_FORMAT(PDREMARKS.createdon,"%d/%m/%Y %r") as log_time,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby')->FROM(PDREMARKS.' as PDREMARKS'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE','USERPROFILE.userid = PDREMARKS.createdby','LEFT'); - $this->db->WHERE('PDREMARKS.fk_pd_id',$pdid); + + $this->db->SELECT('PDREMARKS.remark,DATE_FORMAT(PDREMARKS.createdon,"%d/%m/%Y %r") as log_time,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby')->FROM(PDREMARKS . ' as PDREMARKS'); + $this->db->JOIN(USERPROFILE . ' as USERPROFILE', 'USERPROFILE.userid = PDREMARKS.createdby', 'LEFT'); + $this->db->WHERE('PDREMARKS.fk_pd_id', $pdid); $res = $this->db->GET()->result_array(); - if(count($res)) - { + if (count($res)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $res; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Remarks Available for this PD!'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { $data['dataStatus'] = false; + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'InAppropriate Params!'; + $this->response($data, REST_Controller::HTTP_OK); + } + + $where_condition_array = array('pd_id' => $pdid); + $result = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDTRIGGER); + if (count($result)) { + $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; $data['msg'] = 'No Remarks Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } } - else + + ##v1 + public function getCompaniesListsFromGeneralFormRawJSON_post() { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'InAppropriate Params!'; - $this->response($data,REST_Controller::HTTP_OK); - } + $records = $this->post('records'); + $pd_id = $records['pd_id']; - $where_condition_array = array('pd_id'=>$pdid); - $result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - if(count($result)) - { - $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; - $data['msg'] = 'No Remarks Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); + $ai_flag = 0; + //GET TEMPALE ID FROM MASTER + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + $lender_short_name = $pd_master_details[0]['lender_short_name']; + $product_abbr = $pd_master_details[0]['product_abbr']; + //print_r($lender_short_name); + $str = substr($pd_master_details[0]['customer_segment_abbr'], -2); + //echo $str; + if (!strcmp($str, 'AI')) { + $ai_flag = 1; + } + //echo $ai_flag; -} -} - -##v1 -public function getCompaniesListsFromGeneralFormRawJSON_post() -{ - $records = $this->post('records'); - $pd_id = $records['pd_id']; - - $ai_flag = 0; - //GET TEMPALE ID FROM MASTER - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - $lender_short_name = $pd_master_details[0]['lender_short_name']; - $product_abbr = $pd_master_details[0]['product_abbr']; - //print_r($lender_short_name); - $str = substr($pd_master_details[0]['customer_segment_abbr'],-2); - //echo $str; - if(!strcmp($str,'AI')) { $ai_flag = 1; } - //echo $ai_flag; - - $company_list = array(); - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - if(count($rec)) - { - $temp_data = json_decode($rec[0]['json'],true); + $company_list = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pd_id); + $rec = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + if (count($rec)) { + $temp_data = json_decode($rec[0]['json'], true); // print_r($temp_data);die(); - foreach($temp_data['companies'] as $company) - { + foreach ($temp_data['companies'] as $company) { - if($company['associate_pd_id'] == $pd_id) - { - $temp_array = array('company_order_id' => $company['company_order_id'],'company_name' => $company['company_name'],'is_active' => $company['is_active'],'is_company_applicant'=>$company['is_company_applicant'],'business_entity_type'=>$company['business_entity_type'],'business_years'=>$company['business_years'],'business_month'=>$company['business_month'],'business_month'=>$company['business_month'],'business_date_object'=>$company['business_date_object']); - if(isset($company['business_entity_type_other'])) - { - $temp_array['business_entity_type_other'] = $company['business_entity_type_other']; + if ($company['associate_pd_id'] == $pd_id) { + $temp_array = array('company_order_id' => $company['company_order_id'], 'company_name' => $company['company_name'], 'is_active' => $company['is_active'], 'is_company_applicant' => $company['is_company_applicant'], 'business_entity_type' => $company['business_entity_type'], 'business_years' => $company['business_years'], 'business_month' => $company['business_month'], 'business_month' => $company['business_month'], 'business_date_object' => $company['business_date_object']); + if (isset($company['business_entity_type_other'])) { + $temp_array['business_entity_type_other'] = $company['business_entity_type_other']; + } + $company_list[] = $temp_array; } - $company_list[] = $temp_array; } - } - // $company_list = array( array('company_order_id' => 1)); - //print_r($company_list);die(); - $form_array = array(); - - if($ai_flag == 0) // DI case - { + // $company_list = array( array('company_order_id' => 1)); + //print_r($company_list);die(); + $form_array = array(); - $form_array[] = array('form_id' => 13,'form_name' => 'About Business'); - + if ($ai_flag == 0) // DI case + { - $form_array[] = array('form_id' => 22,'form_name' => 'Business Assets'); - if(!strcasecmp($lender_short_name, 'CLIX')){ - $form_array[] = array('form_id' => 21,'form_name' => 'Business Banking'); - } - $form_array[] = array('form_id' => 14,'form_name' => 'Financial Information'); - $form_array[] = array('form_id' => 1,'form_name' => 'Supplier Details'); - $form_array[] = array('form_id' => 2,'form_name' => 'Client Details'); - $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details'); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) - { - $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments'); - } - - } - else // AI Case - { + $form_array[] = array('form_id' => 13, 'form_name' => 'About Business'); - $form_array[] = array('form_id' => 13,'form_name' => 'About Business'); - $form_array[] = array('form_id' => 22,'form_name' => 'Business Assets'); - if(!strcasecmp($lender_short_name, 'CLIX')){ - $form_array[] = array('form_id' => 21,'form_name' => 'Business Banking'); + + $form_array[] = array('form_id' => 22, 'form_name' => 'Business Assets'); + if (!strcasecmp($lender_short_name, 'CLIX')) { + $form_array[] = array('form_id' => 21, 'form_name' => 'Business Banking'); } - $form_array[] = array('form_id' => 14,'form_name' => 'Financial Information'); - $form_array[] = array('form_id' => 1,'form_name' => 'Supplier Details'); - $form_array[] = array('form_id' => 2,'form_name' => 'Client Details'); - $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details'); - $form_array[] = array('form_id' => 16,'form_name' => 'Assessed Income'); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE')) )// && !strcasecmp($product_abbr,'LFMP')) - { - $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments'); - } + $form_array[] = array('form_id' => 14, 'form_name' => 'Financial Information'); + $form_array[] = array('form_id' => 1, 'form_name' => 'Supplier Details'); + $form_array[] = array('form_id' => 2, 'form_name' => 'Client Details'); + $form_array[] = array('form_id' => 11, 'form_name' => 'Stock Details'); + if (!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) { + $form_array[] = array('form_id' => 23, 'form_name' => 'Future Plans & Business Environments'); + } + } else // AI Case + { - } - - - //print_r($form_array);//die(); - foreach($company_list as $list_key => $company) - { - - $temp = array(); - $business_form_status = 0; - $supplier_form_status = 0; - $client_form_status = 0; - foreach($form_array as $form) - { - - $template_forms_count = 0; - if($form['form_id'] != 16) - { - $this->db->SELECT('count(*) as count'); - $this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); - $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pd_id); - $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$form['form_id']); - $this->db->WHERE('PDFORMDETAILSJSON.company_id',$company['company_order_id']); - $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); - $template_forms_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query());die(); - - } - else - { - - $fields = array('count(*) as count'); - $where_condition_array = array('fk_pd_id'=>$pd_id,'company_id' => $company['company_order_id'],'is_completed' => 1); - $template_forms_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); - } - // print_r($this->db->last_query()); - // print_r($template_forms_count);echo $form['form_id']; - if($template_forms_count[0]['count'] != 0) { + $form_array[] = array('form_id' => 13, 'form_name' => 'About Business'); + $form_array[] = array('form_id' => 22, 'form_name' => 'Business Assets'); + if (!strcasecmp($lender_short_name, 'CLIX')) { + $form_array[] = array('form_id' => 21, 'form_name' => 'Business Banking'); + } + $form_array[] = array('form_id' => 14, 'form_name' => 'Financial Information'); + $form_array[] = array('form_id' => 1, 'form_name' => 'Supplier Details'); + $form_array[] = array('form_id' => 2, 'form_name' => 'Client Details'); + $form_array[] = array('form_id' => 11, 'form_name' => 'Stock Details'); + $form_array[] = array('form_id' => 16, 'form_name' => 'Assessed Income'); + if (!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) // && !strcasecmp($product_abbr,'LFMP')) + { + $form_array[] = array('form_id' => 23, 'form_name' => 'Future Plans & Business Environments'); + } + } - if($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) - { + //print_r($form_array);//die(); + foreach ($company_list as $list_key => $company) { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true); - if($form['form_id'] == 22) - { - $business_form_status = 1; - } - } + $temp = array(); + $business_form_status = 0; + $supplier_form_status = 0; + $client_form_status = 0; + foreach ($form_array as $form) { - else - { - if($business_form_status == 1){ + $template_forms_count = 0; + if ($form['form_id'] != 16) { + $this->db->SELECT('count(*) as count'); + $this->db->FROM(PDFORMDETAILSJSON . ' as PDFORMDETAILSJSON'); + $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id', $pd_id); + $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id', $form['form_id']); + $this->db->WHERE('PDFORMDETAILSJSON.company_id', $company['company_order_id']); + $this->db->WHERE('PDFORMDETAILSJSON.isactive', 1); + $template_forms_count = $this->db->GET()->result_array(); + //print_r($this->db->last_query());die(); + + } else { + + $fields = array('count(*) as count'); + $where_condition_array = array('fk_pd_id' => $pd_id, 'company_id' => $company['company_order_id'], 'is_completed' => 1); + $template_forms_count = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + } + // print_r($this->db->last_query()); + // print_r($template_forms_count);echo $form['form_id']; + if ($template_forms_count[0]['count'] != 0) { + + + if ($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true); + if ($form['form_id'] == 22) { + $business_form_status = 1; + } + } else { + if ($business_form_status == 1) { - if($form['form_id'] == 1)//if supplier form answered set supplier_form_status = 1 + if ($form['form_id'] == 1) //if supplier form answered set supplier_form_status = 1 { - $supplier_form_status = 1; + $supplier_form_status = 1; } - if($form['form_id'] == 2)//if client form answered set client_form_status = 1 + if ($form['form_id'] == 2) //if client form answered set client_form_status = 1 { $client_form_status = 1; - } + } - if($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) - { + if ($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) { //echo "COUNT YES STOCK" - if($client_form_status == 1 && $supplier_form_status == 1) - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true); + if ($client_form_status == 1 && $supplier_form_status == 1) { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true); } + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true); } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true); - } - - } - else //busienss false - { - //echo "business false".$form['form_id']; - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>false); - } - } - } - else //Not previously answered - { - //echo "else-- " .$form['form_id']; - if($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) + } else //busienss false { - - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); - - } - else{ - if($business_form_status == 1){ - - if($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) - { - //echo "BUSISTOCk"; - if($client_form_status == 1 && $supplier_form_status == 1) - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); - } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); - } - } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); - } - - } - else - { - - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); - - } + //echo "business false".$form['form_id']; + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => false); + } + } + } else //Not previously answered + { + //echo "else-- " .$form['form_id']; + if ($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true); + } else { + if ($business_form_status == 1) { + + if ($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) { + //echo "BUSISTOCk"; + if ($client_form_status == 1 && $supplier_form_status == 1) { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true); + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => false); + } + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true); + } + } else { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => false); } } - } - - $company_list[$list_key]['form_status'] = $temp; - - } + + $company_list[$list_key]['form_status'] = $temp; } + } // print_r($company_list);die(); - if(count($company_list)) - { - if($pd_master_details[0]['fk_pd_type'] == 2) - { - $vendor_form_status = $this->PD_Model->getVendorFormStatus($pd_id); - $company_list[0]['vendor_form_status'] = $vendor_form_status; - } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $company_list; - $this->response($data,REST_Controller::HTTP_OK); + if (count($company_list)) { + if ($pd_master_details[0]['fk_pd_type'] == 2) { + $vendor_form_status = $this->PD_Model->getVendorFormStatus($pd_id); + $company_list[0]['vendor_form_status'] = $vendor_form_status; } - else - { $data['dataStatus'] = false; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $company_list; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Comapany Details Found!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } - } -### V2 -public function getCompaniesListsFromGeneralFormRawJSONV2_post() -{ - $records = $this->post('records'); - $pd_id = $records['pd_id']; - $ai_flag = 0; - //GET TEMPALE ID FROM MASTER - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - $lender_short_name = $pd_master_details[0]['lender_short_name']; - $product_abbr = $pd_master_details[0]['product_abbr']; - //print_r($lender_short_name); - $str = substr($pd_master_details[0]['customer_segment_abbr'],-2); - //echo $str; - if(!strcmp($str,'AI')) { $ai_flag = 1; } - //echo $ai_flag; - $map_fields = array('id'); - $map_where_condition_array = array('entity_id' => $pd_master_details[0]['fk_lender_id'],'product_id' => $pd_master_details[0]['fk_product_id'],'customer_segment_id' => $pd_master_details[0]['fk_customer_segment'],'isactive' => 1); - $map_table = $this->PD_Model->selectCustomRecords($map_fields,$map_where_condition_array,TEMPLATE_MAP_V2); - if(count($map_table)>0){ - $map_pk_id = (int)$map_table[0]['id']; }else{ - $map_pk_id = null;} - - $company_list = array(); - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - if(count($rec)) + ### V2 + public function getCompaniesListsFromGeneralFormRawJSONV2_post() { - $temp_data = json_decode($rec[0]['json'],true); - // print_r($temp_data);die(); - foreach($temp_data['companies'] as $company) - { - - if($company['associate_pd_id'] == $pd_id) - { - $temp_array = array('company_order_id' => $company['company_order_id'],'company_name' => $company['company_name'],'is_active' => $company['is_active'],'is_company_applicant'=>$company['is_company_applicant'],'business_entity_type'=>$company['business_entity_type'],'business_years'=>$company['business_years'],'business_month'=>$company['business_month'],'business_month'=>$company['business_month'],'business_date_object'=>$company['business_date_object']); - if(isset($company['business_entity_type_other'])) - { - $temp_array['business_entity_type_other'] = $company['business_entity_type_other']; - } - $company_list[] = $temp_array; - } + $records = $this->post('records'); + $pd_id = $records['pd_id']; + $ai_flag = 0; + //GET TEMPALE ID FROM MASTER + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + $lender_short_name = $pd_master_details[0]['lender_short_name']; + $product_abbr = $pd_master_details[0]['product_abbr']; + //print_r($lender_short_name); + $str = substr($pd_master_details[0]['customer_segment_abbr'], -2); + //echo $str; + if (!strcmp($str, 'AI')) { + $ai_flag = 1; + } + //echo $ai_flag; + $map_fields = array('id'); + $map_where_condition_array = array('entity_id' => $pd_master_details[0]['fk_lender_id'], 'product_id' => $pd_master_details[0]['fk_product_id'], 'customer_segment_id' => $pd_master_details[0]['fk_customer_segment'], 'isactive' => 1); + $map_table = $this->PD_Model->selectCustomRecords($map_fields, $map_where_condition_array, TEMPLATE_MAP_V2); + if (count($map_table) > 0) { + $map_pk_id = (int)$map_table[0]['id']; + } else { + $map_pk_id = null; } - // $company_list = array( array('company_order_id' => 1)); - //print_r($company_list);die(); - $form_array = array(); - - if($ai_flag == 0) // DI case - { - $form_array[] = array('form_id' => 13,'form_name' => 'About Business','map_id'=>$map_pk_id); - + $company_list = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pd_id); + $rec = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + if (count($rec)) { + $temp_data = json_decode($rec[0]['json'], true); + // print_r($temp_data);die(); + foreach ($temp_data['companies'] as $company) { - $form_array[] = array('form_id' => 22,'form_name' => 'Business Assets','map_id'=>$map_pk_id); - if(!strcasecmp($lender_short_name, 'CLIX')){ - $form_array[] = array('form_id' => 21,'form_name' => 'Business Banking','map_id'=>$map_pk_id); // this is temporary have to Remove ( step 2 ) - } - $form_array[] = array('form_id' => 14,'form_name' => 'Financial Information','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 1,'form_name' => 'Supplier Details','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 2,'form_name' => 'Client Details','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details','map_id'=>$map_pk_id); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) - { - $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments','map_id'=>$map_pk_id); - } - - } - else // AI Case - { + if ($company['associate_pd_id'] == $pd_id) { + $temp_array = array('company_order_id' => $company['company_order_id'], 'company_name' => $company['company_name'], 'is_active' => $company['is_active'], 'is_company_applicant' => $company['is_company_applicant'], 'business_entity_type' => $company['business_entity_type'], 'business_years' => $company['business_years'], 'business_month' => $company['business_month'], 'business_month' => $company['business_month'], 'business_date_object' => $company['business_date_object']); + if (isset($company['business_entity_type_other'])) { + $temp_array['business_entity_type_other'] = $company['business_entity_type_other']; + } + $company_list[] = $temp_array; + } + } + // $company_list = array( array('company_order_id' => 1)); + //print_r($company_list);die(); + $form_array = array(); - $form_array[] = array('form_id' => 13,'form_name' => 'About Business','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 22,'form_name' => 'Business Assets','map_id'=>$map_pk_id); - if(!strcasecmp($lender_short_name, 'CLIX')){ - $form_array[] = array('form_id' => 21,'form_name' => 'Business Banking','map_id'=>$map_pk_id);//Removed ( step 2 ) - } - $form_array[] = array('form_id' => 14,'form_name' => 'Financial Information','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 1,'form_name' => 'Supplier Details','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 2,'form_name' => 'Client Details','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details','map_id'=>$map_pk_id); - $form_array[] = array('form_id' => 16,'form_name' => 'Assessed Income','map_id'=>$map_pk_id); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE')) )// && !strcasecmp($product_abbr,'LFMP')) - { - $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments','map_id'=>$map_pk_id); - } + if ($ai_flag == 0) // DI case + { - } - - - //print_r($form_array);//die(); - foreach($company_list as $list_key => $company) - { - - $temp = array(); - $business_form_status = 0; - $supplier_form_status = 0; - $client_form_status = 0; - foreach($form_array as $form) - { - - $template_forms_count = 0; - if($form['form_id'] != 16) - { - $this->db->SELECT('count(*) as count'); - $this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); - $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pd_id); - $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$form['form_id']); - $this->db->WHERE('PDFORMDETAILSJSON.company_id',$company['company_order_id']); - $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); - $template_forms_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query());die(); - - } - else - { - - $fields = array('count(*) as count'); - $where_condition_array = array('fk_pd_id'=>$pd_id,'company_id' => $company['company_order_id'],'is_completed' => 1); - $template_forms_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); - } - // print_r($this->db->last_query()); - // print_r($template_forms_count);echo $form['form_id']; - if($template_forms_count[0]['count'] != 0) { + $form_array[] = array('form_id' => 13, 'form_name' => 'About Business', 'map_id' => $map_pk_id); - if($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) - { + $form_array[] = array('form_id' => 22, 'form_name' => 'Business Assets', 'map_id' => $map_pk_id); + if (!strcasecmp($lender_short_name, 'CLIX')) { + $form_array[] = array('form_id' => 21, 'form_name' => 'Business Banking', 'map_id' => $map_pk_id); // this is temporary have to Remove ( step 2 ) + } + $form_array[] = array('form_id' => 14, 'form_name' => 'Financial Information', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 1, 'form_name' => 'Supplier Details', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 2, 'form_name' => 'Client Details', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 11, 'form_name' => 'Stock Details', 'map_id' => $map_pk_id); + if (!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) { + $form_array[] = array('form_id' => 23, 'form_name' => 'Future Plans & Business Environments', 'map_id' => $map_pk_id); + } + } else // AI Case + { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true); - if($form['form_id'] == 22) - { - $business_form_status = 1; - } - } + $form_array[] = array('form_id' => 13, 'form_name' => 'About Business', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 22, 'form_name' => 'Business Assets', 'map_id' => $map_pk_id); + if (!strcasecmp($lender_short_name, 'CLIX')) { + $form_array[] = array('form_id' => 21, 'form_name' => 'Business Banking', 'map_id' => $map_pk_id); //Removed ( step 2 ) + } + $form_array[] = array('form_id' => 14, 'form_name' => 'Financial Information', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 1, 'form_name' => 'Supplier Details', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 2, 'form_name' => 'Client Details', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 11, 'form_name' => 'Stock Details', 'map_id' => $map_pk_id); + $form_array[] = array('form_id' => 16, 'form_name' => 'Assessed Income', 'map_id' => $map_pk_id); + if (!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MWISE'))) // && !strcasecmp($product_abbr,'LFMP')) + { + $form_array[] = array('form_id' => 23, 'form_name' => 'Future Plans & Business Environments', 'map_id' => $map_pk_id); + } + } - else - { - if($business_form_status == 1){ + + //print_r($form_array);//die(); + foreach ($company_list as $list_key => $company) { + + $temp = array(); + $business_form_status = 0; + $supplier_form_status = 0; + $client_form_status = 0; + foreach ($form_array as $form) { + + $template_forms_count = 0; + if ($form['form_id'] != 16) { + $this->db->SELECT('count(*) as count'); + $this->db->FROM(PDFORMDETAILSJSON . ' as PDFORMDETAILSJSON'); + $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id', $pd_id); + $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id', $form['form_id']); + $this->db->WHERE('PDFORMDETAILSJSON.company_id', $company['company_order_id']); + $this->db->WHERE('PDFORMDETAILSJSON.isactive', 1); + $template_forms_count = $this->db->GET()->result_array(); + //print_r($this->db->last_query());die(); + + } else { + + $fields = array('count(*) as count'); + $where_condition_array = array('fk_pd_id' => $pd_id, 'company_id' => $company['company_order_id'], 'is_completed' => 1); + $template_forms_count = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + } + // print_r($this->db->last_query()); + // print_r($template_forms_count);echo $form['form_id']; + if ($template_forms_count[0]['count'] != 0) { + + + if ($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true); + if ($form['form_id'] == 22) { + $business_form_status = 1; + } + } else { + if ($business_form_status == 1) { - if($form['form_id'] == 1)//if supplier form answered set supplier_form_status = 1 + if ($form['form_id'] == 1) //if supplier form answered set supplier_form_status = 1 { - $supplier_form_status = 1; + $supplier_form_status = 1; } - if($form['form_id'] == 2)//if client form answered set client_form_status = 1 + if ($form['form_id'] == 2) //if client form answered set client_form_status = 1 { $client_form_status = 1; - } + } - if($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) - { + if ($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) { //echo "COUNT YES STOCK" - if($client_form_status == 1 && $supplier_form_status == 1) - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true,'map_id'=>$form['map_id']); + if ($client_form_status == 1 && $supplier_form_status == 1) { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true, 'map_id' => $form['map_id']); } + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => true, 'map_id' => $form['map_id']); } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true,'map_id'=>$form['map_id']); - } - - } - else //busienss false - { - //echo "business false".$form['form_id']; - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>false,'map_id'=>$form['map_id']); - } - } - } - else //Not previously answered - { - //echo "else-- " .$form['form_id']; - if($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) + } else //busienss false { - - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true,'map_id'=>$form['map_id']); - - } - else{ - if($business_form_status == 1){ - - if($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) - { - //echo "BUSISTOCk"; - if($client_form_status == 1 && $supplier_form_status == 1) - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true,'map_id'=>$form['map_id']); - } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false,'map_id'=>$form['map_id']); - } - } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true,'map_id'=>$form['map_id']); - } - - } - else - { - - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false,'map_id'=>$form['map_id']); - - } + //echo "business false".$form['form_id']; + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => true, 'isAnswerable' => false, 'map_id' => $form['map_id']); + } + } + } else //Not previously answered + { + //echo "else-- " .$form['form_id']; + if ($form['form_id'] == 13 || $form['form_id'] == 22 || $form['form_id'] == 23) { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true, 'map_id' => $form['map_id']); + } else { + if ($business_form_status == 1) { + + if ($form['form_id'] == 11 || $form['form_id'] == 22 || $form['form_id'] == 23) { + //echo "BUSISTOCk"; + if ($client_form_status == 1 && $supplier_form_status == 1) { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true, 'map_id' => $form['map_id']); + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => false, 'map_id' => $form['map_id']); + } + } else { + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => true, 'map_id' => $form['map_id']); + } + } else { + + $temp[] = array('form_id' => $form['form_id'], 'form_name' => $form['form_name'], 'isAnswered' => false, 'isAnswerable' => false, 'map_id' => $form['map_id']); } } - } - - $company_list[$list_key]['form_status'] = $temp; - - } + + $company_list[$list_key]['form_status'] = $temp; } + } // print_r($company_list);die(); - if(count($company_list)) - { - if($pd_master_details[0]['fk_pd_type'] == 2) - { - $vendor_form_status = $this->PD_Model->getVendorFormStatus($pd_id); - $company_list[0]['vendor_form_status'] = $vendor_form_status; - } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $company_list; - $this->response($data,REST_Controller::HTTP_OK); + if (count($company_list)) { + if ($pd_master_details[0]['fk_pd_type'] == 2) { + $vendor_form_status = $this->PD_Model->getVendorFormStatus($pd_id); + $company_list[0]['vendor_form_status'] = $vendor_form_status; } - else - { $data['dataStatus'] = false; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $company_list; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Comapany Details Found!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } - } - + public function getPDAddress_post() { $pdid = $this->post('pd_id'); @@ -7222,191 +6368,158 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $address; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } - + public function getEndUseOfLoan_post() { $records = $this->post('records'); $pdid = $records['pd_id']; $sub_product_id = null; - if(isset($records['sub_product_id'])){ $sub_product_id = $records['sub_product_id']; } - - if($sub_product_id != null) - { + if (isset($records['sub_product_id'])) { + $sub_product_id = $records['sub_product_id']; + } + + if ($sub_product_id != null) { $fields = array('*'); - $where_condition_array = array('isactive' => 1,'fk_subproduct_id' => $sub_product_id); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN); - if(count($result_data)) - { + $where_condition_array = array('isactive' => 1, 'fk_subproduct_id' => $sub_product_id); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENDUSEOFLOAN); + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Data Found for Selected Sub Product!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); - if($pd_master_details[0]['fk_subproduct_id'] != "" || $pd_master_details[0]['fk_subproduct_id'] != null) - { + if ($pd_master_details[0]['fk_subproduct_id'] != "" || $pd_master_details[0]['fk_subproduct_id'] != null) { $fields = array('*'); - $where_condition_array = array('isactive' => 1,'fk_subproduct_id' => $pd_master_details[0]['fk_subproduct_id']); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN); - if(count($result_data)) - { + $where_condition_array = array('isactive' => 1, 'fk_subproduct_id' => $pd_master_details[0]['fk_subproduct_id']); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENDUSEOFLOAN); + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Data Found for Selected Sub Product!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $fields = array('*'); - $where_condition_array = array('isactive' => 1,'fk_subproduct_id' => null); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN); + $where_condition_array = array('isactive' => 1, 'fk_subproduct_id' => null); + $result_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ENDUSEOFLOAN); $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['records'] = $result_data; $data['msg'] = 'Sub Product Not Applicable for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } } - } - - + + public function savePDOfficerCurrentLocation_post() { $pdid = $this->post('pd_id'); $current_location = $this->post('link'); - $record_data = array('fk_pd_id' => $pdid,'current_location'=>$current_location); - $id = $this->PD_Model->saveRecords($record_data,PDOFFICERCURRENTLOCATION); + $record_data = array('fk_pd_id' => $pdid, 'current_location' => $current_location); + $id = $this->PD_Model->saveRecords($record_data, PDOFFICERCURRENTLOCATION); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - - + $this->response($data, REST_Controller::HTTP_OK); } - + public function getPDOfficerCurrentLocation_post() { $enc_string = $this->post('pd_id'); - - $pdid = $this->db->SELECT('pd_id')->FROM(PDTRIGGER)->WHERE('random_string',$enc_string)->ORDER_BY(PDTRIGGERID,'DESC')->LIMIT(1)->GET()->result_array(); + + $pdid = $this->db->SELECT('pd_id')->FROM(PDTRIGGER)->WHERE('random_string', $enc_string)->ORDER_BY(PDTRIGGERID, 'DESC')->LIMIT(1)->GET()->result_array(); //print_r($this->db->last_query()); //print_r($pdid); - + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid[0]['pd_id']); $offcier_name = $pd_master_details[0]['pd_allocated_to']; $result_data['officer_details']['officer_name'] = $offcier_name; - $result_data['location'] = $this->db->SELECT('*')->FROM(PDOFFICERCURRENTLOCATION)->WHERE('fk_pd_id',$pdid[0]['pd_id'])->ORDER_BY(PDOFFICERCURRENTLOCATIONID,'DESC')->LIMIT(1)->GET()->result_array(); + $result_data['location'] = $this->db->SELECT('*')->FROM(PDOFFICERCURRENTLOCATION)->WHERE('fk_pd_id', $pdid[0]['pd_id'])->ORDER_BY(PDOFFICERCURRENTLOCATIONID, 'DESC')->LIMIT(1)->GET()->result_array(); - if(count($result_data)) - { + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'No Records Found!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - } - - + + public function getFamilyDetailsFromBusinessAndGeneral_post() { $pdid = $this->post('pd_id'); - //echo $pdid; - //Get Details From General Full + //echo $pdid; + //Get Details From General Full $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); - $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - //print_r($general_data);die(); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pdid); + $general_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + //print_r($general_data);die(); $temp_array = array(); - if(count($general_data)) - { - $json = json_decode($general_data[0]['json'],true); - //print_r($json);die(); - if(array_key_exists('persons_with_relationships',$json)) - { - foreach($json['persons_with_relationships'] as $key => $relation) - { - foreach($json['individuals'] as $ind) - { - if($relation['applicant_name'] == $ind['applicant_name']) - { + if (count($general_data)) { + $json = json_decode($general_data[0]['json'], true); + //print_r($json);die(); + if (array_key_exists('persons_with_relationships', $json)) { + foreach ($json['persons_with_relationships'] as $key => $relation) { + foreach ($json['individuals'] as $ind) { + if ($relation['applicant_name'] == $ind['applicant_name']) { $relation['age'] = $ind['age']; $relation['applicant_title_name'] = $ind['applicant_title_name']; } - } - $temp_array = array_merge($temp_array,array($relation)); + $temp_array = array_merge($temp_array, array($relation)); } } } $final_data['from_general_form'] = $temp_array; - //Get Details from All Business Froms - $fields = array('json','company_id'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid); - $business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + //Get Details from All Business Froms + $fields = array('json', 'company_id'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 13, 'fk_pd_id' => $pdid); + $business_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); - //print_r($business_data); + //print_r($business_data); - if(count($business_data)) - { + if (count($business_data)) { $temp_array = array(); - foreach($business_data as $business_data_key => $business) - { - $json = json_decode($business['json'],true); - //print_r($json); - if(array_key_exists('persons_with_relationships',$json)) - { + foreach ($business_data as $business_data_key => $business) { + $json = json_decode($business['json'], true); + //print_r($json); + if (array_key_exists('persons_with_relationships', $json)) { - foreach($json['persons_with_relationships'] as $person => $value) - { + foreach ($json['persons_with_relationships'] as $person => $value) { - if(count($general_data)) - { - $genjson = json_decode($general_data[0]['json'],true); - foreach($genjson['companies'] as $company_key =>$company) - { - //print_r($compan); - if($value['relationship_with_company_id'] == $company['company_order_id']) - { + if (count($general_data)) { + $genjson = json_decode($general_data[0]['json'], true); + foreach ($genjson['companies'] as $company_key => $company) { + //print_r($compan); + if ($value['relationship_with_company_id'] == $company['company_order_id']) { $json['persons_with_relationships'][$person]['company_name'] = $company['company_name']; $json['persons_with_relationships'][$person]['business_years'] = $company['business_years']; $json['persons_with_relationships'][$person]['business_month'] = $company['business_month']; @@ -7415,7 +6528,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } } } - $temp_array = array_merge($temp_array,$json['persons_with_relationships']); + $temp_array = array_merge($temp_array, $json['persons_with_relationships']); } } } @@ -7426,12 +6539,9 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $final_data; - $this->response($data,REST_Controller::HTTP_OK); - - - + $this->response($data, REST_Controller::HTTP_OK); } - + public function getAssetsWithLoanFromBusiness_post() { $pdid = $this->post('pd_id'); @@ -7439,127 +6549,100 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // GET Assest Types and Properties type from Master $fields = array('*'); $where_condition_array = array('isactive' => 1); - $assest_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ASSETTYPE); + $assest_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, ASSETTYPE); $fields = array('*'); $where_condition_array = array('isactive' => 1); - $property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES); + $property_types = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PROPERTIES); - $fields = array('json','company_id'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>22,'fk_pd_id' => $pdid); - $assest_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $fields = array('json', 'company_id'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 22, 'fk_pd_id' => $pdid); + $assest_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); $business_assest_data = array(); $other_assest_data = array(); $business_address_assest_data = array(); - //print_r($assest_data);die(); - if(count($assest_data)) - { + //print_r($assest_data);die(); + if (count($assest_data)) { - //print_r($property_types);die(); + //print_r($property_types);die(); - foreach($assest_data as $key => $assest) - { - $json = json_decode($assest['json'],true); - //print_r($json);die(); - if(array_key_exists('business_assets_details',$json)) - { - foreach($json['business_assets_details'] as $asset_key => $business_asset) - { + foreach ($assest_data as $key => $assest) { + $json = json_decode($assest['json'], true); + //print_r($json);die(); + if (array_key_exists('business_assets_details', $json)) { + foreach ($json['business_assets_details'] as $asset_key => $business_asset) { - //print_r($business_asset); - if(!strcmp($business_asset['business_emi'],'yes')) - { + //print_r($business_asset); + if (!strcmp($business_asset['business_emi'], 'yes')) { $business_assets_mode_name = ""; - foreach($assest_types as $asset_type) - { - if($asset_type['id'] == $business_asset['business_assets_mode']) - { + foreach ($assest_types as $asset_type) { + if ($asset_type['id'] == $business_asset['business_assets_mode']) { $business_assets_mode_name = $asset_type['name']; - } - } - - if( $business_asset['business_assets_mode'] == 2) - { - //echo $business_asset['business_details'][0]['property_type']; - foreach($property_types as $property_type) - { - if( $property_type['id'] == $business_asset['business_details'][0]['property_type']) - { - $business_asset['business_details'][0]['property_type_name'] = $property_type['name']; - } } } - $business_assest_data[] = array('business_assets_mode'=>$business_asset['business_assets_mode'],'business_assets_mode_name'=>$business_assets_mode_name,'business_details'=>$business_asset['business_details'],'business_name_of_the_owner'=>$business_asset['business_name_of_the_owner'],'business_name_of_the_other_owner' => $business_asset['business_name_of_the_other_owner']); - } + if ($business_asset['business_assets_mode'] == 2) { + //echo $business_asset['business_details'][0]['property_type']; + foreach ($property_types as $property_type) { + if ($property_type['id'] == $business_asset['business_details'][0]['property_type']) { + $business_asset['business_details'][0]['property_type_name'] = $property_type['name']; + } + } + } + $business_assest_data[] = array('business_assets_mode' => $business_asset['business_assets_mode'], 'business_assets_mode_name' => $business_assets_mode_name, 'business_details' => $business_asset['business_details'], 'business_name_of_the_owner' => $business_asset['business_name_of_the_owner'], 'business_name_of_the_other_owner' => $business_asset['business_name_of_the_other_owner']); + } } } - if(array_key_exists('business_assets_for_address',$json)) - { - foreach($json['business_assets_for_address'] as $address_key => $address_asset) - { - if(!strcasecmp($address_asset['business_emi'],'yes')) - { - //echo $address_asset['address_label']; + if (array_key_exists('business_assets_for_address', $json)) { + foreach ($json['business_assets_for_address'] as $address_key => $address_asset) { + if (!strcasecmp($address_asset['business_emi'], 'yes')) { + //echo $address_asset['address_label']; $business_address_assest_data[] = $address_asset; } } } - - } } - //Get Other Assets with Loan + //Get Other Assets with Loan $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>4,'fk_pd_id' => $pdid); - $other_assest = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - // print_r($this->db->last_query()); - // print_r($other_assest);die(); - if(count($other_assest)) - { - foreach($other_assest as $key => $assest) - { - $json = json_decode($assest['json'],true); - //print_r($json);die(); - if(array_key_exists('assets_details',$json)) - { - foreach($json['assets_details'] as $asset_key => $asset) - { - if(!strcmp($asset['emi'],'yes')) - { + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 4, 'fk_pd_id' => $pdid); + $other_assest = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + // print_r($this->db->last_query()); + // print_r($other_assest);die(); + if (count($other_assest)) { + foreach ($other_assest as $key => $assest) { + $json = json_decode($assest['json'], true); + //print_r($json);die(); + if (array_key_exists('assets_details', $json)) { + foreach ($json['assets_details'] as $asset_key => $asset) { + if (!strcmp($asset['emi'], 'yes')) { $assets_mode_name = ""; - foreach($assest_types as $asset_type) - { - if($asset_type['id'] == $asset['assets_mode']) - { + foreach ($assest_types as $asset_type) { + if ($asset_type['id'] == $asset['assets_mode']) { $assets_mode_name = $asset_type['name']; - } - } - - if($asset['assets_mode'] == 2) - { - //echo $business_asset['business_details'][0]['property_type']; - foreach($property_types as $property_type) - { - if( $property_type['id'] == $asset['details'][0]['property_type']) - { - $asset['details'][0]['property_type_name'] = $property_type['name']; - } } } - $other_assest_data[] = array('assets_mode'=>$asset['assets_mode'],'assets_mode_name'=>$assets_mode_name,'details'=>$asset['details'],'name_of_the_owner'=>$asset['name_of_the_owner'],'other_owner' => $asset['other_owner']); - } + if ($asset['assets_mode'] == 2) { + //echo $business_asset['business_details'][0]['property_type']; + foreach ($property_types as $property_type) { + if ($property_type['id'] == $asset['details'][0]['property_type']) { + $asset['details'][0]['property_type_name'] = $property_type['name']; + } + } + } + $other_assest_data[] = array('assets_mode' => $asset['assets_mode'], 'assets_mode_name' => $assets_mode_name, 'details' => $asset['details'], 'name_of_the_owner' => $asset['name_of_the_owner'], 'other_owner' => $asset['other_owner']); + } } } } @@ -7567,235 +6650,193 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = array('business_assets' =>$business_assest_data, 'other_assests'=> $other_assest_data,'business_address_asset' => $business_address_assest_data); - $this->response($data,REST_Controller::HTTP_OK); + $data['record'] = array('business_assets' => $business_assest_data, 'other_assests' => $other_assest_data, 'business_address_asset' => $business_address_assest_data); + $this->response($data, REST_Controller::HTTP_OK); } - + public function getProductsWithTypeofActivityFromBusiness_post() - { + { $pdid = $this->post('pd_id'); $company_id = $this->post('company_id'); - //echo $pdid.$company_id;die(); - //Get Details From General Full + //echo $pdid.$company_id;die(); + //Get Details From General Full $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid,'company_id' => $company_id); - $business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 13, 'fk_pd_id' => $pdid, 'company_id' => $company_id); + $business_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); $final_data_from_business = array(); - //print_r($business_data); - if(count($business_data)) - { - $json = json_decode($business_data[0]['json'],true); - //print_r($json); - if(array_key_exists('manufacturing_activity_details',$json)) - { - $temp_data['type_of_activity_id'] = 2; - $temp_data['name'] = 'Manufacturing'; - foreach($json['manufacturing_activity_details'] as $key => $manufacturing_activity_details) - { - $temp_data['products'][] = $manufacturing_activity_details['main_products']; + //print_r($business_data); + if (count($business_data)) { + $json = json_decode($business_data[0]['json'], true); + //print_r($json); + if (array_key_exists('manufacturing_activity_details', $json)) { + $temp_data['type_of_activity_id'] = 2; + $temp_data['name'] = 'Manufacturing'; + foreach ($json['manufacturing_activity_details'] as $key => $manufacturing_activity_details) { + $temp_data['products'][] = $manufacturing_activity_details['main_products']; } $final_data_from_business[] = $temp_data; $temp_data = array(); } - if(array_key_exists('retail_trading_activity_details',$json)) - { - $temp_data['type_of_activity_id'] = 3; - $temp_data['name'] = 'Retail trading'; - foreach($json['retail_trading_activity_details'] as $key => $retail_trading_activity_details) - { - $temp_data['products'][] = $retail_trading_activity_details['main_products']; + if (array_key_exists('retail_trading_activity_details', $json)) { + $temp_data['type_of_activity_id'] = 3; + $temp_data['name'] = 'Retail trading'; + foreach ($json['retail_trading_activity_details'] as $key => $retail_trading_activity_details) { + $temp_data['products'][] = $retail_trading_activity_details['main_products']; } $final_data_from_business[] = $temp_data; $temp_data = array(); } - if(array_key_exists('wholesale_trading_activity_details',$json)) - { - $temp_data['type_of_activity_id'] = 4; - $temp_data['name'] = 'Wholesale Trade'; - foreach($json['wholesale_trading_activity_details'] as $key => $wholesale_trading_activity_details) - { - $temp_data['products'][] = $wholesale_trading_activity_details['main_products']; + if (array_key_exists('wholesale_trading_activity_details', $json)) { + $temp_data['type_of_activity_id'] = 4; + $temp_data['name'] = 'Wholesale Trade'; + foreach ($json['wholesale_trading_activity_details'] as $key => $wholesale_trading_activity_details) { + $temp_data['products'][] = $wholesale_trading_activity_details['main_products']; } $final_data_from_business[] = $temp_data; $temp_data = array(); } - if(array_key_exists('service_provider_activity_details',$json)) - { - $temp_data['type_of_activity_id'] = 5; - $temp_data['name'] = 'Service Provider'; - foreach($json['service_provider_activity_details'] as $key => $service_provider_activity_details) - { - $temp_data['products'][] = $service_provider_activity_details['main_products']; + if (array_key_exists('service_provider_activity_details', $json)) { + $temp_data['type_of_activity_id'] = 5; + $temp_data['name'] = 'Service Provider'; + foreach ($json['service_provider_activity_details'] as $key => $service_provider_activity_details) { + $temp_data['products'][] = $service_provider_activity_details['main_products']; } $final_data_from_business[] = $temp_data; $temp_data = array(); } - - } - //GET RAW MATERIALS FROM SUPPLIER Form + //GET RAW MATERIALS FROM SUPPLIER Form $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>1,'fk_pd_id' => $pdid,'company_id' => $company_id); - $supplier_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - $final_data_from_supplier = array(); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 1, 'fk_pd_id' => $pdid, 'company_id' => $company_id); + $supplier_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + $final_data_from_supplier = array(); + //print_r($supplier_data); + if (count($supplier_data)) { + + $supplier_data = json_decode($supplier_data[0]['json'], true); //print_r($supplier_data); - if(count($supplier_data)) - { + if (array_key_exists('manufacturing_details', $supplier_data)) { - $supplier_data = json_decode($supplier_data[0]['json'],true); - //print_r($supplier_data); - if(array_key_exists('manufacturing_details',$supplier_data)) - { - - foreach($supplier_data['manufacturing_details'] as $manufacturing_activity_detail_key => $manufacturing_activity_detail) - { + foreach ($supplier_data['manufacturing_details'] as $manufacturing_activity_detail_key => $manufacturing_activity_detail) { $temp_data = $manufacturing_activity_detail['main_raw_materials']; - //print_r($temp_data);die(); - // print_r(count($temp_data)); - // print_r($temp_data[0]); - // print_r($temp_data[1]); - if($temp_data != "" || $temp_data != null) - { - foreach($temp_data as $raw_material) - { - //print_r($raw_material); + //print_r($temp_data);die(); + // print_r(count($temp_data)); + // print_r($temp_data[0]); + // print_r($temp_data[1]); + if ($temp_data != "" || $temp_data != null) { + foreach ($temp_data as $raw_material) { + //print_r($raw_material); $final_data_from_supplier['raw_material'][] = $raw_material['manufacturing_raw_material_name']; } } } - } - if(array_key_exists('trade_details',$supplier_data)) - { + if (array_key_exists('trade_details', $supplier_data)) { - foreach($supplier_data['trade_details'] as $trade_detail_key => $trade_detail) - { + foreach ($supplier_data['trade_details'] as $trade_detail_key => $trade_detail) { $temp_data = $trade_detail['trading_products']; - //print_r($temp_data);die(); - // print_r(count($temp_data)); - // print_r($temp_data[0]); - // print_r($temp_data[1]); - if($temp_data != "" || $temp_data != null) - { - foreach($temp_data as $trade) - { - //print_r($raw_material); + //print_r($temp_data);die(); + // print_r(count($temp_data)); + // print_r($temp_data[0]); + // print_r($temp_data[1]); + if ($temp_data != "" || $temp_data != null) { + foreach ($temp_data as $trade) { + //print_r($raw_material); $final_data_from_supplier['trading_product'][] = $trade['trade_product_name']; } } } - } } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = array('from_business' => $final_data_from_business,'from_supplier' => $final_data_from_supplier); - $this->response($data,REST_Controller::HTTP_OK); - - - - + $data['record'] = array('from_business' => $final_data_from_business, 'from_supplier' => $final_data_from_supplier); + $this->response($data, REST_Controller::HTTP_OK); } //Get All Persons Name Invloved In a PD, includes Applicants,Invloved in Business public function getAllPersonsName_post() { $pdid = $this->post('pd_id'); - //echo $pdid; - //Get Details From General Form + //echo $pdid; + //Get Details From General Form $final_names = array(); $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); - $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - //print_r($general_data);die(); - if(count($general_data)) - { - $json = json_decode($general_data[0]['json'],true); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 18, 'fk_pd_id' => $pdid); + $general_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + //print_r($general_data);die(); + if (count($general_data)) { + $json = json_decode($general_data[0]['json'], true); + //print_r($json); + if (array_key_exists('individuals', $json)) { + foreach ($json['individuals'] as $key => $persons) { + // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) + // { + // $type = 1; + // } + $final_names[] = array('applicant_name' => $persons['applicant_name'], 'applicant_type' => 1, 'applicant_id' => $persons['pd_co_applicant_id']); + } + } + + if (array_key_exists('companies', $json)) { + foreach ($json['companies'] as $key => $persons) { + // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) + // { + // $type = 1; + // } + $final_names[] = array('applicant_name' => $persons['company_name'], 'applicant_type' => 2, 'applicant_id' => $persons['company_name']); + } + } + } + + //print_r($final_names);die(); + //Get Details from All Business Froms + $fields = array('json', 'company_id'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 13, 'fk_pd_id' => $pdid); + $business_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); + + //print_r($business_data);die(); + + if (count($business_data)) { + foreach ($business_data as $business_data_key => $business) { + $json = json_decode($business['json'], true); //print_r($json); - if(array_key_exists('individuals',$json)) - { - foreach($json['individuals'] as $key => $persons) - { - // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) - // { - // $type = 1; - // } - $final_names[] = array('applicant_name' => $persons['applicant_name'],'applicant_type' => 1,'applicant_id'=>$persons['pd_co_applicant_id']); - } - } - - if(array_key_exists('companies',$json)) - { - foreach($json['companies'] as $key => $persons) - { - // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) - // { - // $type = 1; - // } - $final_names[] = array('applicant_name' => $persons['company_name'],'applicant_type' => 2,'applicant_id'=>$persons['company_name']); - } - } - } - - //print_r($final_names);die(); - //Get Details from All Business Froms - $fields = array('json','company_id'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid); - $business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - - //print_r($business_data);die(); - - if(count($business_data)) - { - foreach($business_data as $business_data_key => $business) - { - $json = json_decode($business['json'],true); - //print_r($json); - if(array_key_exists('persons_with_relationships',$json)) - { - foreach($json['persons_with_relationships'] as $key => $persons) - { - $final_names[] = array('applicant_name' => $persons['family_member_name'],'applicant_type' => 3,'applicant_id'=>$persons['family_member_name']); + if (array_key_exists('persons_with_relationships', $json)) { + foreach ($json['persons_with_relationships'] as $key => $persons) { + $final_names[] = array('applicant_name' => $persons['family_member_name'], 'applicant_type' => 3, 'applicant_id' => $persons['family_member_name']); } - } } } - //Get Memebers from Other Family Members form - $fields = array('json','company_id'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>6,'fk_pd_id' => $pdid); - $family_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + //Get Memebers from Other Family Members form + $fields = array('json', 'company_id'); + $where_condition_array = array('isactive' => 1, 'fk_form_id' => 6, 'fk_pd_id' => $pdid); + $family_data = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, PDFORMDETAILSJSON); - if(count($family_data)) - { - $family_data = json_decode($family_data[0]['json'],true); - // echo "familty"; - // print_r($family_data);die(); - foreach($family_data as $family_data_key => $family) - { + if (count($family_data)) { + $family_data = json_decode($family_data[0]['json'], true); + // echo "familty"; + // print_r($family_data);die(); + foreach ($family_data as $family_data_key => $family) { - if(is_array($family)) - { - if(array_key_exists('family_members_details',$family)) - { - foreach($family['family_members_details'] as $key => $persons) - { - $final_names[] = array('applicant_name' => $persons['applicant_name'],'applicant_type' => 3,'applicant_id'=>$persons['applicant_name']); + if (is_array($family)) { + if (array_key_exists('family_members_details', $family)) { + foreach ($family['family_members_details'] as $key => $persons) { + $final_names[] = array('applicant_name' => $persons['applicant_name'], 'applicant_type' => 3, 'applicant_id' => $persons['applicant_name']); } - } } } @@ -7805,136 +6846,123 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['record'] = $final_names; - $this->response($data,REST_Controller::HTTP_OK); - - } - + $this->response($data, REST_Controller::HTTP_OK); + } + // Get List of Cities from PD TriggeredTabel to Frond End Filter. public function getListOfCities_get() { $this->db->DISTINCT(); $this->db->SELECT('CITY.city_id,CITY.name'); - $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); - $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id'); + $this->db->FROM(PDTRIGGER . ' as PDTRIGGER'); + $this->db->JOIN(CITY . ' as CITY', 'PDTRIGGER.fk_city = CITY.city_id'); $city = $this->db->GET()->result_array(); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $city; - $this->response($data,REST_Controller::HTTP_OK); - - } - + $this->response($data, REST_Controller::HTTP_OK); + } + public function savePDPhotos_post() { - + $records = $this->post('records'); - $company_id = isset($records['company_id']) && $records['company_id']? $records['company_id'] : null; + $company_id = isset($records['company_id']) && $records['company_id'] ? $records['company_id'] : null; $rental_count_id = isset($records['rental_count_id']) && $records['rental_count_id'] ? $records['rental_count_id'] : null; //$location = isset($records['link']) ? $records['link'] : null; //echo $rental_count_id;die(); - if(isset($records['images'][0]['pd_document_id']) && $records['images'][0]['pd_document_id'] !=null && $records['images'][0]['pd_document_id'] != ""){ - $where_condition_array = array('pd_document_id' => $records['images'][0]['pd_document_id']); - $to_update = array("pd_image_alias_name"=>$records['images'][0]['pd_image_alias_name']); - $res['count'] = $this->PD_Model->updateRecords($to_update,PDDOCUMENTS,$where_condition_array); + if (isset($records['images'][0]['pd_document_id']) && $records['images'][0]['pd_document_id'] != null && $records['images'][0]['pd_document_id'] != "") { + $where_condition_array = array('pd_document_id' => $records['images'][0]['pd_document_id']); + $to_update = array("pd_image_alias_name" => $records['images'][0]['pd_image_alias_name']); + $res['count'] = $this->PD_Model->updateRecords($to_update, PDDOCUMENTS, $where_condition_array); $res['msg'] = "Updated"; $data['uri'] = null; + } else if (isset($records['images'][0]['image'])) { + $res = $this->saveBase64Images($records['pd_id'], $records['formid'], $company_id, $rental_count_id, $records['images']); } - else if(isset($records['images'][0]['image'])){ - $res = $this->saveBase64Images($records['pd_id'],$records['formid'],$company_id,$rental_count_id,$records['images']); - } - - + + //print_r($res); - if(count($res)) - { + if (count($res)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $res['count']; $data['uri'] = $res['records']; $data['msg'] = $res['msg']; - $this->response($data,REST_Controller::HTTP_OK,true); - } - else - { + $this->response($data, REST_Controller::HTTP_OK, true); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'Something Went Wrong!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - + public function getPDImages_post() { $records = $this->post('records'); - $result_data = $this->PD_Model->getSignedPDDocsURL($records['pd_id'],isset($records['form_id']) ? $records['form_id']: null ,isset($records['company_id']) ? $records['company_id'] : null,isset($records['is_common']) ? $records['is_common'] : null,isset($records['rental_count_id']) ? $records['rental_count_id'] : null); - if(count($result_data)) - { + $result_data = $this->PD_Model->getSignedPDDocsURL($records['pd_id'], isset($records['form_id']) ? $records['form_id'] : null, isset($records['company_id']) ? $records['company_id'] : null, isset($records['is_common']) ? $records['is_common'] : null, isset($records['rental_count_id']) ? $records['rental_count_id'] : null); + if (count($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'No Data Available'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - - public function saveBase64Images($pd_id,$form_id = null,$company_id = null,$rental_count_id = null,$data) + + public function saveBase64Images($pd_id, $form_id = null, $company_id = null, $rental_count_id = null, $data) { - log_message('ERROR','###PDIMAGE saveBase64Images function called'.$pd_id.' - '.$form_id); + log_message('ERROR', '###PDIMAGE saveBase64Images function called' . $pd_id . ' - ' . $form_id); $count = 0; $result = array(); $pks = array(); $uri = null; $pd_details = $this->PD_Model->getPDMasterDetails($pd_id); - //print_r($data);die(); + //print_r($data);die(); EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id); - foreach($data as $iter => $doc) - { + foreach ($data as $iter => $doc) { //make location for water mark helper function $this->location_for_watermark = $doc['link']; - + $temp_base64_string = $doc['image']; $title = $doc['Name']; $is_show_report = isset($doc['is_show_report']) ? $doc['is_show_report'] : null; - if($pd_details[0]['fk_pd_type'] == 2 && strpos($title, 'Approach to PD Location') !== false) - { + if ($pd_details[0]['fk_pd_type'] == 2 && strpos($title, 'Approach to PD Location') !== false) { $is_show_report = 1; } - //$external_path = $this->config->item('external_data_path'); + //$external_path = $this->config->item('external_data_path'); //echo $title.'-'.$is_show_report;die(); $co_applicant_id = isset($doc['co_applicant_id']) ? $doc['co_applicant_id'] : null; $img_type = isset($doc['img_type']) ? $doc['img_type'] : null; - $output_file = $this->external_path."/pd_reports/". $pd_id ."/temp_base64_image.jpeg"; + $output_file = $this->external_path . "/pd_reports/" . $pd_id . "/temp_base64_image.jpeg"; $this->temp_path_for_watermark = $output_file; - //Generate Random File Name + //Generate Random File Name $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').'.jpeg'; + $temp_file_name = $randomString . date('Y-m-d-H-i-s') . '.jpeg'; - log_message('ERROR','###PDIMAGE writing started'.$pd_id.' - '.$form_id); - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); - log_message('ERROR','###PDIMAGE writing done'.$pd_id.' - '.$form_id); + log_message('ERROR', '###PDIMAGE writing started' . $pd_id . ' - ' . $form_id); + $ifp = fopen($output_file, 'wb'); + $temp_data = explode(',', $temp_base64_string); + fwrite($ifp, base64_decode($temp_data[1])); + fclose($ifp); + log_message('ERROR', '###PDIMAGE writing done' . $pd_id . ' - ' . $form_id); - // // ################### start img water marking with text + // // ################### start img water marking with text // $imagetobewatermark = imagecreatefromstring(file_get_contents($output_file)); @@ -7962,61 +6990,59 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // imagejpeg($curret_file,$output_file,100);// save png image in specified location // //###########end of image water marking with logo - log_message('ERROR','###PDIMAGE uploading to S3'.$pd_id.' - '.$form_id); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; - $key = 'pd'.$pd_id.'/'.$tempdocname; - // if($form_id != null) - // { - // $key = 'pd'.$pd_id.'/'.'form'.$form_id.'/'.$tempdocname; - // } - $sourcefile = $tempdoc; + log_message('ERROR', '###PDIMAGE uploading to S3' . $pd_id . ' - ' . $form_id); + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details[0]['fk_lender_id']; + $key = 'pd' . $pd_id . '/' . $tempdocname; + // if($form_id != null) + // { + // $key = 'pd'.$pd_id.'/'.'form'.$form_id.'/'.$tempdocname; + // } + $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); - //this line make this bucket data values in obj level so can access in helpers and hook files - $this->bucket_data_for_watermark = $bucket_data; - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + //this line make this bucket data values in obj level so can access in helpers and hook files + $this->bucket_data_for_watermark = $bucket_data; + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###PDIMAGE stored in S3'.$pd_id.' - '.$form_id); - // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => isset($doc['link']) ? $doc['link'] : null,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type,'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null)); - $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => isset($doc['link']) ? $doc['link'] : null,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type,'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null),"pd_image_alias_name" => (isset($doc['pd_image_alias_name']) ? $doc['pd_image_alias_name'] : null)); - $record_data['company_id'] = $company_id ? $company_id : null; - $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - if($id != null || $id != "") { $count++; $pks[] = $id;} - $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+1 week'); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', '###PDIMAGE stored in S3' . $pd_id . ' - ' . $form_id); + // $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => isset($doc['link']) ? $doc['link'] : null,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type,'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null)); + $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => $title, 'pd_document_name' => $tempdocname, 'fk_form_id' => $form_id, 'is_show_report' => $is_show_report, 'rental_count_id' => $rental_count_id, 'location' => isset($doc['link']) ? $doc['link'] : null, 'co_applicant_id' => $co_applicant_id, 'img_type' => $img_type, 'image_key' => (isset($doc['image_key']) ? $doc['image_key'] : null), "pd_image_alias_name" => (isset($doc['pd_image_alias_name']) ? $doc['pd_image_alias_name'] : null)); + $record_data['company_id'] = $company_id ? $company_id : null; + $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + if ($id != null || $id != "") { + $count++; + $pks[] = $id; + } + $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week'); - $this->img_url_for_watermark = $uri; - //print_r($uri); - } + $this->img_url_for_watermark = $uri; + //print_r($uri); + } + } - } - - if($count == count($data)) - { - //$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['records'] = $uri; - $result['msg'] = "All Images Saved Successfully"; - } - else - { - //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['msg'] = "Some Images Not Saved!"; - } - return $result; + if ($count == count($data)) { + //$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['records'] = $uri; + $result['msg'] = "All Images Saved Successfully"; + } else { + //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['msg'] = "Some Images Not Saved!"; + } + return $result; } - public function saveBase64Images_new($pd_id,$form_id = null,$company_id = null,$rental_count_id = null,$data) + public function saveBase64Images_new($pd_id, $form_id = null, $company_id = null, $rental_count_id = null, $data) { @@ -8024,971 +7050,832 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $result = array(); $pks = array(); $pd_details = $this->PD_Model->getPDMasterDetails($pd_id); - //print_r($data);die(); + //print_r($data);die(); EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id); - foreach($data as $iter => $doc) - { + foreach ($data as $iter => $doc) { $temp_base64_string = $doc['image']; $title = $doc['Name']; $is_show_report = isset($doc['is_show_report']) ? $doc['is_show_report'] : null; - //$external_path = $this->config->item('external_data_path'); - $output_file = $this->external_path."/pd_reports/". $pd_id ."/temp_base64_image.jpeg"; - + //$external_path = $this->config->item('external_data_path'); + $output_file = $this->external_path . "/pd_reports/" . $pd_id . "/temp_base64_image.jpeg"; - //Generate Random File Name + + //Generate Random File Name $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').'.jpeg'; + $temp_file_name = $randomString . date('Y-m-d-H-i-s') . '.jpeg'; - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); + $ifp = fopen($output_file, 'wb'); + $temp_data = explode(',', $temp_base64_string); // fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - //fclose( $ifp ); - $image_p = imagecreatetruecolor(500, 375); - + //fclose( $ifp ); + $image_p = imagecreatetruecolor(500, 375); - // ################### start img water marking with text + + // ################### start img water marking with text //echo $temp_base64_string; - $imagetobewatermark = imagecreatefromstring( base64_decode( $temp_data[ 1 ] )); - - $location_watermarktext="Location: ".$doc['link']; - $font = APPPATH."docs/robold.ttf"; //metion font and it's location - $fontsize="12"; - $x = imagesx($imagetobewatermark); - $y = imagesy($imagetobewatermark); - - $water_mark_text_color = imagecolorallocate($imagetobewatermark, 225, 0, 0); - imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 30), $water_mark_text_color, $font, $location_watermarktext); + $imagetobewatermark = imagecreatefromstring(base64_decode($temp_data[1])); - imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 10), $water_mark_text_color, $font, 'Date: '.date('Y-m-d h:i:s a')); - - //imagejpeg($imagetobewatermark,$output_file,100);//save as png file in ouputfile location - // die(); - //################# end img water marking with text - + $location_watermarktext = "Location: " . $doc['link']; + $font = APPPATH . "docs/robold.ttf"; //metion font and it's location + $fontsize = "12"; + $x = imagesx($imagetobewatermark); + $y = imagesy($imagetobewatermark); - //###########image water marking with logo - $pd_logo = imagecreatefromstring(file_get_contents(APPPATH.'docs/icon.png')); - $curret_file = $imagetobewatermark; - $sx = imagesx($curret_file); - $sy = imagesy($curret_file); - // imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool - //imagecopyresized ( $curret_file , $pd_logo ,5, ($sy - 54) , 0 , 0 , 50 , 50 , 50 , 54 ); + $water_mark_text_color = imagecolorallocate($imagetobewatermark, 225, 0, 0); + imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 30), $water_mark_text_color, $font, $location_watermarktext); - // imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool - imagecopyresampled ( $curret_file , $pd_logo ,5, ($sy - 54) , 0 , 0 , 50 , 50 , 50 , 54 ); + imagettftext($imagetobewatermark, $fontsize, 0, 120, ($y - 10), $water_mark_text_color, $font, 'Date: ' . date('Y-m-d h:i:s a')); - imagejpeg($curret_file,$output_file,100);// save png image in specified location - //###########end of image water marking with logo - //die(); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; - $key = 'pd'.$pd_id.'/'.$tempdocname; - // if($form_id != null) - // { - // $key = 'pd'.$pd_id.'/'.'form'.$form_id.'/'.$tempdocname; - // } - $sourcefile = $tempdoc; + //imagejpeg($imagetobewatermark,$output_file,100);//save as png file in ouputfile location + // die(); + //################# end img water marking with text - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => $doc['link']); - $record_data['company_id'] = $company_id ? $company_id : null; - $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - if($id != null || $id != "") { $count++; $pks[] = $id;} - } + //###########image water marking with logo + $pd_logo = imagecreatefromstring(file_get_contents(APPPATH . 'docs/icon.png')); + $curret_file = $imagetobewatermark; + $sx = imagesx($curret_file); + $sy = imagesy($curret_file); + // imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool + //imagecopyresized ( $curret_file , $pd_logo ,5, ($sy - 54) , 0 , 0 , 50 , 50 , 50 , 54 ); - } + // imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool + imagecopyresampled($curret_file, $pd_logo, 5, ($sy - 54), 0, 0, 50, 50, 50, 54); - if($count == count($data)) - { - //$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['msg'] = "All Images Saved Successfully"; - } - else - { - //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['msg'] = "Some Images Not Saved!"; - } - return $result; + imagejpeg($curret_file, $output_file, 100); // save png image in specified location + //###########end of image water marking with logo + //die(); + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details[0]['fk_lender_id']; + $key = 'pd' . $pd_id . '/' . $tempdocname; + // if($form_id != null) + // { + // $key = 'pd'.$pd_id.'/'.'form'.$form_id.'/'.$tempdocname; + // } + $sourcefile = $tempdoc; + + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => $title, 'pd_document_name' => $tempdocname, 'fk_form_id' => $form_id, 'is_show_report' => $is_show_report, 'rental_count_id' => $rental_count_id, 'location' => $doc['link']); + $record_data['company_id'] = $company_id ? $company_id : null; + $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + if ($id != null || $id != "") { + $count++; + $pks[] = $id; + } + } + } + + if ($count == count($data)) { + //$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['msg'] = "All Images Saved Successfully"; + } else { + //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['msg'] = "Some Images Not Saved!"; + } + return $result; } - public function calculateScore($pdid) - { + public function calculateScore($pdid) + { //echo $pdid;die(); //GET JSON FORM DATA - $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); //print_r($pd_master_details); - $form_data = $this->PD_Model->getScorablePDFormDetailsJSON($pdid); + $form_data = $this->PD_Model->getScorablePDFormDetailsJSON($pdid); //print_r($form_data); //Get Latest Loan Amount form loan form. - $loan_amt_from_loam_form = json_decode($form_data[10][0]['processed_json'],true); - $loan_amt_from_loam_form = $loan_amt_from_loam_form['loan_amount']; + $loan_amt_from_loam_form = json_decode($form_data[10][0]['processed_json'], true); + $loan_amt_from_loam_form = $loan_amt_from_loam_form['loan_amount']; //echo $loan_amt_from_loam_form; //seperate PD Scorable quesitons from JSON - $score_questions = $this->seperateScoreQuestions($form_data,$pd_master_details); + $score_questions = $this->seperateScoreQuestions($form_data, $pd_master_details); // echo "###################################"; //Get Pesrsonal Assets Grid Masters Details - if((int)$loan_amt_from_loam_form >= 100000000 ) - { - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRID); - $this->db->WHERE('isactive',1); - $this->db->ORDER_BY('personal_asset_grid_id','DESC'); - $this->db->LIMIT(1) ; - $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); - } - else - { + if ((int)$loan_amt_from_loam_form >= 100000000) { + $this->db->SELECT('*'); + $this->db->FROM(PERSONALASSETGRID); + $this->db->WHERE('isactive', 1); + $this->db->ORDER_BY('personal_asset_grid_id', 'DESC'); + $this->db->LIMIT(1); + $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); + } else { - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRID); - $this->db->WHERE('isactive',1); - $this->db->WHERE('loan_amount_from<=',(int)$loan_amt_from_loam_form); - $this->db->WHERE('loan_amount_to>=',(int)$loan_amt_from_loam_form); - $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); - } - // print_r($this->db->last_query()); - // print_r($personal_asset_grid['master_grid']); - // die(); - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRIDVARIANCE); - $this->db->WHERE('isactive',1); - $personal_asset_grid['variance_grid'] = $this->db->GET()->result_array(); + $this->db->SELECT('*'); + $this->db->FROM(PERSONALASSETGRID); + $this->db->WHERE('isactive', 1); + $this->db->WHERE('loan_amount_from<=', (int)$loan_amt_from_loam_form); + $this->db->WHERE('loan_amount_to>=', (int)$loan_amt_from_loam_form); + $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); + } + // print_r($this->db->last_query()); + // print_r($personal_asset_grid['master_grid']); + // die(); + $this->db->SELECT('*'); + $this->db->FROM(PERSONALASSETGRIDVARIANCE); + $this->db->WHERE('isactive', 1); + $personal_asset_grid['variance_grid'] = $this->db->GET()->result_array(); // echo "calculateScore"; // print_r($personal_asset_grid);die(); // Call PD score functions - $combination = $pd_master_details[0]['fk_lender_id'].$pd_master_details[0]['fk_product_id'].$pd_master_details[0]['fk_customer_segment']; + $combination = $pd_master_details[0]['fk_lender_id'] . $pd_master_details[0]['fk_product_id'] . $pd_master_details[0]['fk_customer_segment']; - switch($combination) - { - case 111111: - PDSCORE::calculatePDScore111($score_questions,$loan_amt_from_loam_form,$personal_asset_grid); + switch ($combination) { + case 111111: + PDSCORE::calculatePDScore111($score_questions, $loan_amt_from_loam_form, $personal_asset_grid); + break; + + default: + switch ($pd_master_details[0]['fk_pd_type']) { + case 1: //FULL PD + $score_questions = PDSCORE::genericDIPDScoreCalculate($score_questions, $loan_amt_from_loam_form, $personal_asset_grid, $pd_master_details); + break; + case 2: //SMART PD + $score_questions = PDSCORE::genericDISmartPDScoreCalculate($score_questions, $loan_amt_from_loam_form, $personal_asset_grid, $pd_master_details); break; - default: - switch($pd_master_details[0]['fk_pd_type']) - { - case 1://FULL PD - $score_questions = PDSCORE::genericDIPDScoreCalculate($score_questions,$loan_amt_from_loam_form,$personal_asset_grid,$pd_master_details); - break; - case 2://SMART PD - $score_questions = PDSCORE::genericDISmartPDScoreCalculate($score_questions,$loan_amt_from_loam_form,$personal_asset_grid,$pd_master_details); - break; - - - case 3://tele PD - $score_questions = PDSCORE::genericTelePDScoreCalculate($score_questions,$loan_amt_from_loam_form,$personal_asset_grid,$pd_master_details); - break; - } - } - - return $score_questions; - + case 3: //tele PD + $score_questions = PDSCORE::genericTelePDScoreCalculate($score_questions, $loan_amt_from_loam_form, $personal_asset_grid, $pd_master_details); + break; } + } + + return $score_questions; + } //Get All Score able Question from various PD Forms - 3 Questions Pending - public function seperateScoreQuestions($form_data,$pd_master_details) - { - $score_questions = array(); - $OTP = $pd_master_details[0]['is_otp_done']; - $is_this_tele_pd = $pd_master_details[0]['fk_pd_type'] == 3 ? true : null; + public function seperateScoreQuestions($form_data, $pd_master_details) + { + $score_questions = array(); + $OTP = $pd_master_details[0]['is_otp_done']; + $is_this_tele_pd = $pd_master_details[0]['fk_pd_type'] == 3 ? true : null; #####General Form Questions######## - $general_form = (json_decode($form_data[18][0]['processed_json'],true)); + $general_form = (json_decode($form_data[18][0]['processed_json'], true)); // echo "seperateScoreQuestions"; - + // - QNO (1.7) OTP AUTHENDICATION DONE - $score_questions['general']['otp_done'] = $OTP ? 'Yes': 'No'; + $score_questions['general']['otp_done'] = $OTP ? 'Yes' : 'No'; // 1 - QNO(1.1) - Is Person Met, One Of the Applicant's - $qualification_temp_array = array(); + $qualification_temp_array = array(); - $score_questions['general']['person_met_is_applicant'] = 'no'; - foreach($general_form['individuals'] as $person) - { + $score_questions['general']['person_met_is_applicant'] = 'no'; + foreach ($general_form['individuals'] as $person) { //print_r($person); - $qualification_temp_array = array_merge($qualification_temp_array,array($person['qualification'])); - if($person['is_applicant'] == true && $person['is_person_met'] == true) - { + $qualification_temp_array = array_merge($qualification_temp_array, array($person['qualification'])); + if ($person['is_applicant'] == true && $person['is_person_met'] == true) { //echo $person['applicant_name']; - $score_questions['general']['person_met_is_applicant'] = 'yes'; - } - } + $score_questions['general']['person_met_is_applicant'] = 'yes'; + } + } //if tele pd remove person_met_is_applicant - if($is_this_tele_pd){ unset($score_questions['general']['person_met_is_applicant']);} + if ($is_this_tele_pd) { + unset($score_questions['general']['person_met_is_applicant']); + } //print_r($qualification_temp_array); - $qualification_temp_array = array_map(function($item){ - return $item != "" || $item != null ? $item : 6; - },$qualification_temp_array); + $qualification_temp_array = array_map(function ($item) { + return $item != "" || $item != null ? $item : 6; + }, $qualification_temp_array); //print_r($qualification_temp_array); - $min = count($qualification_temp_array) ? min($qualification_temp_array) : 6; + $min = count($qualification_temp_array) ? min($qualification_temp_array) : 6; //die(); // 2 - QNO(1.8) - Qualification - $score_questions['general']['qualification'] = $min; + $score_questions['general']['qualification'] = $min; // 3 - QNO(2.1) - No of Years Business Run - if(array_key_exists('companies',$general_form)) - { - $score_questions['business']['no_of_years_business_run'] = isset($general_form['companies'][0]['business_years']) ? $general_form['companies'][0]['business_years'] : 0; - } + if (array_key_exists('companies', $general_form)) { + $score_questions['business']['no_of_years_business_run'] = isset($general_form['companies'][0]['business_years']) ? $general_form['companies'][0]['business_years'] : 0; + } #####End of General Form Questions######## #####Address Form Questions######## - $address_form = (json_decode($form_data[5][0]['processed_json'],true)); + $address_form = (json_decode($form_data[5][0]['processed_json'], true)); //print_r($address_form);die(); - if(!$is_this_tele_pd) - { - if(isset($address_form['is_pd_done_on_initiated_address']) && $address_form['is_pd_done_on_initiated_address'] != 1) - { + if (!$is_this_tele_pd) { + if (isset($address_form['is_pd_done_on_initiated_address']) && $address_form['is_pd_done_on_initiated_address'] != 1) { - - - // 4 - QNO(1.2) - Comment on locality - $score_questions['general']['comment_locality'] = $address_form['alternative_addresses'][0]['comment_locality_master']; - // 5 - QNO(1.3) - pd location approach - $score_questions['general']['pd_location_approach'] = $address_form['alternative_addresses'][0]['pd_location_master']; - - } - else //get it from alternative address - { - // 4 - QNO(1.2) - Comment on locality - $score_questions['general']['comment_locality'] = $address_form['addresses'][0]['comment_locality_master']; - // 5 - QNO(1.3) - pd location approach - $score_questions['general']['pd_location_approach'] = $address_form['addresses'][0]['pd_location_master']; - - } + // 4 - QNO(1.2) - Comment on locality + $score_questions['general']['comment_locality'] = $address_form['alternative_addresses'][0]['comment_locality_master']; + // 5 - QNO(1.3) - pd location approach + $score_questions['general']['pd_location_approach'] = $address_form['alternative_addresses'][0]['pd_location_master']; + } else //get it from alternative address + { + // 4 - QNO(1.2) - Comment on locality + $score_questions['general']['comment_locality'] = $address_form['addresses'][0]['comment_locality_master']; + // 5 - QNO(1.3) - pd location approach + $score_questions['general']['pd_location_approach'] = $address_form['addresses'][0]['pd_location_master']; + } } - + #####ENd Of Address Form Questions######## //print_r($score_questions['general']);die(); - + #####Final Remarks Form Questions######## - $final_remarks_form = (json_decode($form_data[20][0]['processed_json'],true)); + $final_remarks_form = (json_decode($form_data[20][0]['processed_json'], true)); //print_r($final_remarks_form); - - + + // 6 - QNO(1.4) - customer behaviour - - $score_questions['general']['customer_behaviour'] = $final_remarks_form['final_custormer_remark_type_master']; - - + + $score_questions['general']['customer_behaviour'] = $final_remarks_form['final_custormer_remark_type_master']; + + // 7 - QNO(3.1) - pd_officer_recommadations $score_questions['final_remarks']['pd_officer_recommandations'] = $final_remarks_form['pd_officers_recommendation_master']; // 8 - QNO(2.11) - pd location approach - if(!$is_this_tele_pd) - { + if (!$is_this_tele_pd) { $score_questions['business']['location_suited_for_busienss'] = $final_remarks_form['is_service_provided']; } - + #####End of Final Remarks Form Questions######## - - + + #####Neighbourhood Form Questions######## - - if(!$is_this_tele_pd) - { - $neighbourhood_form = (json_decode($form_data[19][0]['processed_json'],true)); + + if (!$is_this_tele_pd) { + $neighbourhood_form = (json_decode($form_data[19][0]['processed_json'], true)); //print_r($neighbourhood_form); - - + + // 9 - QNO(1.5) - neibourhood_check_as_per_pd_officer $score_questions['general']['neibourhood_check_as_per_pd_officer'] = isset($neighbourhood_form['neighbourhood_status']) ? $neighbourhood_form['neighbourhood_status'] : 'Negative'; } #####End of Neighbourhood Form Questions######## - - + + #####Business Form Questions######## - $business_form = (json_decode($form_data[13][0]['processed_json'],true)); + $business_form = (json_decode($form_data[13][0]['processed_json'], true)); //print_r($business_form);die(); - + // 10 - QNO(1.6) - was_the_company_name_board_sighted $score_questions['general']['was_the_company_name_board_sighted'] = isset($business_form['was_the_company_name_board_sighted']) ? $business_form['was_the_company_name_board_sighted'] : 'No'; - + // 11 - QNO(2.2) - seasonality $score_questions['business']['business_seasonality'] = $business_form['seasonality']; - + // 12 - QNO(2.3) - employees_total - if(!$is_this_tele_pd) - { + if (!$is_this_tele_pd) { $score_questions['business']['employees_total'] = $business_form['employees_total']; } - - + + // 13 - QNO(2.4) - all business certificate $temp = array(); - $temp['shop_eat_act_cert'] = isset($business_form['shop_eat_act_cert'])?$business_form['shop_eat_act_cert']:'not applicable'; - $temp['gst_Regn_cert'] = isset($business_form['gst_Regn_cert'])?$business_form['gst_Regn_cert']:'not applicable'; - $temp['pf_regn'] = isset($business_form['pf_regn'])?$business_form['pf_regn']:'not applicable'; - $temp['esic_regn'] = isset($business_form['esic_regn'])?$business_form['esic_regn']:'not applicable'; - $temp['export_import_cert'] = isset($business_form['export_import_cert'])?$business_form['export_import_cert']:'not applicable'; - $temp['factory_cert'] = isset($business_form['factory_cert'])?$business_form['factory_cert']:'not applicable'; - $temp['cert_of_practice'] = isset($business_form['practice_cert']) ? $business_form['practice_cert']: 'not applicable'; + $temp['shop_eat_act_cert'] = isset($business_form['shop_eat_act_cert']) ? $business_form['shop_eat_act_cert'] : 'not applicable'; + $temp['gst_Regn_cert'] = isset($business_form['gst_Regn_cert']) ? $business_form['gst_Regn_cert'] : 'not applicable'; + $temp['pf_regn'] = isset($business_form['pf_regn']) ? $business_form['pf_regn'] : 'not applicable'; + $temp['esic_regn'] = isset($business_form['esic_regn']) ? $business_form['esic_regn'] : 'not applicable'; + $temp['export_import_cert'] = isset($business_form['export_import_cert']) ? $business_form['export_import_cert'] : 'not applicable'; + $temp['factory_cert'] = isset($business_form['factory_cert']) ? $business_form['factory_cert'] : 'not applicable'; + $temp['cert_of_practice'] = isset($business_form['practice_cert']) ? $business_form['practice_cert'] : 'not applicable'; $score_questions['business']['cerificates'] = $temp; #####End of Business Form Questions######## - - + + #####Business Assets Form Questions######## - $business_assest_form = (json_decode($form_data[22][0]['processed_json'],true)); + $business_assest_form = (json_decode($form_data[22][0]['processed_json'], true)); //print_r($business_assest_form);//die(); - + $property_count = 0; $vechile_count = 0; - if(array_key_exists('business_assets_for_address',$business_assest_form) && isset($business_assest_form['business_assets_for_address'][0])) - { - $property_count = (!strcasecmp($business_assest_form['business_assets_for_address'][0]['business_ownership_type'],'owned')) ? (++$property_count) : $property_count; + if (array_key_exists('business_assets_for_address', $business_assest_form) && isset($business_assest_form['business_assets_for_address'][0])) { + $property_count = (!strcasecmp($business_assest_form['business_assets_for_address'][0]['business_ownership_type'], 'owned')) ? (++$property_count) : $property_count; } - - if(array_key_exists('business_assets_details',$business_assest_form)) - { - - foreach($business_assest_form['business_assets_details'] as $value) - { - if(isset($value['business_assets_mode']) && $value['business_assets_mode'] == 2 && $value['business_ownership_type'] == 'owned') - { + + if (array_key_exists('business_assets_details', $business_assest_form)) { + + foreach ($business_assest_form['business_assets_details'] as $value) { + if (isset($value['business_assets_mode']) && $value['business_assets_mode'] == 2 && $value['business_ownership_type'] == 'owned') { $property_count++; } - if(isset($value['business_assets_mode']) && $value['business_assets_mode'] == 3 && $value['business_ownership_type'] == 'owned') - { + if (isset($value['business_assets_mode']) && $value['business_assets_mode'] == 3 && $value['business_ownership_type'] == 'owned') { $vechile_count++; } } - + //echo // 14 - QNO(2.5) - owned_property - $score_questions['business']['owned_property'] = $property_count ? 'yes':'no'; + $score_questions['business']['owned_property'] = $property_count ? 'yes' : 'no'; // 15 - QNO(2.6) - owned_vechile - $score_questions['business']['owned_vechile'] = $vechile_count ? 'yes':'no'; - + $score_questions['business']['owned_vechile'] = $vechile_count ? 'yes' : 'no'; + // - QNO (2.12) - business_activity seen - if(!$is_this_tele_pd) - { - $score_questions['business']['business_activity_has_seen'] = isset($business_assest_form['business_assets_for_address'][0]['business_is_pd_visited'])? $business_assest_form['business_assets_for_address'][0]['business_is_pd_visited']: 'no'; + if (!$is_this_tele_pd) { + $score_questions['business']['business_activity_has_seen'] = isset($business_assest_form['business_assets_for_address'][0]['business_is_pd_visited']) ? $business_assest_form['business_assets_for_address'][0]['business_is_pd_visited'] : 'no'; } } #####End of Business Assets Form Questions######## - - + + #####supplier Form Questions######## - $supplier_form = isset($form_data[1][0]['processed_json'])?(json_decode($form_data[1][0]['processed_json'],true)):array(); + $supplier_form = isset($form_data[1][0]['processed_json']) ? (json_decode($form_data[1][0]['processed_json'], true)) : array(); $supplier_count = 0; - if(count($supplier_form)) - { - if($supplier_form['supplier_info_available'] == 1) - { - if(array_key_exists('manufacturing_details',$supplier_form)) - { - if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) - { + if (count($supplier_form)) { + if ($supplier_form['supplier_info_available'] == 1) { + if (array_key_exists('manufacturing_details', $supplier_form)) { + if (isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) { - foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) - { + foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) { - if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" ) - { - $supplier_count ++; + if ($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "") { + $supplier_count++; } } } - } - if(array_key_exists('trade_details',$supplier_form)) - { + if (array_key_exists('trade_details', $supplier_form)) { - if(isset($supplier_form['trade_details'][0]['trading_products'])) - { + if (isset($supplier_form['trade_details'][0]['trading_products'])) { - foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value) - { - if($trading_value['trade_product_name'] != "" && $trading_value['trade_supplier_name'] != "" ) - { - $supplier_count ++; + foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value) { + if ($trading_value['trade_product_name'] != "" && $trading_value['trade_supplier_name'] != "") { + $supplier_count++; } } - } } - if(array_key_exists('servicing_details',$supplier_form)) - { + if (array_key_exists('servicing_details', $supplier_form)) { - if(isset($supplier_form['servicing_details'][0]['service_providers'])) - { + if (isset($supplier_form['servicing_details'][0]['service_providers'])) { - foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value) - { - if($service_value['service_provider_name'] != "" && $service_value['service_provider_supplier_name'] != "" ) - { - $supplier_count ++; + foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value) { + if ($service_value['service_provider_name'] != "" && $service_value['service_provider_supplier_name'] != "") { + $supplier_count++; } } - } - } - $score_questions['business']['minimum_supplier_info'] = $supplier_count ? 'Provided':'Not Provided'; - - } - else - { + $score_questions['business']['minimum_supplier_info'] = $supplier_count ? 'Provided' : 'Not Provided'; + } else { $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; } - }else - { + } else { $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; } - + #####End of supplier Form Questions######## - - + + #####client Form Questions######## - $client_form = isset($form_data[2][0]['processed_json'])?(json_decode($form_data[2][0]['processed_json'],true)):array(); + $client_form = isset($form_data[2][0]['processed_json']) ? (json_decode($form_data[2][0]['processed_json'], true)) : array(); $client_count = 0; - //print_r($client_form);die(); - if(count($client_form)) - { - if( isset($client_form['client_info_available']) && $client_form['client_info_available'] == 1) - { + //print_r($client_form);die(); + if (count($client_form)) { + if (isset($client_form['client_info_available']) && $client_form['client_info_available'] == 1) { - if(array_key_exists('manufacturing_details',$client_form)) - { - if(isset($client_form['manufacturing_details'][0]['main_raw_materials'])) - { + if (array_key_exists('manufacturing_details', $client_form)) { + if (isset($client_form['manufacturing_details'][0]['main_raw_materials'])) { - foreach ($client_form['manufacturing_details'][0]['main_raw_materials'] as $key => $value) - { - if($value['manufacturing_product_name'] != "" && $value['manufacturing_client_name'] != "" ) - { $client_count++; } - } - } - } - - if(array_key_exists('trade_details',$client_form)) - { - - if(isset($client_form['trade_details'][0]['trading_products'])) - { - - foreach ($client_form['trade_details'][0]['trading_products'] as $key => $value) - { - //print_r($value);die(); - if($value['trade_product_name'] != "" && (isset($value['trade_client_name'])) && $value['trade_client_name'] != "" ) - { - $client_count++; + foreach ($client_form['manufacturing_details'][0]['main_raw_materials'] as $key => $value) { + if ($value['manufacturing_product_name'] != "" && $value['manufacturing_client_name'] != "") { + $client_count++; } - } - } } - if(array_key_exists('service_provider_details',$client_form)) - { - if(isset($client_form['service_provider_details'][0]['service_products'])) - { - foreach ($client_form['service_provider_details'][0]['service_products'] as $key => $value) - { + if (array_key_exists('trade_details', $client_form)) { - if($value['service_provider_product_name'] != "" && $value['service_provider_client_name'] != "" ) - { $client_count++; } + if (isset($client_form['trade_details'][0]['trading_products'])) { + foreach ($client_form['trade_details'][0]['trading_products'] as $key => $value) { + //print_r($value);die(); + if ($value['trade_product_name'] != "" && (isset($value['trade_client_name'])) && $value['trade_client_name'] != "") { + $client_count++; + } } - } } - $score_questions['business']['minimum_client_info'] = $client_count ? 'Provided':'Not Provided'; + if (array_key_exists('service_provider_details', $client_form)) { + if (isset($client_form['service_provider_details'][0]['service_products'])) { + foreach ($client_form['service_provider_details'][0]['service_products'] as $key => $value) { - } - else - { + if ($value['service_provider_product_name'] != "" && $value['service_provider_client_name'] != "") { + $client_count++; + } + } + } + } + $score_questions['business']['minimum_client_info'] = $client_count ? 'Provided' : 'Not Provided'; + } else { $score_questions['business']['minimum_client_info'] = 'Not Provided'; } - - } - else - { + } else { $score_questions['business']['minimum_client_info'] = 'Not Applicable'; } #####End of client Form Questions######## - - #####Stock Form Questions######## - $stock_form = isset($form_data[11][0]['processed_json'])?(json_decode($form_data[11][0]['processed_json'],true)):array(); - //print_r($stock_form); - if(count($stock_form)) - { - //print_r($stock_form);die(); - if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != "")) - { - $score_questions['business']['stock_raw_material_enough'] = isset($stock_form['manufacturing_details'][0]['is_sufficiant_raw']) ? $stock_form['manufacturing_details'][0]['is_sufficiant_raw']: 'Not Applicable'; + #####Stock Form Questions######## + $stock_form = isset($form_data[11][0]['processed_json']) ? (json_decode($form_data[11][0]['processed_json'], true)) : array(); + //print_r($stock_form); + if (count($stock_form)) { + //print_r($stock_form);die(); + if (isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != "")) { + + $score_questions['business']['stock_raw_material_enough'] = isset($stock_form['manufacturing_details'][0]['is_sufficiant_raw']) ? $stock_form['manufacturing_details'][0]['is_sufficiant_raw'] : 'Not Applicable'; } - $score_questions['business']['stock_finished_goods_enough'] = isset($stock_form['is_sufficiant_finished_and_traded_goods']) && ($stock_form['is_sufficiant_finished_and_traded_goods'] != "" || $stock_form['is_sufficiant_finished_and_traded_goods'] != null)? $stock_form['is_sufficiant_finished_and_traded_goods'] : 'Not Applicable'; - } - else - { + $score_questions['business']['stock_finished_goods_enough'] = isset($stock_form['is_sufficiant_finished_and_traded_goods']) && ($stock_form['is_sufficiant_finished_and_traded_goods'] != "" || $stock_form['is_sufficiant_finished_and_traded_goods'] != null) ? $stock_form['is_sufficiant_finished_and_traded_goods'] : 'Not Applicable'; + } else { $score_questions['business']['stock_raw_material_enough'] = 'Not Applicable'; $score_questions['business']['stock_finished_goods_enough'] = 'Not Applicable'; - //$score_questions['general']['value_of_other_assets'] = 'Not Applicable'; - } - #####End of Stock Form Questions######## + //$score_questions['general']['value_of_other_assets'] = 'Not Applicable'; + } + #####End of Stock Form Questions######## - #####Other Assest Form Questions######## - if($pd_master_details[0]['lender_short_name'] != 'CFPL'){ - $other_asset_form = (json_decode($form_data[4][0]['processed_json'],true)); - //print_r($other_asset_form); + #####Other Assest Form Questions######## + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + $other_asset_form = (json_decode($form_data[4][0]['processed_json'], true)); + //print_r($other_asset_form); - $over_all_asset_value = 0; - if(array_key_exists('assets_details',$other_asset_form)) - { - //print_r($other_asset_form['assets_details']);die(); - foreach($other_asset_form['assets_details'] as $asset) - { - //echo 'Value - '.$asset['approximate_market_value']; - $over_all_asset_value += is_numeric($asset['approximate_market_value']) ? $asset['approximate_market_value'] : 0 ; - if($asset['assets_mode'] == 6)//LIC - { - $over_all_asset_value += $asset['details'][0]['sum_assured']; - } - if($asset['assets_mode'] == 7)//Investments - { - $over_all_asset_value += $asset['details'][0]['amount_of_invest']; - } - + $over_all_asset_value = 0; + if (array_key_exists('assets_details', $other_asset_form)) { + //print_r($other_asset_form['assets_details']);die(); + foreach ($other_asset_form['assets_details'] as $asset) { + //echo 'Value - '.$asset['approximate_market_value']; + $over_all_asset_value += is_numeric($asset['approximate_market_value']) ? $asset['approximate_market_value'] : 0; + if ($asset['assets_mode'] == 6) //LIC + { + $over_all_asset_value += $asset['details'][0]['sum_assured']; + } + if ($asset['assets_mode'] == 7) //Investments + { + $over_all_asset_value += $asset['details'][0]['amount_of_invest']; } } - - - //echo 'over_all_asset_value from FUN - '.$over_all_asset_value;die(); - // 18 Q.NO(1.9) - $score_questions['general']['value_of_other_assets'] = $over_all_asset_value; - } + } + + + //echo 'over_all_asset_value from FUN - '.$over_all_asset_value;die(); + // 18 Q.NO(1.9) + $score_questions['general']['value_of_other_assets'] = $over_all_asset_value; + } #####End of Other Assest Form Questions######## ######Business Banking ############## - //here IF Else is Temporary CLix - //here i am changed to 21 form-id to 7 form-id - $temp_flag = isset($form_data[21][0]['processed_json'])?1:0; - if($temp_flag == 0){ - $business_bank_form = (json_decode($form_data[7][0]['processed_json'],true)); - $vintage = array(); - if(array_key_exists('business_details',$business_bank_form)) - { + //here IF Else is Temporary CLix + //here i am changed to 21 form-id to 7 form-id + $temp_flag = isset($form_data[21][0]['processed_json']) ? 1 : 0; + if ($temp_flag == 0) { + $business_bank_form = (json_decode($form_data[7][0]['processed_json'], true)); + $vintage = array(); + if (array_key_exists('business_details', $business_bank_form)) { - foreach($business_bank_form['business_details'] as $banking) - { - $year = $banking['vintage_year_business'] ? $banking['vintage_year_business'] : 0 ; - $month = $banking['vintage_month_business'] ? $banking['vintage_month_business'] : 0; - $temp = $year.'.'.$month; - $vintage = array_merge($vintage,array($temp)); - } - } - }else{ - $business_bank_form = (json_decode($form_data[21][0]['processed_json'],true)); - $vintage = array(); - if(array_key_exists('banking_details',$business_bank_form)) - { - foreach($business_bank_form['banking_details'] as $banking) - { - $year = $banking['vintage_year'] ? $banking['vintage_year'] : 0 ; - $month = $banking['vintage_month'] ? $banking['vintage_month'] : 0; - $temp = $year.'.'.$month; - $vintage = array_merge($vintage,array($temp)); - } - } + foreach ($business_bank_form['business_details'] as $banking) { + $year = $banking['vintage_year_business'] ? $banking['vintage_year_business'] : 0; + $month = $banking['vintage_month_business'] ? $banking['vintage_month_business'] : 0; + $temp = $year . '.' . $month; + $vintage = array_merge($vintage, array($temp)); } + } + } else { + $business_bank_form = (json_decode($form_data[21][0]['processed_json'], true)); + $vintage = array(); + if (array_key_exists('banking_details', $business_bank_form)) { + foreach ($business_bank_form['banking_details'] as $banking) { + $year = $banking['vintage_year'] ? $banking['vintage_year'] : 0; + $month = $banking['vintage_month'] ? $banking['vintage_month'] : 0; + $temp = $year . '.' . $month; + $vintage = array_merge($vintage, array($temp)); + } + } + } - $score_questions['business']['vintage_of_business_account'] = count($vintage)? max($vintage) : 0; + $score_questions['business']['vintage_of_business_account'] = count($vintage) ? max($vintage) : 0; //echo $vintage_of_business_account_for_display; //$score_questions['business']['vintage_of_business_account_for_display'] = $vintage_of_business_account_for_display; ######End of Business Banking ############## - return $score_questions; + return $score_questions; + } + public function updateSubProductFromLoanDetailsForm($records) + { + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pdid']); - } + $new_sub_product = $records['sub_product']; + $old_sub_product = $pd_master_details[0]['fk_subproduct_id']; - public function updateSubProductFromLoanDetailsForm($records) - { - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pdid']); - - $new_sub_product = $records['sub_product']; - $old_sub_product = $pd_master_details[0]['fk_subproduct_id']; - - if($new_sub_product != $old_sub_product) - { - $where_condition_array = array('pd_id' => $records['pdid']); - $temp = array('fk_subproduct_id' => $new_sub_product,'fk_updatedby' => $records['fk_createdby']); - $pk_id = $this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array); - - } - - } + if ($new_sub_product != $old_sub_product) { + $where_condition_array = array('pd_id' => $records['pdid']); + $temp = array('fk_subproduct_id' => $new_sub_product, 'fk_updatedby' => $records['fk_createdby']); + $pk_id = $this->PD_Model->updateRecords($temp, PDTRIGGER, $where_condition_array); + } + } - public function saveEmpSalaryAsBusinessExpensesFromBusinessForm($records) - { + public function saveEmpSalaryAsBusinessExpensesFromBusinessForm($records) + { //echo "FROM saveEmpSalaryAsBusinessExpensesFromBusinessForm"; - if(isset($records['employees_appx_salary']) && ($records['employees_appx_salary'] != null|| $records['employees_appx_salary'] != '')) - { + if (isset($records['employees_appx_salary']) && ($records['employees_appx_salary'] != null || $records['employees_appx_salary'] != '')) { //pd_expense_id, fk_pd_id, expense_item_id, expense_value, fk_frequency_id, annual_expenses_value, isactive, fk_createdby, createdon, company_id, comments - $annual_emp_salary = ($records['employees_appx_salary'] * 12); + $annual_emp_salary = ($records['employees_appx_salary'] * 12); //echo $annual_emp_salary; - $temp_array = array( 'fk_pd_id' => $records['pdid'],'expense_item_id' => 3,'expense_value' => $records['employees_appx_salary'],'fk_frequency_id' => 7, 'annual_expenses_value' => $annual_emp_salary,'fk_createdby' => $records['fk_createdby'],'company_id' => $records['company_id'],'comments' => 'Derived from Business Form'); + $temp_array = array('fk_pd_id' => $records['pdid'], 'expense_item_id' => 3, 'expense_value' => $records['employees_appx_salary'], 'fk_frequency_id' => 7, 'annual_expenses_value' => $annual_emp_salary, 'fk_createdby' => $records['fk_createdby'], 'company_id' => $records['company_id'], 'comments' => 'Derived from Business Form'); - $fields = array('pd_expense_id','expense_item_id','fk_frequency_id','expense_value','annual_expenses_value','comments'); + $fields = array('pd_expense_id', 'expense_item_id', 'fk_frequency_id', 'expense_value', 'annual_expenses_value', 'comments'); - $table = PDBUSINESSEXPENSES.' as PDBUSINESSEXPENSES'; + $table = PDBUSINESSEXPENSES . ' as PDBUSINESSEXPENSES'; - $where_condition_array = array('fk_pd_id'=>$records['pdid'],'isactive'=>1,'expense_item_id' => 3,'fk_frequency_id' => 7,'company_id' => $records['company_id'],'comments' => 'Derived from Business Form'); + $where_condition_array = array('fk_pd_id' => $records['pdid'], 'isactive' => 1, 'expense_item_id' => 3, 'fk_frequency_id' => 7, 'company_id' => $records['company_id'], 'comments' => 'Derived from Business Form'); - $business_expenses = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table); + $business_expenses = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, $table); //print_r($business_expenses); - if(count($business_expenses)) - { + if (count($business_expenses)) { //echo "Update"; - if($annual_emp_salary != 0) - { - $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); - $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); - } - } - else - { + if ($annual_emp_salary != 0) { + $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); + $this->PD_Model->updateRecords($temp_array, $table, $where_condition_array); + } + } else { //echo "insert"; - if($annual_emp_salary != 0) - { - $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); - } - } - - - - - - + if ($annual_emp_salary != 0) { + $this->PD_Model->saveRecords($temp_array, PDBUSINESSEXPENSES); } } + } + } - public function saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records) - { + public function saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records) + { //echo "saveAssetRentAsBusinessExpensesFromBusinessAssestForm"; - $over_all_rent_amt = 0; - if(isset($records['business_assets_for_address']) && ($records['business_assets_for_address'] != "" || $records['business_assets_for_address'] != null)) - { - foreach($records['business_assets_for_address'] as $business_asset) - { - if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) - { - $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; - } - } + $over_all_rent_amt = 0; + if (isset($records['business_assets_for_address']) && ($records['business_assets_for_address'] != "" || $records['business_assets_for_address'] != null)) { + foreach ($records['business_assets_for_address'] as $business_asset) { + if ($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) { + $over_all_rent_amt += $business_asset['business_monthly_rented_amt']; } + } + } - if(isset($records['business_assets_details']) && ($records['business_assets_details'] != "" || $records['business_assets_details'] != null)) - { - foreach($records['business_assets_details'] as $business_asset) - { - if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) - { - $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; - } - } + if (isset($records['business_assets_details']) && ($records['business_assets_details'] != "" || $records['business_assets_details'] != null)) { + foreach ($records['business_assets_details'] as $business_asset) { + if ($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) { + $over_all_rent_amt += $business_asset['business_monthly_rented_amt']; } + } + } //echo $over_all_rent_amt; - $temp_array = array( 'fk_pd_id' => $records['pdid'],'expense_item_id' => 9,'expense_value' => $over_all_rent_amt,'fk_frequency_id' => 7, 'annual_expenses_value' => ($over_all_rent_amt * 12),'fk_createdby' => $records['fk_createdby'],'company_id' => $records['company_id'],'comments' => 'Derived from Business Form'); + $temp_array = array('fk_pd_id' => $records['pdid'], 'expense_item_id' => 9, 'expense_value' => $over_all_rent_amt, 'fk_frequency_id' => 7, 'annual_expenses_value' => ($over_all_rent_amt * 12), 'fk_createdby' => $records['fk_createdby'], 'company_id' => $records['company_id'], 'comments' => 'Derived from Business Form'); - $fields = array('pd_expense_id','expense_item_id','fk_frequency_id','expense_value','annual_expenses_value','comments'); + $fields = array('pd_expense_id', 'expense_item_id', 'fk_frequency_id', 'expense_value', 'annual_expenses_value', 'comments'); - $table = PDBUSINESSEXPENSES.' as PDBUSINESSEXPENSES'; + $table = PDBUSINESSEXPENSES . ' as PDBUSINESSEXPENSES'; - $where_condition_array = array('fk_pd_id'=>$records['pdid'],'isactive'=>1,'expense_item_id' => 9,'fk_frequency_id' => 7,'company_id' => $records['company_id'],'comments' => 'Derived from Business Form'); - - $business_expenses = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table); - - //print_r($business_expenses); - - if(count($business_expenses)) - { - //echo "Update"; - if($over_all_rent_amt != 0) - { - $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); - $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); - } - } - else - { - //echo "insert"; - if($over_all_rent_amt != 0) - { - $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); - } - } + $where_condition_array = array('fk_pd_id' => $records['pdid'], 'isactive' => 1, 'expense_item_id' => 9, 'fk_frequency_id' => 7, 'company_id' => $records['company_id'], 'comments' => 'Derived from Business Form'); + $business_expenses = $this->PD_Model->selectCustomRecords($fields, $where_condition_array, $table); + //print_r($business_expenses); + if (count($business_expenses)) { + //echo "Update"; + if ($over_all_rent_amt != 0) { + $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); + $this->PD_Model->updateRecords($temp_array, $table, $where_condition_array); } - - public function saveHTMLReport_post() - { - - $records = $this->post('records'); - $pdid = $records['pdid']; - $content = $records['content']; - //print_r($content);die(); - if($content != "") - { - - $report_data = $content; - $start_pos = strpos($report_data,''); - $end_pos = $start_pos + 10; - $report_data = substr_replace($report_data,'',$end_pos,0); - $report_data = substr_replace($report_data,'',0,0); - $report_data = substr_replace($report_data,'',strlen($report_data),0); - $content = $report_data; - - - } - - $fk_createdby = $records['fk_createdby']; - $random_string = $records['random_string']; - $pd_report_time = date('Y-m-d-h-i-s'); - $pd_report_store = $this->external_path.'/pd_reports/'.$pdid.'/'.$pd_report_time.'.html'; - file_put_contents($pd_report_store,$content); - - //Update Latest File name and qc edited status into trigger table - $update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_qc_edited' => 1),PDTRIGGER,array('pd_id' => $pdid,'random_string' => $random_string)); - - //Update previous versions as 0 - $update_reports_version_blob = $this->PD_Model->updateRecords(array('is_latest' => 0),PDREPORTSVERSIONBLOB,array('fk_pd_id' => $pdid,'is_latest' => 1)); - - //insert current PD report html file name as latest - $pd_reports_version_blob_new = $this->PD_Model->saveRecords( array('html_file_name' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_latest' => 1,'fk_pd_id' => $pdid),PDREPORTSVERSIONBLOB ); - - - - if($update && $update_reports_version_blob && $pd_reports_version_blob_new) - { - $logger = MYLOG::logFunction(null,$pdid); - $logger->info('QC Edit Called',array('Edited by' => $fk_createdby,'DB Result' => $update .'-'. $update_reports_version_blob .'-'. $pd_reports_version_blob_new)); - $dat['dataStatus'] = true; - $dat['status'] = REST_Controller::HTTP_OK; - $dat['msg'] = 'Report Generated Successfully..!'; - $this->response($dat,REST_Controller::HTTP_OK); - } - } - - - public function getPDReportHTML_get() - { - $pdid = $this->uri->segment(3); - $random_string = $this->uri->segment(2); - $this->getLatestPDReportHTMLFile($pdid,$random_string); - - } - - function getLatestPDReportHTMLFile($pdid,$random_string,$return_type = false) - { - // echo "now i am in child function "; - // exit(); - if(($pdid != null || $pdid != "")) //&& (strlen($pdid) == 16) &&(is_string($pdid))) - { - $pd_data = $this->PD_Model->selectCustomRecords(array('pd_id','pd_report_html_filename'),array('random_string' => $random_string,'pd_id' => $pdid),PDTRIGGER); - - // print_r($pd_data);exit(); - if(count($pd_data)) - { - - $report_data = file_get_contents($this->external_path.'/pd_reports/'.$pd_data[0]['pd_id'].'/'.$pd_data[0]['pd_report_html_filename'].'.html'); - $temp_file_path = APPPATH.'views/pd_reports/'. $pd_data[0]['pd_id'] .'/temp.html'; - - if(!file_exists($temp_file_path)) - { - mkdir(APPPATH.'views/pd_reports',0777); - mkdir(APPPATH.'views/pd_reports/'.$pd_data[0]['pd_id'],0777); - } - file_put_contents($temp_file_path,$report_data); - $view_name = 'pd_reports/'. $pd_data[0]['pd_id'] .'/temp.html'; - // echo $view_name; - // die(); - return $this->load->view($view_name,array(),$return_type); - - - } - else - { - echo "

Not Found

"; + } else { + //echo "insert"; + if ($over_all_rent_amt != 0) { + $this->PD_Model->saveRecords($temp_array, PDBUSINESSEXPENSES); } } - else + } + + public function saveHTMLReport_post() + { + + $records = $this->post('records'); + $pdid = $records['pdid']; + $content = $records['content']; + //print_r($content);die(); + if ($content != "") { + + $report_data = $content; + $start_pos = strpos($report_data, ''); + $end_pos = $start_pos + 10; + $report_data = substr_replace($report_data, '', $end_pos, 0); + $report_data = substr_replace($report_data, '', 0, 0); + $report_data = substr_replace($report_data, '', strlen($report_data), 0); + $content = $report_data; + } + + $fk_createdby = $records['fk_createdby']; + $random_string = $records['random_string']; + $pd_report_time = date('Y-m-d-h-i-s'); + $pd_report_store = $this->external_path . '/pd_reports/' . $pdid . '/' . $pd_report_time . '.html'; + file_put_contents($pd_report_store, $content); + + //Update Latest File name and qc edited status into trigger table + $update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time, 'fk_createdby' => $fk_createdby, 'is_qc_edited' => 1), PDTRIGGER, array('pd_id' => $pdid, 'random_string' => $random_string)); + + //Update previous versions as 0 + $update_reports_version_blob = $this->PD_Model->updateRecords(array('is_latest' => 0), PDREPORTSVERSIONBLOB, array('fk_pd_id' => $pdid, 'is_latest' => 1)); + + //insert current PD report html file name as latest + $pd_reports_version_blob_new = $this->PD_Model->saveRecords(array('html_file_name' => $pd_report_time, 'fk_createdby' => $fk_createdby, 'is_latest' => 1, 'fk_pd_id' => $pdid), PDREPORTSVERSIONBLOB); + + + + if ($update && $update_reports_version_blob && $pd_reports_version_blob_new) { + $logger = MYLOG::logFunction(null, $pdid); + $logger->info('QC Edit Called', array('Edited by' => $fk_createdby, 'DB Result' => $update . '-' . $update_reports_version_blob . '-' . $pd_reports_version_blob_new)); + $dat['dataStatus'] = true; + $dat['status'] = REST_Controller::HTTP_OK; + $dat['msg'] = 'Report Generated Successfully..!'; + $this->response($dat, REST_Controller::HTTP_OK); + } + } + + + public function getPDReportHTML_get() + { + $pdid = $this->uri->segment(3); + $random_string = $this->uri->segment(2); + $this->getLatestPDReportHTMLFile($pdid, $random_string); + } + + function getLatestPDReportHTMLFile($pdid, $random_string, $return_type = false) + { + // echo "now i am in child function "; + // exit(); + if (($pdid != null || $pdid != "")) //&& (strlen($pdid) == 16) &&(is_string($pdid))) { + $pd_data = $this->PD_Model->selectCustomRecords(array('pd_id', 'pd_report_html_filename'), array('random_string' => $random_string, 'pd_id' => $pdid), PDTRIGGER); + + // print_r($pd_data);exit(); + if (count($pd_data)) { + + $report_data = file_get_contents($this->external_path . '/pd_reports/' . $pd_data[0]['pd_id'] . '/' . $pd_data[0]['pd_report_html_filename'] . '.html'); + $temp_file_path = APPPATH . 'views/pd_reports/' . $pd_data[0]['pd_id'] . '/temp.html'; + + if (!file_exists($temp_file_path)) { + mkdir(APPPATH . 'views/pd_reports', 0777); + mkdir(APPPATH . 'views/pd_reports/' . $pd_data[0]['pd_id'], 0777); + } + file_put_contents($temp_file_path, $report_data); + $view_name = 'pd_reports/' . $pd_data[0]['pd_id'] . '/temp.html'; + // echo $view_name; + // die(); + return $this->load->view($view_name, array(), $return_type); + } else { + echo "

Not Found

"; + } + } else { echo "

Not Found

"; } } public function getPDReportPDFpreview_post() { - - - + + + $pdid = $this->uri->segment(3); - log_message('DEBUG',"getPDReportPDFpreview_post called ");//die(); + log_message('DEBUG', "getPDReportPDFpreview_post called "); //die(); $random_string = $this->uri->segment(2); EXTERNAL_DIR_CHECK::checkExternalDirectory($pdid); $records = $this->post('myData'); - + $report_data = ''; - if($records) - { + if ($records) { $report_data = $records; //attach outer HTML tags - $start_pos = strpos($report_data,''); + $start_pos = strpos($report_data, ''); $end_pos = $start_pos + 10; - $report_data = substr_replace($report_data,'',$end_pos,0); - $report_data = substr_replace($report_data,'',0,0); - $report_data = substr_replace($report_data,'',-1,0); + $report_data = substr_replace($report_data, '', $end_pos, 0); + $report_data = substr_replace($report_data, '', 0, 0); + $report_data = substr_replace($report_data, '', -1, 0); //replace tooltip and span tags - $total_replaces = substr_count($report_data,''); - for($i = 0 ;$i < $total_replaces;$i++) - { - $start_pos = strpos($report_data,''); + $total_replaces = substr_count($report_data, ''); + for ($i = 0; $i < $total_replaces; $i++) { + $start_pos = strpos($report_data, ''); - $end_pos = strpos($report_data, '', strpos($report_data,'')); - $end_pos = $end_pos + 14; + $end_pos = strpos($report_data, '', strpos($report_data, '')); + $end_pos = $end_pos + 14; //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; - $report_data = substr_replace($report_data,'',$start_pos,($end_pos - $start_pos)); + $report_data = substr_replace($report_data, '', $start_pos, ($end_pos - $start_pos)); - $report_data = substr_replace($report_data,'',strpos($report_data,''),(strlen(''))); - - } - } - else - { - $report_data = $this->getLatestPDReportHTMLFile($pdid,$random_string,true); + $report_data = substr_replace($report_data, '', strpos($report_data, ''), (strlen(''))); + } + } else { + $report_data = $this->getLatestPDReportHTMLFile($pdid, $random_string, true); //replace tooltip and span tags - $total_replaces = substr_count($report_data,''); - for($i = 0 ;$i < $total_replaces;$i++) - { - $start_pos = strpos($report_data,''); + $total_replaces = substr_count($report_data, ''); + for ($i = 0; $i < $total_replaces; $i++) { + $start_pos = strpos($report_data, ''); - $end_pos = strpos($report_data, '', strpos($report_data,'')); - $end_pos = $end_pos + 14; + $end_pos = strpos($report_data, '', strpos($report_data, '')); + $end_pos = $end_pos + 14; //echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-'; - $report_data = substr_replace($report_data,'',$start_pos,($end_pos - $start_pos)); + $report_data = substr_replace($report_data, '', $start_pos, ($end_pos - $start_pos)); - $report_data = substr_replace($report_data,'',strpos($report_data,''),(strlen(''))); - - } - + $report_data = substr_replace($report_data, '', strpos($report_data, ''), (strlen(''))); + } } - $pdf_doc = $this->pdfgenerator->generate($report_data, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //End of PDF Gen using DOM PDF - $output_file2 = $this->external_path ."/pd_reports/" . $pdid . "/sample.pdf"; - $link_to_send = 'https://'. $this->config->item('full_server_name').'/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pdid . "/sample.pdf"; + $pdf_doc = $this->pdfgenerator->generate($report_data, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file2 = $this->external_path . "/pd_reports/" . $pdid . "/sample.pdf"; + $link_to_send = 'https://' . $this->config->item('full_server_name') . '/ssa_external_data/' . ENVIRONMENT . '/pd_reports/' . $pdid . "/sample.pdf"; //$link_to_be_create = '/var/www/html/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pdid . "/sample.pdf"; file_put_contents($output_file2, $pdf_doc); $this->load->helper('SYMLINKS'); - SYMLINKS::createSymLinks($pdid,$output_file2); - echo json_encode(array('link'=>$link_to_send)); - + SYMLINKS::createSymLinks($pdid, $output_file2); + echo json_encode(array('link' => $link_to_send)); } - - - public function pdFormsCompletenessCheck_post() + + + public function pdFormsCompletenessCheck_post() { $pdid = $this->post('pd_id'); $client = $this->post('client') ? $this->post('client') : 'WEB'; $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); $res_array = array(); $this->load->helper('pdcompletenesscheck'); - switch($pd_master_details[0]['fk_pd_type']) - { - case 1://FUll PD - case 2://smartPD - $res_array = pdcompletenesscheck::fullPDCompletenessCheck($pdid,$pd_master_details,$client); - break; - case 3://tele PD - $res_array = pdcompletenesscheck::telePDCompletenessCheck($pdid,$pd_master_details,$client); - break; - + switch ($pd_master_details[0]['fk_pd_type']) { + case 1: //FUll PD + case 2: //smartPD + $res_array = pdcompletenesscheck::fullPDCompletenessCheck($pdid, $pd_master_details, $client); + break; + case 3: //tele PD + $res_array = pdcompletenesscheck::telePDCompletenessCheck($pdid, $pd_master_details, $client); + break; } - + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $res_array; $data['msg'] = count($res_array) ? 'PD Details are incomplete' : 'All forms were answered'; - $this->response($data,REST_Controller::HTTP_OK); - - - + $this->response($data, REST_Controller::HTTP_OK); } @@ -8998,28 +7885,23 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $img_url = $this->post('img_url'); $b64image = base64_encode(file_get_contents($img_url)); - if($b64image) - { + if ($b64image) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $b64image; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong / Can`t convet given URL'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - - } public function updateBase64Images_post() { - + $records = $this->post('records'); $pd_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id']); //print_r($records); @@ -9044,49 +7926,53 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // $this->response($data,REST_Controller::HTTP_OK); // } // } - - if(isset($records['image']) && ($records['image'] != '' && !substr_count($records['image'],'https'))) - { - - $output_file = APPPATH."/docs/temp_base64_image.jpeg"; + + if (isset($records['image']) && ($records['image'] != '' && !substr_count($records['image'], 'https'))) { + + $output_file = APPPATH . "/docs/temp_base64_image.jpeg"; $temp_file_name = $records['pd_document_name']; - - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $records['image']); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); + + $ifp = fopen($output_file, 'wb'); + $temp_data = explode(',', $records['image']); + fwrite($ifp, base64_decode($temp_data[1])); + fclose($ifp); $tempdoc = $output_file; $tempdocname = $temp_file_name; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; - $key = 'pd'.$records['fk_pd_id'].'/'.$tempdocname; + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_details[0]['fk_lender_id']; + $key = 'pd' . $records['fk_pd_id'] . '/' . $tempdocname; $sourcefile = $tempdoc; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); } // if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) // { - $record_data = array('fk_updatedby' => $records['fk_updatedby']); - if(isset($records['is_show_report'])){ $record_data['is_show_report'] = $records['is_show_report']; } - if(isset($records['pd_document_title'])){ $record_data['pd_document_title'] = $records['pd_document_title']; } - if(isset($records['isactive'])){ $record_data['isactive'] = $records['isactive']; } - if(isset($records['pd_image_alias_name'])){ $record_data['pd_image_alias_name'] = $records['pd_image_alias_name']; } - $where_condition_array = array('pd_document_id' => $records['pd_document_id']); - $id = $this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array); - if($id != null || $id != "") - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } + $record_data = array('fk_updatedby' => $records['fk_updatedby']); + if (isset($records['is_show_report'])) { + $record_data['is_show_report'] = $records['is_show_report']; + } + if (isset($records['pd_document_title'])) { + $record_data['pd_document_title'] = $records['pd_document_title']; + } + if (isset($records['isactive'])) { + $record_data['isactive'] = $records['isactive']; + } + if (isset($records['pd_image_alias_name'])) { + $record_data['pd_image_alias_name'] = $records['pd_image_alias_name']; + } + $where_condition_array = array('pd_document_id' => $records['pd_document_id']); + $id = $this->PD_Model->updateRecords($record_data, PDDOCUMENTS, $where_condition_array); + if ($id != null || $id != "") { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try later'; + $this->response($data, REST_Controller::HTTP_OK); + } // } // else // { @@ -9109,67 +7995,50 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $fk_user_id = $records['fk_user_id']; $select_data = array('notification_token_id'); - $where_condition_array = array('fk_user_id' =>$fk_user_id ); - $exist_data = $this->PD_Model->selectCustomRecords($select_data,$where_condition_array,USERNOTIFICATIONTOKENS); + $where_condition_array = array('fk_user_id' => $fk_user_id); + $exist_data = $this->PD_Model->selectCustomRecords($select_data, $where_condition_array, USERNOTIFICATIONTOKENS); - if(!count($exist_data)) - { + if (!count($exist_data)) { $insert_data = array('fk_user_id' => $fk_user_id); - if($records['client'] == 'MOB') - { + if ($records['client'] == 'MOB') { $insert_data['mob_token'] = $records['token']; - } - else if($records['client'] == 'WEB') - { + } else if ($records['client'] == 'WEB') { $insert_data['web_token'] = $records['token']; } - $id = $this->PD_Model->saveRecords($insert_data,USERNOTIFICATIONTOKENS); - if($id) - { + $id = $this->PD_Model->saveRecords($insert_data, USERNOTIFICATIONTOKENS); + if ($id) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $exist_notification_token_id = $exist_data[0]['notification_token_id']; $where_condition_array = array('notification_token_id' => $exist_notification_token_id); $update_data = array(); - if($records['client'] == 'MOB') - { + if ($records['client'] == 'MOB') { $update_data['mob_token'] = $records['token']; - } - else if($records['client'] == 'WEB') - { + } else if ($records['client'] == 'WEB') { $update_data['web_token'] = $records['token']; } - $id = $this->PD_Model->updateRecords($update_data,USERNOTIFICATIONTOKENS,$where_condition_array); - if($id) - { + $id = $this->PD_Model->updateRecords($update_data, USERNOTIFICATIONTOKENS, $where_condition_array); + if ($id) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - } @@ -9180,53 +8049,46 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() //CHeck whether this PD is scoreable or not $is_score_card_enabled = $this->PD_Model->getScoreCardEnabledStatusByPDID($pdid); $t = ''; - if(count($is_score_card_enabled) && $is_score_card_enabled[0]['is_score_card_enabled'] == 1) - { + if (count($is_score_card_enabled) && $is_score_card_enabled[0]['is_score_card_enabled'] == 1) { $score = $this->calculateScore($pdid); //print_r($score);die(); $score_questions_display = $this->PD_Model->getScoreableQuestionToDispaly($pdid); - $t = $this->load->view('report_templates/scorecard',array('pd_score' => $score,'score_questions_display' => $score_questions_display),true); + $t = $this->load->view('report_templates/scorecard', array('pd_score' => $score, 'score_questions_display' => $score_questions_display), true); //echo $t;die(); } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $t; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } public function savePDRemark_post() { - + $pd_id = $this->post('pd_id'); $remark = $this->post('remark'); $createdby = $this->post('createdby'); $is_revert_remark = $this->post('is_revert_remark') ? $this->post('is_revert_remark') : 0; - - if($pd_id != null && $remark != null && $createdby != null) - { - $res = $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_id,'remark' => $remark,'createdby' => $createdby,'is_revert_remark' => $is_revert_remark),PDREMARKS); - if($res) - { + if ($pd_id != null && $remark != null && $createdby != null) { + $res = $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_id, 'remark' => $remark, 'createdby' => $createdby, 'is_revert_remark' => $is_revert_remark), PDREMARKS); + + if ($res) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $res; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } - else - { + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'In Appropriate call!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } } @@ -9234,21 +8096,17 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $records = $this->post('records'); - $lender_contact_persons = $this->PD_Model->getLenderContactPersons($records['fk_lender_id'],isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null ); - if(count($lender_contact_persons)) - { + $lender_contact_persons = $this->PD_Model->getLenderContactPersons($records['fk_lender_id'], isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null); + if (count($lender_contact_persons)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] =$lender_contact_persons; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $data['records'] = $lender_contact_persons; + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Credit Person Lender Profile was not found?. Create Credit Person Lender profile'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } } @@ -9273,134 +8131,113 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records = $this->post(); $current_operation = null; $applicant_id = null; - - $custom_log_info = '###Payload Size - '. (int) $_SERVER['CONTENT_LENGTH'].' ###saveApplicantFromGeneralForm - PDID - ('. $records['fk_pd_id'] .') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - $applicant_type = ($records['is_person_met'] ? 3 : ($records['is_applicant'] ? 0 : ''));//3 - person met,0 - co applicant - $applicant_details = array('fk_pd_id' => $records['fk_pd_id'],'applicant_name' => trim($records['applicant_name']),'applicant_title_name' => $records['applicant_title_name'],'applicant_type' => $applicant_type ); + $custom_log_info = '###Payload Size - ' . (int) $_SERVER['CONTENT_LENGTH'] . ' ###saveApplicantFromGeneralForm - PDID - (' . $records['fk_pd_id'] . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + + $applicant_type = ($records['is_person_met'] ? 3 : ($records['is_applicant'] ? 0 : '')); //3 - person met,0 - co applicant + $applicant_details = array('fk_pd_id' => $records['fk_pd_id'], 'applicant_name' => trim($records['applicant_name']), 'applicant_title_name' => $records['applicant_title_name'], 'applicant_type' => $applicant_type); //print_r($applicant_details); - if($records['pd_co_applicant_id'] == "" || $records['pd_co_applicant_id'] == null) - { - $applicant_id = $this->PD_Model->saveRecords($applicant_details,PDAPPLICANTSDETAILS); - $current_operation = 1;// 1 means INSERT - } - else - { + if ($records['pd_co_applicant_id'] == "" || $records['pd_co_applicant_id'] == null) { + $applicant_id = $this->PD_Model->saveRecords($applicant_details, PDAPPLICANTSDETAILS); + $current_operation = 1; // 1 means INSERT + } else { //pull applicant details from master - $curret_applicant_type = $this->PD_Model->selectCustomRecords(array('*'),array('pd_co_applicant_id' => $records['pd_co_applicant_id']),PDAPPLICANTSDETAILS); + $curret_applicant_type = $this->PD_Model->selectCustomRecords(array('*'), array('pd_co_applicant_id' => $records['pd_co_applicant_id']), PDAPPLICANTSDETAILS); //print_r($curret_applicant_type);//die(); - if($curret_applicant_type[0]['applicant_type'] == 1) - { + if ($curret_applicant_type[0]['applicant_type'] == 1) { unset($applicant_details['applicant_type']); } //print_r($applicant_details);die(); - $applicant_id = $this->PD_Model->updateRecords($applicant_details,PDAPPLICANTSDETAILS,array('pd_co_applicant_id' => $records['pd_co_applicant_id'])); - $current_operation = 2;// 2 means UPDATE + $applicant_id = $this->PD_Model->updateRecords($applicant_details, PDAPPLICANTSDETAILS, array('pd_co_applicant_id' => $records['pd_co_applicant_id'])); + $current_operation = 2; // 2 means UPDATE } - //echo $current_operation.$applicant_id; + //echo $current_operation.$applicant_id; //die(); - if($records['is_person_met']) - { + if ($records['is_person_met']) { $img_data = array(); - if($current_operation == 1) - { + if ($current_operation == 1) { - if($records['is_person_met_pic'] != "") - { - $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'],'co_applicant_id' => $applicant_id,'img_type' => 1); + if ($records['is_person_met_pic'] != "") { + $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 1); } - if($records['is_person_met_id_proof'] != "") - { - $img_data[] = array('Name' => (trim($records['applicant_name']).'-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'],'co_applicant_id' => $applicant_id,'img_type' => 2); + if ($records['is_person_met_id_proof'] != "") { + $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $applicant_id, 'img_type' => 2); } } ///print_r( $img_data ); - if($current_operation == 2) - { - - - if($records['is_person_met_pic'] != "" && !substr_count($records['is_person_met_pic'],'https')) - { - $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'],'co_applicant_id' => $records['pd_co_applicant_id'],'img_type' => 1); - - // Make inactive old entries with same data - $sql = 'UPDATE '. PDDOCUMENTS.' SET isactive = 0 where fk_pd_id = '.$records['fk_pd_id'].' and co_applicant_id = '.$records['pd_co_applicant_id'] .' and img_type = 1'; + if ($current_operation == 2) { - $this->db->query($sql); - } - else - { - $this->PD_Model->updateRecords(array('pd_document_title' => trim($records['applicant_name'])),PDDOCUMENTS,array('fk_pd_id' => $records['fk_pd_id'],'fk_form_id' => 18,'co_applicant_id' => $records['pd_co_applicant_id'],'img_type' => 1,'isactive' => 1));// 1- person met img - } - if($records['is_person_met_id_proof'] != "" && !substr_count($records['is_person_met_id_proof'],'https')) - { - $img_data[] = array('Name' => (trim($records['applicant_name']).'-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'],'co_applicant_id' => $records['pd_co_applicant_id'],'img_type' => 2); - + if ($records['is_person_met_pic'] != "" && !substr_count($records['is_person_met_pic'], 'https')) { + $img_data[] = array('Name' => trim($records['applicant_name']), 'image' => $records['is_person_met_pic'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1); // Make inactive old entries with same data - $sql = 'UPDATE '. PDDOCUMENTS.' SET isactive = 0 where fk_pd_id = '.$records['fk_pd_id'].' and co_applicant_id = '.$records['pd_co_applicant_id'] .' and img_type = 2'; + $sql = 'UPDATE ' . PDDOCUMENTS . ' SET isactive = 0 where fk_pd_id = ' . $records['fk_pd_id'] . ' and co_applicant_id = ' . $records['pd_co_applicant_id'] . ' and img_type = 1'; $this->db->query($sql); + } else { + $this->PD_Model->updateRecords(array('pd_document_title' => trim($records['applicant_name'])), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 1, 'isactive' => 1)); // 1- person met img } - else - { - $this->PD_Model->updateRecords(array('pd_document_title' => (trim($records['applicant_name']).'-id_proof')),PDDOCUMENTS,array('fk_pd_id' => $records['fk_pd_id'],'fk_form_id' => 18,'co_applicant_id' => $records['pd_co_applicant_id'],'img_type' => 2,'isactive' => 1));// 2- person met ID proof img + + if ($records['is_person_met_id_proof'] != "" && !substr_count($records['is_person_met_id_proof'], 'https')) { + $img_data[] = array('Name' => (trim($records['applicant_name']) . '-id_proof'), 'image' => $records['is_person_met_id_proof'], 'link' => $records['link'], 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2); + + + // Make inactive old entries with same data + $sql = 'UPDATE ' . PDDOCUMENTS . ' SET isactive = 0 where fk_pd_id = ' . $records['fk_pd_id'] . ' and co_applicant_id = ' . $records['pd_co_applicant_id'] . ' and img_type = 2'; + + $this->db->query($sql); + } else { + $this->PD_Model->updateRecords(array('pd_document_title' => (trim($records['applicant_name']) . '-id_proof')), PDDOCUMENTS, array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => 18, 'co_applicant_id' => $records['pd_co_applicant_id'], 'img_type' => 2, 'isactive' => 1)); // 2- person met ID proof img } } - if(count($img_data)) - { - $d = $this->saveBase64Images($records['fk_pd_id'],18,null,null,$img_data); + if (count($img_data)) { + $d = $this->saveBase64Images($records['fk_pd_id'], 18, null, null, $img_data); //print_r($d); } } - $is_person_met_id_proof = ''; - $is_person_met_pic = ''; - $lender_id = $this->PD_Model->selectCustomRecords(array('fk_lender_id'),array('pd_id' => $records['fk_pd_id']),PDTRIGGER); - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id']; - - $applicant_name = $this->PD_Model->selectCustomRecords(array('pd_document_name'),array('fk_pd_id' => $records['fk_pd_id'],'pd_document_title' => (trim($records['applicant_name'])),'isactive' => 1,'co_applicant_id is not null' => null,'img_type' => 1),PDDOCUMENTS); - //print_r($this->db->last_query()); - if(count($applicant_name)) - { - $profilepics3path = 'pd'.$records['fk_pd_id'].'/'.($applicant_name[0]['pd_document_name']); - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'30 minutes'); - $is_person_met_pic = $singed_uri; - } - $applicant_name_id = $this->PD_Model->selectCustomRecords(array('pd_document_name'),array('fk_pd_id' => $records['fk_pd_id'],'pd_document_title' => (trim($records['applicant_name']).'-id_proof'),'isactive' => 1,'co_applicant_id is not null' =>null,'img_type' => 2),PDDOCUMENTS); - //print_r($this->db->last_query()); - if(count($applicant_name_id)) - { - $profilepics3path = 'pd'.$records['fk_pd_id'].'/'.($applicant_name_id[0]['pd_document_name']); - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'30 minutes'); - $is_person_met_id_proof = $singed_uri; - } - + $is_person_met_id_proof = ''; + $is_person_met_pic = ''; + $lender_id = $this->PD_Model->selectCustomRecords(array('fk_lender_id'), array('pd_id' => $records['fk_pd_id']), PDTRIGGER); + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + + $applicant_name = $this->PD_Model->selectCustomRecords(array('pd_document_name'), array('fk_pd_id' => $records['fk_pd_id'], 'pd_document_title' => (trim($records['applicant_name'])), 'isactive' => 1, 'co_applicant_id is not null' => null, 'img_type' => 1), PDDOCUMENTS); + //print_r($this->db->last_query()); + if (count($applicant_name)) { + $profilepics3path = 'pd' . $records['fk_pd_id'] . '/' . ($applicant_name[0]['pd_document_name']); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '30 minutes'); + $is_person_met_pic = $singed_uri; + } + $applicant_name_id = $this->PD_Model->selectCustomRecords(array('pd_document_name'), array('fk_pd_id' => $records['fk_pd_id'], 'pd_document_title' => (trim($records['applicant_name']) . '-id_proof'), 'isactive' => 1, 'co_applicant_id is not null' => null, 'img_type' => 2), PDDOCUMENTS); + //print_r($this->db->last_query()); + if (count($applicant_name_id)) { + $profilepics3path = 'pd' . $records['fk_pd_id'] . '/' . ($applicant_name_id[0]['pd_document_name']); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '30 minutes'); + $is_person_met_id_proof = $singed_uri; + } + + + $custom_log_info = ' ###Response saveApplicantFromGeneralForm - PDID - (' . $records['fk_pd_id'] . ') - ' . date('Y-m-d H:i:s A'); + log_message('ERROR', $custom_log_info); + if ($applicant_id != null) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array("pd_co_applicant_id" => $applicant_id, "is_person_met_pic" => $is_person_met_pic, "is_person_met_id_proof" => $is_person_met_id_proof); + $this->response($data, REST_Controller::HTTP_OK); + } else { + + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Data Not Updated, Try one more!'; + $this->response($data, REST_Controller::HTTP_OK); + } - $custom_log_info = ' ###Response saveApplicantFromGeneralForm - PDID - ('. $records['fk_pd_id'] .') - ' . date('Y-m-d H:i:s A'); - log_message('ERROR',$custom_log_info); - if($applicant_id != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array("pd_co_applicant_id" => $applicant_id,"is_person_met_pic" => $is_person_met_pic, "is_person_met_id_proof" => $is_person_met_id_proof); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Data Not Updated, Try one more!'; - $this->response($data,REST_Controller::HTTP_OK); - } - //pd_co_applicant_id, fk_pd_id, , applicant_type, mobile_no, landline, email, isactive, addressline1, addressline2, addressline3, fk_city, fk_state, pincode, relation, company_name, applicant_title_name, additional_pd_id } @@ -9408,37 +8245,33 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() { $records = $this->post('records'); $client = $this->post('client'); - - $lender_applicant_id = isset($records['lender_applicant_id']) ? $records['lender_applicant_id'] : null; - $applicant_name = isset($records['applicant_name']) ? strtolower(trim($records['applicant_name'])) : null; - $mobile_no = isset($records['mobile_no']) ? $records['mobile_no'] : null; + + $lender_applicant_id = isset($records['lender_applicant_id']) ? $records['lender_applicant_id'] : null; + $applicant_name = isset($records['applicant_name']) ? strtolower(trim($records['applicant_name'])) : null; + $mobile_no = isset($records['mobile_no']) ? $records['mobile_no'] : null; $params = array(); $table = null; - if($lender_applicant_id) - { + if ($lender_applicant_id) { $params['lender_applicant_id'] = $lender_applicant_id; $table = PDTRIGGER; } - if($applicant_name) - { + if ($applicant_name) { $params['applicant_name'] = $applicant_name; $table = PDAPPLICANTSDETAILS; } - if($mobile_no) - { + if ($mobile_no) { $params['mobile_no'] = $mobile_no; $table = PDAPPLICANTSDETAILS; } - $result_data = $this->PD_Model->checkExistPDDetails($params,$table,$client); + $result_data = $this->PD_Model->checkExistPDDetails($params, $table, $client); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } public function deactiveFormData_post() @@ -9451,34 +8284,29 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $fk_createdby = $records['fk_createdby']; $rental_count_id = $records['rental_count_id']; - $fields = array('isactive' => 0,'fk_updatedby' => $fk_createdby); - $where_condition_array = array('fk_pd_id' => $fk_pd_id,'fk_form_id' => $fk_form_id); - if($company_id) - { + $fields = array('isactive' => 0, 'fk_updatedby' => $fk_createdby); + $where_condition_array = array('fk_pd_id' => $fk_pd_id, 'fk_form_id' => $fk_form_id); + if ($company_id) { $where_condition_array['company_id'] = $company_id; } - if($rental_count_id) - { + if ($rental_count_id) { $where_condition_array['rental_count_id'] = $rental_count_id; } //print_r($where_condition_array);die(); - - $id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array); - //print_r($this->db->last_query()); - if($id) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong..! Try Later...!'; - $this->response($data,REST_Controller::HTTP_OK); - } + + $id = $this->PD_Model->updateRecords($fields, PDFORMDETAILSJSON, $where_condition_array); + //print_r($this->db->last_query()); + if ($id) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong..! Try Later...!'; + $this->response($data, REST_Controller::HTTP_OK); + } // } // else // { @@ -9494,20 +8322,17 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function getNextRentalCount_get() { $pdid = $this->get('pdid'); - $nxt_rental_count_id = $this->PD_Model->selectCustomRecords(array('max(rental_count_id) as nxt_rental_count'),array('fk_pd_id' => $pdid,'fk_form_id' => 17),PDFORMDETAILSJSON); - if(is_array($nxt_rental_count_id) && count($nxt_rental_count_id)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = ( $nxt_rental_count_id[0]['nxt_rental_count'] + 1); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = 1; - $this->response($data,REST_Controller::HTTP_OK); + $nxt_rental_count_id = $this->PD_Model->selectCustomRecords(array('max(rental_count_id) as nxt_rental_count'), array('fk_pd_id' => $pdid, 'fk_form_id' => 17), PDFORMDETAILSJSON); + if (is_array($nxt_rental_count_id) && count($nxt_rental_count_id)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = ($nxt_rental_count_id[0]['nxt_rental_count'] + 1); + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = 1; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -9517,29 +8342,23 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records = $this->post('records'); $id = null; - if($records['id']) - { - $id = $this->PD_Model->updateRecords($records,XTRA_CHECK,array('id' => $records['id'])); - } - else - { - $id = $this->PD_Model->saveRecords($records,XTRA_CHECK); + if ($records['id']) { + $id = $this->PD_Model->updateRecords($records, XTRA_CHECK, array('id' => $records['id'])); + } else { + $id = $this->PD_Model->saveRecords($records, XTRA_CHECK); } - if($id) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong..! Try Later...!'; - $this->response($data,REST_Controller::HTTP_OK); + if ($id) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong..! Try Later...!'; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -9548,38 +8367,29 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records = $this->post('records'); - $id = $this->PD_Model->updateRecords(array('start_location' => $records['geo_location'],'fk_updatedby' => $records['fk_updatedby']),PDTRIGGER,array('pd_id' => $records['pd_id'])); - - if($id) - { - $is_gen = satellite_image::getSatelliteImage($records['pd_id'],1,true); - - if($is_gen) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong..! Try Later...!'; - $this->response($data,REST_Controller::HTTP_OK); - } + $id = $this->PD_Model->updateRecords(array('start_location' => $records['geo_location'], 'fk_updatedby' => $records['fk_updatedby']), PDTRIGGER, array('pd_id' => $records['pd_id'])); - } - else - { - - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong..! Try Later...!'; - $this->response($data,REST_Controller::HTTP_OK); - } - + if ($id) { + $is_gen = satellite_image::getSatelliteImage($records['pd_id'], 1, true); + if ($is_gen) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong..! Try Later...!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong..! Try Later...!'; + $this->response($data, REST_Controller::HTTP_OK); + } } //CUstomer Link for Tele PD to upload photos @@ -9589,239 +8399,197 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $img_array = array(); $current_doc_title = null; $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id']); - + // for business related images $company_id = null; - if($records['image_key'] == 'selfie_with_person_met' || $records['image_key'] == 'person_met_id') - { + if ($records['image_key'] == 'selfie_with_person_met' || $records['image_key'] == 'person_met_id') { //get main applicant name - $main_applicant_name = $this->PD_Model->selectCustomRecords(array('fk_pd_id','applicant_name','pd_co_applicant_id'),array('fk_pd_id' => $records['fk_pd_id'],'applicant_type' => 1),PDAPPLICANTSDETAILS); + $main_applicant_name = $this->PD_Model->selectCustomRecords(array('fk_pd_id', 'applicant_name', 'pd_co_applicant_id'), array('fk_pd_id' => $records['fk_pd_id'], 'applicant_type' => 1), PDAPPLICANTSDETAILS); //print_r($main_applicant_name); - - if($records['image_key'] == 'selfie_with_person_met') - { + + if ($records['image_key'] == 'selfie_with_person_met') { $img_array['img_type'] = 1; $img_array['co_applicant_id'] = $main_applicant_name[0]['pd_co_applicant_id']; $img_array['image'] = $records['image']; $img_array['Name'] = $main_applicant_name[0]['applicant_name']; - $current_doc_title = $main_applicant_name[0]['applicant_name']; + $current_doc_title = $main_applicant_name[0]['applicant_name']; - if($pd_master_details[0]['fk_pd_type'] == 2)// if smard pd + if ($pd_master_details[0]['fk_pd_type'] == 2) // if smard pd { - $this->PD_Model->updateRecords(array('start_location' => $records['link']),PDTRIGGER,array('pd_id' => $records['fk_pd_id'])); + $this->PD_Model->updateRecords(array('start_location' => $records['link']), PDTRIGGER, array('pd_id' => $records['fk_pd_id'])); satellite_image::getSatelliteImage($records['fk_pd_id']); } - } - else if($records['image_key'] == 'person_met_id') - { + } else if ($records['image_key'] == 'person_met_id') { $img_array['img_type'] = 2; $img_array['co_applicant_id'] = $main_applicant_name[0]['pd_co_applicant_id']; $img_array['image'] = $records['image']; - $img_array['Name'] = $main_applicant_name[0]['applicant_name'].'-id_proof'; - $current_doc_title = $main_applicant_name[0]['applicant_name'].'-id_proof'; + $img_array['Name'] = $main_applicant_name[0]['applicant_name'] . '-id_proof'; + $current_doc_title = $main_applicant_name[0]['applicant_name'] . '-id_proof'; } - } - else if(strpos($records['image_key'], 'approach') !== false) - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['name']; - $img_array['is_show_report'] = 1; - $current_doc_title = $records['image_key']; - } - else if(strpos($records['image_key'], 'name_board_seen') !== false) - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['name']; - $current_doc_title = $records['image_key']; + } else if (strpos($records['image_key'], 'approach') !== false) { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $img_array['is_show_report'] = 1; + $current_doc_title = $records['image_key']; + } else if (strpos($records['image_key'], 'name_board_seen') !== false) { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $current_doc_title = $records['image_key']; - //update geo location to pd master table - if($pd_master_details[0]['fk_pd_type'] == 3)//tele pd - { - $this->PD_Model->updateRecords(array('start_location' => $records['link']),PDTRIGGER,array('pd_id' => $records['fk_pd_id'])); - satellite_image::getSatelliteImage($records['fk_pd_id']); - } - } - else if(strpos($records['image_key'], 'common_image') !== false) - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['name']; - $current_doc_title = $records['image_key']; - } - else if(strpos($records['image_key'], 'stock_image') !== false) - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['image_key']; - $current_doc_title = $records['image_key']; - $company_id = 1; - } - else if(strpos($records['image_key'], 'docs_to_be_collected') !== false) - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['name']; - $current_doc_title = $records['name']; - - } - else - { - $img_array['image'] = $records['image']; - $img_array['Name'] = $records['image_key']; - $current_doc_title = $records['image_key']; + //update geo location to pd master table + if ($pd_master_details[0]['fk_pd_type'] == 3) //tele pd + { + $this->PD_Model->updateRecords(array('start_location' => $records['link']), PDTRIGGER, array('pd_id' => $records['fk_pd_id'])); + satellite_image::getSatelliteImage($records['fk_pd_id']); + } + } else if (strpos($records['image_key'], 'common_image') !== false) { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $current_doc_title = $records['image_key']; + } else if (strpos($records['image_key'], 'stock_image') !== false) { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['image_key']; + $current_doc_title = $records['image_key']; + $company_id = 1; + } else if (strpos($records['image_key'], 'docs_to_be_collected') !== false) { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['name']; + $current_doc_title = $records['name']; + } else { + $img_array['image'] = $records['image']; + $img_array['Name'] = $records['image_key']; + $current_doc_title = $records['image_key']; } $img_array['pd_image_alias_name'] = $records['pd_image_alias_name']; $img_array['image_key'] = $records['image_key']; $img_array['link'] = isset($records['link']) ? $records['link'] : null; //set company id for business related forms - $business_forms = array(1,2,13,14,11,16,21,22,23); - if(in_array($records['fk_form_id'], $business_forms)) - { + $business_forms = array(1, 2, 13, 14, 11, 16, 21, 22, 23); + if (in_array($records['fk_form_id'], $business_forms)) { $company_id = 1; } // echo $company_id;die(); //de activate previous one - - if(!$records['is_multiple'] || isset($records['pd_document_id'])) - { - $where_condition_array = array('fk_pd_id' => $records['fk_pd_id'],'fk_form_id' => $records['fk_form_id'],'pd_document_title' => $current_doc_title); - if(isset($records['pd_document_id']) && isset($records['retake_flag']) && $records['retake_flag']) - { - $where_condition_array = array('pd_document_id' => $records['pd_document_id']); - unset($records['pd_document_id']); unset($records['retake_flag']) ; - $to_update = array('isactive' => 0,'retake_flag' => 0); - } - else if(isset($records['pd_document_id']) && $records['pd_document_id'] !=null && $records['pd_document_id'] != "" && $records['image'] == ""){ - $where_condition_array = array('pd_document_id' => $records['pd_document_id']); - $to_update = array("pd_image_alias_name"=>$records['pd_image_alias_name']); - }else{ - $to_update = array('isactive' => 0,'retake_flag' => 0); + + if (!$records['is_multiple'] || isset($records['pd_document_id'])) { + $where_condition_array = array('fk_pd_id' => $records['fk_pd_id'], 'fk_form_id' => $records['fk_form_id'], 'pd_document_title' => $current_doc_title); + if (isset($records['pd_document_id']) && isset($records['retake_flag']) && $records['retake_flag']) { + $where_condition_array = array('pd_document_id' => $records['pd_document_id']); + unset($records['pd_document_id']); + unset($records['retake_flag']); + $to_update = array('isactive' => 0, 'retake_flag' => 0); + } else if (isset($records['pd_document_id']) && $records['pd_document_id'] != null && $records['pd_document_id'] != "" && $records['image'] == "") { + $where_condition_array = array('pd_document_id' => $records['pd_document_id']); + $to_update = array("pd_image_alias_name" => $records['pd_image_alias_name']); + } else { + $to_update = array('isactive' => 0, 'retake_flag' => 0); } - $res = $this->PD_Model->updateRecords($to_update,PDDOCUMENTS,$where_condition_array); - } - - - if($records['image'] != ""){ - $res = $this->saveBase64Images($records['fk_pd_id'],($records['fk_form_id'] ? $records['fk_form_id'] : null),$company_id,$rental_count_id = null,array($img_array)); - } - - if($res) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $res; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = "Something Went Wrong! Try Later"; - $this->response($data,REST_Controller::HTTP_OK); + $res = $this->PD_Model->updateRecords($to_update, PDDOCUMENTS, $where_condition_array); } + if ($records['image'] != "") { + $res = $this->saveBase64Images($records['fk_pd_id'], ($records['fk_form_id'] ? $records['fk_form_id'] : null), $company_id, $rental_count_id = null, array($img_array)); + } + + if ($res) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = "Something Went Wrong! Try Later"; + $this->response($data, REST_Controller::HTTP_OK); + } } //Applicant Link Check and Get Image Details public function getPDImgDetails_post() { $random_string = $this->post('random_string'); - $pd_id = $this->post('pd_id'); + $pd_id = $this->post('pd_id'); $where_condition_array = array('random_string' => $random_string); - if($pd_id){ $where_condition_array['pd_id'] = $pd_id; } - - //Get PD ID by Random String - $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id','is_cus_link_valid','cus_link_count','is_cus_link_disabled'),$where_condition_array,PDTRIGGER); + if ($pd_id) { + $where_condition_array['pd_id'] = $pd_id; + } - if(count($pd_id) && count($pd_id) == 1) - { - //check and update link meta data - if($pd_id[0]['is_cus_link_valid']) - { - //$this->updateLinkMetaData($pd_id[0]['pd_id'],$pd_id[0]['cus_link_count'],$random_string); + //Get PD ID by Random String + $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id', 'is_cus_link_valid', 'cus_link_count', 'is_cus_link_disabled'), $where_condition_array, PDTRIGGER); - //get img Data - $this->getPDImgData($pd_id[0]['pd_id'],$random_string,$pd_id[0]['is_cus_link_disabled']); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Link Expired'; - $this->response($data,REST_Controller::HTTP_OK); - } + if (count($pd_id) && count($pd_id) == 1) { + //check and update link meta data + if ($pd_id[0]['is_cus_link_valid']) { + //$this->updateLinkMetaData($pd_id[0]['pd_id'],$pd_id[0]['cus_link_count'],$random_string); + //get img Data + $this->getPDImgData($pd_id[0]['pd_id'], $random_string, $pd_id[0]['is_cus_link_disabled']); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Link Expired'; + $this->response($data, REST_Controller::HTTP_OK); } - else if(count($pd_id) > 1 || !count($pd_id)) - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Invalid Link'; - $this->response($data,REST_Controller::HTTP_OK); - } - + } else if (count($pd_id) > 1 || !count($pd_id)) { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Invalid Link'; + $this->response($data, REST_Controller::HTTP_OK); + } } - + //update link meta data - public function updateLinkMetaData($pd_id,$link_count,$random_string) + public function updateLinkMetaData($pd_id, $link_count, $random_string) { //echo 'updateLinkMetaData'; - $this->load->library('user_agent'); - $agent = 'DEFAULT'; - if ($this->agent->is_browser()) - { - $agent = $this->agent->browser().' '.$this->agent->version(); - } - elseif ($this->agent->is_robot()) - { - $agent = $this->agent->robot(); - } - elseif ($this->agent->is_mobile()) - { - $agent = $this->agent->mobile(); - } - else - { - $agent = 'Unidentified User Agent'; + $this->load->library('user_agent'); + $agent = 'DEFAULT'; + if ($this->agent->is_browser()) { + $agent = $this->agent->browser() . ' ' . $this->agent->version(); + } elseif ($this->agent->is_robot()) { + $agent = $this->agent->robot(); + } elseif ($this->agent->is_mobile()) { + $agent = $this->agent->mobile(); + } else { + $agent = 'Unidentified User Agent'; } //echo $agent;echo $this->input->ip_address();echo $this->agent->platform(); - + //$this->PD_Model->saveRecords(array('fk_pd_id' => $pd_id,'browser' => $agent,'ip_address' => $this->input->ip_address(),'platform' => $this->agent->platform()),CUS_LINK_META_DATA); //update link access count in PD trigger table - + //$this->PD_Model->updateRecords(array('cus_link_count' =>($link_count + 1) ),PDTRIGGER,array('pd_id' => $pd_id,'random_string' => $random_string)); } - public function getPDImgData($pd_id,$random_string,$is_cus_link_disabled) + public function getPDImgData($pd_id, $random_string, $is_cus_link_disabled) { - $this->existing_imges = $this->PD_Model->getSignedPDDocsURL($pd_id,null,null,null,null,'customer_app'); - $docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' =>$pd_id),PDDOCSTOBECOLLECTED); - + $this->existing_imges = $this->PD_Model->getSignedPDDocsURL($pd_id, null, null, null, null, 'customer_app'); + $docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('*'), array('fk_pd_id' => $pd_id), PDDOCSTOBECOLLECTED); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - if($pd_master_details[0]['customer_segment_abbr'] == 'SAL') - { - $this->photo_names['attendance_seen_pic'] = array('Attendance Img','13'); + if ($pd_master_details[0]['customer_segment_abbr'] == 'SAL') { + $this->photo_names['attendance_seen_pic'] = array('Attendance Img', '13'); } $final_data = array(); $common_images = array(); - //print_r(($this->existing_imges));die(); - if(count($this->existing_imges)) - { - foreach ($this->photo_names as $key => $value) - { - $temp = $this->photoMapping($key,$value); - if(is_array($temp) && count($temp)) - { + //print_r(($this->existing_imges));die(); + if (count($this->existing_imges)) { + foreach ($this->photo_names as $key => $value) { + $temp = $this->photoMapping($key, $value); + if (is_array($temp) && count($temp)) { //echo count($temp); // if($temp['is_multiple']) // { - + // if(!array_key_exists($temp['img_key'], $final_data)) // { // $temp['img_data'][] = array('img_url' => $temp['img_url']); @@ -9832,7 +8600,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // { // $final_data[$temp['img_key']]['img_data'] = array('img_url' => $temp['img_url']); // } - + // } // else // { @@ -9843,187 +8611,141 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // $temp = array_values($temp); // } $final_data[] = $temp; - - } - else - { - $temp_array = array('img_key' =>$key,'img_name' => $value[0],'fk_form_id' => $value[1],"is_multiple" => $value[2],'pd_image_alias_name'=> "",'is_name_editable'=> $value[3]); + } else { + $temp_array = array('img_key' => $key, 'img_name' => $value[0], 'fk_form_id' => $value[1], "is_multiple" => $value[2], 'pd_image_alias_name' => "", 'is_name_editable' => $value[3]); $temp_array[($value[2] ? 'img_data' : 'img_url')] = ($value[2] ? array() : ''); $final_data[] = $temp_array; - } - - } - foreach ($this->existing_imges as $key => $value) - { - //print_r(count($this->existing_imges)); - if(!$value['fk_form_id'] && ($value['pd_document_title'] != 'satellite')) - { - $final_data[] = array('img_key' =>'common_image','img_name' => $value['pd_document_title'],'img_url' => $value['doc_url'],'fk_form_id' => null,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name'=> $value['pd_image_alias_name'],'is_name_editable'=> $value['is_name_editable']); - unset($this->existing_imges[$key]); - } - elseif($value['pd_document_title'] != 'satellite' && $value['fk_form_id'] == 24) - { - // doc to be collected img check add it to final data - if(is_array($docs_to_be_collected) && count($docs_to_be_collected)) - { - //print_r(count($this->existing_imges)); - $is_listed = false; - foreach ($docs_to_be_collected as $dc_key => $dc_value) - { - //echo 'before if check - '.$dc_value['doc_name'].'#'.$value['pd_document_title'].'****'; - if ($dc_value['doc_name'] == $value['pd_document_title']) - { - $is_listed = true; - unset($docs_to_be_collected[$dc_key]); - unset($this->existing_imges[$key]); - //echo 'inside if check - '.$dc_value['doc_name'].'#'.$value['pd_document_title'].'****'; - } - } - - if($is_listed) - { - $final_data[] = array('img_key' => 'docs_to_be_collected','img_name' => $value['pd_document_title'],'img_url' => $value['doc_url'],'fk_form_id' => 24,'is_multiple' => 0,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name'=> $value['pd_image_alias_name'],'is_name_editable'=> $value['is_name_editable']); - - //break; - } + foreach ($this->existing_imges as $key => $value) { + //print_r(count($this->existing_imges)); + if (!$value['fk_form_id'] && ($value['pd_document_title'] != 'satellite')) { + $final_data[] = array('img_key' => 'common_image', 'img_name' => $value['pd_document_title'], 'img_url' => $value['doc_url'], 'fk_form_id' => null, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable']); + unset($this->existing_imges[$key]); + } elseif ($value['pd_document_title'] != 'satellite' && $value['fk_form_id'] == 24) { + // doc to be collected img check add it to final data + if (is_array($docs_to_be_collected) && count($docs_to_be_collected)) { + //print_r(count($this->existing_imges)); + $is_listed = false; + foreach ($docs_to_be_collected as $dc_key => $dc_value) { + //echo 'before if check - '.$dc_value['doc_name'].'#'.$value['pd_document_title'].'****'; + if ($dc_value['doc_name'] == $value['pd_document_title']) { + $is_listed = true; + unset($docs_to_be_collected[$dc_key]); + unset($this->existing_imges[$key]); + //echo 'inside if check - '.$dc_value['doc_name'].'#'.$value['pd_document_title'].'****'; } - - } + } - + if ($is_listed) { + $final_data[] = array('img_key' => 'docs_to_be_collected', 'img_name' => $value['pd_document_title'], 'img_url' => $value['doc_url'], 'fk_form_id' => 24, 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable']); + + //break; + } + } + } } //print_r(($this->existing_imges));die(); //add remaining docs_to_be_collected into final array - if(is_array($docs_to_be_collected) && count($docs_to_be_collected)) - { - foreach ($docs_to_be_collected as $key => $value) - { - $final_data[] = array('img_key' => 'docs_to_be_collected','img_name' => $value['doc_name'],'img_url' => "",'fk_form_id' => "24",'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name'=> $value['pd_image_alias_name'],'is_name_editable'=> $value['is_name_editable']); - } - } - - - } - else - { - foreach ($this->photo_names as $key => $value) - { - $final_data[] = array('img_key' => $key,'img_name' => $value[0],'img_url' => "",'fk_form_id' => $value[1],"is_multiple" => $value[2],'pd_image_alias_name'=> "",'is_name_editable'=> $value[3]); - + if (is_array($docs_to_be_collected) && count($docs_to_be_collected)) { + foreach ($docs_to_be_collected as $key => $value) { + $final_data[] = array('img_key' => 'docs_to_be_collected', 'img_name' => $value['doc_name'], 'img_url' => "", 'fk_form_id' => "24", 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable']); + } } - - if(is_array($docs_to_be_collected) && count($docs_to_be_collected)) - { - foreach ($docs_to_be_collected as $key => $value) - { - $final_data[] = array('img_key' => 'docs_to_be_collected','img_name' => $value['doc_name'],'img_url' => "",'fk_form_id' => "24","is_multiple" => 0,'pd_image_alias_name'=> "",'is_name_editable'=> 0); + } else { + foreach ($this->photo_names as $key => $value) { + $final_data[] = array('img_key' => $key, 'img_name' => $value[0], 'img_url' => "", 'fk_form_id' => $value[1], "is_multiple" => $value[2], 'pd_image_alias_name' => "", 'is_name_editable' => $value[3]); + } + + if (is_array($docs_to_be_collected) && count($docs_to_be_collected)) { + foreach ($docs_to_be_collected as $key => $value) { + $final_data[] = array('img_key' => 'docs_to_be_collected', 'img_name' => $value['doc_name'], 'img_url' => "", 'fk_form_id' => "24", "is_multiple" => 0, 'pd_image_alias_name' => "", 'is_name_editable' => 0); } } } //print_r($final_data);die(); - //$final_data[] = array('imag_data' => $common_images,'is_multiple' => 1); - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pd_id' => $pd_id,'random_string' => $random_string,'is_cus_link_disabled' => $is_cus_link_disabled,'img_data' => $final_data); - $this->response($data,REST_Controller::HTTP_OK); - } + //$final_data[] = array('imag_data' => $common_images,'is_multiple' => 1); - function photoMapping($current_img_key,$current_img) + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pd_id' => $pd_id, 'random_string' => $random_string, 'is_cus_link_disabled' => $is_cus_link_disabled, 'img_data' => $final_data); + $this->response($data, REST_Controller::HTTP_OK); + } + + function photoMapping($current_img_key, $current_img) { - + ///echo $img_key;die(); //;die(); $multiple_img_data = array(); $current_multiple_img_key = null; - foreach ($this->existing_imges as $key => $value) - { + foreach ($this->existing_imges as $key => $value) { //print_r($value);die(); - // echo $current_img_key.'***'.$value['pd_document_title']; - // echo '
'; - // echo '
'; + // echo $current_img_key.'***'.$value['pd_document_title']; + // echo '
'; + // echo '
'; // print_r(count($this->existing_imges)); // echo $value['pd_document_title']; - if($current_img_key == 'selfie_with_person_met' && $value['img_type'] == 1 ) - { - - //echo "SELFIE"; - $arr = array('img_key' => 'selfie_with_person_met','img_name' => $this->photo_names['selfie_with_person_met'][0],'fk_form_id' => $this->photo_names['selfie_with_person_met'][1],'img_url' => $value['doc_url'],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $this->photo_names['selfie_with_person_met'][3]); - unset($this->existing_imges[$key]); - return $arr; - - } - else if($current_img_key == 'person_met_id' && $value['img_type'] == 2) - { - - //echo 'HOLD'; - $arr = array('img_key' => 'person_met_id','img_name' => $this->photo_names['person_met_id'][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names['person_met_id'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $this->photo_names['person_met_id'][3]); - - unset($this->existing_imges[$key]); - return $arr; - // unset($this->photo_names['selfie_with_person_met']); - // return $arr; - } - else if($current_img_key == 'approach_to_pd_location' && strpos($value['pd_document_title'], 'Approach') !== false) - { - - //echo "APPROACH"; - $arr = array('img_key' => 'approach_to_pd_location','img_name' => $this->photo_names['approach_to_pd_location'][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names['approach_to_pd_location'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $this->photo_names['person_met_id'][3]); - unset($this->existing_imges[$key]); - return $arr; - // unset($this->photo_names['selfie_with_person_met']); - // return $arr; - } - else if($current_img_key == 'name_board_seen' && strpos($value['pd_document_title'], 'Name Board Seen') !== false) - { - - //echo "APPROACH"; - $arr = array('img_key' => 'name_board_seen','img_name' => $this->photo_names['name_board_seen'][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names['name_board_seen'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $this->photo_names['name_board_seen'][3]); - unset($this->existing_imges[$key]); - return $arr; - // unset($this->photo_names['selfie_with_person_met']); - // return $arr; - } - else if(strpos($current_img_key, $value['pd_document_title']) !== false) - { - //echo $current_img_key.'***'.$value['pd_document_title']; - //unset($this->existing_imges[$key]); - //echo "OTHER"; - if($current_img[2]) - { - - $current_multiple_img_key = $current_img_key; - if(!array_key_exists($current_img_key, $multiple_img_data)) - { - $multiple_img_data[$current_img_key] = array('img_key' => $value['pd_document_title'],'img_name' => $this->photo_names[ $value['pd_document_title'] ][0],'img_data' => array(array('img_url' => $value['doc_url'],'img_name' => $value['pd_document_title'],'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $value['is_name_editable'])),'fk_form_id' => $this->photo_names[ $value['pd_document_title'] ][1],'is_multiple' => $current_img[2],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $this->photo_names[ $value['pd_document_title'] ][3]); - } - else - { - $multiple_img_data[$current_img_key]['img_data'][] = array('img_url' => $value['doc_url'],'img_name' => $value['pd_document_title'],'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $value['is_name_editable']); - - } - + if ($current_img_key == 'selfie_with_person_met' && $value['img_type'] == 1) { + + //echo "SELFIE"; + $arr = array('img_key' => 'selfie_with_person_met', 'img_name' => $this->photo_names['selfie_with_person_met'][0], 'fk_form_id' => $this->photo_names['selfie_with_person_met'][1], 'img_url' => $value['doc_url'], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['selfie_with_person_met'][3]); + unset($this->existing_imges[$key]); + return $arr; + } else if ($current_img_key == 'person_met_id' && $value['img_type'] == 2) { + + //echo 'HOLD'; + $arr = array('img_key' => 'person_met_id', 'img_name' => $this->photo_names['person_met_id'][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names['person_met_id'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['person_met_id'][3]); + + unset($this->existing_imges[$key]); + return $arr; + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } else if ($current_img_key == 'approach_to_pd_location' && strpos($value['pd_document_title'], 'Approach') !== false) { + + //echo "APPROACH"; + $arr = array('img_key' => 'approach_to_pd_location', 'img_name' => $this->photo_names['approach_to_pd_location'][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names['approach_to_pd_location'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['person_met_id'][3]); + unset($this->existing_imges[$key]); + return $arr; + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } else if ($current_img_key == 'name_board_seen' && strpos($value['pd_document_title'], 'Name Board Seen') !== false) { + + //echo "APPROACH"; + $arr = array('img_key' => 'name_board_seen', 'img_name' => $this->photo_names['name_board_seen'][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names['name_board_seen'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names['name_board_seen'][3]); + unset($this->existing_imges[$key]); + return $arr; + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } else if (strpos($current_img_key, $value['pd_document_title']) !== false) { + //echo $current_img_key.'***'.$value['pd_document_title']; + //unset($this->existing_imges[$key]); + //echo "OTHER"; + if ($current_img[2]) { + + $current_multiple_img_key = $current_img_key; + if (!array_key_exists($current_img_key, $multiple_img_data)) { + $multiple_img_data[$current_img_key] = array('img_key' => $value['pd_document_title'], 'img_name' => $this->photo_names[$value['pd_document_title']][0], 'img_data' => array(array('img_url' => $value['doc_url'], 'img_name' => $value['pd_document_title'], 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable'])), 'fk_form_id' => $this->photo_names[$value['pd_document_title']][1], 'is_multiple' => $current_img[2], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $this->photo_names[$value['pd_document_title']][3]); + } else { + $multiple_img_data[$current_img_key]['img_data'][] = array('img_url' => $value['doc_url'], 'img_name' => $value['pd_document_title'], 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable']); } - else - { - $arr = array('img_key' => $value['pd_document_title'],'img_name' => $this->photo_names[ $value['pd_document_title'] ][0],'img_url' => $value['doc_url'],'fk_form_id' => $this->photo_names[ $value['pd_document_title'] ][1],'is_multiple' => $current_img[2],'pd_document_id' => $value['pd_document_id'],'pd_image_alias_name' =>$value['pd_image_alias_name'] ,'is_name_editable' => $value['is_name_editable']); - return $arr; - } - unset($this->existing_imges[$key]); - - - // unset($this->photo_names['selfie_with_person_met']); - // return $arr; + } else { + $arr = array('img_key' => $value['pd_document_title'], 'img_name' => $this->photo_names[$value['pd_document_title']][0], 'img_url' => $value['doc_url'], 'fk_form_id' => $this->photo_names[$value['pd_document_title']][1], 'is_multiple' => $current_img[2], 'pd_document_id' => $value['pd_document_id'], 'pd_image_alias_name' => $value['pd_image_alias_name'], 'is_name_editable' => $value['is_name_editable']); + return $arr; } - // else - // { - // //unset($this->existing_imges[$key]); - // echo "ELSE"; - // return array('img_key' =>$current_img_key,'img_name' => $current_img_key,'img_url' => '','fk_form_id' => $current_img[1]); - // } + unset($this->existing_imges[$key]); + + + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } + // else + // { + // //unset($this->existing_imges[$key]); + // echo "ELSE"; + // return array('img_key' =>$current_img_key,'img_name' => $current_img_key,'img_url' => '','fk_form_id' => $current_img[1]); + // } } return $current_multiple_img_key ? $multiple_img_data[$current_multiple_img_key] : $multiple_img_data; //return $multiple_img_data; @@ -10038,153 +8760,134 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $response = false; $sms_flag = $this->post('sms_flag'); - $msg = "Dear Applicant, Please click the link to upload the photographs. " . CUSTOMER_IMG_URL .$random_string; - if($sms_flag == 2)//recapture + $msg = "Dear Applicant, Please click the link to upload the photographs. " . CUSTOMER_IMG_URL . $random_string; + if ($sms_flag == 2) //recapture { $msg .= "/recapture"; } - + //SALESPD_CUSTOMER_IMG_URL - $res = SMS_GUPSHUP::sendSMS($msg,$mobile_no,array('pd_id' => $pd_id,'status' => 'STARTED','msg' => 'Cus Link from PD controlller'),true); + $res = SMS_GUPSHUP::sendSMS($msg, $mobile_no, array('pd_id' => $pd_id, 'status' => 'STARTED', 'msg' => 'Cus Link from PD controlller'), true); //print_r($res); $res = explode('|', $res); - - if(is_array($res) && count($res)) - { - - if(trim($res[0]) == "success") - { - $response = true; + + if (is_array($res) && count($res)) { + + if (trim($res[0]) == "success") { + $response = true; } } - if($response) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = 'SMS Sent Successfully'; - $this->response($data,REST_Controller::HTTP_OK); + if ($response) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'SMS Sent Successfully'; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'SMS Sent Falied. Try Later!'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'SMS Sent Falied. Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } public function saveCusVideo_post() { - $records = json_decode($this->post('records'),true); + $records = json_decode($this->post('records'), true); $id = null; //log_message('ERROR','hi'); - // print_r($records); - // print_r($_FILES); - // die(); + // print_r($records); + // print_r($_FILES); + // die(); - $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; - $lender_id = $records['pd_category'] == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; - $file_folder = $records['pd_category'] == "2" ? "sales_pd" : "pd_reports" ; - if(!empty($_FILES['video_file'])) - { - - if($pd_category == '2'){ - $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} - if($pd_category == '1'){ - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']);} - - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $key = 'pd'.$records['pd_id'].'/video/'.$records['filename']; + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $lender_id = $records['pd_category'] == "1" ? $pd_master_details[0]['fk_lender_id'] : $pd_master_details[0]['lender_id']; + $file_folder = $records['pd_category'] == "2" ? "sales_pd" : "pd_reports"; + if (!empty($_FILES['video_file'])) { + + if ($pd_category == '2') { + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type', 'isactive', 'rand_string as random_string', 'pd_branch_id'), array('sales_pd_id' => $pd_id, 'rand_string' => $random_string), SALES_PD_DATA); + } + if ($pd_category == '1') { + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); + } + + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + $key = 'pd' . $records['pd_id'] . '/video/' . $records['filename']; $file_name_wo_extension = explode('.', ($records['filename']))[0]; $file_type = explode('/', ($_FILES['video_file']['type']))[1]; - $folder_to_check = XLPATH.'/'.$file_folder.'/'.$records['pd_id'].'/videos'; + $folder_to_check = XLPATH . '/' . $file_folder . '/' . $records['pd_id'] . '/videos'; //echo $folder_to_check;//die(); - if(!file_exists($folder_to_check)) { mkdir(XLPATH.'/'.$file_folder.'/'.$records['pd_id'],0777); mkdir($folder_to_check,0777); } + if (!file_exists($folder_to_check)) { + mkdir(XLPATH . '/' . $file_folder . '/' . $records['pd_id'], 0777); + mkdir($folder_to_check, 0777); + } //die(); - $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $file_name_wo_extension.'.'.$file_type); + $config = array('upload_path' => $folder_to_check, 'overwrite' => TRUE, 'allowed_types' => '*', 'file_name' => $file_name_wo_extension . '.' . $file_type); $this->load->library('upload', $config); - if($this->upload->do_upload('video_file')) - { + if ($this->upload->do_upload('video_file')) { $upload_data = $this->upload->data(); //$this->load->view('upload_success',$data); //print_r($upload_data); - $command_to_execute = FFMPEG_PATH.' -i '.$folder_to_check.'/'.$file_name_wo_extension.'.'.$file_type.' '.$folder_to_check.'/'.$file_name_wo_extension.'.mp4'.' 2>&1' ; + $command_to_execute = FFMPEG_PATH . ' -i ' . $folder_to_check . '/' . $file_name_wo_extension . '.' . $file_type . ' ' . $folder_to_check . '/' . $file_name_wo_extension . '.mp4' . ' 2>&1'; //print_r($command_to_execute);die(); - exec($command_to_execute,$o,$v); + exec($command_to_execute, $o, $v); // print_r($o); // echo $command_to_execute;die(); - if($o) - { - $sourcefile = $folder_to_check.'/'.$file_name_wo_extension.'.mp4'; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - // print_r($s3result); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###PDVIDEO stored in S3'.$records['pd_id']); - $record_data = array('fk_pd_id' => $records['pd_id'],'video_part_name'=>$records['filename'],'video_key' => $records['video_key'],'pd_category'=>$pd_category); - $id = $this->PD_Model->saveRecords($record_data,CUS_VIDEO); - unlink($folder_to_check.'/'.$file_name_wo_extension.'.webm'); - unlink($folder_to_check.'/'.$file_name_wo_extension.'.mp4'); - - } + if ($o) { + $sourcefile = $folder_to_check . '/' . $file_name_wo_extension . '.mp4'; + + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + // print_r($s3result); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', '###PDVIDEO stored in S3' . $records['pd_id']); + $record_data = array('fk_pd_id' => $records['pd_id'], 'video_part_name' => $records['filename'], 'video_key' => $records['video_key'], 'pd_category' => $pd_category); + $id = $this->PD_Model->saveRecords($record_data, CUS_VIDEO); + unlink($folder_to_check . '/' . $file_name_wo_extension . '.webm'); + unlink($folder_to_check . '/' . $file_name_wo_extension . '.mp4'); + } // if it is last part of a video call, then call video merge functionality - if(isset($records['is_call_ended']) && $records['is_call_ended'] == 1) - { - $final_video_name = $records['pd_id'].'-'.$records['video_key']; + if (isset($records['is_call_ended']) && $records['is_call_ended'] == 1) { + $final_video_name = $records['pd_id'] . '-' . $records['video_key']; sleep(10); - $this->mergeVideo($records['pd_id'],$pd_master_details,$final_video_name,$records['video_key'],$pd_category); - } + $this->mergeVideo($records['pd_id'], $pd_master_details, $final_video_name, $records['video_key'], $pd_category); + } - if($id != null || $id != "") - { + if ($id != null || $id != "") { - $data['dataStatus'] = true; + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'Video Saved Successfully'; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Wrong. Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'Something Wrong. Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data, REST_Controller::HTTP_OK); } - + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Wrong. Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'No Image found to upload'; - $this->response($data,REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Image found to upload'; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -10193,104 +8896,102 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function getVideoURL_post() { $pd_id = $this->post('pd_id'); - $random_string = $this->post('random_string'); + $random_string = $this->post('random_string'); $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; - $this->load->helper('video_grabber_helper'); - if($pd_category == '1'){//normal Credit PD; - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - }if($pd_category == '2'){//Sales PD; - $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA);} - $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details,$pd_category); - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - - + $this->load->helper('video_grabber_helper'); + if ($pd_category == '1') { //normal Credit PD; + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id, $random_string); + } + if ($pd_category == '2') { //Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type', 'isactive', 'rand_string as random_string', 'pd_branch_id'), array('sales_pd_id' => $pd_id, 'rand_string' => $random_string), SALES_PD_DATA); + } + $result_data = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'], $pd_master_details[0]['random_string'], $pd_master_details, $pd_category); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data, REST_Controller::HTTP_OK); } // To Inactive Video Recorded. - public function deleteVideo_get(){ + public function deleteVideo_get() + { $id = $this->get('id'); // $id = (int) $id; // if(!empty($id)){ // // $multipleWhere['fk_pd_id'] = $multipleWhere['pd_id']; // // unset($multipleWhere['pd_id']); - $this->load->helper('video_grabber_helper'); - $result_data = (new video_grabber_helper)->deleteVideo($id); + $this->load->helper('video_grabber_helper'); + $result_data = (new video_grabber_helper)->deleteVideo($id); // }else{ // $result_data = "ID Not Available. Unable to Delete"; // } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = $result_data ; - $this->response($data,REST_Controller::HTTP_OK); + $data['msg'] = $result_data; + $this->response($data, REST_Controller::HTTP_OK); } function updateTwlioVideoStatus_post() { $pd_id = $this->post('pd_id'); - $random_string = $this->post('random_string'); - $room_id = $this->post('room_id'); + $random_string = $this->post('random_string'); + $room_id = $this->post('room_id'); $pd_category = $this->post('pd_category') ? $this->post('pd_category') : "1"; - - $result_data = $this->getTwiloVideoStatus($pd_id,$random_string,$room_id,$pd_category); - + + $result_data = $this->getTwiloVideoStatus($pd_id, $random_string, $room_id, $pd_category); + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - - + $this->response($data, REST_Controller::HTTP_OK); } - function getTwiloVideoStatus($pd_id,$random_string,$room_id = '',$pd_category) + function getTwiloVideoStatus($pd_id, $random_string, $room_id = '', $pd_category) { - $this->load->library('twlio'); + $this->load->library('twlio'); $result_data = 0; // $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;"; - if($pd_category == "1"){ - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string); - }else{ - $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $pd_id,'rand_string'=>$random_string),SALES_PD_DATA); + if ($pd_category == "1") { + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id, $random_string); + } else { + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type', 'isactive', 'rand_string as random_string', 'pd_branch_id'), array('sales_pd_id' => $pd_id, 'rand_string' => $random_string), SALES_PD_DATA); } - - $query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0 and pd_category = $pd_category";// and twilo_status = 'enqueued' and composition_id is not null;"; - if($room_id) - { - $query .=" and room_id = '$room_id'"; + + $query = "SELECT * FROM " . VIDEO_ROOM_INFO . " where fk_pd_id = $pd_id and isactive = 1 and is_uploaded = 0 and pd_category = $pd_category"; // and twilo_status = 'enqueued' and composition_id is not null;"; + if ($room_id) { + $query .= " and room_id = '$room_id'"; } $video_info = $this->db->query($query); - if($video_info->num_rows()) - { + if ($video_info->num_rows()) { $video_info = $video_info->result_array(); - - foreach ($video_info as $key => $value) - { - - if($value['composition_id'] && $value['vsp'] != 'google') - { - $res = $this->twlio->getCompositionStatus($value['composition_id']); - - if(count($res) && $res['status'] == 'completed') - { - - $is_copied = $this->copyMediaFromTwiloToS3($pd_master_details,$value,$pd_category);// copy media from twlio s3 to our s3 - $fields_to_update = array('twilo_status' => 'completed'); - if($is_copied) { $fields_to_update['s3_copied'] = 1; } - $id = $this->PD_Model->updateRecords($fields_to_update,VIDEO_ROOM_INFO,array('video_room_info_id' => $value['video_room_info_id'])); - - if($id){ if($room_id) {$result_data = $is_copied;}else{$result_data++ ;}} + foreach ($video_info as $key => $value) { + + if ($value['composition_id'] && $value['vsp'] != 'google') { + $res = $this->twlio->getCompositionStatus($value['composition_id']); + + if (count($res) && $res['status'] == 'completed') { + + $is_copied = $this->copyMediaFromTwiloToS3($pd_master_details, $value, $pd_category); // copy media from twlio s3 to our s3 + $fields_to_update = array('twilo_status' => 'completed'); + if ($is_copied) { + $fields_to_update['s3_copied'] = 1; + } + $id = $this->PD_Model->updateRecords($fields_to_update, VIDEO_ROOM_INFO, array('video_room_info_id' => $value['video_room_info_id'])); + + if ($id) { + if ($room_id) { + $result_data = $is_copied; + } else { + $result_data++; + } + } } - } - else - { - $room_status = $this->twlio->getRoomDataByRoomID($value['room_id']); - if($room_status == 'completed') - { - $composition_result_data = $this->twlio->startComposistion($value['room_id']); + } else { + $room_status = $this->twlio->getRoomDataByRoomID($value['room_id']); + if ($room_status == 'completed') { + $composition_result_data = $this->twlio->startComposistion($value['room_id']); // $composition_result_data = $this->twlio->startComposistion('RM23b8d502434e46e696d1fbd5d64c59c8'); // print_r($composition_result_data); $composition_result_data_json = json_encode($composition_result_data); @@ -10300,55 +9001,54 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records['composition_id'] = $composition_result_data['compositionId']; $records['is_call_ended'] = 1; $where_condition_array = array('fk_pd_id' => $pd_id); - if($value['room_id']){ $where_condition_array['room_id'] = $value['room_id']; } - $id = $this->PD_Model->updateRecords($records,VIDEO_ROOM_INFO,$where_condition_array); + if ($value['room_id']) { + $where_condition_array['room_id'] = $value['room_id']; + } + $id = $this->PD_Model->updateRecords($records, VIDEO_ROOM_INFO, $where_condition_array); } - } - + } } - } return $result_data; } - function copyMediaFromTwiloToS3($pd_master_details,$value,$pd_catgory)// copy media from twlio s3 to our s3 + function copyMediaFromTwiloToS3($pd_master_details, $value, $pd_catgory) // copy media from twlio s3 to our s3 { EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id']); - //get media uri from twlio - $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); - //echo $singed_uri; - $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports" ; + //get media uri from twlio + $singed_uri = $this->twlio->compositionVideoFile($value['composition_id']); + //echo $singed_uri; + $file_folder = $pd_catgory == "2" ? "sales_pd" : "pd_reports"; $lender_id = $pd_master_details[0]['fk_lender_id']; - $internal_server_tmp_location = XLPATH.'/'.$file_folder.'/'.$pd_master_details[0]['pd_id'].'/videos'; - if($pd_catgory == "2"){ - EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id'],$internal_server_tmp_location); - } - $internal_server_tmp_location_filename = ($internal_server_tmp_location.'/'.$value['composition_id'].'.mp4'); - if(!file_exists($internal_server_tmp_location)){ mkdir($internal_server_tmp_location,0777); }; - $is_writed = file_put_contents($internal_server_tmp_location_filename,file_get_contents($singed_uri)); - //upload it to aws s3 - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; - $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$value['composition_id'].'.mp4'; - - $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($internal_server_tmp_location_filename)); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###TWLIO TO S3 STARTED'.$value['composition_id']); - - unlink($internal_server_tmp_location_filename); - return $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+7 days'); - //unlink($folder_to_check.'/'.$final_video_name.'.mp4'); - } - return null; + $internal_server_tmp_location = XLPATH . '/' . $file_folder . '/' . $pd_master_details[0]['pd_id'] . '/videos'; + if ($pd_catgory == "2") { + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_master_details[0]['pd_id'], $internal_server_tmp_location); + } + $internal_server_tmp_location_filename = ($internal_server_tmp_location . '/' . $value['composition_id'] . '.mp4'); + if (!file_exists($internal_server_tmp_location)) { + mkdir($internal_server_tmp_location, 0777); + }; + $is_writed = file_put_contents($internal_server_tmp_location_filename, file_get_contents($singed_uri)); + //upload it to aws s3 + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $lender_id; + $final_key = 'pd' . $pd_master_details[0]['pd_id'] . '/video/' . $value['composition_id'] . '.mp4'; + $bucket_data = array('bucket_name' => $bucket_name, 'key' => $final_key, 'sourcefile' => ($internal_server_tmp_location_filename)); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', '###TWLIO TO S3 STARTED' . $value['composition_id']); + unlink($internal_server_tmp_location_filename); + return $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $final_key, '+7 days'); + //unlink($folder_to_check.'/'.$final_video_name.'.mp4'); + } + return null; } - function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key,$pd_category) + function mergeVideo($pd_id, $pd_master_details, $final_video_name, $video_key, $pd_category) { - $pd_category = $pd_category ? $pd_category : "1"; - $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; + $pd_category = $pd_category ? $pd_category : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports"; // $pd_id = $this->post('pd_id'); // $random_string = $this->post('random_string'); //$final_video_name = $pd_id.'-'.$random_string; @@ -10361,84 +9061,70 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // if(count($pd_master_details) && isset($pd_master_details[0]['pd_id'])) // { - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$final_video_name.'.mp4'; - - //Get all video info - $qu = "SELECT *,convert(substr(substring_index(video_part_name,'-',1),6),UNSIGNED INTEGER) as sno FROM sineedgedemo.t_cus_video + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + $final_key = 'pd' . $pd_master_details[0]['pd_id'] . '/video/' . $final_video_name . '.mp4'; + + //Get all video info + $qu = "SELECT *,convert(substr(substring_index(video_part_name,'-',1),6),UNSIGNED INTEGER) as sno FROM sineedgedemo.t_cus_video where fk_pd_id = $pd_id and video_key = '$video_key' and is_active = 1 order by sno"; - $video_info = $this->db->query($qu)->result_array(); - $folder_to_check = XLPATH.'/'.$file_folder.'/'.$pd_id.'/videos'; - $file_list = $folder_to_check.'/filelist.txt'; - - //Get All video and temp store it in xlpath - $file_pointer = fopen($file_list, 'w+'); - $all_input_files_names_with_path = ''; - foreach ($video_info as $video_info_key => $video_info_value) - { - $key = 'pd'.$pd_id.'/video/'.$video_info_value['video_part_name']; - $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'+10 minutes'); - $file_to_create = $folder_to_check.'/'.$video_info_value['video_part_name']; - $output = file_put_contents($file_to_create,file_get_contents($temp_uri)); - if($output) - { + $video_info = $this->db->query($qu)->result_array(); + $folder_to_check = XLPATH . '/' . $file_folder . '/' . $pd_id . '/videos'; + $file_list = $folder_to_check . '/filelist.txt'; - $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; - - //fwrite($file_pointer,"file "."'".$file_name_wo_extension.".mp4"."'\n"); - fwrite($file_pointer,"file "."'".$file_name_wo_extension."'\n"); - } - } - fclose($file_pointer); - // echo '***************************************';//die(); - - $merge_cmd = FFMPEG_PATH.' -f concat -safe 0 -i '.$folder_to_check.'/'.'filelist.txt -c copy '.$folder_to_check.'/'.$final_video_name.'.mp4 2>&1'; - //echo '#########################################'; - //echo $merge_cmd;//die(); - exec($merge_cmd,$ou,$v); - //print_r($ou);//die(); - if($ou && file_exists($folder_to_check.'/'.$final_video_name.'.mp4')) - { - //echo 'upload to s3'; - $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$final_key,'sourcefile'=>($folder_to_check.'/'.$final_video_name.'.mp4')); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###PDVIDEO merged video stored in S3'.$pd_id); - $record_data = array('is_video_merged' => 1); - $id = $this->PD_Model->updateRecords($record_data,PDTRIGGER,array('pd_id' => $pd_id)); - unlink($folder_to_check.'/'.$final_video_name.'.mp4'); - - } + //Get All video and temp store it in xlpath + $file_pointer = fopen($file_list, 'w+'); + $all_input_files_names_with_path = ''; + foreach ($video_info as $video_info_key => $video_info_value) { + $key = 'pd' . $pd_id . '/video/' . $video_info_value['video_part_name']; + $temp_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $key, '+10 minutes'); + $file_to_create = $folder_to_check . '/' . $video_info_value['video_part_name']; + $output = file_put_contents($file_to_create, file_get_contents($temp_uri)); + if ($output) { - foreach($video_info as $video_info_key => $video_info_value) - { - $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; - //unlink($folder_to_check.'/'.$file_name_wo_extension.'.ts'); - unlink($folder_to_check.'/'.$file_name_wo_extension); - } + $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; + + //fwrite($file_pointer,"file "."'".$file_name_wo_extension.".mp4"."'\n"); + fwrite($file_pointer, "file " . "'" . $file_name_wo_extension . "'\n"); + } + } + fclose($file_pointer); + // echo '***************************************';//die(); + + $merge_cmd = FFMPEG_PATH . ' -f concat -safe 0 -i ' . $folder_to_check . '/' . 'filelist.txt -c copy ' . $folder_to_check . '/' . $final_video_name . '.mp4 2>&1'; + //echo '#########################################'; + //echo $merge_cmd;//die(); + exec($merge_cmd, $ou, $v); + //print_r($ou);//die(); + if ($ou && file_exists($folder_to_check . '/' . $final_video_name . '.mp4')) { + //echo 'upload to s3'; + $bucket_data = array('bucket_name' => $bucket_name, 'key' => $final_key, 'sourcefile' => ($folder_to_check . '/' . $final_video_name . '.mp4')); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', '###PDVIDEO merged video stored in S3' . $pd_id); + $record_data = array('is_video_merged' => 1); + $id = $this->PD_Model->updateRecords($record_data, PDTRIGGER, array('pd_id' => $pd_id)); + unlink($folder_to_check . '/' . $final_video_name . '.mp4'); + } + + foreach ($video_info as $video_info_key => $video_info_value) { + $file_name_wo_extension = explode('.', ($video_info_value['video_part_name']))[0]; + //unlink($folder_to_check.'/'.$file_name_wo_extension.'.ts'); + unlink($folder_to_check . '/' . $file_name_wo_extension); + } - // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); - // $data['dataStatus'] = true; - // $data['status'] = REST_Controller::HTTP_OK; - // $data['url'] = $singed_uri; - // $this->response($data,REST_Controller::HTTP_OK); + // $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+3 hrs'); + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['url'] = $singed_uri; + // $this->response($data,REST_Controller::HTTP_OK); - } - else - { - log_message('ERROR','###PDVIDEO merged video not stored in S3'.$pd_id); - } - - - - - - - } + } else { + log_message('ERROR', '###PDVIDEO merged video not stored in S3' . $pd_id); + } + } //make duplicate of a exist pd public function duplicatePD_post() @@ -10451,372 +9137,322 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $applicants_ids_array = array(); $docs_to_be_uploads_ids_array = array(); $add_req_ids_array = array(); - $form_ids_to_replace_new_co_applicants_id = array(18,4,6,7,8,9,10,13,17,19,21,22); - - $logger = MYLOG::logFunction(null,$pdid); - $logger->info("duplicatePD_post called: ".$pdid,array('ENV'=>ENVIRONMENT,'DATA' => $lender_applicant_id)); + $form_ids_to_replace_new_co_applicants_id = array(18, 4, 6, 7, 8, 9, 10, 13, 17, 19, 21, 22); + + $logger = MYLOG::logFunction(null, $pdid); + $logger->info("duplicatePD_post called: " . $pdid, array('ENV' => ENVIRONMENT, 'DATA' => $lender_applicant_id)); // Get All PD Masters Details - log_message('ERROR','####duplicatePD_post called:-'.$pdid.'-'.$lender_applicant_id); - $pd_fields = array('fk_lender_id', 'sub_entity_id', 'imgc_fin_institute', 'fk_entity_billing_id','fk_product_id', 'fk_subproduct_id', 'fk_pd_type','fk_pd_template_id', 'fk_customer_segment','loan_amount', 'addressline1', 'fk_city', 'fk_state', 'pincode','lender_sales_person', 'lender_credit_person', 'pd_contact_person', 'pd_contact_mobileno', 'pd_contact_person_mail','pd_branch_id', 'pd_contact_landline','other_pincode','is_notify_enabled'); - $pd_master_details = $this->PD_Model->selectCustomRecords($pd_fields,array('pd_id' => $pdid),PDTRIGGER); + log_message('ERROR', '####duplicatePD_post called:-' . $pdid . '-' . $lender_applicant_id); + $pd_fields = array('fk_lender_id', 'sub_entity_id', 'imgc_fin_institute', 'fk_entity_billing_id', 'fk_product_id', 'fk_subproduct_id', 'fk_pd_type', 'fk_pd_template_id', 'fk_customer_segment', 'loan_amount', 'addressline1', 'fk_city', 'fk_state', 'pincode', 'lender_sales_person', 'lender_credit_person', 'pd_contact_person', 'pd_contact_mobileno', 'pd_contact_person_mail', 'pd_branch_id', 'pd_contact_landline', 'other_pincode', 'is_notify_enabled'); + $pd_master_details = $this->PD_Model->selectCustomRecords($pd_fields, array('pd_id' => $pdid), PDTRIGGER); - if(count($pd_master_details)) - { + if (count($pd_master_details)) { $pd_master_details = $pd_master_details[0]; $pd_master_details['lender_applicant_id'] = $lender_applicant_id; $pd_master_details['pd_date_of_initiation'] = date('Y-m-d H-i-s'); //$pd_master_details['pd_date_of_initiation'] = '2020-07-07 12:24:00'; $pd_master_details['createdon'] = date('Y-m-d H-i-s'); $pd_master_details['pd_status'] = 'TRIGGERED'; - + $pd_master_details['fk_createdby'] = $fk_createdby; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomIter = rand(0, 15); - for ($i = 0; $i < 16; $i++) - { + for ($i = 0; $i < 16; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; - if($i == $randomIter){$randomString .= 'cc';} + if ($i == $randomIter) { + $randomString .= 'cc'; + } } $pd_master_details['random_string'] = $randomString; - $url = OFFICER_TRACKING_URL.$randomString; + $url = OFFICER_TRACKING_URL . $randomString; $pd_master_details['encrypted_url'] = $url; //print_r($pd_master_details); - $new_pd_id = $this->PD_Model->saveRecords($pd_master_details,PDTRIGGER); - log_message('ERROR','####NEW PD Trigged by dup funciton:-'.$new_pd_id); + $new_pd_id = $this->PD_Model->saveRecords($pd_master_details, PDTRIGGER); + log_message('ERROR', '####NEW PD Trigged by dup funciton:-' . $new_pd_id); } - //Get All Applicant's Details - $applicants_details = $this->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name', 'applicant_type', 'mobile_no','relation', 'company_name', 'applicant_title_name','landline'),array('fk_pd_id' => $pdid),PDAPPLICANTSDETAILS); + //Get All Applicant's Details + $applicants_details = $this->PD_Model->selectCustomRecords(array('pd_co_applicant_id', 'applicant_name', 'applicant_type', 'mobile_no', 'relation', 'company_name', 'applicant_title_name', 'landline'), array('fk_pd_id' => $pdid), PDAPPLICANTSDETAILS); - //print_r($applicants_details); - if($new_pd_id && count($applicants_details)) - { - log_message('ERROR','####Copying Applicants started:-'.$new_pd_id); - foreach ($applicants_details as $key => $value) - { - $current_applicant_id = $value['pd_co_applicant_id'];unset($value['pd_co_applicant_id']); - $value['fk_pd_id'] = $new_pd_id; - $new_applicant_id = $this->PD_Model->saveRecords($value,PDAPPLICANTSDETAILS); - //$new_applicant_id = $current_applicant_id + 10; - $applicants_ids_array[$current_applicant_id] = $new_applicant_id; - //print_r($value); - } - log_message('ERROR','####Copying Applicants end:-'.$new_pd_id); + //print_r($applicants_details); + if ($new_pd_id && count($applicants_details)) { + log_message('ERROR', '####Copying Applicants started:-' . $new_pd_id); + foreach ($applicants_details as $key => $value) { + $current_applicant_id = $value['pd_co_applicant_id']; + unset($value['pd_co_applicant_id']); + $value['fk_pd_id'] = $new_pd_id; + $new_applicant_id = $this->PD_Model->saveRecords($value, PDAPPLICANTSDETAILS); + //$new_applicant_id = $current_applicant_id + 10; + $applicants_ids_array[$current_applicant_id] = $new_applicant_id; + //print_r($value); } + log_message('ERROR', '####Copying Applicants end:-' . $new_pd_id); + } - - //Get All PD Related Documents - // $pd_documnets = $this->PD_Model->selectCustomRecords(array('fk_pd_id','fk_form_id', 'co_applicant_id', 'img_type', 'pd_document_title', 'pd_document_name','company_id', 'is_show_report', 'rental_count_id','location', 'isactive'),array('isactive' => 1,'fk_pd_type' => $pdid),PDDOCUMENTS); - // if(!$new_pd_id && count($applicants_details)) - // { - // log_message('ERROR','####Copying ALl Images started:-'.$new_pd_id); - // foreach ($pd_documnets as $key => $value) - // { - // $value['fk_pd_id'] = $new_pd_id; - // $this->PD_Model->saveRecords($value,PDDOCUMENTS); - // //print_r($value); - // } - // log_message('ERROR','####Copying All Images END:-'.$new_pd_id); - // // log_message('ERROR','####Copying S3 started:-'.$new_pd_id); - - // // log_message('ERROR','####Copying S3 END:-'.$new_pd_id); - // } + //Get All PD Related Documents + // $pd_documnets = $this->PD_Model->selectCustomRecords(array('fk_pd_id','fk_form_id', 'co_applicant_id', 'img_type', 'pd_document_title', 'pd_document_name','company_id', 'is_show_report', 'rental_count_id','location', 'isactive'),array('isactive' => 1,'fk_pd_type' => $pdid),PDDOCUMENTS); + // if(!$new_pd_id && count($applicants_details)) + // { + // log_message('ERROR','####Copying ALl Images started:-'.$new_pd_id); + // foreach ($pd_documnets as $key => $value) + // { + // $value['fk_pd_id'] = $new_pd_id; + // $this->PD_Model->saveRecords($value,PDDOCUMENTS); + // //print_r($value); + // } + // log_message('ERROR','####Copying All Images END:-'.$new_pd_id); - - - //Get All PD Address - $pd_address = $this->PD_Model->selectCustomRecords(array('addressline1', 'fk_city', 'fk_state', 'pincode', 'isactive', 'is_visited','other_pincode', 'is_primary'),array('isactive' => 1,'fk_pd_id' => $pdid),PDADDRESS); - if($new_pd_id && count($pd_address)) - { - log_message('ERROR','####Copying address started:-'.$new_pd_id); - foreach ($pd_address as $key => $value) - { - $value['fk_pd_id'] = $new_pd_id; - $value['assigned_pd'] = $new_pd_id; - $address_id = $this->PD_Model->saveRecords($value,PDADDRESS); - //print_r($value); - } - log_message('ERROR','####Copying address end:-'.$new_pd_id); + // // log_message('ERROR','####Copying S3 started:-'.$new_pd_id); + + // // log_message('ERROR','####Copying S3 END:-'.$new_pd_id); + // } + + + + //Get All PD Address + $pd_address = $this->PD_Model->selectCustomRecords(array('addressline1', 'fk_city', 'fk_state', 'pincode', 'isactive', 'is_visited', 'other_pincode', 'is_primary'), array('isactive' => 1, 'fk_pd_id' => $pdid), PDADDRESS); + if ($new_pd_id && count($pd_address)) { + log_message('ERROR', '####Copying address started:-' . $new_pd_id); + foreach ($pd_address as $key => $value) { + $value['fk_pd_id'] = $new_pd_id; + $value['assigned_pd'] = $new_pd_id; + $address_id = $this->PD_Model->saveRecords($value, PDADDRESS); + //print_r($value); } - - //Get Addtional Requirements details - $pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_req_id','add_requirement','isactive'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDADDTIONALREQUIREMENTS); - if($new_pd_id && count($pd_additional_requirements)) - { - log_message('ERROR','####Copying Additional Req started:-'.$new_pd_id); - foreach ($pd_additional_requirements as $key => $value) - { - $current_add_req_id = $value['add_req_id'];unset($value['add_req_id']); - $value['fk_pd_id'] = $new_pd_id; - $new_add_req_id = $this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS); - //print_r($value); - //$new_add_req_id = $current_add_req_id + 100; - $add_req_ids_array[$current_add_req_id] = $new_add_req_id; - } - log_message('ERROR','####Copying Addtional Req end:-'.$new_pd_id); + log_message('ERROR', '####Copying address end:-' . $new_pd_id); + } + + //Get Addtional Requirements details + $pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_req_id', 'add_requirement', 'isactive'), array('isactive' => 1, 'fk_pd_id' => $pdid), PDADDTIONALREQUIREMENTS); + if ($new_pd_id && count($pd_additional_requirements)) { + log_message('ERROR', '####Copying Additional Req started:-' . $new_pd_id); + foreach ($pd_additional_requirements as $key => $value) { + $current_add_req_id = $value['add_req_id']; + unset($value['add_req_id']); + $value['fk_pd_id'] = $new_pd_id; + $new_add_req_id = $this->PD_Model->saveRecords($value, PDADDTIONALREQUIREMENTS); + //print_r($value); + //$new_add_req_id = $current_add_req_id + 100; + $add_req_ids_array[$current_add_req_id] = $new_add_req_id; } - - - //Get Docs to be collected array - $docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('pd_doc_to_be_collect_id','doc_name'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDDOCSTOBECOLLECTED); - if($new_pd_id && count($docs_to_be_collected)) - { - log_message('ERROR','####Copying Docs to be collected started:-'.$new_pd_id); - foreach ($docs_to_be_collected as $key => $value) - { - $current_doc_id = $value['pd_doc_to_be_collect_id'];unset($value['pd_doc_to_be_collect_id']); - $value['fk_pd_id'] = $new_pd_id; - $new_doc_id = $this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED); - //print_r($value); - //$new_doc_id = $current_doc_id + 100; - $docs_to_be_uploads_ids_array[$current_doc_id] = $new_doc_id; - } - log_message('ERROR','####Copying Docs to be collected end:-'.$new_pd_id); + log_message('ERROR', '####Copying Addtional Req end:-' . $new_pd_id); + } + + + //Get Docs to be collected array + $docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('pd_doc_to_be_collect_id', 'doc_name'), array('isactive' => 1, 'fk_pd_id' => $pdid), PDDOCSTOBECOLLECTED); + if ($new_pd_id && count($docs_to_be_collected)) { + log_message('ERROR', '####Copying Docs to be collected started:-' . $new_pd_id); + foreach ($docs_to_be_collected as $key => $value) { + $current_doc_id = $value['pd_doc_to_be_collect_id']; + unset($value['pd_doc_to_be_collect_id']); + $value['fk_pd_id'] = $new_pd_id; + $new_doc_id = $this->PD_Model->saveRecords($value, PDDOCSTOBECOLLECTED); + //print_r($value); + //$new_doc_id = $current_doc_id + 100; + $docs_to_be_uploads_ids_array[$current_doc_id] = $new_doc_id; } - - - //Get all JSON - $json_data = $this->PD_Model->getAllJSONFormData($pdid); - if($new_pd_id && count($json_data)) - { + log_message('ERROR', '####Copying Docs to be collected end:-' . $new_pd_id); + } - log_message('ERROR','####Copying All JSON Data started:-'.$new_pd_id); - foreach ($json_data as $key => $value) - { - $value['fk_pd_id'] = $new_pd_id; - - if(in_array($value['fk_form_id'], $form_ids_to_replace_new_co_applicants_id)) - { - $current_form_string = ($value['json']); - foreach ($applicants_ids_array as $old_value => $new_value) - { - $current_form_string = str_replace( $old_value, $new_value, $current_form_string); - } + //Get all JSON + $json_data = $this->PD_Model->getAllJSONFormData($pdid); + if ($new_pd_id && count($json_data)) { - //replace pd id - $current_form_string = str_replace( $pdid, $new_pd_id, $current_form_string); - $value['json'] = $current_form_string; - + log_message('ERROR', '####Copying All JSON Data started:-' . $new_pd_id); + foreach ($json_data as $key => $value) { + + $value['fk_pd_id'] = $new_pd_id; + + if (in_array($value['fk_form_id'], $form_ids_to_replace_new_co_applicants_id)) { + $current_form_string = ($value['json']); + foreach ($applicants_ids_array as $old_value => $new_value) { + $current_form_string = str_replace($old_value, $new_value, $current_form_string); } - if($value['fk_form_id'] == 24)//credit managers query form - { - - $current_form_string = ($value['json']); - //print_r($gen_form_string); - // - foreach ($docs_to_be_uploads_ids_array as $old_value => $new_value) - { - $current_form_string = str_replace( $old_value, $new_value, $current_form_string); - } - foreach ($add_req_ids_array as $old_value => $new_value) - { - $current_form_string = str_replace( $old_value, $new_value, $current_form_string); - } - - - $current_form_string = str_replace( $pdid, $new_pd_id, $current_form_string); - $value['json'] = $current_form_string; - - } - - //replace old img string from gen & busi forms - if($value['fk_form_id'] == 18 || $value['fk_form_id'] == 13 || $value['fk_form_id'] == 24) - { - //print_r($value); - $value = $this->emptyImgStringsInsideJSON($value); - //print_r($value); - } - - //die(); - $this->PD_Model->saveRecords($value,PDFORMDETAILSJSON); - + //replace pd id + $current_form_string = str_replace($pdid, $new_pd_id, $current_form_string); + $value['json'] = $current_form_string; } - log_message('ERROR','####Copying ALL JSON END:-'.$new_pd_id); + + if ($value['fk_form_id'] == 24) //credit managers query form + { + + $current_form_string = ($value['json']); + //print_r($gen_form_string); + // + foreach ($docs_to_be_uploads_ids_array as $old_value => $new_value) { + $current_form_string = str_replace($old_value, $new_value, $current_form_string); + } + foreach ($add_req_ids_array as $old_value => $new_value) { + $current_form_string = str_replace($old_value, $new_value, $current_form_string); + } + + + $current_form_string = str_replace($pdid, $new_pd_id, $current_form_string); + $value['json'] = $current_form_string; + } + + //replace old img string from gen & busi forms + if ($value['fk_form_id'] == 18 || $value['fk_form_id'] == 13 || $value['fk_form_id'] == 24) { + //print_r($value); + $value = $this->emptyImgStringsInsideJSON($value); + //print_r($value); + } + + //die(); + $this->PD_Model->saveRecords($value, PDFORMDETAILSJSON); } - // die(); - //copy Assessed Income Tables - if($pd_master_details['fk_customer_segment'] == 4 && $new_pd_id)//AI - { - - $this->dupAssessedIncomeInfo($pdid,$new_pd_id,$fk_createdby); - } - - + log_message('ERROR', '####Copying ALL JSON END:-' . $new_pd_id); + } + // die(); + //copy Assessed Income Tables + if ($pd_master_details['fk_customer_segment'] == 4 && $new_pd_id) //AI + { + + $this->dupAssessedIncomeInfo($pdid, $new_pd_id, $fk_createdby); + } + + //copy all s3 into new pd folder - if($new_pd_id) - { + if ($new_pd_id) { //update some master info - $this->PD_Model->updateRecords(array('parent_pd_id' => $new_pd_id,'fk_primary_address_id' => $address_id,'fk_address_id' => $address_id,'dupof' => $pdid),PDTRIGGER,array('pd_id' => $new_pd_id)); - log_message('ERROR','####UPDATE PD:-'.$new_pd_id); - $logger->info("NEW PD Trigged by dup funciton : ".$new_pd_id,array('ENV'=>ENVIRONMENT)); - PDALERTS::pdnotification($new_pd_id); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $new_pd_id; - $this->response($data,REST_Controller::HTTP_OK); + $this->PD_Model->updateRecords(array('parent_pd_id' => $new_pd_id, 'fk_primary_address_id' => $address_id, 'fk_address_id' => $address_id, 'dupof' => $pdid), PDTRIGGER, array('pd_id' => $new_pd_id)); + log_message('ERROR', '####UPDATE PD:-' . $new_pd_id); + $logger->info("NEW PD Trigged by dup funciton : " . $new_pd_id, array('ENV' => ENVIRONMENT)); + PDALERTS::pdnotification($new_pd_id); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $new_pd_id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - - - } function emptyImgStringsInsideJSON($value) { - - if($value['fk_form_id'] == 18) - { - $temp_json = (json_decode($value['json'],true)); - if(isset($temp_json['individuals']) && count($temp_json['individuals'])) - { - foreach ($temp_json['individuals'] as $tj_key => $tj_value) - { - if($tj_value['is_applicant'] == 1) - { + + if ($value['fk_form_id'] == 18) { + $temp_json = (json_decode($value['json'], true)); + if (isset($temp_json['individuals']) && count($temp_json['individuals'])) { + foreach ($temp_json['individuals'] as $tj_key => $tj_value) { + if ($tj_value['is_applicant'] == 1) { $temp_json['individuals'][$tj_key]['is_person_met_pic'] = ''; $temp_json['individuals'][$tj_key]['is_person_met_id_proof'] = ''; } } } $value['json'] = json_encode($temp_json); - } - if($value['fk_form_id'] == 24) - { - $temp_json = (json_decode($value['json'],true)); + if ($value['fk_form_id'] == 24) { + $temp_json = (json_decode($value['json'], true)); //print_r($temp_json);//die(); - if(isset($temp_json['docs_to_be_sighted']) && count($temp_json['docs_to_be_sighted'])) - { - foreach ($temp_json['docs_to_be_sighted'] as $dskey => $ds_value) - { - if(isset($ds_value['img'])) - { - $temp_json['docs_to_be_sighted'][$dskey]['img'] = ''; + if (isset($temp_json['docs_to_be_sighted']) && count($temp_json['docs_to_be_sighted'])) { + foreach ($temp_json['docs_to_be_sighted'] as $dskey => $ds_value) { + if (isset($ds_value['img'])) { + $temp_json['docs_to_be_sighted'][$dskey]['img'] = ''; } } } //print_r($temp_json); $value['json'] = json_encode($temp_json); } - - if($value['fk_form_id'] == 13) - { - $temp_json = (json_decode($value['json'],true)); - if(isset($temp_json['shop_eat_act_cert_pic'])) - { - $temp_json['shop_eat_act_cert_pic'] = ""; - } - if(isset($temp_json['practice_cert_pic'])) - { - $temp_json['practice_cert_pic'] = ""; - } - if(isset($temp_json['gst_Regn_cert_pic'])) - { - $temp_json['gst_Regn_cert_pic'] = ''; - } - if(isset($temp_json['pf_regn_pic'])) - { - $temp_json['pf_regn_pic'] =''; - } - if(isset($temp_json['esic_regn_pic'])) - { - $temp_json['esic_regn_pic'] = ''; - } - if(isset($temp_json['export_import_cert_pic'])) - { - $temp_json['export_import_cert_pic'] = ''; - } - if(isset($temp_json['factory_cert_pic'])) - { - $temp_json['factory_cert_pic'] = ''; - } - if(isset($temp_json['practice_cert_pic'])) - { - $temp_json['practice_cert_pic'] = ''; - } - if(isset($temp_json['fire_noc_pic'] )) - { - $temp_json['fire_noc_pic'] = ''; - } - if(isset($temp_json['eb_bill_pic'])) - { - $temp_json['eb_bill_pic'] = ''; - } - - if(isset($temp_json['documents']) && count($temp_json['documents'])) - { - $temp_iter = $temp_json['documents']; - - foreach ($temp_iter as $tikey => $itvalue) - { - $temp_json['documents'][$tikey]['document_pic'] = ''; - } - } - - $value['json'] = json_encode($temp_json); + if ($value['fk_form_id'] == 13) { + $temp_json = (json_decode($value['json'], true)); + if (isset($temp_json['shop_eat_act_cert_pic'])) { + $temp_json['shop_eat_act_cert_pic'] = ""; + } + if (isset($temp_json['practice_cert_pic'])) { + $temp_json['practice_cert_pic'] = ""; + } + if (isset($temp_json['gst_Regn_cert_pic'])) { + $temp_json['gst_Regn_cert_pic'] = ''; + } + if (isset($temp_json['pf_regn_pic'])) { + $temp_json['pf_regn_pic'] = ''; + } + if (isset($temp_json['esic_regn_pic'])) { + $temp_json['esic_regn_pic'] = ''; + } + if (isset($temp_json['export_import_cert_pic'])) { + $temp_json['export_import_cert_pic'] = ''; + } + if (isset($temp_json['factory_cert_pic'])) { + $temp_json['factory_cert_pic'] = ''; + } + if (isset($temp_json['practice_cert_pic'])) { + $temp_json['practice_cert_pic'] = ''; + } + if (isset($temp_json['fire_noc_pic'])) { + $temp_json['fire_noc_pic'] = ''; + } + if (isset($temp_json['eb_bill_pic'])) { + $temp_json['eb_bill_pic'] = ''; + } - + + if (isset($temp_json['documents']) && count($temp_json['documents'])) { + $temp_iter = $temp_json['documents']; + + foreach ($temp_iter as $tikey => $itvalue) { + $temp_json['documents'][$tikey]['document_pic'] = ''; + } + } + + $value['json'] = json_encode($temp_json); } return $value; - //die(); + //die(); } - function dupAssessedIncomeInfo($pdid,$new_pd_id,$fk_createdby) + function dupAssessedIncomeInfo($pdid, $new_pd_id, $fk_createdby) { //$new_pd_id = 9999; //echo $pdid.'/'.$new_pd_id;//die(); - $grossprofittype = $this->PD_Model->selectCustomRecords(array('mode', 'margin','company_id', 'purchase_type'),array('fk_pd_id' => $pdid),PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); - - if(count($grossprofittype)) - { + $grossprofittype = $this->PD_Model->selectCustomRecords(array('mode', 'margin', 'company_id', 'purchase_type'), array('fk_pd_id' => $pdid), PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + + if (count($grossprofittype)) { $grossprofittype = $grossprofittype[0]; $grossprofittype['fk_createdby'] = $fk_createdby; $grossprofittype['fk_pd_id'] = $new_pd_id; //print_r($grossprofittype); - $this->PD_Model->saveRecords($grossprofittype,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + $this->PD_Model->saveRecords($grossprofittype, PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); } - $purchasedeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('purchase_declared_by_customer', 'comments','company_id'),array('fk_pd_id' => $pdid,'isactive' => 1),PURCHASEDECLAREDBYCUSTOMER); + $purchasedeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('purchase_declared_by_customer', 'comments', 'company_id'), array('fk_pd_id' => $pdid, 'isactive' => 1), PURCHASEDECLAREDBYCUSTOMER); - if(count($purchasedeclaredbycustomer)) - { + if (count($purchasedeclaredbycustomer)) { $purchasedeclaredbycustomer = $purchasedeclaredbycustomer[0]; $purchasedeclaredbycustomer['fk_pd_id'] = $new_pd_id; $purchasedeclaredbycustomer['fk_createdby'] = $fk_createdby; - $this->PD_Model->saveRecords($purchasedeclaredbycustomer,PURCHASEDECLAREDBYCUSTOMER); + $this->PD_Model->saveRecords($purchasedeclaredbycustomer, PURCHASEDECLAREDBYCUSTOMER); //print_r($purchasedeclaredbycustomer); } - $salesdeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('sales_declared_by_customer', 'margin_per','company_id','margin_value','comments'),array('fk_pd_id' => $pdid,'isactive' => 1),SALESDECLAREDBYCUSTOMER); + $salesdeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('sales_declared_by_customer', 'margin_per', 'company_id', 'margin_value', 'comments'), array('fk_pd_id' => $pdid, 'isactive' => 1), SALESDECLAREDBYCUSTOMER); - if(count($salesdeclaredbycustomer)) - { + if (count($salesdeclaredbycustomer)) { $salesdeclaredbycustomer = $salesdeclaredbycustomer[0]; $salesdeclaredbycustomer['fk_pd_id'] = $new_pd_id; $salesdeclaredbycustomer['fk_createdby'] = $fk_createdby; - $this->PD_Model->saveRecords($salesdeclaredbycustomer,SALESDECLAREDBYCUSTOMER); + $this->PD_Model->saveRecords($salesdeclaredbycustomer, SALESDECLAREDBYCUSTOMER); //print_r($salesdeclaredbycustomer); } @@ -10832,59 +9468,51 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // } - $pdhouseholdexpenses = $this->PD_Model->selectCustomRecords(array('expense_item', 'expense_value','fk_frequency_id','annual_expense_value','comments','company_id'),array('fk_pd_id' => $pdid,'isactive' => 1),PDHOUSEHOLDEXPENSES); + $pdhouseholdexpenses = $this->PD_Model->selectCustomRecords(array('expense_item', 'expense_value', 'fk_frequency_id', 'annual_expense_value', 'comments', 'company_id'), array('fk_pd_id' => $pdid, 'isactive' => 1), PDHOUSEHOLDEXPENSES); + + if (count($pdhouseholdexpenses)) { + + foreach ($pdhouseholdexpenses as $key => $value) { - if(count($pdhouseholdexpenses)) - { - - foreach ($pdhouseholdexpenses as $key => $value) - { - $value['fk_pd_id'] = $new_pd_id; $value['fk_createdby'] = $fk_createdby; - $this->PD_Model->saveRecords($value,PDHOUSEHOLDEXPENSES); + $this->PD_Model->saveRecords($value, PDHOUSEHOLDEXPENSES); //print_r($value); } } - $pdbusinessexpenses = $this->PD_Model->selectCustomRecords(array('expense_item_id', 'expense_value','fk_frequency_id','annual_expenses_value','comments','company_id','other_expense_item'),array('fk_pd_id' => $pdid,'isactive' => 1),PDBUSINESSEXPENSES); + $pdbusinessexpenses = $this->PD_Model->selectCustomRecords(array('expense_item_id', 'expense_value', 'fk_frequency_id', 'annual_expenses_value', 'comments', 'company_id', 'other_expense_item'), array('fk_pd_id' => $pdid, 'isactive' => 1), PDBUSINESSEXPENSES); + + if (count($pdbusinessexpenses)) { + + foreach ($pdbusinessexpenses as $key => $value) { - if(count($pdbusinessexpenses)) - { - - foreach ($pdbusinessexpenses as $key => $value) - { - $value['fk_pd_id'] = $new_pd_id; $value['fk_createdby'] = $fk_createdby; - $this->PD_Model->saveRecords($value,PDBUSINESSEXPENSES); + $this->PD_Model->saveRecords($value, PDBUSINESSEXPENSES); //print_r($value); } } //sales itemwise - $salescalculatedbyitemwise = $this->PD_Model->selectCustomRecords(array('sci_id','sales_item','sales_qty','fk_uom_id','rate_per_unit', 'fk_frequency_id','annual_sale_value','margin_per','margin_per_uom','margin_final_value','company_id', 'uom_other', 'comments', 'sales_type', 'other_sales_item'),array('fk_pd_id' => $pdid,'isactive' => 1),SALESCALCULATEDBYITEMWISE); - - if(count($salescalculatedbyitemwise)) - { - foreach ($salescalculatedbyitemwise as $salescalculatedbyitemwise_key => $salescalculatedbyitemwise_value) - { - $pre_sci_id = $salescalculatedbyitemwise_value['sci_id']; unset($salescalculatedbyitemwise_value['sci_id']); + $salescalculatedbyitemwise = $this->PD_Model->selectCustomRecords(array('sci_id', 'sales_item', 'sales_qty', 'fk_uom_id', 'rate_per_unit', 'fk_frequency_id', 'annual_sale_value', 'margin_per', 'margin_per_uom', 'margin_final_value', 'company_id', 'uom_other', 'comments', 'sales_type', 'other_sales_item'), array('fk_pd_id' => $pdid, 'isactive' => 1), SALESCALCULATEDBYITEMWISE); + + if (count($salescalculatedbyitemwise)) { + foreach ($salescalculatedbyitemwise as $salescalculatedbyitemwise_key => $salescalculatedbyitemwise_value) { + $pre_sci_id = $salescalculatedbyitemwise_value['sci_id']; + unset($salescalculatedbyitemwise_value['sci_id']); $salescalculatedbyitemwise_value['fk_pd_id'] = $new_pd_id; $salescalculatedbyitemwise_value['fk_createdby'] = $fk_createdby; - $new_sci_id = $this->PD_Model->saveRecords($salescalculatedbyitemwise_value,SALESCALCULATEDBYITEMWISE); + $new_sci_id = $this->PD_Model->saveRecords($salescalculatedbyitemwise_value, SALESCALCULATEDBYITEMWISE); //get child values if any - if($salescalculatedbyitemwise_value['sales_type'] == 3) - { - $salesitemmonthwisechild = $this->PD_Model->selectCustomRecords(array('sales_date', 'sales_value','fk_frequency_id', 'frequency_value'),array('fk_sci_id' => $pre_sci_id,'isactive' => 1),SALESITEMMONTHWISECHILD); - - if(count($salesitemmonthwisechild)) - { - foreach ($salesitemmonthwisechild as $child_key => $child_value) - { + if ($salescalculatedbyitemwise_value['sales_type'] == 3) { + $salesitemmonthwisechild = $this->PD_Model->selectCustomRecords(array('sales_date', 'sales_value', 'fk_frequency_id', 'frequency_value'), array('fk_sci_id' => $pre_sci_id, 'isactive' => 1), SALESITEMMONTHWISECHILD); + + if (count($salesitemmonthwisechild)) { + foreach ($salesitemmonthwisechild as $child_key => $child_value) { $child_value['fk_sci_id'] = $new_sci_id; - $this->PD_Model->saveRecords($child_value,SALESITEMMONTHWISECHILD); + $this->PD_Model->saveRecords($child_value, SALESITEMMONTHWISECHILD); } } } @@ -10892,35 +9520,28 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() } //purchase details - $pdpurchasedetails = $this->PD_Model->selectCustomRecords(array('purchase_id','purchase_item','purchase_qty', 'fk_uom_id', 'rate_per_unit', 'fk_frequency_id', 'annual_purchase_value','company_id', 'uom_other', 'comments','purchase_type', 'other_purchase_item'),array('fk_pd_id' => $pdid,'isactive' => 1),PDPURCHASEDETAILS); - - if(count($pdpurchasedetails)) - { - foreach ($pdpurchasedetails as $pdpurchasedetails_key => $pdpurchasedetails_value) - { - $pre_purchase_id = $pdpurchasedetails_value['purchase_id']; unset($pdpurchasedetails_value['purchase_id']); + $pdpurchasedetails = $this->PD_Model->selectCustomRecords(array('purchase_id', 'purchase_item', 'purchase_qty', 'fk_uom_id', 'rate_per_unit', 'fk_frequency_id', 'annual_purchase_value', 'company_id', 'uom_other', 'comments', 'purchase_type', 'other_purchase_item'), array('fk_pd_id' => $pdid, 'isactive' => 1), PDPURCHASEDETAILS); + + if (count($pdpurchasedetails)) { + foreach ($pdpurchasedetails as $pdpurchasedetails_key => $pdpurchasedetails_value) { + $pre_purchase_id = $pdpurchasedetails_value['purchase_id']; + unset($pdpurchasedetails_value['purchase_id']); $pdpurchasedetails_value['fk_pd_id'] = $new_pd_id; $pdpurchasedetails_value['fk_createdby'] = $fk_createdby; - $new_purchase_id = $this->PD_Model->saveRecords($pdpurchasedetails_value,PDPURCHASEDETAILS); + $new_purchase_id = $this->PD_Model->saveRecords($pdpurchasedetails_value, PDPURCHASEDETAILS); //get child values if any - if($pdpurchasedetails_value['purchase_type'] == 3) - { - $pdpurchasebillwisechild = $this->PD_Model->selectCustomRecords(array('purchase_date', 'purchase_value'),array('fk_purchase_id' => $pre_purchase_id,'isactive' => 1),PDPURCHASEBILLWISECHILD); - - if(count($pdpurchasebillwisechild)) - { - foreach ($pdpurchasebillwisechild as $child_key => $child_value) - { + if ($pdpurchasedetails_value['purchase_type'] == 3) { + $pdpurchasebillwisechild = $this->PD_Model->selectCustomRecords(array('purchase_date', 'purchase_value'), array('fk_purchase_id' => $pre_purchase_id, 'isactive' => 1), PDPURCHASEBILLWISECHILD); + + if (count($pdpurchasebillwisechild)) { + foreach ($pdpurchasebillwisechild as $child_key => $child_value) { $child_value['fk_purchase_id'] = $new_purchase_id; - $this->PD_Model->saveRecords($child_value,PDPURCHASEBILLWISECHILD); + $this->PD_Model->saveRecords($child_value, PDPURCHASEBILLWISECHILD); } } } } } - - - } @@ -10931,80 +9552,72 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $uri = null; EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id); - - $temp_base64_string = $this->post('is_person_met_pic') !== null ? $this->post('is_person_met_pic') : $this->post('is_person_met_id_proof'); - $title = $this->post('is_person_met_pic') !== null ? trim($this->post('applicant_name')) : (trim($this->post('applicant_name')).'-id_proof'); - - //$external_path = $this->config->item('external_data_path'); - $co_applicant_id = $this->post('pd_co_applicant_id'); - $img_type = $this->post('is_person_met_pic') !== null ? 1 : 2; - $output_file = $this->external_path."/pd_reports/". $pd_id ."/temp_base64_image.jpeg"; - //echo $img_type;die(); - //Generate Random File Name - $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').'.jpeg'; + $temp_base64_string = $this->post('is_person_met_pic') !== null ? $this->post('is_person_met_pic') : $this->post('is_person_met_id_proof'); + $title = $this->post('is_person_met_pic') !== null ? trim($this->post('applicant_name')) : (trim($this->post('applicant_name')) . '-id_proof'); - log_message('ERROR','###PDIMAGE writing started'.$pd_id.' - '.'13'); - $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $temp_base64_string ); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); - log_message('ERROR','###PDIMAGE writing done'.$pd_id.' - '.'13'); + //$external_path = $this->config->item('external_data_path'); + $co_applicant_id = $this->post('pd_co_applicant_id'); + $img_type = $this->post('is_person_met_pic') !== null ? 1 : 2; + $output_file = $this->external_path . "/pd_reports/" . $pd_id . "/temp_base64_image.jpeg"; + //echo $img_type;die(); + + //Generate Random File Name + $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') . '.jpeg'; + + log_message('ERROR', '###PDIMAGE writing started' . $pd_id . ' - ' . '13'); + $ifp = fopen($output_file, 'wb'); + $temp_data = explode(',', $temp_base64_string); + fwrite($ifp, base64_decode($temp_data[1])); + fclose($ifp); + log_message('ERROR', '###PDIMAGE writing done' . $pd_id . ' - ' . '13'); - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - $key = 'pd'.$pd_id.'/'.$temp_file_name; - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$output_file); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + $key = 'pd' . $pd_id . '/' . $temp_file_name; + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $output_file); // die(); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR','###PDIMAGE stored in S3'.$pd_id.' - '.'18'); - $record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'fk_form_id'=>18,'co_applicant_id' => $co_applicant_id,'img_type' => $img_type); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', '###PDIMAGE stored in S3' . $pd_id . ' - ' . '18'); + $record_data = array('fk_pd_id' => $pd_id, 'pd_document_title' => $title, 'fk_form_id' => 18, 'co_applicant_id' => $co_applicant_id, 'img_type' => $img_type); - //de activate older one - $this->PD_Model->updateRecords(array('isactive' => 0),PDDOCUMENTS,$record_data); + //de activate older one + $this->PD_Model->updateRecords(array('isactive' => 0), PDDOCUMENTS, $record_data); - $record_data['pd_document_name'] = $temp_file_name; - $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,$time = '+1 week'); - if($id) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $data['uri'] = $uri; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - + $record_data['pd_document_name'] = $temp_file_name; + $id = $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + $uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, $time = '+1 week'); + if ($id) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $data['uri'] = $uri; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); + } } @@ -11013,102 +9626,85 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records = $this->post('records'); $exist_pd_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); //print_r($exist_pd_details);die(); - + //print_r($records); - $fields_to_update = array('vendor_status' => $records['vendor_status'],'fk_updatedby' => $records['fk_updatedby']); - if(isset($records['vendor_pdofficer'])) - { + $fields_to_update = array('vendor_status' => $records['vendor_status'], 'fk_updatedby' => $records['fk_updatedby']); + if (isset($records['vendor_pdofficer'])) { $fields_to_update['vendor_pdofficer'] = $records['vendor_pdofficer']; } // if(isset($records['vendor_status']) && $records['vendor_status'] == STARTED) // { // $fields_to_update['start_location'] = $records['link']; // } - if(isset($records['vendor_status']) && ($records['vendor_status'] == BOUNCED)) - { + if (isset($records['vendor_status']) && ($records['vendor_status'] == BOUNCED)) { unset($records['bounce_reason']); unset($records['bounce_reason_others']); } - if(isset($records['vendor_status']) && ($records['vendor_status'] == SCHEDULED)) - { + if (isset($records['vendor_status']) && ($records['vendor_status'] == SCHEDULED)) { $fields_to_update['vendor_scheduled_on'] = $records['vendor_scheduled_on']; } - - if(isset($records['vendor_status']) && ($records['vendor_status'] == COMPLETED || $records['vendor_status'] == QC_COMPLETED)) - { - //echo 'sanskl'; - $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //SMC lender id MWISE in live and demo - $current_lender_id = $exist_pd_details[0]['fk_lender_id']; - $agency_id = $exist_pd_details[0]['pd_agency_id']; - // IF Condition - using PDID get the lender and mapped with SMC_lender_id macthed means Vendor status dynamically assigned - // is_smc_vendor(true/false) - here this api called both smart pd(vendor) and SMC(vendor) also but we using this key only for SMC(vendor module). - if($smc_lender_id == $current_lender_id && isset($agency_id) && $agency_id != null && $records['is_smc_vendor'] == true){ - if(isset($records['vendor_status']) && ($records['vendor_status'] == QC_COMPLETED)){ + + if (isset($records['vendor_status']) && ($records['vendor_status'] == COMPLETED || $records['vendor_status'] == QC_COMPLETED)) { + //echo 'sanskl'; + $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //SMC lender id MWISE in live and demo + $current_lender_id = $exist_pd_details[0]['fk_lender_id']; + $agency_id = $exist_pd_details[0]['pd_agency_id']; + // IF Condition - using PDID get the lender and mapped with SMC_lender_id macthed means Vendor status dynamically assigned + // is_smc_vendor(true/false) - here this api called both smart pd(vendor) and SMC(vendor) also but we using this key only for SMC(vendor module). + if ($smc_lender_id == $current_lender_id && isset($agency_id) && $agency_id != null && $records['is_smc_vendor'] == true) { + if (isset($records['vendor_status']) && ($records['vendor_status'] == QC_COMPLETED)) { $fields_to_update['pd_status'] = COMPLETED; //Here vendor_status is (QC_COMPLETED) means i have to update the Normal Status as COMPLETED. - } + } // else{ $fields_to_update['vendor_status'] = $records['pd_status']; } } - if(!isset($records['complete_override_data']) && isset($records['is_smc_vendor']) && $records['is_smc_vendor'] == false) - { - $vendor_form = $this->PD_Model->selectCustomRecords(array('json'),array('isactive' => 1,'fk_form_id' => 25,'fk_pd_id' => $records['pd_id']) - ,PDFORMDETAILSJSON); - if(count($vendor_form)) - { - //echo 'sanskl'; - $vendor_form = json_decode($vendor_form[0]['json'],true); - if(isset($vendor_form['is_form_validated']) && !$vendor_form['is_form_validated']) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['enable_complete'] = true; - $data['msg'] = 'Form Saved as Draft! Please Fill and submit the form'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Form Not filled !'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $fields_to_update['complete_override_data'] = $exist_pd_details[0]['complete_override_data'].'[Vendor Complete Check Overrided]'; - } - // print_r($vendor_form); - if($records['vendor_status'] == COMPLETED) - { - $fields_to_update['pd_visit_date'] = date('Y-m-d H:i:s'); - } - - - - - - } + if (!isset($records['complete_override_data']) && isset($records['is_smc_vendor']) && $records['is_smc_vendor'] == false) { + $vendor_form = $this->PD_Model->selectCustomRecords( + array('json'), + array('isactive' => 1, 'fk_form_id' => 25, 'fk_pd_id' => $records['pd_id']), + PDFORMDETAILSJSON + ); + if (count($vendor_form)) { + //echo 'sanskl'; + $vendor_form = json_decode($vendor_form[0]['json'], true); + if (isset($vendor_form['is_form_validated']) && !$vendor_form['is_form_validated']) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['enable_complete'] = true; + $data['msg'] = 'Form Saved as Draft! Please Fill and submit the form'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Form Not filled !'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $fields_to_update['complete_override_data'] = $exist_pd_details[0]['complete_override_data'] . '[Vendor Complete Check Overrided]'; + } + // print_r($vendor_form); + if ($records['vendor_status'] == COMPLETED) { + $fields_to_update['pd_visit_date'] = date('Y-m-d H:i:s'); + } + } // die(); // print_r($fields_to_update);die(); - $id = $this->PD_Model->updateRecords($fields_to_update,PDTRIGGER,array('pd_id' => $records['pd_id'])); - if($id) - { + $id = $this->PD_Model->updateRecords($fields_to_update, PDTRIGGER, array('pd_id' => $records['pd_id'])); + if ($id) { // if(isset($records['vendor_status']) && $records['vendor_status'] == STARTED) // { // satellite_image::getSatelliteImage($records['fk_pd_id']); // } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -11121,111 +9717,95 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $pd_master_details = $this->PD_Model->getPDMasterDetails($fk_pd_id); - if(($pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] == QC_COMPLETED) || (!$pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] == COMPLETED)) - { - $vendor_pd_form = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $fk_pd_id, 'fk_form_id' => 25,'isactive' => 1),PDFORMDETAILSJSON); - if(count($vendor_pd_form)) - { - $business_forms = array(1,2,13,14,11,16,21,22,23); - $vendor_pd_form = json_decode($vendor_pd_form[0]['json'],true); - $is_business_form = in_array($fk_form_id,$business_forms); + if (($pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] == QC_COMPLETED) || (!$pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] == COMPLETED)) { + $vendor_pd_form = $this->PD_Model->selectCustomRecords(array('*'), array('fk_pd_id' => $fk_pd_id, 'fk_form_id' => 25, 'isactive' => 1), PDFORMDETAILSJSON); + if (count($vendor_pd_form)) { + $business_forms = array(1, 2, 13, 14, 11, 16, 21, 22, 23); + $vendor_pd_form = json_decode($vendor_pd_form[0]['json'], true); + $is_business_form = in_array($fk_form_id, $business_forms); //print_r($vendor_pd_form['questions']);die(); - foreach ($vendor_pd_form['questions'] as $key => $value) - { - if($is_business_form && is_string($value['form_id']) && !strcasecmp($value['form_id'],'BUSINESS_GROUP')) - { - //echo 'busienss';break; + foreach ($vendor_pd_form['questions'] as $key => $value) { + if ($is_business_form && is_string($value['form_id']) && !strcasecmp($value['form_id'], 'BUSINESS_GROUP')) { + //echo 'busienss';break; //print_r($value);die(); - foreach ($value['business_group'] as $bkey => $bvalue) - { + foreach ($value['business_group'] as $bkey => $bvalue) { - if($bvalue['form_id'] == $fk_form_id) - { - //echo 'nor';break; - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $bvalue; - $this->response($data,REST_Controller::HTTP_OK); + if ($bvalue['form_id'] == $fk_form_id) { + //echo 'nor';break; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $bvalue; + $this->response($data, REST_Controller::HTTP_OK); } } - - - } - else if($value['form_id'] == $fk_form_id) - { - //echo 'nor';break; - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $value; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - + } else if ($value['form_id'] == $fk_form_id) { + //echo 'nor';break; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $value; + $this->response($data, REST_Controller::HTTP_OK); + } + } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Vendor Form Not Found!'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Vendor Form Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - if(($pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] != QC_COMPLETED)) - { + } else { + if (($pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] != QC_COMPLETED)) { $data['msg'] = 'Vendor yet to QC Complete the PD'; - } - else if((!$pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] != COMPLETED)) - { + } else if ((!$pd_master_details[0]['is_qc_enabled'] && $pd_master_details[0]['vendor_status'] != COMPLETED)) { $data['msg'] = 'Vendor yet to Complete the PD'; } - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $this->response($data, REST_Controller::HTTP_OK); } - } public function loadCreditPDTemplate_post() { - + $where_condition_array = array('isactive' => 1); - if($this->post('fk_entity_id')){ $where_condition_array['fk_entity_id'] = $this->post('fk_entity_id'); }else{ $where_condition_array['fk_entity_id'] = NULL; } - if($this->post('fk_product_id')){ $where_condition_array['fk_product_id'] = $this->post('fk_product_id'); }else{ $where_condition_array['fk_product_id'] = NULL; } - if($this->post('pd_form_id')){ $where_condition_array['pd_form_id'] = $this->post('pd_form_id'); } + if ($this->post('fk_entity_id')) { + $where_condition_array['fk_entity_id'] = $this->post('fk_entity_id'); + } else { + $where_condition_array['fk_entity_id'] = NULL; + } + if ($this->post('fk_product_id')) { + $where_condition_array['fk_product_id'] = $this->post('fk_product_id'); + } else { + $where_condition_array['fk_product_id'] = NULL; + } + if ($this->post('pd_form_id')) { + $where_condition_array['pd_form_id'] = $this->post('pd_form_id'); + } $fk_pd_id = $this->post('fk_pd_id'); //print_r($where_condition_array);die(); $pd_master_details = $this->PD_Model->getPDMasterDetails($fk_pd_id); - - if($pd_master_details[0]['customer_segment_abbr'] != 'SAL') - { - $template = $this->PD_Model->selectCustomRecords(array('credit_pd_template_id', 'template_name', 'template_desc', 'template', 'fk_entity_id', 'fk_product_id', 'pd_form_id'),$where_condition_array,CREDITPDTEMPLATE); - if(count($template)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $template[0]; - $this->response($data,REST_Controller::HTTP_OK); + if ($pd_master_details[0]['customer_segment_abbr'] != 'SAL') { + $template = $this->PD_Model->selectCustomRecords(array('credit_pd_template_id', 'template_name', 'template_desc', 'template', 'fk_entity_id', 'fk_product_id', 'pd_form_id'), $where_condition_array, CREDITPDTEMPLATE); + + if (count($template)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template[0]; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Template Not Found!'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Template Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Template Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Template Not Found!'; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -11238,37 +9818,35 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $result_array = array(); $is_api_processed = false; $total_affected_rows = null; - - $where_condition_array = array(); - if(count($docs)) - { - foreach ($docs as $key => $value) - { - if(isset($value['pd_document_id']) && is_numeric($value['pd_document_id'])) { $where_condition_array[] = $value['pd_document_id']; } - } - - $ids = $this->db->WHERE_IN('pd_document_id',$where_condition_array)->UPDATE(PDDOCUMENTS,array('retake_flag' => 1)); - $total_affected_rows = $this->db->affected_rows(); - $is_api_processed = $total_affected_rows == count($docs) ? true : false; - //print_r($this->db->last_query()); + $where_condition_array = array(); + if (count($docs)) { + foreach ($docs as $key => $value) { + if (isset($value['pd_document_id']) && is_numeric($value['pd_document_id'])) { + $where_condition_array[] = $value['pd_document_id']; + } } - //echo count($docs);echo($total_affected_rows);echo ($is_api_processed); - if($ids)// && $is_api_processed) - { - //$this->PD_Model->updateRecords(array('is_cus_link_disabled' => 0),PDTRIGGER,array()); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $total_affected_rows; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); - } + + $ids = $this->db->WHERE_IN('pd_document_id', $where_condition_array)->UPDATE(PDDOCUMENTS, array('retake_flag' => 1)); + $total_affected_rows = $this->db->affected_rows(); + $is_api_processed = $total_affected_rows == count($docs) ? true : false; + //print_r($this->db->last_query()); + + } + //echo count($docs);echo($total_affected_rows);echo ($is_api_processed); + if ($ids) // && $is_api_processed) + { + //$this->PD_Model->updateRecords(array('is_cus_link_disabled' => 0),PDTRIGGER,array()); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $total_affected_rows; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later!'; + $this->response($data, REST_Controller::HTTP_OK); + } } public function getAuditedImages_post() @@ -11278,183 +9856,153 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $result_array = array(); $where_condition_array = array('random_string' => $random_string); - if($pd_id){ $where_condition_array['pd_id'] = $pd_id; } - - //Get PD ID by Random String - $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id','fk_lender_id','is_cus_link_valid','cus_link_count','is_cus_link_disabled'),$where_condition_array,PDTRIGGER); + if ($pd_id) { + $where_condition_array['pd_id'] = $pd_id; + } - if(count($pd_id) && count($pd_id) == 1) - { - //check and update link meta data - // echo $pd_id[0]['is_cus_link_valid'];echo $pd_id[0]['is_cus_link_disabled']; - // if($pd_id[0]['is_cus_link_valid'] && !$pd_id[0]['is_cus_link_disabled']) - // { + //Get PD ID by Random String + $pd_id = $this->PD_Model->selectCustomRecords(array('pd_id', 'fk_lender_id', 'is_cus_link_valid', 'cus_link_count', 'is_cus_link_disabled'), $where_condition_array, PDTRIGGER); - $where_condition_array = array('fk_pd_id' => $pd_id[0]['pd_id'],'retake_flag' => 1); - $document_lists = $this->db->SELECT('*')->FROM(PDDOCUMENTS)->WHERE($where_condition_array)->get()->result_array(); - // print_r($this->db->last_query()); - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_id[0]['fk_lender_id']; - - foreach($document_lists as $key => $value) - { - $profilepics3path = 'pd'.$pd_id[0]['pd_id'].'/'.$value['pd_document_name']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+5 minutes'); - //$document_lists[$key]['doc_url'] = $singed_uri; + if (count($pd_id) && count($pd_id) == 1) { + //check and update link meta data + // echo $pd_id[0]['is_cus_link_valid'];echo $pd_id[0]['is_cus_link_disabled']; + // if($pd_id[0]['is_cus_link_valid'] && !$pd_id[0]['is_cus_link_disabled']) + // { + + $where_condition_array = array('fk_pd_id' => $pd_id[0]['pd_id'], 'retake_flag' => 1); + $document_lists = $this->db->SELECT('*')->FROM(PDDOCUMENTS)->WHERE($where_condition_array)->get()->result_array(); + // print_r($this->db->last_query()); + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $pd_id[0]['fk_lender_id']; + + foreach ($document_lists as $key => $value) { + $profilepics3path = 'pd' . $pd_id[0]['pd_id'] . '/' . $value['pd_document_name']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $profilepics3path, '+5 minutes'); + //$document_lists[$key]['doc_url'] = $singed_uri; - ####################################################################################################################### + ####################################################################################################################### - if($value['img_type'] == 1 ) - { - - //echo "SELFIE"; - $arr = array('img_key' => 'selfie_with_person_met','img_name' => $this->photo_names['selfie_with_person_met'][0],'fk_form_id' => $this->photo_names['selfie_with_person_met'][1],'img_url' => $singed_uri,'is_multiple' => 0,'pd_document_id' => $value['pd_document_id']); - // unset($this->existing_imges[$key]); - $result_array[] = $arr; - // return $arr; - - } - else if($value['img_type'] == 2) - { - - //echo 'HOLD'; - $arr = array('img_key' => 'person_met_id','img_name' => $this->photo_names['person_met_id'][0],'img_url' => $singed_uri,'fk_form_id' => $this->photo_names['person_met_id'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id']); - $result_array[] = $arr; - } - else if(strpos($value['pd_document_title'], 'Approach') !== false) - { - - //echo "APPROACH"; - $arr = array('img_key' => 'approach_to_pd_location','img_name' => $this->photo_names['approach_to_pd_location'][0],'img_url' => $singed_uri,'fk_form_id' => $this->photo_names['approach_to_pd_location'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id']); - $result_array[] = $arr; - } - else if(strpos($value['pd_document_title'], 'Name Board Seen') !== false) - { - - //echo "APPROACH"; - $arr = array('img_key' => 'name_board_seen','img_name' => $this->photo_names['name_board_seen'][0],'img_url' => $singed_uri,'fk_form_id' => $this->photo_names['name_board_seen'][1],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id']); - $result_array[] = $arr; - // unset($this->photo_names['selfie_with_person_met']); - // return $arr; - } - else - { - $img_key = isset($this->photo_names[ $value['pd_document_title'] ]) ? $this->photo_names[ $value['pd_document_title'] ][0] : ($value['fk_form_id'] == 24 ? 'docs_to_be_collected':'common_image'); - $arr = array('img_key' => $img_key,'img_name' => $value['pd_document_title'],'img_url' => $singed_uri,'fk_form_id' => $value['fk_form_id'],'is_multiple' => 0,'pd_document_id' => $value['pd_document_id']); - //if(!$value['fk_form_id']){ $arr } - $result_array[] = $arr; - } - ####################################################################################################################### - } + if ($value['img_type'] == 1) { - if(count($result_array)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pd_id' => $pd_id[0]['pd_id'],'img_data' => $result_array,'is_cus_link_disabled' => $pd_id[0]['is_cus_link_disabled'],'random_string' => $random_string); - $this->response($data,REST_Controller::HTTP_OK); - } - + //echo "SELFIE"; + $arr = array('img_key' => 'selfie_with_person_met', 'img_name' => $this->photo_names['selfie_with_person_met'][0], 'fk_form_id' => $this->photo_names['selfie_with_person_met'][1], 'img_url' => $singed_uri, 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id']); + // unset($this->existing_imges[$key]); + $result_array[] = $arr; + // return $arr; + } else if ($value['img_type'] == 2) { - - //} - // else - // { - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NOT_FOUND; - // $data['msg'] = 'Link Expired'; - // $this->response($data,REST_Controller::HTTP_OK); - // } + //echo 'HOLD'; + $arr = array('img_key' => 'person_met_id', 'img_name' => $this->photo_names['person_met_id'][0], 'img_url' => $singed_uri, 'fk_form_id' => $this->photo_names['person_met_id'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id']); + $result_array[] = $arr; + } else if (strpos($value['pd_document_title'], 'Approach') !== false) { - } - else if(count($pd_id) > 1 || !count($pd_id)) - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Invalid Link'; - $this->response($data,REST_Controller::HTTP_OK); + //echo "APPROACH"; + $arr = array('img_key' => 'approach_to_pd_location', 'img_name' => $this->photo_names['approach_to_pd_location'][0], 'img_url' => $singed_uri, 'fk_form_id' => $this->photo_names['approach_to_pd_location'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id']); + $result_array[] = $arr; + } else if (strpos($value['pd_document_title'], 'Name Board Seen') !== false) { + + //echo "APPROACH"; + $arr = array('img_key' => 'name_board_seen', 'img_name' => $this->photo_names['name_board_seen'][0], 'img_url' => $singed_uri, 'fk_form_id' => $this->photo_names['name_board_seen'][1], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id']); + $result_array[] = $arr; + // unset($this->photo_names['selfie_with_person_met']); + // return $arr; + } else { + $img_key = isset($this->photo_names[$value['pd_document_title']]) ? $this->photo_names[$value['pd_document_title']][0] : ($value['fk_form_id'] == 24 ? 'docs_to_be_collected' : 'common_image'); + $arr = array('img_key' => $img_key, 'img_name' => $value['pd_document_title'], 'img_url' => $singed_uri, 'fk_form_id' => $value['fk_form_id'], 'is_multiple' => 0, 'pd_document_id' => $value['pd_document_id']); + //if(!$value['fk_form_id']){ $arr } + $result_array[] = $arr; + } + ####################################################################################################################### } + if (count($result_array)) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pd_id' => $pd_id[0]['pd_id'], 'img_data' => $result_array, 'is_cus_link_disabled' => $pd_id[0]['is_cus_link_disabled'], 'random_string' => $random_string); + $this->response($data, REST_Controller::HTTP_OK); + } + + + + + //} + // else + // { + // $data['dataStatus'] = false; + // $data['status'] = REST_Controller::HTTP_NOT_FOUND; + // $data['msg'] = 'Link Expired'; + // $this->response($data,REST_Controller::HTTP_OK); + // } + + } else if (count($pd_id) > 1 || !count($pd_id)) { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Invalid Link'; + $this->response($data, REST_Controller::HTTP_OK); + } } public function updateVendorFormStatus_post() { //print_r($this->post()); - $id = $this->PD_Model->updateRecords(array('form_status' => 1),VENDORFORMSTATUS,array('fk_pd_id' => $this->post('fk_pd_id'),'fk_form_id' => $this->post('fk_form_id'))); + $id = $this->PD_Model->updateRecords(array('form_status' => 1), VENDORFORMSTATUS, array('fk_pd_id' => $this->post('fk_pd_id'), 'fk_form_id' => $this->post('fk_form_id'))); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data, REST_Controller::HTTP_OK); } function getBusinessDocsToVendorForm_get() { - $pd_id = $this->get('pdid') ; + $pd_id = $this->get('pdid'); - $business_form = $this->PD_Model->selectCustomRecords(array('json'),array('fk_pd_id' => $pd_id,'fk_form_id' => 13,'isactive' => 1,'company_id' => 1),PDFORMDETAILSJSON); - if(count($business_form)) - { + $business_form = $this->PD_Model->selectCustomRecords(array('json'), array('fk_pd_id' => $pd_id, 'fk_form_id' => 13, 'isactive' => 1, 'company_id' => 1), PDFORMDETAILSJSON); + if (count($business_form)) { $records = array(); - $business_form = json_decode($business_form[0]['json'],true); + $business_form = json_decode($business_form[0]['json'], true); //print_r($business_form); - if(isset($business_form['shop_eat_act_cert']) && strtoupper($business_form['shop_eat_act_cert'])=='YES') - { - $records[] = 'shop_eat_act_cert'; + if (isset($business_form['shop_eat_act_cert']) && strtoupper($business_form['shop_eat_act_cert']) == 'YES') { + $records[] = 'shop_eat_act_cert'; } - if(isset($business_form['gst_Regn_cert']) && strtoupper($business_form['gst_Regn_cert'])=='YES') - { - $records[] = 'gst_Regn_cert'; + if (isset($business_form['gst_Regn_cert']) && strtoupper($business_form['gst_Regn_cert']) == 'YES') { + $records[] = 'gst_Regn_cert'; } - if(isset($business_form['pf_regn']) && strtoupper($business_form['pf_regn'])=='YES') - { - $records[] = 'pf_regn'; + if (isset($business_form['pf_regn']) && strtoupper($business_form['pf_regn']) == 'YES') { + $records[] = 'pf_regn'; } - if(isset($business_form['esic_regn']) && strtoupper($business_form['esic_regn'])=='YES') - { - $records[] = 'esic_regn'; + if (isset($business_form['esic_regn']) && strtoupper($business_form['esic_regn']) == 'YES') { + $records[] = 'esic_regn'; } - if(isset($business_form['factory_cert']) && strtoupper($business_form['factory_cert'])=='YES') - { - $records[] = 'factory_cert'; + if (isset($business_form['factory_cert']) && strtoupper($business_form['factory_cert']) == 'YES') { + $records[] = 'factory_cert'; } - if(isset($business_form['export_import_cert']) && strtoupper($business_form['export_import_cert'])=='YES') - { - $records[] = 'export_import_cert'; + if (isset($business_form['export_import_cert']) && strtoupper($business_form['export_import_cert']) == 'YES') { + $records[] = 'export_import_cert'; } - if(isset($business_form['practice_cert']) && strtoupper($business_form['practice_cert'])=='YES') - { - $records[] = 'practice_cert'; + if (isset($business_form['practice_cert']) && strtoupper($business_form['practice_cert']) == 'YES') { + $records[] = 'practice_cert'; } - if(count($records)) - { + if (count($records)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $records; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'No Records Found!'; - $this->response($data,REST_Controller::HTTP_OK); - + $this->response($data, REST_Controller::HTTP_OK); } - - - - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'No Records Found!'; - $this->response($data,REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Records Found!'; + $this->response($data, REST_Controller::HTTP_OK); } } @@ -11468,13 +10016,11 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records = $this->post('records'); $id = null; //print_r($records); - if(!$records['is_call_ended'])// != '' || $records['video_room_info_id'] != null) + if (!$records['is_call_ended']) // != '' || $records['video_room_info_id'] != null) { - $id = $this->PD_Model->saveRecords($records,VIDEO_ROOM_INFO); + $id = $this->PD_Model->saveRecords($records, VIDEO_ROOM_INFO); // print_r($this->db->last_query()); - } - else - { + } else { $this->load->library('twlio'); $composition_result_data = $this->twlio->startComposistion($records['room_id']); // $composition_result_data = $this->twlio->startComposistion('RM23b8d502434e46e696d1fbd5d64c59c8'); @@ -11484,441 +10030,400 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $records['res_json'] = $composition_result_data_json; $records['twilo_status'] = $composition_result_data['status']; $records['composition_id'] = $composition_result_data['compositionId']; - $id = $this->PD_Model->updateRecords($records,VIDEO_ROOM_INFO,array('room_id' => $records['room_id'],'fk_pd_id' => $records['fk_pd_id'])); - + $id = $this->PD_Model->updateRecords($records, VIDEO_ROOM_INFO, array('room_id' => $records['room_id'], 'fk_pd_id' => $records['fk_pd_id'])); } - if($id) - { + if ($id) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + $this->response($data, REST_Controller::HTTP_OK); + } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'Something went wrong!'; - $this->response($data,REST_Controller::HTTP_OK); + $this->response($data, REST_Controller::HTTP_OK); } - } public function uploadVideoFile_post() - { - $records = json_decode($this->post('records'),true); - $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; - $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports" ; - if($pd_category == '1'){//normal Credit PD; - $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'],$records['random_string']); - }if($pd_category == '2'){//Sales PD; - $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type','isactive', 'rand_string as random_string', 'pd_branch_id'),array('sales_pd_id' => $records['fk_pd_id'],'rand_string'=>$records['random_string']),SALES_PD_DATA); - } - - $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; - // echo XLPATH; - // print_r($records);die(); - // print_r($pd_master_details);die(); - $is_bucket_upload_sucess = false; - $id = null; - //die(); - if(!empty($_FILES['video_file'])) - { - $folder_to_check = XLPATH.'/'.$file_folder.'/'.$records['fk_pd_id'].'/videos'; - - if(!file_exists($folder_to_check)) - { - mkdir($folder_to_check,0777); - } - // die(); - // $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name'])); - $modified_fname = str_replace(' ','_',($_FILES['video_file']['name'])); - // echo file_exists($folder_to_check);die(); - - $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $modified_fname); - - $this->load->library('upload', $config); - $this->upload->initialize($config); - - - try { - - - if($this->upload->do_upload('video_file')) - { - log_message('ERROR','video uplaod done :' . $folder_to_check); - $sourcefile = $folder_to_check.'/'.$modified_fname; - // echo $sourcefile; - $key = 'pd'.$records['fk_pd_id'].'/video/'.$modified_fname; - - $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$sourcefile); - // print_r($bucket_data);die(); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - //print_r($s3result);die(); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - $is_bucket_upload_sucess = 1; - $id = $this->PD_Model->saveRecords(array('fk_pd_id' =>$records['fk_pd_id'],'room_id' => $modified_fname,'composition_id' => $modified_fname,'twilo_status' => 'completed','is_call_ended' => 1,'s3_copied' => 1,'is_uploaded' => 1),VIDEO_ROOM_INFO); - unlink($sourcefile); - } - } - else - { - log_message('ERROR','video uplaod failed :' . $folder_to_check); - } - - } catch (Exception $e) { - log_message('ERROR','video uplaod failed exception:' . $folder_to_check.' - '.$e->getMessage()); - } - // die(); - - if($is_bucket_upload_sucess && $id) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['msg'] = 'File Uploaded Successfully'; - // $data['excel_file_id'] = $id; - // $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Wrong. Try Later!'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'No Data File Found!'; - $this->response($data,REST_Controller::HTTP_OK); - } + { + $records = json_decode($this->post('records'), true); + $pd_category = $records['pd_category'] ? $records['pd_category'] : "1"; + $file_folder = $pd_category == "2" ? "sales_pd" : "pd_reports"; + if ($pd_category == '1') { //normal Credit PD; + $pd_master_details = $this->PD_Model->getPDMasterDetails($records['fk_pd_id'], $records['random_string']); } + if ($pd_category == '2') { //Sales PD; + $pd_master_details = $this->PD_Model->selectCustomRecords(array('sales_pd_id as pd_id', 'lender_id as fk_lender_id', 'product_id', 'sales_pd_type', 'isactive', 'rand_string as random_string', 'pd_branch_id'), array('sales_pd_id' => $records['fk_pd_id'], 'rand_string' => $records['random_string']), SALES_PD_DATA); + } + + $bucket_name = LENDER_BUCKET_NAME_PREFIX . $pd_master_details[0]['fk_lender_id']; + // echo XLPATH; + // print_r($records);die(); + // print_r($pd_master_details);die(); + $is_bucket_upload_sucess = false; + $id = null; + //die(); + if (!empty($_FILES['video_file'])) { + $folder_to_check = XLPATH . '/' . $file_folder . '/' . $records['fk_pd_id'] . '/videos'; + + if (!file_exists($folder_to_check)) { + mkdir($folder_to_check, 0777); + } + // die(); + // $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name'])); + $modified_fname = str_replace(' ', '_', ($_FILES['video_file']['name'])); + // echo file_exists($folder_to_check);die(); + + $config = array('upload_path' => $folder_to_check, 'overwrite' => TRUE, 'allowed_types' => '*', 'file_name' => $modified_fname); + + $this->load->library('upload', $config); + $this->upload->initialize($config); + + + try { + + + if ($this->upload->do_upload('video_file')) { + log_message('ERROR', 'video uplaod done :' . $folder_to_check); + $sourcefile = $folder_to_check . '/' . $modified_fname; + // echo $sourcefile; + $key = 'pd' . $records['fk_pd_id'] . '/video/' . $modified_fname; + + $bucket_data = array('bucket_name' => $bucket_name, 'key' => $key, 'sourcefile' => $sourcefile); + // print_r($bucket_data);die(); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + //print_r($s3result);die(); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + $is_bucket_upload_sucess = 1; + $id = $this->PD_Model->saveRecords(array('fk_pd_id' => $records['fk_pd_id'], 'room_id' => $modified_fname, 'composition_id' => $modified_fname, 'twilo_status' => 'completed', 'is_call_ended' => 1, 's3_copied' => 1, 'is_uploaded' => 1), VIDEO_ROOM_INFO); + unlink($sourcefile); + } + } else { + log_message('ERROR', 'video uplaod failed :' . $folder_to_check); + } + } catch (Exception $e) { + log_message('ERROR', 'video uplaod failed exception:' . $folder_to_check . ' - ' . $e->getMessage()); + } + // die(); + + if ($is_bucket_upload_sucess && $id) { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'File Uploaded Successfully'; + // $data['excel_file_id'] = $id; + // $data['records'] = $result_data; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Wrong. Try Later!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Data File Found!'; + $this->response($data, REST_Controller::HTTP_OK); + } + } public function checkAfterResponse_post() { - $this->myvariable = 10; - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'No Data File Found!'; - $this->response($data,REST_Controller::HTTP_OK,true); + $this->myvariable = 10; + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'No Data File Found!'; + $this->response($data, REST_Controller::HTTP_OK, true); // echo 'Hi'; - } + } - public function smcStuffs($pd_details,$existing_pd_details = array()) + public function smcStuffs($pd_details, $existing_pd_details = array()) { // echo "i am here"; // echo $pd_details['pd_status']; - //if is this MWISE (SMC Credit PD) lender then auto allocate to RCM users and make pd status as allocated + //if is this MWISE (SMC Credit PD) lender then auto allocate to RCM users and make pd status as allocated - //get RCM user for auto allocation based on pd address - - // $pd_details['fk_lender_id'] = 35; - // $addresses[0]['fk_city'] = 3374; - $mwise_lender_id = (ENVIRONMENT == 'production' ? 7 : 35); - - $current_lender_id = (isset($pd_details['fk_lender_id']) && $pd_details['fk_lender_id'] != '' ? $pd_details['fk_lender_id'] : $existing_pd_details[0]['fk_lender_id']) ; - $is_mwise_lender = ( $current_lender_id == $mwise_lender_id ? true : false); - // echo !$is_mwise_lender; - // echo "curr".$current_lender_id;die(); - if($is_mwise_lender && (($pd_details['pd_status'] == TRIGGERED) || ($pd_details['pd_status'] == ALLOCATED))) - { - $regional_credit_manager = $this->PD_Model->getRCM($pd_details['fk_state']);//pass pd address city as param - $agency_id = $pd_details['pd_agency_id']; - if((!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0)) - { - $pd_details['pd_status'] = ALLOCATED_TO_FIA; - $pd_details['vendor_status'] = ALLOCATED; - $sudhirbaranwal = (ENVIRONMENT == 'production' ? 187 : 324); - if($pd_details['fk_pd_allocated_to'] != $sudhirbaranwal){ - PDALERTS::sendMWcreditPDMail($this,$pd_details,3);} + //get RCM user for auto allocation based on pd address + + // $pd_details['fk_lender_id'] = 35; + // $addresses[0]['fk_city'] = 3374; + $mwise_lender_id = (ENVIRONMENT == 'production' ? 7 : 35); + + $current_lender_id = (isset($pd_details['fk_lender_id']) && $pd_details['fk_lender_id'] != '' ? $pd_details['fk_lender_id'] : $existing_pd_details[0]['fk_lender_id']); + $is_mwise_lender = ($current_lender_id == $mwise_lender_id ? true : false); + // echo !$is_mwise_lender; + // echo "curr".$current_lender_id;die(); + if ($is_mwise_lender && (($pd_details['pd_status'] == TRIGGERED) || ($pd_details['pd_status'] == ALLOCATED))) { + $regional_credit_manager = $this->PD_Model->getRCM($pd_details['fk_state']); //pass pd address city as param + $agency_id = $pd_details['pd_agency_id']; + if ((!empty($agency_id)) && ($agency_id != null) && ((int)$agency_id != 0)) { + $pd_details['pd_status'] = ALLOCATED_TO_FIA; + $pd_details['vendor_status'] = ALLOCATED; + $sudhirbaranwal = (ENVIRONMENT == 'production' ? 187 : 324); + if ($pd_details['fk_pd_allocated_to'] != $sudhirbaranwal) { + PDALERTS::sendMWcreditPDMail($this, $pd_details, 3); } - else if(count($regional_credit_manager)) - { - $pd_details['fk_pd_allocated_to'] = $regional_credit_manager[0]['userid']; - $pd_details['pd_status'] = ALLOCATED; - } - else - { - log_message('ERROR',('### Couldnot find RCM users - '.$pd_details['fk_state'])); - - } + } else if (count($regional_credit_manager)) { + $pd_details['fk_pd_allocated_to'] = $regional_credit_manager[0]['userid']; + $pd_details['pd_status'] = ALLOCATED; + } else { + log_message('ERROR', ('### Couldnot find RCM users - ' . $pd_details['fk_state'])); + } + } else if ($is_mwise_lender && $pd_details['pd_status'] == BOUNCED) { + //find current user role + $this->load->model('User_Management_Model'); + $this->load->model('SMC_Credit_PD_Model'); + $user_details = $this->User_Management_Model->getUserDetails($pd_details['fk_updatedby']); + if ($user_details['data'][0]['user_role'] == 26) //Credit Manager + { + //get RCM and allocate to RCM + $rcm = $this->SMC_Credit_PD_Model->getSMCFlowUsers($existing_pd_details[0]['fk_state'], 27); + if (count($rcm)) { + $pd_details['fk_pd_allocated_to'] = $rcm[0]['userid']; + } else { + log_message('ERROR', ('### Couldnot find RCM users in BOUNCED status - ' . $existing_pd_details[0]['fk_state'])); + } + } else if ($user_details['data'][0]['user_role'] == 27) //Reg Credit Manager + { - } - else if($is_mwise_lender && $pd_details['pd_status'] == BOUNCED) - { - //find current user role - $this->load->model('User_Management_Model'); - $this->load->model('SMC_Credit_PD_Model'); - $user_details = $this->User_Management_Model->getUserDetails($pd_details['fk_updatedby']); - if($user_details['data'][0]['user_role'] == 26)//Credit Manager - { - //get RCM and allocate to RCM - $rcm = $this->SMC_Credit_PD_Model->getSMCFlowUsers($existing_pd_details[0]['fk_state'],27); - if(count($rcm)) - { - $pd_details['fk_pd_allocated_to'] = $rcm[0]['userid']; - } - else - { - log_message('ERROR',('### Couldnot find RCM users in BOUNCED status - '.$existing_pd_details[0]['fk_state'])); - } - - - } - else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager - { - - // //get CPA and allocate to CPA - // $cpa = $this->SMC_Credit_PD_Model->getSMCFlowUsers($existing_pd_details[0]['fk_city'],25); - // if(count($cpa)) - // { - // $pd_details['fk_pd_allocated_to'] = $rcm[0]['userid']; - // } - // else - // { - // log_message('ERROR',('### Couldnot find RCPACM users in BOUNCED status - '.$existing_pd_details[0]['fk_city'])); - // } + // //get CPA and allocate to CPA + // $cpa = $this->SMC_Credit_PD_Model->getSMCFlowUsers($existing_pd_details[0]['fk_city'],25); + // if(count($cpa)) + // { + // $pd_details['fk_pd_allocated_to'] = $rcm[0]['userid']; + // } + // else + // { + // log_message('ERROR',('### Couldnot find RCPACM users in BOUNCED status - '.$existing_pd_details[0]['fk_city'])); + // } - //now allocated to pd triggered to user - $pd_details['fk_pd_allocated_to'] = $existing_pd_details[0]['fk_createdby']; - } + //now allocated to pd triggered to user + $pd_details['fk_pd_allocated_to'] = $existing_pd_details[0]['fk_createdby']; + } + } - - } - - // echo $pd_details['fk_pd_allocated_to'];die(); - return $pd_details; + // echo $pd_details['fk_pd_allocated_to'];die(); + return $pd_details; } - function getAdditionalRequirements_get(){ + function getAdditionalRequirements_get() + { $pdid = $this->get('pdid'); - if(!isset($pdid) && empty($pdid)){ + if (!isset($pdid) && empty($pdid)) { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'PDID Not Found! Try again'; + $data['msg'] = 'PDID Not Found! Try again'; } $result_data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); $result_data['docs_to_be_collected'] = $this->PD_Model->getDocsToBeCollected($pdid); - if(!empty($result_data)) - { + if (!empty($result_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result_data; + } else if (empty($result_data['pd_additional_requirements']) && empty($result_data['docs_to_be_collected'])) { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Data Not Found'; + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; } - else if(empty($result_data['pd_additional_requirements']) && empty($result_data['docs_to_be_collected'])) - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Data Not Found'; - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Went Wrong! Try Later'; - } - $this->response($data,REST_Controller::HTTP_OK); - } - - function saveSMCTempAddress($pd_id,$addresses) - { - $records = array('file_id' => $pd_id,'addressline' => $addresses[0]['addressline1'],'city' => $addresses[0]['fk_city'],'state' => $addresses[0]['fk_state'],'pincode' => $addresses[0]['pincode']); - $this->PD_Model->saveRecords($records,SMC_TEMP_ADDRESS); + $this->response($data, REST_Controller::HTTP_OK); } - function distancematrix_get(){ + function saveSMCTempAddress($pd_id, $addresses) + { + $records = array('file_id' => $pd_id, 'addressline' => $addresses[0]['addressline1'], 'city' => $addresses[0]['fk_city'], 'state' => $addresses[0]['fk_state'], 'pincode' => $addresses[0]['pincode']); + $this->PD_Model->saveRecords($records, SMC_TEMP_ADDRESS); + } + + function distancematrix_get() + { $pd_loc = $this->get('loc'); $lender = $this->get('lender'); $entity_loc = $this->PD_Model->getEntityAddr($lender); - $this->response(satellite_image::getdistancematrix($entity_loc,$pd_loc),REST_Controller::HTTP_OK,true); - } - - function PDjson_get(){ - $data = $this->PD_Model->testSection($this->get('id'),$this->get('fid')); - $this->response($data,REST_Controller::HTTP_OK); + $this->response(satellite_image::getdistancematrix($entity_loc, $pd_loc), REST_Controller::HTTP_OK, true); } - function checkmail_post(){ - $records = $this->post('records'); - PDALERTS::sendMWcreditPDMail($this,$records,1); - PDALERTS::sendMWcreditPDMail($this,$records,2); - } - function optimizeImages_get() - { - $this->load->helper('MYHTTPCLIENT'); - $pd_id = $this->uri->segment(2); - $lender_id = $this->PD_Model->selectCustomRecords(array('fk_lender_id'),array('pd_id' => $pd_id),PDTRIGGER); - $sourceBucket = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id']; - //echo $sourceBucket; - $result = MYHTTPCLIENT::startOptimizeImages($sourceBucket,$pd_id); - //print_r($result);die(); - // $code = $result->getStatusCode(); - // echo $code; - // $body = $result->getBody(); - // //$body = $body->getContents(); - // print_r($body);die(); - if($result['statusCode'] == 200) - { - $data['dataStatus'] = true; + function PDjson_get() + { + $data = $this->PD_Model->testSection($this->get('id'), $this->get('fid')); + $this->response($data, REST_Controller::HTTP_OK); + } + function checkmail_post() + { + $records = $this->post('records'); + PDALERTS::sendMWcreditPDMail($this, $records, 1); + PDALERTS::sendMWcreditPDMail($this, $records, 2); + } + + function optimizeImages_get() + { + $this->load->helper('MYHTTPCLIENT'); + $pd_id = $this->uri->segment(2); + $lender_id = $this->PD_Model->selectCustomRecords(array('fk_lender_id'), array('pd_id' => $pd_id), PDTRIGGER); + $sourceBucket = LENDER_BUCKET_NAME_PREFIX . $lender_id[0]['fk_lender_id']; + //echo $sourceBucket; + $result = MYHTTPCLIENT::startOptimizeImages($sourceBucket, $pd_id); + //print_r($result);die(); + // $code = $result->getStatusCode(); + // echo $code; + // $body = $result->getBody(); + // //$body = $body->getContents(); + // print_r($body);die(); + if ($result['statusCode'] == 200) { + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result['body']; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - //print_r($result); - - } + $this->response($data, REST_Controller::HTTP_OK); + } + //print_r($result); + + } - public function downloadSMCExcelFile_get() - { - $pd_id = $this->uri->segment(2); - $pd_master_data = $this->PD_Model->getPDMasterDetails($pd_id); - // print_r($pd_master_details);die(); - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_data[0]['fk_lender_id']; - $key = 'tmp/'. ($pd_master_data[0]['re_uploaded'] ? $pd_master_data[0]['re_uploaded_file_name'] : $pd_master_data[0]['modified_fname']); - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - if($singed_uri) - { - $data['dataStatus'] = true; + public function downloadSMCExcelFile_get() + { + $pd_id = $this->uri->segment(2); + $pd_master_data = $this->PD_Model->getPDMasterDetails($pd_id); + // print_r($pd_master_details);die(); + $bucketname = LENDER_BUCKET_NAME_PREFIX . $pd_master_data[0]['fk_lender_id']; + $key = 'tmp/' . ($pd_master_data[0]['re_uploaded'] ? $pd_master_data[0]['re_uploaded_file_name'] : $pd_master_data[0]['modified_fname']); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes'); + if ($singed_uri) { + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $singed_uri; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; + $this->response($data, REST_Controller::HTTP_OK); + } else { + $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'Something Went Wrong! Try Later'; - $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); + $this->response($data, REST_Controller::HTTP_OK); + } } - public function sendNotificationToOfficers_post(){ - log_message('ERROR',"send Notification To Officers "); + + 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)){ + 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)); + 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 "); + } 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 "); + } 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 "); + } 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); - - } + $this->response($data, REST_Controller::HTTP_OK); + } /**** create gmeet link for smart and tele pd and update it in pd trigger table - */ + */ function createGmeetLink_get() // function createGmeetLink($pdid) { - + // echo Date('Y-m-d').'T'. Date('H:i:s', (strtotime(Date('H:i:s') . '+ 1 hour'))); // die(); $pdid = $this->get('pdid'); @@ -11926,133 +10431,122 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $pd_details = $this->PD_Model->getPDMasterDetails($pdid); // print_r($pd_details); - if(!$pd_details[0]['gmeet_code'] && ($pd_details[0]['fk_pd_type'] == 2 || $pd_details[0]['fk_pd_type'] == 3)) - { - $event = array( - 'summary' => 'PD for '.$pd_details[0]['title_name'].' '.$pd_details[0]['main_applicant'].' & case no -'.$pd_details[0]['pd_sno'].' & Applicant ID - '.$pd_details[0]['lender_applicant_id'], - 'start' => Date('Y-m-d').'T'.Date('H:i:s'), - 'end' => Date('Y-m-d').'T'. Date('H:i:s', (strtotime(Date('H:i:s') . '+ 1 hour'))), - 'pdid' => $pdid, - - ); - // print_r($event);die(); - $event_data = $this->googleapi->addGoogleCalenterEvent($event); - if(is_object($event_data)) - { - $meet_code = isset($event_data['conferenceData']['conferenceId']) ? $event_data['conferenceData']['conferenceId'] : null; - $meet_id = isset($event_data['id']) ? $event_data['id'] : null; - $where_condition_array = array('pd_id' => $pdid); - $this->PD_Model->updateRecords(['gmeet_code' => $meet_code,'gmeet_id' => $meet_id],PDTRIGGER,$where_condition_array); + if (!$pd_details[0]['gmeet_code'] && ($pd_details[0]['fk_pd_type'] == 2 || $pd_details[0]['fk_pd_type'] == 3)) { + $event = array( + 'summary' => 'PD for ' . $pd_details[0]['title_name'] . ' ' . $pd_details[0]['main_applicant'] . ' & case no -' . $pd_details[0]['pd_sno'] . ' & Applicant ID - ' . $pd_details[0]['lender_applicant_id'], + 'start' => Date('Y-m-d') . 'T' . Date('H:i:s'), + 'end' => Date('Y-m-d') . 'T' . Date('H:i:s', (strtotime(Date('H:i:s') . '+ 1 hour'))), + 'pdid' => $pdid, - $data['dataStatus'] = true; + ); + // print_r($event);die(); + $event_data = $this->googleapi->addGoogleCalenterEvent($event); + if (is_object($event_data)) { + $meet_code = isset($event_data['conferenceData']['conferenceId']) ? $event_data['conferenceData']['conferenceId'] : null; + $meet_id = isset($event_data['id']) ? $event_data['id'] : null; + $where_condition_array = array('pd_id' => $pdid); + $this->PD_Model->updateRecords(['gmeet_code' => $meet_code, 'gmeet_id' => $meet_id], PDTRIGGER, $where_condition_array); + + $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['data'] = ['gmeet_code' => $meet_code]; - $this->response($data,REST_Controller::HTTP_OK); - } + $this->response($data, REST_Controller::HTTP_OK); + } + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'gmeet already created'; + $this->response($data, REST_Controller::HTTP_OK); } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'gmeet already created'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - } /**** delete Calender Event from google calender - */ + */ // function deleteCalenderEvent_get() function deleteCalenderEvent($eventID) { // $eventID = $this->get('eventID'); $this->load->library('Googleapi'); - $event_data = $this->googleapi->deleteGoogleCalenderEvent($eventID); - } - + $event_data = $this->googleapi->deleteGoogleCalenderEvent($eventID); + } + + - // public function toMakeFaceBoundingBox_get(){ - public function toMakeFaceBoundingBox($master_details){ + public function toMakeFaceBoundingBox($master_details) + { // $pdid = $this->get('pd');//pdid 3184 comment this - $pdid = $master_details[0]['pd_id']; - log_message('ERROR',"In PD Controller @ line no : 11951 (to Make FaceBoundingBox called ) PDID : ".$pdid); + $pdid = $master_details[0]['pd_id']; + log_message('ERROR', "In PD Controller @ line no : 11951 (to Make FaceBoundingBox called ) PDID : " . $pdid); $bounding_box = array(); - if(!empty($pdid)){ - // $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this - if($master_details[0]['facemark_image_generated'] == 0){ - log_message('ERROR',"In PD Controller @ line no : 11956 Facemark Image Generated : ".$master_details[0]['facemark_image_generated']); - $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'),array('pd_id' => $pdid),PDTRIGGER); - $string = $db_result[0]['faceapi_result']; - // echo gettype($string); - $my_array = json_decode($string,true); - // echo gettype($my_array); - if(!empty($my_array) && !empty($my_array["FaceMatches"])){ - $arr = $my_array["FaceMatches"]; - log_message('ERROR',"In PD Controller @ line no : 11964 to Make FaceBoundingBox FaceMatches array cnt : ".count($arr)); - for($i=0;$iPD_Model->getPDMasterDetails($pdid);//comment this + if ($master_details[0]['facemark_image_generated'] == 0) { + log_message('ERROR', "In PD Controller @ line no : 11956 Facemark Image Generated : " . $master_details[0]['facemark_image_generated']); + $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'), array('pd_id' => $pdid), PDTRIGGER); + $string = $db_result[0]['faceapi_result']; + // echo gettype($string); + $my_array = json_decode($string, true); + // echo gettype($my_array); + if (!empty($my_array) && !empty($my_array["FaceMatches"])) { + $arr = $my_array["FaceMatches"]; + log_message('ERROR', "In PD Controller @ line no : 11964 to Make FaceBoundingBox FaceMatches array cnt : " . count($arr)); + for ($i = 0; $i < count($arr); $i++) { + $bounding_box[$i] = $arr[$i]['Face']['BoundingBox']; + $bounding_box[$i]['Similarity'] = $arr[$i]['Similarity']; } - $where_condition_array = array('fk_pd_id' => $pdid,'isactive' => 1,'image_key' => "selfie_with_person_met"); - $img_result = $this->PD_Model->selectCustomRecords(array('pd_document_id','pd_document_name','pd_document_title','image_key'),$where_condition_array,PDDOCUMENTS); - - $bucketname = LENDER_BUCKET_NAME_PREFIX.$master_details[0]['fk_lender_id']; - $key = 'pd'.$pdid.'/'.$img_result[0]['pd_document_name']; - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - log_message('ERROR',"In PD Controller @ line no : 11973 to Make FaceBoundingBox FaceMatches singed_uri : ".$singed_uri); - - // $temp_image_name = "sample.png"; - $temp_image_name = "face_api_image.jpeg"; - $destination_path = $this->external_path."/pd_reports/". $pdid ."/".$temp_image_name; - file_put_contents($destination_path, file_get_contents($singed_uri)); - - faceapi::toMakeFaceBoundingBox($temp_image_name,$bounding_box,$destination_path); - - $key = 'pd'.$pdid.'/'.$temp_image_name; - $sourcefile = $destination_path; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - log_message('ERROR',"In PD Controller @ line no : 11990 to Make FaceBoundingBox FaceMatches s3result : ".$s3result['@metadata']['statusCode']); - - // print_r($s3result);die(); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { - log_message('ERROR',"In PD Controller @ line no : 11996 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); - //Update - $this->db->WHERE('pd_id',$pdid)->UPDATE(PDTRIGGER,array('facemark_image_generated' => 1)); - log_message('ERROR',"In PD Controller @ line no : 11998 to Make FaceBoundingBox save document table face_api_result_image after unlink"); - $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>'face_api_result_image','pd_document_name'=>$temp_image_name); - $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - unlink($destination_path); - } - // $data['dataStatus'] = true; - // $data['status'] = REST_Controller::HTTP_OK; - // $data['msg'] = 'Success '; - // $data['details'] = $bounding_box; } - else{ - log_message('ERROR',"In PD Controller @ line no : 12009 to Make FaceBoundingBox Faceapi Image Already Generated"); - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'Faceapi Image Already Generated'; + $where_condition_array = array('fk_pd_id' => $pdid, 'isactive' => 1, 'image_key' => "selfie_with_person_met"); + $img_result = $this->PD_Model->selectCustomRecords(array('pd_document_id', 'pd_document_name', 'pd_document_title', 'image_key'), $where_condition_array, PDDOCUMENTS); + + $bucketname = LENDER_BUCKET_NAME_PREFIX . $master_details[0]['fk_lender_id']; + $key = 'pd' . $pdid . '/' . $img_result[0]['pd_document_name']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes'); + log_message('ERROR', "In PD Controller @ line no : 11973 to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri); + + // $temp_image_name = "sample.png"; + $temp_image_name = "face_api_image.jpeg"; + $destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $temp_image_name; + file_put_contents($destination_path, file_get_contents($singed_uri)); + + faceapi::toMakeFaceBoundingBox($temp_image_name, $bounding_box, $destination_path); + + $key = 'pd' . $pdid . '/' . $temp_image_name; + $sourcefile = $destination_path; + + $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); + $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); + log_message('ERROR', "In PD Controller @ line no : 11990 to Make FaceBoundingBox FaceMatches s3result : " . $s3result['@metadata']['statusCode']); + + // print_r($s3result);die(); + if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR', "In PD Controller @ line no : 11996 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); + //Update + $this->db->WHERE('pd_id', $pdid)->UPDATE(PDTRIGGER, array('facemark_image_generated' => 1)); + log_message('ERROR', "In PD Controller @ line no : 11998 to Make FaceBoundingBox save document table face_api_result_image after unlink"); + $record_data = array('fk_pd_id' => $pdid, 'pd_document_title' => 'face_api_result_image', 'pd_document_name' => $temp_image_name); + $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); + unlink($destination_path); } - } - else{ - log_message('ERROR',"In PD Controller @ line no : 12016 to Make FaceBoundingBox PDID is Not Available"); + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['msg'] = 'Success '; + // $data['details'] = $bounding_box; + } else { + log_message('ERROR', "In PD Controller @ line no : 12009 to Make FaceBoundingBox Faceapi Image Already Generated"); // $data['dataStatus'] = false; // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'PDID is Not Available'; + // $data['msg'] = 'Faceapi Image Already Generated'; + } + } else { + log_message('ERROR', "In PD Controller @ line no : 12016 to Make FaceBoundingBox PDID is Not Available"); + // $data['dataStatus'] = false; + // $data['status'] = REST_Controller::HTTP_NO_CONTENT; + // $data['msg'] = 'PDID is Not Available'; } // $this->response($data,REST_Controller::HTTP_OK); - } - - -} \ No newline at end of file + } +} diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index 999da10b..19a211f7 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -768,11 +768,12 @@ class SMC_Credit_PD_Controller extends REST_Controller { //echo 'final';die(); $id = $this->SMC_Credit_PD_Model->updateRecords($records,SMC_CREDIT_PD,array('smc_credit_pd' => $records['smc_credit_pd'])); log_message('ERROR','####COMPLETE SMC Credit PD = '.$records['smc_credit_pd']); - $random_string = $records['random_string']; - $ZIP = smc_creditpd::covertSMCImgs2ZIP($records['smc_credit_pd'],$random_string,array(),0); - log_message('ERROR','####COMPLETE SMC IMAGE ZIP = '.$ZIP); - $PDF = smc_creditpd::covertSMCImgs2PDF($records['smc_credit_pd'],$random_string,array(),0); - log_message('ERROR','####COMPLETE SMC IMAGE PDF = '.$PDF); + // $random_string = $this->SMC_Credit_PD_Model->selectCustomRecords(array('rand_string'),array('smc_credit_pd' => $records['smc_credit_pd'],'isactive' => 1),SMC_CREDIT_PD); + // $random_string = $random_string[0]['rand_string']; + // $ZIP = smc_creditpd::covertSMCImgs2ZIP($records['smc_credit_pd'],$random_string,array(),0); + // log_message('ERROR','####COMPLETE SMC IMAGE ZIP = '.$ZIP); + // $PDF = smc_creditpd::covertSMCImgs2PDF($records['smc_credit_pd'],$random_string,array(),0); + // log_message('ERROR','####COMPLETE SMC IMAGE PDF = '.$PDF); //$this->prepareSalesPDReport($records['smc_credit_pd'],false); // sleep(10); // log_message('ERROR','####SALESPD AFTER 10 PREPARED REPORT'.$records['smc_credit_pd']); diff --git a/api/application/helpers/smc_creditpd_helper.php b/api/application/helpers/smc_creditpd_helper.php index 65101a57..0edc124e 100644 --- a/api/application/helpers/smc_creditpd_helper.php +++ b/api/application/helpers/smc_creditpd_helper.php @@ -669,9 +669,9 @@ class smc_creditpd } public static function covertSMCImgs2PDF($pdid,$random_string,$pd_master_details = array(),$regenerate = 0) { - //echo 'this is from daiu'; $CI =&get_instance(); $CI->load->model('PD_Model'); + $CI->load->model('SMC_Credit_PD_Model'); $CI->load->library('pdfgenerator'); if(!count($pd_master_details)) From 9d8e793e56d90f21a0e4cfd7aecbb60bf70d9867 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 10 Sep 2022 22:18:23 +0530 Subject: [PATCH 071/132] Face Compare report Changes : 1 --- api/application/controllers/PD_Controller.php | 83 +++++++++++-------- api/application/helpers/faceapi_helper.php | 19 +++++ .../report_templates/JSONTOREPORT_DI_AI.php | 33 ++++++-- 3 files changed, 96 insertions(+), 39 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 2236d5ea..bdec2cf1 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -842,8 +842,6 @@ class PD_Controller extends REST_Controller EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_details['pd_id']); $exist_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['pd_id']); // print_r($pd_details); - // print_r($exist_pd_details); - if (!file_exists($this->external_path . '/pd_reports/' . $pd_details['pd_id'])) { mkdir($this->external_path . '/pd_reports/' . $pd_details['pd_id'], 0777); } @@ -891,9 +889,9 @@ class PD_Controller extends REST_Controller if (isset($pd_details['pd_status']) && (($pd_details['pd_status'] == COMPLETED) || ($pd_details['pd_status'] == ADD_ON_PENDING))) { if ($pd_details['pd_status'] == COMPLETED) { - // $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); + $pd_details['complete_override_data'] = isset($pd_details['complete_override_data']) ? json_encode($pd_details['complete_override_data']) : null; $pd_details['completed_on'] = date('Y-m-d H:i:s'); - log_message('ERROR', "In PD Controller @ line no : 992 (When Completed status means calling to Make FaceBoundingBox fns below"); + log_message('ERROR', "In PD Controller (When Completed status means calling to Make FaceBoundingBox fns below"); $this->toMakeFaceBoundingBox($exist_pd_details); if(isset($pd_details['is_this_smc_pd']) && $pd_details['is_this_smc_pd'] == 1 && $pd_details['pd_status'] == COMPLETED){ $this->load->helper('smc_creditpd'); @@ -5798,6 +5796,24 @@ class PD_Controller extends REST_Controller } } + $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'), array('pd_id' => $pdid), PDTRIGGER); + $string = $db_result[0]['faceapi_result']; + // echo gettype($string); + $my_array = json_decode($string, true); + // echo gettype($my_array); + if (!empty($my_array) && !empty($my_array["FaceMatches"])) { + $data['faceapi_result'] = $my_array; + $arr = $my_array["FaceMatches"]; + log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches array cnt : " . count($arr)); + for ($i = 0; $i < count($arr); $i++) { + $data['bounding_box'][$i] = $arr[$i]['Face']['BoundingBox']; + $data['bounding_box'][$i]['Similarity'] = $arr[$i]['Similarity']; + } + }else{ + $data['faceapi_result'] = array(); + $data['bounding_box'] = array(); + } + // print_r($data['add_on_pd_images']); // die(); @@ -5844,8 +5860,8 @@ class PD_Controller extends REST_Controller $t = $this->load->view('report_templates/JSONTOREPORT_DI_AI_ADDON', $data, true); } //$t = $this->load->view('temp_html.html',null,true); - echo $data['pd_master_details'][0]['customer_segment_abbr']; - echo $data['pd_master_details'][0]['fk_pd_type']; + // echo $data['pd_master_details'][0]['customer_segment_abbr']; + // echo $data['pd_master_details'][0]['fk_pd_type']; echo $t; die(); @@ -10474,17 +10490,17 @@ class PD_Controller extends REST_Controller - // public function toMakeFaceBoundingBox_get(){ - public function toMakeFaceBoundingBox($master_details) - { - // $pdid = $this->get('pd');//pdid 3184 comment this - $pdid = $master_details[0]['pd_id']; - log_message('ERROR', "In PD Controller @ line no : 11951 (to Make FaceBoundingBox called ) PDID : " . $pdid); + public function toMakeFaceBoundingBox_get(){ + // public function toMakeFaceBoundingBox($master_details) + // { + $pdid = $this->get('pd');//pdid 3184 comment this + // $pdid = $master_details[0]['pd_id']; + log_message('ERROR', "In PD Controller (to Make FaceBoundingBox called ) PDID : " . $pdid); $bounding_box = array(); if (!empty($pdid)) { - // $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this - if ($master_details[0]['facemark_image_generated'] == 0) { - log_message('ERROR', "In PD Controller @ line no : 11956 Facemark Image Generated : " . $master_details[0]['facemark_image_generated']); + $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this + if ($master_details[0]['facemark_image_generated']) { + log_message('ERROR', "In PD Controller Facemark Image Generated : " . $master_details[0]['facemark_image_generated']); $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'), array('pd_id' => $pdid), PDTRIGGER); $string = $db_result[0]['faceapi_result']; // echo gettype($string); @@ -10492,7 +10508,7 @@ class PD_Controller extends REST_Controller // echo gettype($my_array); if (!empty($my_array) && !empty($my_array["FaceMatches"])) { $arr = $my_array["FaceMatches"]; - log_message('ERROR', "In PD Controller @ line no : 11964 to Make FaceBoundingBox FaceMatches array cnt : " . count($arr)); + log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches array cnt : " . count($arr)); for ($i = 0; $i < count($arr); $i++) { $bounding_box[$i] = $arr[$i]['Face']['BoundingBox']; $bounding_box[$i]['Similarity'] = $arr[$i]['Similarity']; @@ -10504,7 +10520,7 @@ class PD_Controller extends REST_Controller $bucketname = LENDER_BUCKET_NAME_PREFIX . $master_details[0]['fk_lender_id']; $key = 'pd' . $pdid . '/' . $img_result[0]['pd_document_name']; $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $key, '+30 minutes'); - log_message('ERROR', "In PD Controller @ line no : 11973 to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri); + log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches singed_uri : " . $singed_uri); // $temp_image_name = "sample.png"; $temp_image_name = "face_api_image.jpeg"; @@ -10518,35 +10534,34 @@ class PD_Controller extends REST_Controller $bucket_data = array('bucket_name' => $bucketname, 'key' => $key, 'sourcefile' => $sourcefile); $s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data); - log_message('ERROR', "In PD Controller @ line no : 11990 to Make FaceBoundingBox FaceMatches s3result : " . $s3result['@metadata']['statusCode']); - + log_message('ERROR', "In PD Controller to Make FaceBoundingBox FaceMatches s3result : " . $s3result['@metadata']['statusCode']); // print_r($s3result);die(); if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - log_message('ERROR', "In PD Controller @ line no : 11996 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); + log_message('ERROR', "In PD Controller to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); //Update $this->db->WHERE('pd_id', $pdid)->UPDATE(PDTRIGGER, array('facemark_image_generated' => 1)); - log_message('ERROR', "In PD Controller @ line no : 11998 to Make FaceBoundingBox save document table face_api_result_image after unlink"); + log_message('ERROR', "In PD Controller to Make FaceBoundingBox save document table face_api_result_image after unlink"); $record_data = array('fk_pd_id' => $pdid, 'pd_document_title' => 'face_api_result_image', 'pd_document_name' => $temp_image_name); $this->PD_Model->saveRecords($record_data, PDDOCUMENTS); unlink($destination_path); } - // $data['dataStatus'] = true; - // $data['status'] = REST_Controller::HTTP_OK; - // $data['msg'] = 'Success '; - // $data['details'] = $bounding_box; + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['msg'] = 'Success '; + $data['details'] = $bounding_box; } else { - log_message('ERROR', "In PD Controller @ line no : 12009 to Make FaceBoundingBox Faceapi Image Already Generated"); - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'Faceapi Image Already Generated'; + log_message('ERROR', "In PD Controller to Make FaceBoundingBox Faceapi Image Already Generated"); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Faceapi Image Already Generated'; } } else { - log_message('ERROR', "In PD Controller @ line no : 12016 to Make FaceBoundingBox PDID is Not Available"); - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'PDID is Not Available'; + log_message('ERROR', "In PD Controller to Make FaceBoundingBox PDID is Not Available"); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'PDID is Not Available'; } - // $this->response($data,REST_Controller::HTTP_OK); + $this->response($data,REST_Controller::HTTP_OK); } } diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index fc28974a..2ef4859f 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -35,6 +35,7 @@ class faceapi $y1 = $Top_coordinate; self::DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path); + self::imgCrop($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path,$i); } @@ -119,6 +120,24 @@ class faceapi return imagepolygon($image, $points, 4, $color); } +public static function imgCrop($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path,$i){ + $temp_image_name = "face_crop_".$i.".jpeg"; + log_message('ERROR','In faceapi helper - imgCrop @ line no : 126 x1 : '.$x1.' y1 : '.$y1.' Face_width : '.$Face_width.' Face_height : '.$Face_height.' Similarity : '.$Similarity.' img : '.$img.' destination_path : '.$destination_path); + $destination_path_2 = preg_replace('#/\w+(\.\w+)$#', '/'.$temp_image_name, $destination_path); + log_message('ERROR','In faceapi helper - imgCrop @ line no : 126 destination_path b4 : '.$destination_path.' destination_path after : '.$destination_path_2); + $to_crop_array = array('x' =>$x1 , 'y' => $y1, 'width' => $Face_width, 'height'=> $Face_height); + $dest = imagecrop($img, $to_crop_array); + $get_image_format = explode(".",$destination_path); + $image_format = $get_image_format[1]; + if($image_format == 'png'){ + imagepng($dest, $destination_path_2); + }else if($image_format == 'jpeg'){ + imagejpeg($dest, $destination_path_2); + }else if($image_format == 'jpg'){ + imagejpg($dest, $destination_path_2); + } +} + } ?> \ No newline at end of file diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php index d1545529..b9a3e68b 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php @@ -9,6 +9,10 @@ $loan_word = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? 'Loan' : 'Fa + + + + + + + + + + + + + + + + +
+
+ Powered by PD Genie™ +
+ +
+
+
+
+ + +
"; + ?> +
"; + + echo "
"; + echo "

PERSONAL DISCUSSION REPORT

"; + echo "
for the case of
"; + + echo "

" . $main_applicant_name . "

"; + echo "
"; + echo "



"; + ?> + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + ?> + + Loan Amount Applied For :

"; + //echo '
PD Initiated Date : ' . $pd_master_details[0]['createdon'] . '
FI PD Date : ' . $pd_master_details[0]['pd_visit_date'] . '
PD Report Date : ' . $pd_master_details[0]['pd_report_generated_date'] . '
PD Initiated by : ' . $pd_master_details[0]['branch_name'] . ' Branch
PD Type : Telephonic
Product : ' . $pd_master_details[0]['product_name'] . '
Customer Segment : ' . (explode('-', $pd_master_details[0]['customer_segment_name'])[0]) . '
+ echo '
'; + //echo "
"; + echo "

"; + echo "

"; + echo "

"; + echo "

"; + echo "

"; + echo "

"; + + $header_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 1); + if (isset($header_lender_disclaimer['disclaimer']) && $header_lender_disclaimer['disclaimer'] != '' && $header_lender_disclaimer['type'] == 1) { + echo '

Disclaimer: ' . $header_lender_disclaimer['disclaimer'] . '

'; + } + + echo '

Registered / Corporate Office: SineEdge Consulting Private Limited. A-211, Pioneer Urban Square, Golf Course Extension Road, Sector 62, Gurgaon, Haryana - 122002

'; + ?> + + + + + + $individual) { + //print_r($individual);die(); + if ($individual['is_person_met'] == true) { + //array_push($person_met_images); + $temp_person_met = array(); + $applicant_name = $individual['applicant_name']; + //$applicant_name = array_key_exists('pd_co_applicant_id_master',$individual) ? $individual['pd_co_applicant_id_master'] : "Not Available" ; + //echo '
'.$individual['applicant_title_name_master'] .' '. $applicant_name.'
' ; + $temp_person_met['name'] = $individual['applicant_title_name_master'] . ' ' . $applicant_name; + $temp_person_met['photo'] = ''; + $temp_person_met['id_proof'] = ''; + foreach ($pd_images[18] as $pm_Key => $pm_value) { + + //echo $applicant_name.'-'.$pm_value['pd_document_title']; + if (!strcasecmp(trim($applicant_name), trim($pm_value['pd_document_title']))) { + $temp_person_met['photo'] = $pm_value['doc_url']; + } + + $id = trim($applicant_name) . '-id_proof'; + if (!strcasecmp($id, trim($pm_value['pd_document_title']))) { + $temp_person_met['id_proof'] = $pm_value['doc_url']; + } + } + $company_relationship_data = null; + foreach ($general_form['company_with_relationships'] as $company_with_relationship) { + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name']) { + //FInd Company Name from JSON + $company_relationship_data .= $company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']; + + //$company_relationship_data.='
and

'; + $company_relationship_data .= ', '; + } + } + //$temp_person_met['name'] = + //print_r($general_form['persons_with_relationships']); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + if ($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && isset($persons_with_relationship['relationship'])) { + + if (isset($persons_with_relationship['relation_to_master'])) { + //? $persons_with_relationship['relation_to_master'] : " Could Not Find"; + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' Of ' . $RSNA; + //$personal_relationship_data.='
and

'; + $personal_relationship_data .= ', '; + } + } + } + } + + $company_relationship_data .= $personal_relationship_data; + $temp_person_met['relations'] = $company_relationship_data; + array_push($person_met_data, $temp_person_met); + } + } + + + //print_r($person_met_data);die(); + echo '
'; + echo '

Person(s) Met:

'; + echo '
'; + foreach ($person_met_data as $pk => $person) { + $display_for_person_met = $person['relations'] != "" ? substr_replace($person['relations'], '.', strrpos($person['relations'], ','), 1) : ''; + + $person_met_details = $person['name']; + if (strcasecmp($pd_master_details[0]['customer_segment_abbr'], 'SEP_INDV')) { + $person_met_details .= ($display_for_person_met != "" ? ' - ' . $display_for_person_met : ''); + } + echo '

' . $person_met_details . '

'; + + //if($display_for_person_met != "" || $display_for_person_met != null){ + echo '

'; + //} + if ($person['photo']) { + echo ''; + } + echo '     '; + if ($person['id_proof']) { + echo ''; + } + + //echo count($person_met_data) != ($pk+1)? '
':''; + + + } + $faceimage_url = array(); + if (isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) { + foreach ($pd_images['common_images'] as $com_key => $com_value) { + if ($com_value['pd_document_title'] == 'face_api_result_image') { + // $faceimage_url = $com_value['doc_url'];break; + array_push($faceimage_url, $com_value['doc_url']); + } + } + } + if (!empty($faceimage_url)) { + for ($i = 0; $i < count($faceimage_url); $i++) { + echo '     '; + echo ''; + } + } + echo '
'; + echo '
'; + ?> + +
+ Face Comparison"; + $notequal_mark = '
'; + $equal_mark = '
=
'; + for ($i = 0; $i < count($ci); $i++) { + $symbol = (round($ci[$i]["Similarity"]) > 50) ? '

' . $equal_mark . '

' : '

' . $notequal_mark . '

'; + echo '
+
+ ' . $si[ +
+
' . $symbol . '
+
+ ' . $ci[$i][ +
+
'; + + echo '

Similarity + ' . round($ci[$i]["Similarity"]) . ' +

+
+
+ ' . round($ci[$i]["Similarity"]) . ' +
+
'; + } + // ########################### End of Percentage Bar Section ######################################### + } + } + ?> + + + + + + + + + + + + + $individual) { + + if ($individual['is_applicant'] == true && $individual['is_active'] == true) { + + $education_qualification = $individual['qualification_master']; + $education_qualification = $individual['course_name'] != "" || $individual['course_name'] != null ? $education_qualification . '
(' . $individual['course_name'] . ')' : $education_qualification; + + + $applicant_name = array_key_exists('pd_co_applicant_id_master', $individual) ? $individual['pd_co_applicant_id_master'] : " Could Not Find"; + //echo $applicant_name.'**************************'; + + $title = isset($individual['applicant_title_name_master']) && $individual['applicant_title_name_master'] != "" ? $individual['applicant_title_name_master'] : ''; + + //$kyc_data = ''; + $applicant_name = $title . ' ' . $applicant_name; + if ($ind_key == 0 && array_key_exists('is_kyc', $general_form) && $general_form['is_kyc'] == 'no') { + $applicant_name = 'As per the request received applicant name is ' . $applicant_name . '
but as per KYC name is ' . $general_form['kyc_and_captur_the_name']; + //$kyc_data = "

Name noticed as per KYC is ". $general_form['kyc_and_captur_the_name']; + } + echo '"; + } + } + + if (isset($general_form['companies']) && count($general_form['companies'])) { + $business_entity_type_master = array(1 => 'Others', 2 => 'Public Ltd Company', 3 => 'Sole proprietorship', 4 => 'HUF (Hindu Undivided Family)', 5 => 'Partnership', 6 => 'Cooperative', 7 => 'Limited Liability Partnership(LLP)', 8 => 'OPC (One Person Company)', 9 => 'Society', 10 => 'Trust', 11 => 'Private Limited Company'); + foreach ($general_form['companies'] as $comp_key => $ind_company) { + if ($ind_company['is_company_applicant'] != null) { + + echo ''; + } + } + } + ?> + +
NameAge
(Yrs/Mns)
Qualification / Type of EntityRelationships
' . $applicant_name . '' . $individual['age'] . '' . $education_qualification . ''; + + $company_relationship_data = null; + //print_r($general_form['company_with_relationships']); + foreach ($general_form['company_with_relationships'] as $crk => $company_with_relationship) { + + //print_r($company_with_relationship); + + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name'] && $company_with_relationship['company_name'] != '') { + //FInd Company Name from JSON + + //echo "ONCE"; + //echo '### '.$crk.'-ICID'.$individual['pd_co_applicant_id'].'--'.$company_with_relationship['applicant_name'].'-'.$company_with_relationship['company_name']; + $company_relationship_data .= ($company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']); + + $company_relationship_data .= '
and

'; + //echo $company_relationship_data; + } + } + //echo $company_relationship_data; + // die(); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + + + + if (($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] || !strcasecmp($applicant_name, $persons_with_relationship['applicant_name'])) && isset($persons_with_relationship['relationship'])) { + + + if (isset($persons_with_relationship['relation_to_master'])) { + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' of ' . $RSNA; + + $personal_relationship_data .= '
and

'; + } + } + } + } + $company_relationship_data .= $personal_relationship_data; + echo substr_replace($company_relationship_data, '', strrpos($company_relationship_data, '
and

'), strlen($company_relationship_data)); + + echo "
' . $ind_company['company_name'] . '' . $ind_company['business_years'] . (isset($ind_company['business_month']) ? ' . ' . $ind_company['business_month'] : null) . '' . ($ind_company['business_entity_type'] == 1 ? $ind_company['business_entity_type_other'] : $business_entity_type_master[$ind_company['business_entity_type']]) . ' Not Applicable
+ + + + + ' . $general_form['general_remark'] . '

'; + } + ?> + + + + + + + 'well suited', 'fairly_suited' => 'fairly suited', 'not_suited' => 'not suited'); + //die(); + if (isset($pd_score) && count($pd_score)) { + echo '
'; + echo '

PD Score Summary

'; + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Actual ScoreMax ScoreScore %
General Section Score
Business Section Score
Final Remarks Score
Final PD Score
+ +
"; + + echo '

'; + } + // else + // { echo "Score Chart Not Generated"; } + + + + //######################### CHART ########################### + + + // if(isset($dsc_cards['base64_dsc_business'])) + // { + // echo "

"; + + // echo '

'; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + // if(isset($dsc_cards['base64_dsc_general'])) + // { + // echo "

"; + + // echo '

'; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + + echo "
"; + //######################### CHART ########################### + + $business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>", "owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>", "stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>"); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>", "value_of_other_assets" => "Asset Value by Loan Amount % >>"); + } else { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>"); + } + + + + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['business'] as $bsk => $business_score) { + + $class = null; + $answer = null; + $per = $business_score['attributed_score'] > 0 && $business_score['max_score'] > 0 ? (($business_score['attributed_score'] / $business_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + // if($bsk == 'business_seasonality') + // { + // echo "BUSINESS"; + // echo $per; + // echo $class; + // echo $per >= 80 ? 'rcorners_green' : 'SOME'; + // die(); + // } + + if ($bsk == 'location_suited_for_busienss') { + $answer = $address_type_remarks_caption[$business_score['answer']]; + } else if ($bsk == 'cerificates') { + $answer = $per > 0 ? 'Yes' : 'No'; + } else if ($bsk == 'no_of_years_business_run') { + $answer = isset($business_score['answer']) ? $business_score['answer'] . ' Yrs' : ''; + } else if ($bsk == 'business_seasonality') { + $answer = isset($business_score['answer']) ? ((!strcasecmp($business_score['answer'], 'yes')) ? 'Seasonal' : 'Not Seasonal') : ''; + } else if ($bsk == 'vintage_of_business_account') { + $answer = isset($business_score['answer']) && $business_score['answer'] != '' ? $business_score['answer'] : 'No'; + } else { + $answer = isset($business_score['answer']) ? $business_score['answer'] : ''; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
Business Related Parameters Impacting Score Response
' . $business_captions[$bsk] . ' ' . '
' . ucfirst($answer) . '
'; + echo '


'; + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['general'] as $gsk => $general_score) { + $class = null; + $per = $general_score['attributed_score'] > 0 && $general_score['max_score'] > 0 ? (($general_score['attributed_score'] / $general_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + $answer = ucfirst($general_score['answer']); + + if ($gsk == 'value_of_other_assets') { + //print_r($general_score);die(); + $answer = round((($answer / $loan_form['loan_amount']) * 100), 2) . ' %'; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
Other Parameters Impacting ScoreResponse
' . $general_captions[$gsk] . ' ' . '
' . $answer . '
'; + + + // + } //end of is score card enabled for this pd + + ?> + + $address_image_value) { + if ($address_image_value['is_show_report'] == 1) { + $pd_location_approach_img_url = isset($address_image_value['doc_url']) ? $address_image_value['doc_url'] : ''; + //$pd_location_approach_img_location = $address_image_value['location']; + //$pd_location_approach_img_date = date('Y/m/d h:s:i A',$address_image_value['createdon']); + break; + } + } + + $name_board_seen_img_url = ''; + if (isset($pd_processed_forms[13][0])) { + + $first_business_form = json_decode($pd_processed_forms[13][0]['processed_json'], true); + //if($first_business_form['was_the_company_name_board_sighted']=='yes') + //{ + //echo 'YES';die(); + foreach ($pd_images[13] as $image_key => $image_value) { + if ($image_value['pd_document_title'] == 'Name Board Seen') { + + $name_board_seen_img_url = $image_value['doc_url']; + break; + } + } + //} + } + + //echo $name_board_seen_img_url;die(); + //print_r($address_images);die(); + ?> +
+

BUSINESS LOCATION

+ +

Address at which PD was initiated: ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + + echo '
Address at which PD Visit actually done: ' . $pd_alternative_address['alternative_address'] . ', ' . $pd_alternative_address['city_master'] . ', ' . $pd_alternative_address['state_master'] . ' - ' . $alter_native_pincode . '.'; + + echo '
Reason for change in PD address:' . $pd_alternative_address['reason_for_alternative_address']; + } else { + + echo 'Business Address : ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + } + + echo '

GPS Coordinates of Business Address : '; + echo isset($pd_master_details[0]['start_location']) ? $pd_master_details[0]['start_location'] : 'Not Available'; + echo '

'; + ?> + $com_value) { + if ($com_value['pd_document_title'] == 'satellite') { + $satellite_url = $com_value['doc_url']; + break; + } + } + } + + ?> +  Satellite Image of location of Where PD was Done


+ + + + + + + + + + + + +
Name Board of Business/Entrance
+ Name Board +
+ +

+
+

Location Summary

+ '; + echo 'The ' . $address_type . 'Address Form - Type of Address is ' . $property_owner_type . 'Business Assest Form - Owner of the Property and the business has been in operation from here for the last ' . $yrs_being_run . 'Business Assest Form - Business running Yrs in this premise .'; + echo '

The ' . $address_type . 'Address Form - Type of Address is located in ' . $locality . 'Address Form - Locality of Address ' . ($estimated_area != 0 ? 'and the estimated area of the ' . $address_type . 'Address Form - Type of Address is ' . $estimated_area . 'Address Form - Estimated Area .' : ''); + // echo '

The PD location was '. $pd_address['pd_location_master'].'Address Form - Approach to PD location . ' . 'As Per PD Officer, the '.$address_type .'Address Form - Type of Address is situated in '.$comment_locality_master .'Address Form - Comment on locality Locality.'; + // echo '

The PD officer also made the following observations:' ; + echo '
'; + + // echo '
  • The location of the '.$address_type.'Address Form - Type of Address is '.$address_type_remarks_caption [ $final_remark_data['is_service_provided'] ].'Final Remarks Form - The location of the busienss suitability for Business to the nature of business.
  • '; + + if ($first_business_form['was_the_company_name_board_sighted'] == 'yes') { + echo '

    The business name board photograph was shared by applicant.Business Form'; + } else { + echo '

    The business name board photograph was not shared by applicant.Business Form'; + } + + if ($address_form['address_proof_provided'] == 'yes') { + echo ' The address proof was shared by applicant.Business Form'; + } else { + echo ' The address proof was not shared by applicant.Business Form'; + } + echo '

    '; + + + // if($business_assets_details['business_assets_for_address'][0]['business_is_pd_visited'] == 'yes') + // { + // echo '
  • Business Activity was seen during visit.Business Assest Form - Busienss activity seen during PD visit
  • '; + // } + // else{ + // echo '
  • No business activity was seen during the PD visit.Business Assest Form - Busienss activity seen during PD visit
  • '; + // } + // if(isset($business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark']) && $business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] != ""){ + // echo '
  • '.$business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] .'Business Assest Form - Busienss Assest Form Remarks
  • ';} + + if (isset($final_remark_data['is_competition'])) { + if ($final_remark_data['is_competition'] == 'yes') { + echo '
  • ' . $final_remark_data['appx_outlet_or_stores'] . ' Units with similar business were sighted in the locality
  • '; + } else { + echo '
  • PD officer did not observe any similar business units in the locality.
  • '; + } + } + if (isset($final_remark_data['demolition_activity'])) { + if ($final_remark_data['demolition_activity'] == 'yes') { + echo '
  • ' . $final_remark_data['comment_of_demolition_activity'] . '
  • '; + echo '
    Demolition Image Not Available'; + } else { + echo '
  • No demolition activity was observed in the locality.
  • '; + } + } + + + if (isset($final_remark_data['sealing_activity'])) { + if ($final_remark_data['sealing_activity'] == 'yes') { + echo '
  • ' . $final_remark_data['comment_of_sealing_activity'] . '
  • '; + echo '
    Demolition Image Not Available'; + } else { + echo '
  • No sealing activity was observed in the locality.
  • '; + } + } + + if (isset($final_remark_data['outlet_location'])) { + if ($final_remark_data['outlet_location'] == 'heavy_footfall') { + echo '
  • Heavy Footfall ( Lots of customer in the locality / market place )
  • '; + } else if ($final_remark_data['outlet_location'] == 'medium_footfall') { + echo '
  • Medium Footfall ( Meduim no of customer in the locality / market place )
  • '; + } else if ($final_remark_data['outlet_location'] == 'low_footfall') { + echo '
  • LOw Footfall ( Few customer in the locality / market place )
  • '; + } + } + + echo ""; + + if ($address_form['address_form_remark']) { + echo '' . $address_form['address_form_remark'] . 'Address Form - Address Form Remarks '; + } + echo "

    "; + // echo "
    "; + //die(); + // + ?> + + + + + + + + The following loan related information was provided by applicant.
    '; + + $is_current_product_bl = $pd_master_details[0]['prod_catagory'] == "BL" ? true : false; + $is_current_product_lab = $pd_master_details[0]['prod_catagory'] == "LAP" ? true : false; + $is_current_product_laep = $pd_master_details[0]['prod_catagory'] == "LAEP" ? true : false; + // echo $pd_master_details[0]['product_abbr']; + // echo '-bl-'. $is_current_product_bl; + // echo '-lap-'.$is_current_product_lab; + // die(); + $loan_table_dispaly_rows = array(); + + + if ($is_current_product_bl || $is_current_product_laep) { + $to_dispaly = !strcasecmp($loan_form['is_there_total_fund'], 'yes disclose') ? ('Disclosed ' . "" . " " . MYUTIL::customIndianNumberFormat($loan_form['fund_amt']) . ' (' . MYUTIL::numtowords($loan_form['fund_amt']) . ')') : 'Not Disclosed'; + $loan_table_dispaly_rows[] = array('particulars' => 'Total Fund Requirement', 'details' => $to_dispaly); + } + + + $end_use = ''; + $to_remove_for = false; + foreach ($loan_form['end_use_master'] as $enduse) { + if (strpos(strval($enduse), 'Others') === false) { + $end_use .= $enduse . ' and '; + } else { + + $to_remove_for = true; + $end_use .= $loan_form['end_use_other'] . ' and'; + } + } + $end_use = substr_replace($end_use, '', strrpos($end_use, 'and'), strlen($end_use)); + //echo substr($end_use,0,3); + + + if (strcasecmp(substr($end_use, 0, 3), 'for')) { + if (!(count($loan_form['end_use_master']) == 1 && $to_remove_for)) { + $end_use = 'For ' . $end_use; + } + } + + + + if (strcasecmp($loan_form['is_transfer'], 'no')) { + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer Amount', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['balance_transfer_amount']) . ' (' . MYUTIL::numtowords($loan_form['balance_transfer_amount']) . ')'); + + $loan_table_dispaly_rows[] = array('particulars' => 'Top Up Amount applied for', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['topup_amount']) . ($loan_form['topup_amount'] ? (' (' . MYUTIL::numtowords($loan_form['topup_amount']) . ')') : '')); + + if ($loan_form['end_use_topup_master']) { + $loan_table_dispaly_rows[] = array('particulars' => 'End Use of Topup', 'details' => (strcasecmp('others', $loan_form['end_use_topup_master'])) ? $loan_form['end_use_topup_master'] : $loan_form['other_end_use_topup']); + } + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer from', 'details' => $loan_form['lender'] == 1 ? $loan_form['other_bt_lender'] : $loan_form['lender_master']); + } else { + //echo 'sdn-'.((!$is_current_product_bl) && !$is_current_product_lab); die(); + if ((!$is_current_product_bl) && !$is_current_product_lab && !$is_current_product_laep) { + $loan_table_dispaly_rows[] = array('particulars' => 'Amount of Own Contribution', 'details' => is_numeric($loan_form['own_contribution']) && $loan_form['own_contribution'] != 0 ? ("" . " " . MYUTIL::customIndianNumberFormat($loan_form['own_contribution']) . ' (' . MYUTIL::numtowords($loan_form['own_contribution']) . ')') : 'Not Provided'); + $source_of_own_contribution = ''; + + foreach ($loan_form['source_of_own_contribution_master'] as $own_source) { + + if (!strcasecmp($own_source, 'others')) { + $source_of_own_contribution .= $loan_form['other_source'] . ' and '; + } else { + $source_of_own_contribution .= $own_source . ' and '; + } + } + + $source_of_own_contribution = substr_replace($source_of_own_contribution, '', strrpos($source_of_own_contribution, ' and '), strlen($source_of_own_contribution)); + + $loan_table_dispaly_rows[] = array('particulars' => 'Source of Own Contribution', 'details' => $source_of_own_contribution); + } + } + if (!($pd_master_details[0]['lender_short_name'] == 'UDAAN' || $pd_master_details[0]['lender_short_name'] == 'CFPL')) { + $loan_table_dispaly_rows[] = array('particulars' => 'EMI Comfortable Paying', 'details' => is_numeric($loan_form['emi_level']) && $loan_form['emi_level'] != 0 ? ($rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emi_level']) . ' (' . MYUTIL::numtowords($loan_form['emi_level']) . ')') : "Not Provided"); + } + + if (!$is_current_product_bl && !$is_current_product_laep) { + + if (isset($loan_form['property_type_master']) && $loan_form['property_type_master'] != "") { + $loan_table_dispaly_rows[] = array('particulars' => 'Type of Property Being Mortgaged', 'details' => substr_count($loan_form['property_type_master'], 'Others') ? $loan_form['property_type_others'] : $loan_form['property_type_master']); + + //print_r($loan_form);die(); + $owners_list = null; + foreach ($loan_form['owners_list_master'] as $owner) { + $owners_list .= $owner . ' and '; + } + ///echo $owners_list; + $owners_list = substr_replace($owners_list, '', strrpos($owners_list, 'and'), strlen($owners_list)); + if ($owners_list == '') { + if (isset($loan_form['owner_name_group'][0]['owner_name'])) { + $owners_list = $loan_form['owner_name_group'][0]['owner_name']['name']; + } + } + $loan_table_dispaly_rows[] = array('particulars' => 'Name of the current / proposed owner(s) of the Property being Mortgaged', 'details' => $owners_list); + + $loan_table_dispaly_rows[] = array('particulars' => 'Status of Construction', 'details' => $loan_form['construction_status_master']); + + $loan_table_dispaly_rows[] = array('particulars' => 'Estimated Market Value of the property being mortgaged', 'details' => ($loan_form['emv_per_customer'] != "" ? $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emv_per_customer']) . ' (' . MYUTIL::numtowords($loan_form['emv_per_customer']) . ')' : 'Not Provided')); + } + } + + if (isset($loan_form['property_seller']) && $loan_form['property_seller'] != '') { + $loan_table_dispaly_rows[] = array('particulars' => 'Current Owner/Seller of the property', 'details' => $loan_form['property_seller']); + } + + if (isset($loan_form['address']) && $loan_form['address'] != '') { + $address_of_owner_seller_property = $loan_form['address'] . (isset($loan_form['city_master']) ? ', ' . $loan_form['city_master'] : '') . (isset($loan_form['state_master']) ? ', ' . $loan_form['state_master'] : '') . (isset($loan_form['pincode_master']) ? ', ' . $loan_form['pincode_master'] : ''); + + $loan_table_dispaly_rows[] = array('particulars' => 'Address of the property', 'details' => $address_of_owner_seller_property); + } + //print_r($loan_table_dispaly_rows); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + ?> +

    + + + + + + $row) { + echo '"; + } + ?> + +
    S.No
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    + +
    +

    Anchor Details Section:

    + + + + + + + + $row) { + echo '"; + } + ?> + +
    S.No Particulars Particular Details
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    +
    " . $loan_form['loandetails_remarks']; + ?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + + if ($general_form['companies'][$business_count]['is_active'] == true) { // $temp_show = null; + // if($temp_show == null) + // { + ?> + + .
    '; + } + $bindEachResult['company_employees'] = ''; + + + // this is for no of employees details + if (isset($businessRow['employees_permanent']) && $businessRow['employees_permanent'] <= 0) { + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent'; + } else { + $bindEachResult['company_employees'] = 'As per loan applicant, there are ' . $businessRow['employees_permanent'] . ' permanent '; + } + + if (isset($businessRow['employees_temporary']) && $businessRow['employees_temporary'] > 0) { + + $bindEachResult['company_employees'] .= 'and ' . $businessRow['employees_temporary'] . ' temporary employee(s) with company.'; + } else { + + $bindEachResult['company_employees'] .= ' and no temporary employees with company.'; + } + + if (($businessRow['employees_permanent'] != "" && $businessRow['employees_permanent'] == 0) && ($businessRow['employees_temporary'] != "" && $businessRow['employees_temporary'] == 0)) { + + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent or temporary employees with the company.'; + } + + if (isset($businessRow['employees_appx_salary']) && $businessRow['employees_appx_salary'] != "") { + $bindEachResult['employees_appx_salary'] = 'Approximately ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($businessRow['employees_appx_salary']) . ' is being paid as salary to employees'; + } + if (isset($businessRow['officer_total']) && $businessRow['officer_total'] > 0) { + $emp = $businessRow['officer_total'] > 1 ? 'employees' : 'employee'; + $bindEachResult['officer_visit_company_employees'] = 'At the time of PD visit, the officer sighted ' . $businessRow['officer_total'] . ' ' . $emp . ' at the business premises.'; + } else { + + $bindEachResult['officer_visit_company_employees'] = ''; + //$bindEachResult['officer_visit_company_employees']='At the time of PD visit, no employees seen at the business premises.'; + } + //this is documents visited + $getDocuments = array(); + if (array_key_exists('shop_eat_act_cert', $businessRow) && strtoupper($businessRow['shop_eat_act_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Shop/Est act Certificate.', 'img' => isset($businessRow['shop_eat_act_cert_pic']) ? $businessRow['shop_eat_act_cert_pic'] : '', 'key_name' => 'shop_eat_act_cert_pic')); + } + if (array_key_exists('gst_Regn_cert', $businessRow) && strtoupper($businessRow['gst_Regn_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'GST Registration.', 'img' => isset($businessRow['gst_Regn_cert_pic']) ? $businessRow['gst_Regn_cert_pic'] : '', 'key_name' => 'gst_Regn_cert_pic')); + } + if (array_key_exists('pf_regn', $businessRow) && strtoupper($businessRow['pf_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'PF Registration.', 'img' => isset($businessRow['pf_regn_pic']) ? $businessRow['pf_regn_pic'] : '', 'key_name' => 'pf_regn_pic')); + } + if (array_key_exists('esic_regn', $businessRow) && strtoupper($businessRow['esic_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'ESIC Registration.', 'img' => isset($businessRow['esic_regn_pic']) ? $businessRow['esic_regn_pic'] : '', 'key_name' => 'esic_regn_pic')); + } + if (array_key_exists('export_import_cert', $businessRow) && strtoupper($businessRow['export_import_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Export/Import Certificate.', 'img' => isset($businessRow['export_import_cert_pic']) ? $businessRow['export_import_cert_pic'] : '', 'key_name' => 'export_import_cert_pic')); + } + if (array_key_exists('factory_cert', $businessRow) && strtoupper($businessRow['factory_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Factory Certificate.', 'img' => isset($businessRow['factory_cert_pic']) ? $businessRow['factory_cert_pic'] : '', 'key_name' => 'factory_cert_pic')); + } + if (array_key_exists('eb_bill', $businessRow) && strtoupper($businessRow['eb_bill']) == 'YES') { + array_push($getDocuments, array('name' => 'Electric Bill.', 'img' => isset($businessRow['eb_bill_pic']) ? $businessRow['eb_bill_pic'] : '', 'key_name' => 'eb_bill_pic')); + } + if (strtoupper($businessRow['other_documents']) == 'YES' && array_key_exists('documents', $businessRow)) { + foreach ($businessRow['documents'] as $docValue) { + array_push($getDocuments, array('name' => $docValue['document'], 'img' => isset($docValue['document_pic']) ? $docValue['document_pic'] : '', 'key_name' => $docValue['document'])); + } + } + + //print_r($getDocuments); + if (count($getDocuments)) { + foreach ($getDocuments as $getDocument_key => $getDocument_value) { + foreach ($pd_images[13] as $img_key => $img_value) { + if (!strcasecmp($getDocument_value['key_name'], $img_value['pd_document_title'])) { + $getDocuments[$getDocument_key]['img'] = $img_value['doc_url']; + break; + } + } + } + } + //print_r($getDocuments);die(); + $bindEachResult['visit_documents'] = $getDocuments; + array_push($businessResult, $bindEachResult); + + + + ?> +

    BUSINESS INFORMATION:

    + $fetchRow) { + //print_r($fetchRow['company_details']);die(); + ?> + +

    +

    +

    + +
    Date of Incorporation :
    + +
    Business Vintage : +

    + + +
    +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    NameShare HoldingNo.of Years in Current BusinessTotal Work Experience(Yrs)Previous ExperienceStarted Business
    + + + 0) { ?> +
    +

    Other Family Members involved in business :

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    NameIndividual RelationshipRelated toRelationship to Company / FirmStarted Business (Yes / No)
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    ' . $process_brief['description'] . '

    '; ?>
    + + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    ServicesArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + 0) { ?> + + +
    + + + + + + + + + + + + + + + +
    Other Business Activity
    +
    ' . $fetchRow['total_per_of_export'] . ' % of total sales is export.
    '; + } + + ?> + + + + + Loan applicant is using Mobile Wallets/UPI for business transactions.

    '; + } //else + //{ + // echo '

    As per person`s met,applicant using Mobile Wallets/UPI for business transactions.

    ' + //} + if (!strcasecmp($fetchRow['applicant_use_pos_machines'], 'yes')) { + echo '

    The applicant has the following POS machines:

    '; + echo ''; + echo ''; + foreach ($fetchRow['pos_machines_details'] as $pos) { + echo ''; + } + echo '
    Name of the Financial Insitution TID Number of POS machine
    ' . ($pos['pos_machines_financial_institution_name'] ? $pos['pos_machines_financial_institution_name'] : 'Not Provided') . ' ' . $pos['tid_no_of_pos_machine'] . '
    '; + } + + + + ?> + + + + + + + + + + + +
    +

    +
    + + + + +

    +

    +

    + + + + +

    The below document images were shared :

    + + + + '; + for ($doc = $from; $doc <= $to; $doc++) { + if (isset($visit_documents[$doc])) { + ?> + + '; + $from_index_increment = $from_index_increment + 2; + } ?> + +
    + +
    + + + + ' . $business_form_common_remarks . '

    '; + } + + ?> + + + + + + + +
    + + + + + + 0 && $is_business_asset_available) { + $bindBusinessAsset['details'] = ASSETSFORM::getBusinessAssetsDetails($businessAssetRow['business_assets_details'], $pd_master_details[0]['pd_id']); + } + array_push($businessAssetResult, $bindBusinessAsset); + + + //print_r($businessAssetResult);die(); + ?> + + + + +
    +
    +
    +

    Assets used in Business

    + $iterateAsset) { ?> +

    + + $value) { + echo ''; + echo ''; + echo $value['header_row']; ?> + +'; + echo '
    '; + echo '
    '; + } + } + } + } else { + echo '

    No other assests used for business.

    '; + } + if ($business_assets_form_remark != "") { + echo '

    ' . $business_assets_form_remark . '

    '; + } + } // ENd of if business assesst available in this current index +?> + + + + + + +
    +↑ /'; + + if (isset($pd_processed_forms[14][$business_count])) { + $baRow = $pd_processed_forms[14][$business_count]; + $businessFinancialRow = json_decode($baRow['processed_json'], true); + //print_r($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']);die(); + $financial_remarks = $businessFinancialRow['financial_remarks']; + $comments_on_financials = isset($businessFinancialRow['financial_reason']) ? $businessFinancialRow['financial_reason'] : ''; + //echo $financial_remarks;die(); + // statementdate_per_financial + if (isset($businessFinancialRow['kuccha_records_shown'])) { + $financial_kuccha_info['kuccha_records_shown'] = $businessFinancialRow['kuccha_records_shown']; + $financial_kuccha_info['kuccha_bill_allowed'] = $businessFinancialRow['kuccha_bill_allowed']; + $financial_kuccha_info['customer_declared_turnover'] = $businessFinancialRow['customer_declared_turnover']; + } + + //only for Indusind Lender + if (isset($businessFinancialRow['tot_business_FY'])) { + $current_business_info['tot_business_FY'] = $businessFinancialRow['tot_business_FY']; + $current_business_info['remarks_tot_business_FY'] = $businessFinancialRow['remarks_tot_business_FY']; + $current_business_info['orders_hand_FY'] = $businessFinancialRow['orders_hand_FY']; + } + + //print_r($financial_kuccha_info);die(); + if (strtoupper($businessFinancialRow['is_financial_statements']) == 'YES' && count($businessFinancialRow['date_per_financial']) > 0) { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + //$bindBusinessFinancial["company_name"] .= count($businessFinancialRow['date_per_financial'])>1 ? ' provided with last '.count($businessFinancialRow['date_per_financial']).' years of financial statements and the snapshot is as below :' : ' we were provided with last '.count($businessFinancialRow['date_per_financial']).' year of financial statements and the snapshot is as below :'; + $bindBusinessFinancial["years_data_provided"] = count($businessFinancialRow['date_per_financial']); + $bindBusinessFinancial['is_statement'] = 1; + $bindBusinessFinancial['statements'] = FINANCIALFORM::getBusinessFinancialDetails($businessFinancialRow['date_per_financial']); + } else { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + $bindBusinessFinancial["years_data_provided"] = 0; + $bindBusinessFinancial['statements'] = array(); + $bindBusinessFinancial['is_statement'] = 0; + } + // customer + if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && (!isset($businessFinancialRow['estimated_value']))) { + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } else if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && count($businessFinancialRow['estimated_value']) > 0) { + + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['is_customer_statement'] = 1; + } else { + + + $bindBusinessFinancial["financial_customer"] = "As per Loan Applicant(s), the actual turnover and net profit of his business is same as disclosed in financial statements."; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } + + + // ############### this section only for CLIX HOUSING FINANCE LENDER + if (isset($businessFinancialRow['is_turnover_validated']) && strtoupper($businessFinancialRow['is_turnover_validated']) == 'YES') { + $bindBusinessFinancial['turnover_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['how_turnover_validated'] = (!strcasecmp(strtolower($businessFinancialRow['how_turnover_validated']), 'others')) ? 'Validated from ' . $businessFinancialRow['turnover_validated_others'] : $businessFinancialRow['how_turnover_validated']; + $bindBusinessFinancial['is_turnover_validated'] = 1; + } + // ############### this section only for CLIX HOUSING FINANCE LENDER + $bindBusinessFinancial['working_capital_receive'] = $businessFinancialRow['receive_the_money_in_days']; + $bindBusinessFinancial['working_capital_pay'] = $businessFinancialRow['pay_the_money_in_days']; + $bindBusinessFinancial['working_capital_unsold_stock'] = is_numeric($businessFinancialRow['unsold_stock_lies_in_days']) ? $businessFinancialRow['unsold_stock_lies_in_days'] : 'Data Not Provided'; + $bindBusinessFinancial['is_working_capital_facility'] = $businessFinancialRow['is_there_working_capital_available']; + if (isset($businessFinancialRow['select_working_capital_facilities_availed'])) { + foreach ($businessFinancialRow['select_working_capital_facilities_availed'] as $k => $v) { + switch ($v['id']) { + case 1: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['name'] = $businessFinancialRow['other_reason_for_working_capital_facilities_availed']; + + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['reason_for_working_capital_facilities_availed']; + break; + + case 2: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['bank_guarantee']; + break; + + case 3: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['cash_credit_limit']; + break; + + case 4: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 5: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 6: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['letter_of_credit']; + break; + case 7: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['od_limit']; + break; + case 8: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['lender_name']; + break; + case 9: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_amount']; + break; + case 10: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_type']; + break; + case 11: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_tenor']; + break; + case 12: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_start_date']; + break; + case 13: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['monthly_emi']; + break; + } + } + } + + $bindBusinessFinancial['working_capital_facilites'] = isset($businessFinancialRow['select_working_capital_facilities_availed']) ? $businessFinancialRow['select_working_capital_facilities_availed'] : null; + + $bindBusinessFinancial['estimate_posmachine_or_cc_annual_sales'] = isset($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']) ? $businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales'] : null; + //print_r($bindBusinessFinancial['select_working_capital_facilities_availed']); //FINANCIALFORM::getAvailableFacilities($businessFinancialRow[-'"working_capital_facilities_availed']); + if ($pd_master_details[0]['lender_short_name'] == 'CFPL') { + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Turnover in last completed Year", 'details' => isset($businessFinancialRow['turnover_lastcomplete_year']) ? $businessFinancialRow['turnover_lastcomplete_year'] : null); + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "YTD turnover (till last month)", 'details' => isset($businessFinancialRow['ytd_turnover']) ? $businessFinancialRow['ytd_turnover'] : null); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall debtor collection period",'details' => isset($businessFinancialRow['deptor_collection_period'])?$businessFinancialRow['deptor_collection_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall Inventory holding period",'details' => isset($businessFinancialRow['inventory_holding_period'])?$businessFinancialRow['inventory_holding_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall creditor payment period",'details' => isset($businessFinancialRow['creditor_payment_period'])?$businessFinancialRow['creditor_payment_period']: null ); + } + array_push($businessFinancialResult, $bindBusinessFinancial); + +?> + + 0) { + + ?> + +

    Financial Information

    + 0) { + ?> +

    Company / Firm Name : " . $iterateFinance['company_name']; ?>

    +

    No of Years of Financial Statements provided : " . $iterateFinance['years_data_provided']; ?>

    +

    Snapshot of Financials as per Books of Account Provided : "; ?>

    + + + + + + " . "FY " . $bfRow['financial_year'] . ""; + } ?> + + + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_sales_revenue']) . ''; + } ?> + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_profit']) . ''; + } else { + echo ''; + } + } ?> + + + + ' . $bfRow['financial_margin_of_profit'] . ' %'; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } ?> + + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + +
    Particulars
    Sales / Revenue (Rs)
    Net Profit / (Net Loss) (Rs) (' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_loss']) . ')
    Net Profit or (Net Loss) to Sales % (' . $bfRow['financial_margin_of_loss'] . ' %)
    % () in Sales over PY' . $bfRow['sale_variation'] . ' %(' . $bfRow['sale_variation'] . ' %)NA
    % () in Net Profit over PY' . $bfRow['profit_variation'] . ' %(' . $bfRow['profit_variation'] . ')NA
    % () in Net Profit % over PY' . $bfRow['financial_profit_to_sale_variation'] . ' %(' . $bfRow['financial_profit_to_sale_variation'] . ' %)NA
    +

    ' . $comments_on_financials . '

    '; + } + } + //else{ echo "

    Financial statements not provided by Loan Applicants to PD officer.

    ";} + ?> + + + +

    + 0) { + //print_r($iterateFinance['customer_statements']); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    As per Loan Applicant(s), the Financials are as below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + + As per Loan Applicant(s) met,' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($iterateFinance['estimate_posmachine_or_cc_annual_sales']) . ' as Annual sales through credit cards / POS machines.

    '; + }; + } ?> + As per Loan Applicant(s) met, the financials figures were not provided.

    "; } + + // ####################### THIS SECTION ONLY FOR CLIX HOUSING FINANCE LENDER ##########################--> + + if (isset($iterateFinance['turnover_statements'])) { + foreach ($iterateFinance['turnover_statements'] as $turnover) { + if (!strcasecmp($turnover['estimate_net_margin_availablity'], 'yes')) { + ?> +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + Turnover and Netprofit was ' . $iterateFinance['how_turnover_validated']; + } + ?> + + + + + + Validation of Customer Declared Financials :

    '; + // echo 'Kuccha Record Seen (Yes/No) : ';echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : 'No Kuccha Records made available to PD officer and therefore validation of customer declared financials was not possible.'; + if ($financial_kuccha_info['kuccha_records_shown'] == 'yes') { + echo '

    Validation of Customer Declared Financials :

    '; + echo 'Kuccha Record Seen (Yes/No) : '; + echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : ''; + echo '

    Photograph of Kuchha Bills Shared (Yes/No) : ' . ($financial_kuccha_info['kuccha_bill_allowed'] == 'yes' ? 'Yes, enclosed with report' : 'No'); + + // echo '

    Number of Kuccha Bills and Values therein, justifies the customer declared turnover (Yes / No): '. ( $financial_kuccha_info['customer_declared_turnover'] == 'yes' ? 'Yes': 'No'); + } + } + + //only for Indusind Lender + if (count($current_business_info)) { + echo '

    Current Business :

    '; + echo 'Approximate Total Business / Sales Done for Current FY as on date is ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($current_business_info['tot_business_FY']); + echo $current_business_info['remarks_tot_business_FY'] != "" ? ' ( ' . $current_business_info['remarks_tot_business_FY'] . ' ) ' : ''; + echo '
    Orders in Hand to be executed in Current FY : ' . $current_business_info['orders_hand_FY']; + } + ?> + + + + + + + + + + + + $facility) { + echo ''; + } ?> + +
    S.NoParticularsDetails
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    S.NoParticularsDays
    1Debtor Days
    2Creditor Days
    3Stock Days
    + + + +

    + + + + + + + + + + + $facility) { + + echo ''; + } ?> + +
    S.NoFacility TypeFacility Details
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + The Loan Applicants have not availed any " . $business_fin_sub_title2 . " from any financial institution.

    "; + } + } + ?> + + ' . $financial_remarks . '

    '; + } + } else { ?> +

    Financial information is not available.

    + + + + + + 0) { + $getEachValues['is_od_cc'] = null; + foreach ($businessBankRow['banking_details'] as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $getEachValues['is_od_cc'] = true; + } + } + $getEachValues['bankDetails'] = BANKINGFORM::getBusinessBankingDetails($businessBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getEachValues); + } + } + + ?> + + Business Banking:'; + if ($is_business_banking_available != null) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant(s), Applicant does not have any business account.

    '; + } + + if ($business_banking_common_remarks != "") { + echo '

    ' . $business_banking_common_remarks . '

    '; + } + } // end of busienss bankDetails available in this currrent index + ?> + + + + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $newBankingResult = array_merge($newBankingResult, $getBuinessEachValues); + } + } + // if(isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) + // { + // if(count($individualBankRow['banking_details'])>0){ + // $getIndividualEachValues=BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'],$pd_master_details[0]['pd_id']); + // $newBankingResult = array_merge($newBankingResult,$getIndividualEachValues); + // } + // } + } + foreach ($newBankingResult as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $is_od_cc = true; + } + } + if (count($newBankingResult) > 0) { + $filteredBankingResult = array(); + $b = 0; + for ($a = 0; $a <= count($newBankingResult); $a++) { + if ($newBankingResult[$a]['account_name'] == $fetchRow['company_details']['company_name'] && $newBankingResult[$a]['str_flag'] == "buiness-company") { + $filteredBankingResult[$b] = $newBankingResult[$a]; + $b++; + } + } + } //forloop ends here. + ?> + Business Banking:'; + if (count($filteredBankingResult) > 0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant, he does not have any business account.

    '; + } + } + ?> + + + 1Product / Service '; + $client_second_row = '2Contact Person '; + $client_third_row = '3Mobile Number '; + $client_fourth_row = '4Landline No'; + $client_fifth_row = '5Payment Terms'; + $client_sixth_row = '6Payment Mode'; + $client_seventh_row = '7No of Days Credit'; + + + // this is for manufacturing + if (array_key_exists('manufacturing_details', $clientRow)) { + + $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] ? $done_on_credit['manufacturing prodcuts'] = $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['manufacturing_details'] as $manuRow) { + + if (isset($manuRow['main_raw_materials'])) { + + //$to_no_of_clients += count($manuRow['main_raw_materials']); + + foreach ($manuRow['main_raw_materials'] as $main_raw_material_key => $main_raw_material) { + + if ($main_raw_material['manufacturing_product_name'] != "" || $main_raw_material['manufacturing_product_name'] != null) { + $to_no_of_clients++; + } + //print_r($main_raw_material); + $client_first_row .= '' . $main_raw_material['manufacturing_product_name'] . ''; + + $client_second_row .= isset($main_raw_material['person_title_name_master']) ? '' . $main_raw_material['person_title_name_master'] . ' ' : ''; + $client_second_row .= $main_raw_material['manufacturing_contact_person_name']; + + $client_second_row .= isset($main_raw_material['person_designation']) && $main_raw_material['person_designation'] == 1 ? ' ' . $main_raw_material['other_person_designation'] : ' '; // + + $client_second_row .= isset($main_raw_material['person_designation_master']) && $main_raw_material['person_designation'] != 1 ? $main_raw_material['person_designation_master'] : ''; + + $client_second_row .= ' ' . $main_raw_material['manufacturing_client_name'] . ''; + + $client_third_row .= '' . ($main_raw_material['manufacturing_contact_person_mobile_number'] ? $main_raw_material['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $main_raw_material['person_stdcode'] && $main_raw_material['person_landline'] ? '' . $main_raw_material['person_stdcode'] . ' ' . $main_raw_material['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($main_raw_material['manufacturing_payment_type_master']) && $main_raw_material['manufacturing_payment_type_master'] ? '' . $main_raw_material['manufacturing_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $main_raw_material['manufacturing_payment_mode'] ? '' . $main_raw_material['manufacturing_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $main_raw_material['manufacturing_credit_days_from'] && $main_raw_material['manufacturing_credit_days_to'] ? '' . $main_raw_material['manufacturing_credit_days_from'] . ' to ' . $main_raw_material['manufacturing_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + + // this is for trading + if (array_key_exists('trade_details', $clientRow)) { + $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] ? $done_on_credit['trading products'] = $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] : ''; + foreach ($clientRow['trade_details'] as $tradeRow) { + + if (isset($tradeRow['trading_products'])) { + + //$to_no_of_clients += count($tradeRow['trading_products']); + + foreach ($tradeRow['trading_products'] as $trading_product_key => $trading_product) { + + if ($trading_product['trade_product_name'] != "" || $trading_product['trade_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $trading_product['trade_product_name'] . ''; + + $client_second_row .= isset($trading_product['person_title_name_master']) ? '' . $trading_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $trading_product['trade_product_contact_person_name']; + + $client_second_row .= isset($trading_product['person_designation']) && $trading_product['person_designation'] == 1 ? ' ' . $trading_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($trading_product['person_designation_master']) & $trading_product['person_designation'] != 1 ? $trading_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $trading_product['trade_client_name'] . ''; + + $client_third_row .= '' . ($trading_product['trade_product_contact_person_mobile_number'] ? $trading_product['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $trading_product['person_stdcode'] && $trading_product['person_landline'] ? '' . $trading_product['person_stdcode'] . ' ' . $trading_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($trading_product['trade_product_payment_type_master']) ? '' . $trading_product['trade_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $trading_product['trade_product_payment_mode'] ? '' . $trading_product['trade_product_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $trading_product['trade_product_credit_days_from'] && $trading_product['trade_product_credit_days_to'] ? '' . $trading_product['trade_product_credit_days_from'] . ' to ' . $trading_product['trade_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + //this is for service + if (array_key_exists('service_provider_details', $clientRow)) { + + $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] ? $done_on_credit['service providing'] = $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['service_provider_details'] as $serviceRow) { + + if (isset($serviceRow['service_products'])) { + + //$to_no_of_clients += count($serviceRow['service_products']); + foreach ($serviceRow['service_products'] as $service_product_key => $service_product) { + + if ($service_product['service_provider_product_name'] != "" || $service_product['service_provider_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $service_product['service_provider_product_name'] . ''; + + $client_second_row .= isset($service_product['person_title_name_master']) ? '' . $service_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $service_product['service_provider_product_contact_person_name']; + + $client_second_row .= isset($service_product['person_designation']) && $service_product['person_designation'] == 1 ? ' ' . $service_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($service_product['person_designation_master']) && $service_product['person_designation'] != 1 ? $service_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $service_product['service_provider_client_name'] . ''; + + $client_third_row .= '' . ($service_product['service_provider_product_contact_person_mobile_number'] ? $service_product['service_provider_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $service_product['person_stdcode'] && $service_product['person_landline'] ? '' . $service_product['person_stdcode'] . ' ' . $service_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= $service_product['service_provider_product_payment_type_master'] ? '' . $service_product['service_provider_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $service_product['service_provider_product_payment_mode'] ? '' . $service_product['service_provider_product_payment_mode'] . '' : 'NA'; + + $client_seventh_row .= $service_product['service_provider_product_credit_days_from'] && $service_product['service_provider_product_credit_days_to'] ? '' . $service_product['service_provider_product_credit_days_from'] . ' to ' . $service_product['service_provider_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + } + + + + $client_first_row .= ''; + $client_second_row .= ''; + $client_third_row .= ''; + $client_fourth_row .= ''; + $client_fifth_row .= ''; + $client_sixth_row .= ''; + $client_seventh_row .= ''; + //echo $client_third_row; + ?> + + Client Details'; + if ($is_client_details_available != null) { + + + + + ?> + + + + + + + + Client $i"; + } ?> + + + + + + + + + + + + + + + + +
    Sr.NoParticulars
    + $value) { + if (count($temp)) { + foreach ($temp as $tk => $tvalue) { + $value == $tvalue ? $all_same = true : $all_same = false; + array_push($temp, $value); + } + } else { + array_push($temp, $value); + } + } + + if ($all_same || count($done_on_credit) == 1) { + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $vals[0] . "% is done on credit.

    "; + } else { + $activities = ''; + foreach ($done_on_credit as $dkey => $dvalue) { + $activities .= $dkey . ' ' . $dvalue . '%, '; + } + $activities = substr_replace($activities, ' ', -2); + $activities = substr_replace($activities, ' and ', strripos($activities, ','), 2); + + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $activities . "are done on credit.

    "; + } + } + + + //CLient Photo Section + // $client_photo_count = $pd_images[2]; + // $client_img_row_count = ceil(count($client_photo_count) / 3); + + // if(count($client_photo_count)){ + // // echo '
    '; + // // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // // echo '
    '; + // echo ''; + + // $client_from_index_increment = 0; + // for($img_row = 1; $img_row <= $client_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $client_from_index_increment; + // $to = ($from + 2); + // for($client_photo_iter = $from; $client_photo_iter <= $to;$client_photo_iter++) + // { + + // if(isset($client_photo_count[$client_photo_iter]) &&$client_photo_count[$client_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $client_from_index_increment = $client_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // } + ?> + ' . $client_form_remarks . '

    '; + } // ENd of client info available in this current index + ?> + + + + + + + 1Item Purchased '; + $supplier_second_row = '2Contact Person '; + $supplier_third_row = '3Mobile Number '; + $supplier_fourth_row = '4Landline No'; + $supplier_fifth_row = '5Payment Terms'; + $supplier_sixth_row = '6Payment Mode'; + $supplier_seventh_row = '7No of Days Credit'; + + if (isset($pd_processed_forms[1][$business_count])) { + + $supplier_details = $pd_processed_forms[1][$business_count]; + $supplierRow = json_decode($supplier_details['processed_json'], true); + //print_r($supplierRow); + $supplier_form_remarks = (isset($supplierRow['supplier_info_form_remark']) ? $supplierRow['supplier_info_form_remark'] : ''); + + if (isset($supplierRow['supplier_info_available']) && $supplierRow['supplier_info_available'] == 1) { + $is_supplier_details_avaialable = 1; + $company_name_for_supplier_form_dispaly = MYUTIL::findCompanyName($all_company_details, $supplierRow['company_id'], 1); + //$supplierResult['company_name'] = $company_name; + $total_no_of_suppliers = 0; + $total_payments_percent_on_credit_for_supplier = 0; + + + foreach ($supplierRow['manufacturing_details'] as $manuRow) { + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit']) ? $supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : 0; + + if (isset($manuRow['main_raw_materials'])) { + + + foreach ($manuRow['main_raw_materials'] as $rawkey => $raw) { + + if ($raw['manufacturing_raw_material_name'] != "" || $raw['manufacturing_raw_material_name'] != null) { + $total_no_of_suppliers++; + } + $supplier_first_row .= '' . $raw['manufacturing_raw_material_name'] . ''; + + $supplier_second_row .= isset($raw['person_title_name_master']) ? '' . $raw['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $raw['manufacturing_contact_person_name']; + + $supplier_second_row .= isset($raw['person_designation']) && $raw['person_designation'] == 1 ? ' ' . $raw['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($raw['person_designation_master']) && $raw['person_designation'] != 1 ? $raw['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $raw['manufacturing_supplier_name'] . ''; + + $supplier_third_row .= '' . ($raw['manufacturing_contact_person_mobile_number'] ? $raw['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $raw['person_stdcode'] && $raw['person_landline'] ? '' . $raw['person_stdcode'] . ' ' . $raw['person_landline'] . '' : '' . 'Not Provided' . ''; + + + + $supplier_fifth_row .= $raw['manufacturing_payment_type_master'] ? '' . $raw['manufacturing_payment_type_master'] . '' : 'NA'; + + + + $supplier_sixth_row .= $raw['manufacturing_payment_mode'] ? '' . $raw['manufacturing_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $raw['manufacturing_credit_days_from'] && $raw['manufacturing_credit_days_to'] ? '' . $raw['manufacturing_credit_days_from'] . ' to ' . $raw['manufacturing_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + } + } + } + // this is for trading + //print_r($supplierRow['trade_details'][0]['trading_products']); + if (isset($supplierRow['trade_details'][0]['trading_products']) && count($supplierRow['trade_details'][0]['trading_products'])) { + $total_payments_percent_on_credit_for_supplier += $supplierRow['trade_details'][0]['trading_products_total_payments_percent_on_credit']; + foreach ($supplierRow['trade_details'][0]['trading_products'] as $tradeRow) { + + if ($tradeRow['trade_product_name'] != "" || $tradeRow['trade_product_name'] != null) { + $total_no_of_suppliers++; + } + + + + + + + $supplier_first_row .= '' . $tradeRow['trade_product_name'] . ''; + $supplier_second_row .= isset($tradeRow['person_title_name_master']) ? '' . $tradeRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $tradeRow['trade_product_contact_person_name']; + + $supplier_second_row .= isset($tradeRow['person_designation']) && $tradeRow['person_designation'] == 1 ? ' ' . $tradeRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($tradeRow['person_designation_master']) && $tradeRow['person_designation'] != 1 ? $tradeRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $tradeRow['trade_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($tradeRow['trade_product_contact_person_mobile_number'] ? $tradeRow['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $tradeRow['person_stdcode'] && $tradeRow['person_landline'] ? '' . $tradeRow['person_stdcode'] . ' ' . $tradeRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + + $supplier_fifth_row .= isset($tradeRow['trade_product_payment_type_master']) ? '' . $tradeRow['trade_product_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $tradeRow['trade_product_payment_mode'] ? '' . $tradeRow['trade_product_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $tradeRow['trade_product_credit_days_from'] && $tradeRow['trade_product_credit_days_to'] ? '' . $tradeRow['trade_product_credit_days_from'] . ' to ' . $tradeRow['trade_product_credit_days_to'] . ' days' : 'NA'; + ///array_push($supplierResult,$temp); + + //} + //} + + } + } + + if (isset($supplierRow['servicing_details'][0]['service_providers']) && count($supplierRow['servicing_details'][0]['service_providers'])) { + + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + //echo isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + + foreach ($supplierRow['servicing_details'][0]['service_providers'] as $serviceRow) { + + + if ($serviceRow['service_provider_name'] != "" || $serviceRow['service_provider_name'] != null) { + $total_no_of_suppliers++; + } + + $supplier_first_row .= '' . $serviceRow['service_provider_name'] . ''; + + + $supplier_second_row .= isset($serviceRow['person_title_name_master']) ? '' . $serviceRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $serviceRow['service_provider_contact_person_name']; + + $supplier_second_row .= isset($serviceRow['person_designation']) && $serviceRow['person_designation'] == 1 ? ' ' . $serviceRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($serviceRow['person_designation_master']) && $serviceRow['person_designation'] != 1 ? $serviceRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $serviceRow['service_provider_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($serviceRow['service_provider_contact_person_mobile_number'] ? $serviceRow['service_provider_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $supplier_fourth_row .= $serviceRow['person_stdcode'] && $serviceRow['person_landline'] ? '' . $serviceRow['person_stdcode'] . ' ' . $serviceRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + $supplier_fifth_row .= isset($serviceRow['service_provider_payment_type_master']) ? '' . $serviceRow['service_provider_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $serviceRow['service_provider_payment_mode'] ? '' . $serviceRow['service_provider_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $serviceRow['service_provider_credit_days_from'] && $serviceRow['service_provider_credit_days_to'] ? '' . $serviceRow['service_provider_credit_days_from'] . ' to ' . $serviceRow['service_provider_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + //} + } //} + + } + + $supplier_first_row .= ''; + $supplier_second_row .= ''; + $supplier_third_row .= ''; + $supplier_fourth_row .= ''; + $supplier_fifth_row .= ''; + $supplier_sixth_row .= ''; + $supplier_seventh_row .= ''; + } + // echo "dsfnsdkfnj**********"; + // print_r($supplierResult);// + + + + echo '

    Supplier Details

    '; + if ($is_supplier_details_avaialable != null) { + ?> + + + $fetchRow){ + //echo '
    Supplier '.($k+1).':

    '; + ?> + + + + + + + + Supplier $i"; + } ?> + + + + + + + +
    Sr.NoParticulars
    + '; + // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // echo '
    '; + // echo ''; + + // $supplier_from_index_increment = 0; + // for($img_row = 1; $img_row <= $supplier_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $supplier_from_index_increment; + // $to = ($from + 2); + // for($supplier_photo_iter = $from; $supplier_photo_iter <= $to;$supplier_photo_iter++) + // { + + // if(isset($supplier_photo_count[$supplier_photo_iter]) &&$supplier_photo_count[$supplier_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $supplier_from_index_increment = $supplier_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // }*/ + + + //End of Supplier Photo section + + //}//End of supplier foreach + ?> + + 0) { + //$company_name = MYUTIL::findCompanyName($all_company_details,$supplierRow['company_id'],1); + echo "

    Out of total purchases done by " . $company_name_for_supplier_form_dispaly . ", " . $total_payments_percent_on_credit_for_supplier . " % is done on credit.

    "; //in advance rest on delivery. + } + } + echo '

    ' . $supplier_form_remarks . '

    '; + } // End of supplier info avilable in this current index + ?> + + + + + + 0 || (is_array($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) > 0)) { + + $is_raw_materials_sufficient_enough = $stockRow['manufacturing_details'][0]['is_sufficiant_raw']; + $is_raw_materials_sufficient_enough_remarks = $stockRow['manufacturing_details'][0]['rawmaterial_remarks']; + $bindStockResult["manufacturing"] = Stockform::getStockManufacturingDetails($stockRow['manufacturing_details'][0]['manufacturing_raw_materials'], $stockRow['manufacturing_details'][0]['manufacturing_finished_goods']); + //print_r($bindStockResult["manufacturing"]); + } else { + $bindStockResult["manufacturing"] = array(); + } + // this is for stock retail details + if (count($stockRow['retail_details'][0]['retail_traded_goods']) > 0) { + $bindStockResult["retail"] = Stockform::getStockRetailDetails($stockRow['retail_details'][0]['retail_traded_goods']); + } else { + $bindStockResult["retail"] = array(); + } + // this is for stock whole sale details + if (count($stockRow['trade_details'][0]['trading_traded_goods']) > 0) { + $bindStockResult["wholesale"] = Stockform::getStockWholesaleDetails($stockRow['trade_details'][0]['trading_traded_goods']); + } else { + $bindStockResult["wholesale"] = array(); + } + + // this is for stock service details + //print_r($stockRow['servicing_details']); + if (count($stockRow['servicing_details'][0]['service_provider']) > 0) { + $bindStockResult["service_stocks"] = Stockform::getStockServiceDetails($stockRow['servicing_details'][0]['service_provider']); + } else { + $bindStockResult["service_stocks"] = array(); + } + //print_r($bindStockResult);die(); + count($bindStockResult['wholesale']) || count($bindStockResult['retail']) || count($bindStockResult['manufacturing']) || count($bindStockResult["service_stocks"]) ? array_push($stockResult, $bindStockResult) : array(); + //echo "**********************"; + //print_r($stockResult);die(); + ?> + +

    Stock Details

    + +

    + + + + + + + + + + + + + 0) { + foreach ($getstRow['manufacturing'] as $pstRow) { + if ($pstRow['name']) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Sr.NoType of StockStock ItemStock Value (Rs)Stock Quantity
    + Considering the size of operations, the stock of finished goods maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_stock_sufficient_enough,'no')){ + // echo '

    Considering the size of operations, the stock of finished goods maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_stock_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_stock_sufficient_enough,'not applicable')) + // { + // echo '

    Finished goods Stock not required to be maintained.

    '; + // } + + // if(!strcasecmp($is_raw_materials_sufficient_enough,'yes')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_raw_materials_sufficient_enough,'no')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_raw_materials_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_raw_materials_sufficient_enough,'not applicable')) + // { + // echo '

    Raw material Stock not required to be maintained.

    '; + // } + + // //serivce + // if(!strcasecmp($is_sufficiant_service_goods,'yes')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_sufficiant_service_goods,'no')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $service_goods_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_sufficiant_service_goods,'not applicable')) + // { + // echo '

    Stock not required to be maintained.

    '; + // } + //echo '

    '.$stock_remarks.'

    '; + + + $stock_photo_count = array_filter($pd_images[11], function ($d) use ($business_count) { + if ($d['company_id'] == ($business_count + 1)) { + return 1; + } else { + return 0; + } + }); + //echo 'stock_photo_count - ' . count($stock_photo_count); + $stock_img_row_count = ceil(count($stock_photo_count) / 3); + if (count($stock_photo_count)) { + echo '
    '; + echo '

    Stock Photograph`s :

    '; + echo '
    '; + echo ''; + + for ($img_row = 0; $img_row < $stock_img_row_count; $img_row++) { + // if($img_row > 0) { break; } + echo ''; + $from = $img_row == 0 ? $img_row : ($img_row + 2); + $to = ($from + 2); + for ($stock_photo_iter = $from; $stock_photo_iter <= $to; $stock_photo_iter++) { + + if (isset($stock_photo_count[$stock_photo_iter]) && $stock_photo_count[$stock_photo_iter]['company_id'] == ($business_count + 1)) { + echo ''; + //unset($stock_photo_count[$stock_photo_iter]); + } + } + //echo "


    "; + echo ''; + } + //echo ''; + echo '
    '; + echo ''; + echo '
    '; + } + // + ?> + + + ' . $stock_form_remarks . '

    '; + //else { + ?> + + + + + + + + +

    Future Plan and Business Environment

    + + + + + + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + + ?> + +
    ParticularsDetails
    USP of the business (How applicant’s business is different from others in the business)' . $future_plan_business_environment['usp_of_the_business'] . '
    Future plan for business expansion' . $future_plan_business_environment['future_plans_for_business_expansion'] . '
    Impact of GST on business' . $future_plan_business_environment['impact_of_gst_on_the_business'] . '
    Key competitors in the business' . $future_plan_business_environment['key_competitors'] . '
    Succession Plan for business' . $future_plan_business_environment['succession_plan'] . '
    Brief of other group concerns/ Business run by the applicant' . $future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'] . '
    + '; + echo '

    ' . $future_plan_business_environment['remarks'] . '

    '; + } + } + + ?> + + + + + + Assessed Income - " . MYUTIL::findCompanyName($all_company_details, ($business_count + 1), 1) . ""; + if (isset($ai_core_details) && count($ai_summary_details_processed)) { + echo '

    ' . $order_dipaly_array[0] . ') Financial Snapshot

    '; + echo ''; + echo ''; + echo $ai_summary_details_processed['ai_table_header_row']; + echo ''; + echo ''; + echo $ai_summary_details_processed['sale_revenue_row']; + echo $ai_summary_details_processed['purchase_row']; + echo $ai_summary_details_processed['gross_profit_loss_row']; + echo $ai_summary_details_processed['gross_profit_loss_per_row']; + echo $ai_summary_details_processed['business_expense_row']; + echo $ai_summary_details_processed['net_profit_loss_row']; + echo $ai_summary_details_processed['house_hold_expense_row']; + echo $ai_summary_details_processed['disposable_income_row']; + echo $ai_summary_details_processed['net_margin_row']; + + echo ''; + echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + array_shift($order_dipaly_array); + } + + + echo '

    '; + //die(); + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '

    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // } + // array_shift($order_dipaly_array); + // echo '

    Detail Available on Annexure A'; + // } + + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '
    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // echo '
    '; + // $row_count = ceil(count($sale_month_wise['months']) / 5); + // //print_r(($sale_month_wise['months'])); + // // echo $row_count; + // //die(); + // echo ''; + + // for($i = 0; $i <= $row_count; $i++) + // { + // $from = $i== 0 ? $i : ($i + 3); + // $to = ($from + 3); + // echo ''; + // for($j = $from ; $j <= $to ;$j++) + // { + // //$sale_month_wise['months'] as $sale_month_data + // //echo ''; + // if(isset($sale_month_wise['months'][$j])) + // { + // echo ''; + // } + // } + // echo ''; + // } + // echo '
    '; + // echo ''; + // echo ''; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // }else if($sale_month_wise['months'][$j]['sales_type'] == 2) + // { + // echo ''; + // } + // echo ''; + + // echo ''; + + // foreach($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) + // { + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($m_key == 20)break; + // else if($sale_month_wise['sales_type'] == 2) + // { + // echo ''; + // } + // } + // echo ''; + + // echo '
    '.$sale_month_wise['months'][$j]['month_to_dispaly'].'
    Date Value
    Frequncy Value
    '.$month['date'] .' '.$month['value'] .'
    '.$month['frequency_name'] .' '.$month['frequency_value'] .'
    '; + // echo '
    '; + // echo '
    '; + + // //} + // } + + // array_shift($order_dipaly_array); + // } + + + $GLOBALS['is_kuccha_records_available'] = null; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + echo '

    ' . $order_dipaly_array[0] . ') Sales Itemwise :

    '; + echo ''; + echo ''; + echo $ai_core_details_processed['sales_calculated_by_itemwise_header']; + echo ''; + echo ''; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sid) { + //print_r($sid); + if ($sid['sales_type'] == 3) { + $GLOBALS['is_kuccha_records_available'] = true; + } + $rate_per_unit = ($sid['rate_per_unit'] != 0 && $sid['rate_per_unit'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['rate_per_unit']) : '-'); + echo ''; + echo ''; + if (isset($sid['margin_per'])) { + echo ''; + } + // if(isset($sid['margin_per_uom'])){echo ''; } + if (isset($sid['margin_final_value'])) { + echo ''; + } + + echo ''; + } + echo ''; + echo '
    ' . ($sid['other_sales_item'] != '' ? $sid['other_sales_item'] : $sid['sale_item']) . '' . $sid['sales_qty'] . '' . $sid['uom'] . '' . $rate_per_unit . '' . $sid['frequency'] . '' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['annual_sale_value']) . ($sid['sales_type'] == 3 ? ' *' : '') . '' . ($sid['margin_per'] != 0 ? $sid['margin_per'] : '-') . ''.($sid['margin_per_uom'] != 0? $sid['margin_per_uom'] : '-').'' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['margin_final_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if ($GLOBALS['is_kuccha_records_available']) { + echo '
    * Assessed From Kuchha Records, Details Available in Annexure A'; + } + + + if (isset($ai_core_details) && count($ai_core_details['sales_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Sales Declared By Customer

    '; + + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) + // { + // echo '

    As per person met, the following Purchase details were shared:

    '; + // } + // else if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + // } + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ) declared as annual sale value.'; + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + $str .= '
    and ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' )' . '( ' . $ai_core_details['sales_declared_by_customer'][0]['margin_per'] . '% sales declared ) as net margin amount.'; + } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) { + echo '

    As per person met, the following Purchase details were shared:

    '; + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + } + + echo '
    '; + if (isset($ai_core_details) && count($ai_core_details['purchase_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Purchase Declared By Customer

    '; + + + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ) declared as annual purchase value.'; + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // $str .= '
    and '.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']).' ( '.MYUTIL::numtowords( $ai_core_details['sales_declared_by_customer'][0]['margin_value']).' )'.'( '.$ai_core_details['sales_declared_by_customer'][0]['margin_per'].'% sales declared ) as net margin amount.'; + // } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 1) { + echo '

    ' . $order_dipaly_array[0] . ') Itemwise Purchase Details :

    '; + + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($ai_core_details_processed['purchase_to_display'] as $dat) { + $rate = $dat['rate'] != 0 && $dat['rate'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['rate']) : '-'; + echo ''; + } + echo ''; + + echo '
    Raw Material/Trading Item Purchase Quantity UOM Rate/Unit of Purchase Frequency Annual Purchase(Rs)
    ' . $dat['material_name'] . ' ' . $dat['qty'] . ' ' . $dat['uom'] . ' ' . $rate . ' ' . $dat['frequency'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['annual_value']) . '
    '; + array_shift($order_dipaly_array); + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 2) { + echo '

    ' . $order_dipaly_array[0] . ') Billwise Purchase Details :

    '; + foreach ($ai_core_details_processed['purchase_to_display'] as $billwise) { + echo '
    '; + echo 'Item name : ' . $billwise['item_name'] . '
    '; + echo '' . $billwise['month_count'] . ' month(s) purchase value : ' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value']) . ' Annual Purchase value:' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value'] * (12 / $billwise['month_count'])) . ''; + echo '
    '; + foreach ($billwise['months'] as $month_data) { + //echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($month_data['month_data'] as $month) { + echo ''; + } + echo ''; + + echo '
    ' . $month_data['month_to_dispaly'] . '
    Date Value
    ' . $month['date'] . ' ' . $month['value'] . '
    '; + //echo '
    '; + } + echo '
    '; + } + array_shift($order_dipaly_array); + } + } + + // + if (isset($ai_core_details) && count($ai_core_details['business_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Business Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['business_expenses_to_diaplay'] as $b_exp) { + if ($b_exp['expense_value'] != 0) { + echo ''; + } + } + echo ''; + echo '
    Business Expense Amount Frequency Annual Expenses
    ' . $b_exp['expense_item'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['expense_value']) . ' ' . $b_exp['frequency_name'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['annual_expenses_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if (isset($ai_core_details) && count($ai_core_details['house_hold_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Household Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['household_expenses_to_diaplay'] as $h_exp) { + echo ''; + } + echo ''; + echo '
    Expense Particulars Amount (Rs) Frequency Annual Expenses(Rs)
    ' . $h_exp['expense_item'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['expense_value']) . ' ' . $h_exp['frequency_name'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['annual_expense_value']) . '
    '; + array_shift($order_dipaly_array); + } + + + // if(isset($ai_core_details) && count($ai_summary_details_processed)) + // { + // echo '

    The Summary of Income :

    '; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['ai_table_header_row']; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['sale_revenue_row']; + // echo $ai_summary_details_processed['purchase_row']; + // echo $ai_summary_details_processed['gross_profit_loss_row']; + // echo $ai_summary_details_processed['business_expense_row']; + // echo $ai_summary_details_processed['net_profit_loss_row']; + // echo $ai_summary_details_processed['house_hold_expense_row']; + // echo $ai_summary_details_processed['disposable_income_row']; + // echo $ai_summary_details_processed['net_margin_row']; + + // echo ''; + // echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + // } + // echo "
    "; + // + + ?> + + + + + + + + + + $oaRow) { + $otherAssetRow = json_decode($oaRow['processed_json'], true); + //print_r($otherAssetRow);die(); + $other_assest_common_remrks = $otherAssetRow['assets_form_remark']; + if (isset($otherAssetRow['asset_info_available']) && $otherAssetRow['asset_info_available'] == 1) { + $is_personal_info_available = 1; + + if (count($otherAssetRow['assets_details']) > 0) { + $otherAssetResult = ASSETSFORM::getOthersAssetsDetails($otherAssetRow['assets_details'], $pd_master_details[0]['pd_id']); + + //print_r($otherAssetResult); + } + } +} +?> + +

    Personal Assets

    + + + + + + + + + + + + + + $paRow) { + ?> + + + + + + + + + + + +
    Sr.NoAsset TypeAsset DescriptionAsset Owned ByApprox Market Value(Rs)Age of the Assest
    ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : (($paRow['approximate_market_value'] != '' && $paRow['approximate_market_value'] != 0 ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : 'Not Provided')); ?>
    + +

    As per Loan applicant, he does not have any other assets.

    +' . $other_assest_common_remrks . '

    '; +} + +?> + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + $ind_banking_common_remarks = $individualBankRow['banking_form_remark']; + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + // $is_personal_banking_available = 1; + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getBuinessEachValues); + } + } + if (isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) { + if (count($individualBankRow['banking_details']) > 0) { + $getIndividualEachValues = BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getIndividualEachValues); + } + } +} +if (count($bankingResult) > 0) { + $filteredPersonalBankingResult = array(); + $x = 0; + for ($y = 0; $y < count($bankingResult); $y++) { + if ($bankingResult[$y]['str_flag'] !== "buiness-company") { + $filteredPersonalBankingResult[$x] = $bankingResult[$y]; + $x++; + } + if ($bankingResult[$y]['same_ac_used_for'] == "Business") { + $stmt_flag++; + } + } +} + + +?> +

    Personal Banking Details:

    + 0) { ?> +

    Below bank account details were shared :

    + + + + + + + + + + + + + + + $bdRow) { + ?> + + + + + + + + + + + + +
    Sr.NoAccount Holder's NameBank NameAccount TypeOD / CC LimitVintage
    + 0) { + echo '

    The personal banking is done through same account used for business banking

    '; +} +if ($ind_banking_common_remarks != '') { + echo '

    ' . $ind_banking_common_remarks . '

    '; +} +if (count($filteredPersonalBankingResult) == 0) { + echo '

    As per loan applicant, he does not have any personal account

    '; +} ?> + + + + + + + $iRow) { + $otherIcomeRow = json_decode($iRow['processed_json'], true); + $other_source_income_common_remarks = $otherIcomeRow['otherincome_remarks']; + //print_r($otherIcomeRow);die(); + + if (strtoupper($otherIcomeRow['other_income']) == 'YES' && count($otherIcomeRow['income_details']) > 0) { + $is_other_income_available = 1; + $otherIncomeResult = OTHERINCOMEFORM::getIncomeDetails($otherIcomeRow['income_details'], $pd_master_details[0]['pd_id']); + } +} +?> +
    + + + + + + + + + + + + + + $oiRow) { + ?> + + + + + + + + + +
    Sr.NoIncome SourceEarned byAmount(Rs)
    (Details Available in Annexure B)'; + $GLOBALS['is_rental_available'] = 1; + } ?>
    + +

    As per the loan applicants, they do not have any other source of Income.

    +' . $other_source_income_common_remarks . '

    '; +} + +?> + + + + + $fRow) { + $familyRow = json_decode($fRow['processed_json'], true); + //print_r($familyRow);die(); + $other_family_form_common_remarks = $familyRow['family_details_form_remark']; + if (array_key_exists('family_details', $familyRow) && count($familyRow['family_details']) > 0) { + $familyResult = OTHERFAMILYFORM::getFamilyDetails($familyRow['family_details'], $pd_master_details[0]['pd_id']); + } +} +?> + +

    Family Information:

    + 0) { + //print_r($familyResult); +?> + + + $fmValue) { ?> + + ' . $fmValue['selected_person_title'] . $fmValue['selected_person'] . 'Family Information - Select person for capturing family details, who is an applicant in the case, resides at ' . $fmValue['residency_address'] . 'Family Information - Residence Address of Select person .'; + + $residence_text = 'This is a ' . $fmValue['residence_ownership'] . ' Family Information - Ownership of Residence residence, where the applicant has been staying for ' . $fmValue['residence_No_of_years'] . 'Family Information - No of Yrs in current residence .'; + $residence_text .= (!strcasecmp($fmValue['residence_ownership'], 'rented')) ? ' The rent paid ' . $rupee_symbol . ' ' . $fmValue['rent'] . ' per month.' : ''; + + echo '

    ' . $intro_text . '

    '; + echo '

    ' . $residence_text . '

    '; + + ?> + + +

    The table below provides details of other family members of

    + + + + + + + + + + + + + $fmRow) { + ?> + + + + + + + + + + +
    Sr.NoNameRelationAgeEarning StatusOccupation Details
    + ' . $text . '

    '; + } + } ?> + +

    Other Family Members is not available.

    +' . $other_family_form_common_remarks . '

    '; +} + +?> + + + + + + $elRow) { + $otherLoanRow = json_decode($elRow['processed_json'], true); + $existing_loan_form_common_remarks = $otherLoanRow['currentloan_remarks']; + $is_all_loan_details_availble = 'yes'; + $out_standing_loan_info = array(); + if (array_key_exists('loan_info_available', $otherLoanRow)) { + $is_all_loan_details_availble = $otherLoanRow['loan_info_available']; + } + $total_no_of_data = 0; + if (strtoupper($otherLoanRow['existing_loan']) == 'YES' && (!strcasecmp($is_all_loan_details_availble, 'yes') && count($otherLoanRow['loan_details']) > 0)) { + $is_existing_loans_available = 1; + $total_no_of_data = count($otherLoanRow['loan_details']); + $existLoanResult = FINANCIALFORM::getOtherLoanDetails($otherLoanRow['loan_details'], $pd_master_details[0]['pd_id']); + } else if (!strcasecmp($is_all_loan_details_availble, 'no')) { + $out_standing_loan_info['tot_running_loans'] = $otherLoanRow['tot_running_loans']; + $out_standing_loan_info['tot_emi_paid'] = $otherLoanRow['tot_emi_paid']; + $out_standing_loan_info['tot_outstanding_loans'] = $otherLoanRow['tot_outstanding_loans']; + } +} +?> +
    +

    Existing loan obligation

    + + + + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. +

    + $single_table) { + //print_r($single_table);die(); + + if (is_numeric($table_key)) { + ?> + + + + + Loan $pre_loan_no"; + } ?> + + + + + + +
    Particulars
    +
    + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. + + + + + + + + + + + + + + + +
    Total No of Running LoansTotal Outstanding AmountTotal EMI being Paid (Monthly)
    + + +

    As per loan applicant he does not have any existing loan obligations.

    + +' . $existing_loan_form_common_remarks . '

    '; +} +?> + + + + + + + + + + +'; +echo '

    Credit Manager`s Specific Queries:

    '; +//echo '
    '; +if (isset($credit_officier_specific_queries['additional_requirements_processed']) && count($credit_officier_specific_queries['additional_requirements_processed'])) { + + + foreach ($credit_officier_specific_queries['additional_requirements_processed'] as $key => $value) { + echo 'Question - ' . $value['question'] . '
    '; + echo 'Answer - ' . $value['answer']; + echo '

    '; + } +} else { + echo 'There are no specific queries raised by Credit Manager.'; +} + +echo '
    '; +echo '

    Document to be photographed/scanned:

    '; +// +if (isset($credit_officier_specific_queries['docs_to_be_sighted_processed']) && count($credit_officier_specific_queries['docs_to_be_sighted_processed'])) { + + + foreach ($credit_officier_specific_queries['docs_to_be_sighted_processed'] as $doc_key => $doc_value) { + echo 'Document Required : ' . $doc_value['doc_name'] . '
    '; + echo 'Provided ( Yes / No ) : ' . ($doc_value['ans'] == 'yes' ? 'YES, Document available in zipped file enclosed with report' . '
    ' : 'NO
    '); + if ($doc_value['ans'] != 'yes') { + echo 'Reason : ' . $doc_value['reason']; + } + echo '

    '; + } +} else { + echo 'There are no specific documents to be collect.'; +} + +if (isset($credit_officier_specific_queries['covid_section']) && isset($credit_officier_specific_queries['covid_section']['question_info']) && count($credit_officier_specific_queries['covid_section']['question_info'])) { + echo '
    '; + echo '

    Queries related to Covid-19:

    '; + + foreach ($credit_officier_specific_queries['covid_section']['question_info'] as $covid_key => $covid_value) { + if (isset($covid_value['is_subfield']) && !$covid_value['is_subfield']) { + echo 'Question : ' . $covid_value['question'] . '
    '; + $temp_answer = $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (($covid_value['type'] == 1 || $covid_value['type'] == 9) && ($covid_value['field_type'] == 'str&numtoword' || $covid_value['field_type'] == 'num' || $covid_value['field_type'] == 'numtoword') && is_numeric($temp_answer)) { + $temp_answer = MYUTIL::customIndianNumberFormat($temp_answer) . ' (' . MYUTIL::numtowords($temp_answer) . ')'; + } + echo 'Answer : ' . $temp_answer . '
    '; + $sub_field_key = $covid_value['question_key'] . '_' . $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (isset($credit_officier_specific_queries['covid_section'][$sub_field_key])) { + echo 'Reason/Description : ' . $credit_officier_specific_queries['covid_section'][$sub_field_key] . '
    '; + } + + echo '
    '; + } + } +} + +//} + +?> + + + + +
    +
    +

    PD OFFICER`S REMARKS ON CUSTOMER BEHAVIOUR & OVERALL PD STATUS

    + +
    + + '; + echo '

    Personal feedback or market intelligence on the case (if any):

    '; + echo '

    ' . $final_remark_data['market_intelligence'] . '

    '; + echo '
    '; + //echo '
    '; + } + ?> +
      +
    • Customer Behaviour:
    • + +

      + + ✔'; + ?> + + + + + + + + +
      +
      Polite
      +
      +
      +
      Rude
      +
      +
      +
      Others*
      +
      +
      +
      +
      '; + } ?> + + + +
      +
    • PD Officer’s overall assessment:
    • +

      + + + + + + + + + + + + + + + + +
      +
      Positive
      +
      +
      +
      Refer to Credit
      +
      +
      +
      Negative
      +
      +
      +
      Others*
      +
      +
      +
      + +
    +
    + + +

    PD officer recommendation is ' . $fo_diplay . '.

    '; ?> +

    The following key points were considered while arriving at the aforementioned status.

    +"; + foreach ($final_remark_data['recommendation_positive'] as $pos) { + echo "
  • " . $pos['reason_for_positive'] . "
  • "; + } + } else if ($negative) { + echo "
      "; + foreach ($final_remark_data['recommendation_negative'] as $neg) { + echo "
    • " . $neg['reason_for_negative'] . "
    • "; + } + } else if ($refer_to_credit) { + echo "
        "; + foreach ($final_remark_data['recommendation_refer_to_credit'] as $rtc) { + echo "
      • " . $rtc['reason_for_refer_to_credit'] . "
      • "; + } + } + echo "
      "; +?> +" . $other_command_remark . "

      "; + } + + echo '

      ' . $pd_officer_final_remark . '

      ' +?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + if (is_array($assessed_income_details) && count($assessed_income_details) && isset($assessed_income_details[($business_count + 1)]) && count($ai_core_details['sales_calculated_by_itemwise']) && $GLOBALS['is_kuccha_records_available']) { + echo '
      '; + echo '

      Annexure A

      '; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + //echo "
      "; + echo '

      Kuchha Sales Book/Bills Details:

      '; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);//die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sale_month_wise) { + + //echo '
      '; + if ($sale_month_wise['sales_type'] == 3 || $sale_month_wise['sales_type'] == 2) { + //print_r($sale_month_wise);//die(); + echo 'Item name : ' . $sale_month_wise['sale_item'] . '
      '; + if ($sale_month_wise['sales_type'] == 3) { + echo '' . $sale_month_wise['month_count'] . ' month sales value : ' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']) . ' Annual Sales value:' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']))) . ' (i.e. ' . (12 / $sale_month_wise['month_count']) . ' * ' . $sale_month_wise['total_months_value'] . ')'; + } else { + echo 'Annual Sales value:' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'])) . ''; + } + echo '
      '; + echo '
      '; + $row_count = ceil(count($sale_month_wise['months']) / 5); + //print_r(($sale_month_wise['months'])); + // echo $row_count; + //die(); + echo '
      '; + + for ($i = 0; $i <= $row_count; $i++) { + $from = $i == 0 ? $i : ($i + 3); + $to = ($from + 3); + //echo ''; + for ($j = $from; $j <= $to; $j++) { + //$sale_month_wise['months'] as $sale_month_data + //echo ''; + if (isset($sale_month_wise['months'][$j])) { + + //print_r($sale_month_wise['months'][$j]) ;die(); + echo '
      '; + //echo ''; + echo '
      '; + echo ''; + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } else if (($sale_month_wise['sales_type'] == 2)) { + echo ''; + } + echo ''; + + echo ''; + + $month_sub_total = 0; + foreach ($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) { + + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + $month_sub_total += $month['value']; + } + //if($m_key == 20)break; + else if ($sale_month_wise['sales_type'] == 2) { + echo ''; + $month_sub_total += $sale_month_wise['annual_sale_value']; + } + } + echo ''; + $month_sub_total = 0; + echo ''; + + echo '
      ' . $sale_month_wise['months'][$j]['month_to_dispaly'] . '
      Date Value
      Frequncy Value
      ' . $month['date'] . ' ' . $month['value'] . '
      ' . $month['frequency_name'] . ' ' . $month['frequency_value'] . '
      Total ' . MYUTIL::customIndianNumberFormat($month_sub_total) . '
      '; + echo '
      '; + echo '   '; + } + } + //echo ''; + } + echo '
      '; + echo '
      '; + } + } + } + } // end of if AI available in current business count + } //end of total no of business for loop +} +?> + + + + + + $rental_property) { + //echo $rental_property_key; + $current_property = json_decode($rental_property['processed_json'], true); + $rental_data[] = RENTALFORM::getRentalText($current_property); + } + + + if (count($rental_data)) { + echo '
      '; + echo '

      Annexure B : Rental Income Details

      '; + + foreach ($rental_data as $key => $value) { + + echo '
      Property : ' . ($key + 1) . ''; + echo '

      Address of Property : ' . ($value['address_property']) . ''; + echo '

      Type of Property : ' . ($value['type_of_property']) . ''; + echo '

      Name of the Property Owner`s : ' . ($value['property_owners_name']) . ''; + echo '

      Name of the person`s who showing Property : ' . ($value['property_showing_persons_name']) . ''; + echo '

      Property Document Proof Seen : ' . ($value['property_document_proof_visted']) . ''; + if (!strcasecmp($value['property_document_proof_visted'], 'yes')) { + echo '      Type of Property Document Visted : ' . ($value['type_of_document_visited']) . ''; + } + echo '

      Unit Type : ' . ($value['unit_type']) . ''; + echo '

      No of Floors/Units : ' . ($value['no_of_floors']) . ''; + echo '      '; + echo $value['area_coverd'] != "" ? 'Area covered : ' . ($value['area_coverd'] . ' ' . $value['area_uom'] . '') : ''; + + if (isset($value['unit_details']['multistorey']) && count($value['unit_details']['multistorey'])) { + echo '

      Multistorey Details:

      '; + echo ''; + echo ''; + foreach ($value['unit_details']['multistorey'] as $multistorey_key => $multistorey_value) { + echo ''; + } + echo ''; + echo '
      Floor Name No of Units Rent same for
      all Units
      Unit Details Total
      Rent Amount
      ' . $multistorey_value['floor_name'] . ' ' . $multistorey_value['no_units_in_floor'] . '' . $multistorey_value['same_rent'] . '' . $multistorey_value['unit_details'] . '' . $multistorey_value['total_floor_rent'] . '
      Total ' . $rupee_symbol . ' ' . $value['unit_details']['multistorey_over_all_total'] . '
      '; + } + + echo '

      Unit Details:

      '; + foreach ($value['unit_details']['property_core'] as $u_key => $unit_value) { + echo '
      '; + echo $unit_value['unit_name']; + echo ''; + echo $unit_value['header_row']; + echo $unit_value['first_owners_row']; + echo $unit_value['second_lessee_name_row']; + echo $unit_value['third_area_of_unit_row']; + echo $unit_value['fourth_payment_mode_row']; + echo $unit_value['fifth_lease_period_row']; + echo $unit_value['sixth_security_deposit_row']; + echo $unit_value['eigth_current_rent_received_row']; + echo $unit_value['nineth_difference_between_rent_amount_row']; + echo '
      '; + } + + //print_r($value['third_check_details']); + if ($value['third_check_details']['done_third_party_check']) { + echo '
      For property' . ($key + 1) . ' Third Party check was done with ' . $value['third_check_details']['whom_third_party_check_done']; + echo isset($value['third_check_details']['description_third_party_check_done']) ? ' (' . $value['third_check_details']['description_third_party_check_done'] . '). ' : ' '; + if ($value['third_check_details']['rental_rates_third_party_check_done'] != "") { + echo 'Rental rates in the area as per person whom third party check is done is ' . $value['third_check_details']['rental_rates_third_party_check_done']; + } + } else { + + echo '
      For property ' . ($key + 1) . ' Third Party check not done.'; + echo isset($value['third_check_details']['why_third_party_check_not_done']) && $value['third_check_details']['why_third_party_check_not_done'] != "" ? 'Resaon - ' . $value['third_check_details']['why_third_party_check_not_done'] : ''; + } + echo '
      ' . $value['property_remark']; + } + } +} + + +?> + + + + +"; +$footer_lender_stamp = MYUTIL::dispatchDisclaimer($lender_disclaimer, 3); +if (isset($footer_lender_stamp)) { + //$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer,3); + echo '

      '; +} + +$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 2); + +if (isset($footer_lender_disclaimer)) { + echo '

      ' . $footer_lender_disclaimer['disclaimer'] . '

      '; +} +echo "

      "; + +// ########################### End disclaimer end ######################################### +?> + + + + + + +
      '; + echo "

      Detailed Score Card Section

      "; + // *** General Section Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['general'] as $key => $general) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['score_band'] . ')'; + $max_span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['max_score_band'] . ')'; + echo '' . ''; + } + + echo ''; + echo '
      General Questions L1(" . $pd_score['general']['otp_done']['l1_weightage'] . "%) L2 Answer Score Attributed Score Max Score
      ' . $question . '' . $general['l2_weightage'] . '%' . $general['answer'] . + '' . $general['score_band'] . '' . $general['attributed_score'] . '
      ' . $span . '
      ' . $general['max_score'] . '
      ' . $max_span . '
      General Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['general']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['general']['max_score'], 2, '.', ',') . '
      '; + + echo '

      '; + + + // *** Asset Caculation Score Table + echo ''; + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + + + echo '
      Asset Value Calculaitons
      Actual Value Of Assets (a)" . number_format($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets'], 2, '.', ',') . "
      Loan Amount (b)" . number_format($pd_score['score_summary']['asset_calculation_details']['loan_amount'], 2, '.', ',') . "
      Avg Expected Value Of Assets (c)" . round($pd_score['score_summary']['asset_calculation_details']['avg_expected_value_of_assets'], 2) . "%
      Expected Value Of Assets (d = c*b)" . number_format($pd_score['score_summary']['asset_calculation_details']['expected_value_of_assets'], 2, '.', ',') . "
      Actual Value Of Assets Percentage (e = (a/b) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets_percentage'], 2) . "%
      Variance (f = ((e-c)/c) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['variance'], 2) . "%
      Score As per Grid" . round($pd_score['score_summary']['asset_calculation_details']['score'], 2) . "
      '; + + echo '


      '; + // *** Final Remarks Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['final_remarks'] as $key => $final_remark) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + + $span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['score_band'] . ')'; + + $max_span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['max_score_band'] . ')'; + + echo '' . ''; + } + + echo ''; + echo '
      Final Remarks Questions L1(" . $pd_score['final_remarks']['pd_officer_recommandations']['l1_weightage'] . "%) L2Answer ScoreAttributed Score Max Score
      ' . $question . '' . $final_remark['l2_weightage'] . '%' . $final_remark['answer'] . '' . $final_remark['score_band'] . '' . $final_remark['attributed_score'] . '
      ' . $span . '
      ' . $final_remark['max_score'] . '
      ' . $max_span . '
      Final Remarks Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['final_remarks']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['final_remarks']['max_score'], 2, '.', ',') . '
      '; + echo '


      '; + + //print_r($pd_score['business']); + echo ''; + + // *** Business Section Questions Score Table + echo ""; + $certificates = array(); + foreach ($pd_score['business'] as $key => $business) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['score_band'] . ')'; + $max_span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['max_score_band'] . ')'; + + if (($key != 'cerificates') && ($key != 'location_suited_for_busienss')) { + echo '' . ''; + } + + if ($key == 'location_suited_for_busienss') { + echo '' . ''; + } + + if ($key == 'cerificates') { + $certificates = $business; + + echo '' . ''; + } + } + + echo ''; + echo '
      Business Questions L1(" . $pd_score['business']['no_of_years_business_run']['l1_weightage'] . "%) L2Answer Score Attributed ScoreMax Score
      ' . $question . '' . $business['l2_weightage'] . '%' . $business['answer'] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      ' . $question . '' . $business['l2_weightage'] . '%' . $address_type_remarks_caption[$business['answer']] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      Certificates ' . round($business['l2_weightage'], 2) . '%' . 'Refer Cert Table' . '' . $business['score_band'] . '' . $business['attributed_score'] . '' . $business['max_score'] . '
      Business Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['business']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['business']['max_score'], 2, '.', ',') . '
      '; + + + // *** Business Certificates Score Table + + + echo '

      '; + + echo ""; + echo ""; + $index = 0; + // print_r($certificates); + foreach ($certificates as $key => $cerificate) { + $index++; + if ($index <= 7) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['score_band'] . ')'; + + $max_span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['max_score_band'] . ')'; + + echo '' . ''; + } + } + echo "
      Business Certificates Answer Score Attributed Score Max Score
      ' . $question . '' . $cerificate['answer'] . '' . $cerificate['score_band'] . '' . round($cerificate['attributed_score'], 3) . '
      ' . $span . '
      ' . round($cerificate['max_score'], 3) . '
      ' . $max_span . '
      "; +} +// ########################### End Of Score Card Section ######################################### + + + + + + +?> + + + + \ No newline at end of file diff --git a/api/application/views/report_templates/JSONTOREPORT_FI_OV_SAL.php b/api/application/views/report_templates/JSONTOREPORT_FI_OV_SAL.php new file mode 100644 index 00000000..b98413f4 --- /dev/null +++ b/api/application/views/report_templates/JSONTOREPORT_FI_OV_SAL.php @@ -0,0 +1,5194 @@ + + + + + + + + + + + + + + + + + + + + + + + +
      +
      + Powered by PD Genie™ +
      + +
      +
      +
      +
      + + + ₹"; + ?> +
      "; + + echo "
      "; + echo "

      PERSONAL DISCUSSION REPORT

      "; + echo "
      for the case of
      "; + + echo "

      " . $main_applicant_name . "

      "; + echo "
      "; + echo "



      "; + ?> + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + ?> + + + + Loan Amount Applied For :

      "; + //echo '
      PD Initiated Date : ' . $pd_master_details[0]['createdon'] . '
      Tele PD Date : ' . $pd_master_details[0]['pd_visit_date'] . '
      PD Report Date : ' . $pd_master_details[0]['pd_report_generated_date'] . '
      PD Initiated by : ' . $pd_master_details[0]['branch_name'] . ' Branch
      PD Type : Telephonic
      ' . $loan_word . ' Application ID : ' . $pd_master_details[0]['lender_applicant_id'] . '
      Product : ' . $pd_master_details[0]['product_name'] . '
      Customer Segment : ' . (explode('-', $pd_master_details[0]['customer_segment_name'])[0]) . '
      + $pd_initiation_loan_amt = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? $loan_form['loan_amount'] : $loan_form['facility_amount']; + echo ''; + // echo ''; + echo '
      ' . $loan_word . ' Amount
      (As Per PD Initiation)
      : ' . ' ' . MYUTIL::customIndianNumberFormat($pd_master_details[0]['loan_amount']) . '
      (' . MYUTIL::numtowords($pd_master_details[0]['loan_amount']) . ')
      ' . $loan_word . ' Amount
      (As Per ' . $loan_word . ' Applicants during PD)
      : ' . ' ' . MYUTIL::customIndianNumberFormat($pd_initiation_loan_amt) . '
      (' . MYUTIL::numtowords($pd_initiation_loan_amt) . ')
      '.$loan_word.' Amount
      (As Per PD Initiation)
      : ' .' '. MYUTIL::customIndianNumberFormat($pd_master_details[0]['loan_amount']). '
      ('. MYUTIL::numtowords($pd_master_details[0]['loan_amount']) .')
      '.$loan_word.' Amount
      (As Per '.$loan_word.' Applicants during PD)
      : ' .' '. MYUTIL::customIndianNumberFormat($loan_form['loan_amount']). '
      ('. MYUTIL::numtowords($loan_form['loan_amount']) .')
      '; + //echo "
      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + + $header_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 1); + if (isset($header_lender_disclaimer['disclaimer']) && $header_lender_disclaimer['disclaimer'] != '' && $header_lender_disclaimer['type'] == 1) { + echo '

      Disclaimer: ' . $header_lender_disclaimer['disclaimer'] . '

      '; + } + + echo '

      Registered / Corporate Office: SineEdge Consulting Private Limited. A-211, Pioneer Urban Square, Golf Course Extension Road, Sector 62, Gurgaon, Haryana - 122002

      '; + ?> + + + + + + $individual) { + //print_r($individual);die(); + if ($individual['is_person_met'] == true) { + //array_push($person_met_images); + $temp_person_met = array(); + $applicant_name = $individual['applicant_name']; + //$applicant_name = array_key_exists('pd_co_applicant_id_master',$individual) ? $individual['pd_co_applicant_id_master'] : "Not Available" ; + //echo '
      '.$individual['applicant_title_name_master'] .' '. $applicant_name.'
      ' ; + $temp_person_met['name'] = $individual['applicant_title_name_master'] . ' ' . $applicant_name; + $temp_person_met['photo'] = ''; + $temp_person_met['id_proof'] = ''; + foreach ($pd_images[18] as $pm_Key => $pm_value) { + + //echo $applicant_name.'-'.$pm_value['pd_document_title']; + if (!strcasecmp(trim($applicant_name), trim($pm_value['pd_document_title']))) { + $temp_person_met['photo'] = $pm_value['doc_url']; + } + + $id = trim($applicant_name) . '-id_proof'; + if (!strcasecmp($id, trim($pm_value['pd_document_title']))) { + $temp_person_met['id_proof'] = $pm_value['doc_url']; + } + } + $company_relationship_data = null; + foreach ($general_form['company_with_relationships'] as $company_with_relationship) { + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name']) { + //FInd Company Name from JSON + $company_relationship_data .= $company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']; + + //$company_relationship_data.='
      and

      '; + $company_relationship_data .= ', '; + } + } + //$temp_person_met['name'] = + //print_r($general_form['persons_with_relationships']); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + if ($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && isset($persons_with_relationship['relationship'])) { + + if (isset($persons_with_relationship['relation_to_master'])) { + //? $persons_with_relationship['relation_to_master'] : " Could Not Find"; + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' Of ' . $RSNA; + //$personal_relationship_data.='
      and

      '; + $personal_relationship_data .= ', '; + } + } + } + } + + $company_relationship_data .= $personal_relationship_data; + $temp_person_met['relations'] = $company_relationship_data; + array_push($person_met_data, $temp_person_met); + } + } + + + //print_r($person_met_data);die(); + echo '
      '; + echo '

      Person(s) Met:

      '; + echo '
      '; + foreach ($person_met_data as $pk => $person) { + $display_for_person_met = $person['relations'] != "" ? substr_replace($person['relations'], '.', strrpos($person['relations'], ','), 1) : ''; + + $person_met_details = $person['name']; + if (strcasecmp($pd_master_details[0]['customer_segment_abbr'], 'SEP_INDV')) { + $person_met_details .= ($display_for_person_met != "" ? ' - ' . $display_for_person_met : ''); + } + echo '

      ' . $person_met_details . '

      '; + + //if($display_for_person_met != "" || $display_for_person_met != null){ + echo '

      '; + //} + if ($person['photo']) { + echo ''; + } + echo '     '; + if ($person['id_proof']) { + echo ''; + } + + //echo count($person_met_data) != ($pk+1)? '
      ':''; + + + } + $faceimage_url = array(); + if (isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) { + foreach ($pd_images['common_images'] as $com_key => $com_value) { + if ($com_value['pd_document_title'] == 'face_api_result_image') { + // $faceimage_url = $com_value['doc_url'];break; + array_push($faceimage_url, $com_value['doc_url']); + } + } + } + if (!empty($faceimage_url)) { + for ($i = 0; $i < count($faceimage_url); $i++) { + echo '     '; + echo ''; + } + } + echo '
      '; + echo '
      '; + ?> + +
      + Face Comparison"; + $notequal_mark = '
      '; + $equal_mark = '
      =
      '; + for ($i = 0; $i < count($ci); $i++) { + $symbol = (round($ci[$i]["Similarity"]) > 50) ? '

      ' . $equal_mark . '

      ' : '

      ' . $notequal_mark . '

      '; + echo '
      +
      + ' . $si[ +
      +
      ' . $symbol . '
      +
      + ' . $ci[$i][ +
      +
      '; + + echo '

      Similarity + ' . round($ci[$i]["Similarity"]) . ' +

      +
      +
      + ' . round($ci[$i]["Similarity"]) . ' +
      +
      '; + } + // ########################### End of Percentage Bar Section ######################################### + } + } + ?> + +

      Applicants:

      + + + + + + + + + + + $individual) { + + if ($individual['is_applicant'] == true && $individual['is_active'] == true) { + + $education_qualification = $individual['qualification_master']; + $education_qualification = $individual['course_name'] != "" || $individual['course_name'] != null ? $education_qualification . '
      (' . $individual['course_name'] . ')' : $education_qualification; + + + $applicant_name = array_key_exists('pd_co_applicant_id_master', $individual) ? $individual['pd_co_applicant_id_master'] : " Could Not Find"; + //echo $applicant_name.'**************************'; + + $title = isset($individual['applicant_title_name_master']) && $individual['applicant_title_name_master'] != "" ? $individual['applicant_title_name_master'] : ''; + + //$kyc_data = ''; + $applicant_name = $title . ' ' . $applicant_name; + if ($ind_key == 0 && array_key_exists('is_kyc', $general_form) && $general_form['is_kyc'] == 'no') { + $applicant_name = 'As per the request received applicant name is ' . $applicant_name . '
      but as per KYC name is ' . $general_form['kyc_and_captur_the_name']; + //$kyc_data = "

      Name noticed as per KYC is ". $general_form['kyc_and_captur_the_name']; + } + echo '"; + } + } + + if (isset($general_form['companies']) && count($general_form['companies'])) { + $business_entity_type_master = array(1 => 'Others', 2 => 'Public Ltd Company', 3 => 'Sole proprietorship', 4 => 'HUF (Hindu Undivided Family)', 5 => 'Partnership', 6 => 'Cooperative', 7 => 'Limited Liability Partnership(LLP)', 8 => 'OPC (One Person Company)', 9 => 'Society', 10 => 'Trust', 11 => 'Private Limited Company'); + foreach ($general_form['companies'] as $comp_key => $ind_company) { + if ($ind_company['is_company_applicant'] != null) { + + echo ''; + } + } + } + ?> + +
      NameAge
      (Yrs/Mns)
      Qualification / Type of EntityRelationships
      ' . $applicant_name . '' . $individual['age'] . '' . $education_qualification . ''; + + $company_relationship_data = null; + //print_r($general_form['company_with_relationships']); + foreach ($general_form['company_with_relationships'] as $crk => $company_with_relationship) { + + //print_r($company_with_relationship); + + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name'] && $company_with_relationship['company_name'] != '') { + //FInd Company Name from JSON + + //echo "ONCE"; + //echo '### '.$crk.'-ICID'.$individual['pd_co_applicant_id'].'--'.$company_with_relationship['applicant_name'].'-'.$company_with_relationship['company_name']; + $company_relationship_data .= ($company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']); + + $company_relationship_data .= '
      and

      '; + //echo $company_relationship_data; + } + } + //echo $company_relationship_data; + // die(); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + + + + if (($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] || !strcasecmp($applicant_name, $persons_with_relationship['applicant_name'])) && isset($persons_with_relationship['relationship'])) { + + + if (isset($persons_with_relationship['relation_to_master'])) { + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' of ' . $RSNA; + + $personal_relationship_data .= '
      and

      '; + } + } + } + } + $company_relationship_data .= $personal_relationship_data; + echo substr_replace($company_relationship_data, '', strrpos($company_relationship_data, '
      and

      '), strlen($company_relationship_data)); + + echo "
      ' . $ind_company['company_name'] . '' . $ind_company['business_years'] . (isset($ind_company['business_month']) ? ' . ' . $ind_company['business_month'] : null) . '' . ($ind_company['business_entity_type'] == 1 ? $ind_company['business_entity_type_other'] : $business_entity_type_master[$ind_company['business_entity_type']]) . ' Not Applicable
      + + + + + ' . $general_form['general_remark'] . '

      '; + } + ?> + + + + + + + 'well suited', 'fairly_suited' => 'fairly suited', 'not_suited' => 'not suited'); + //die(); + if (isset($pd_score) && count($pd_score)) { + echo '
      '; + echo '

      PD Score Summary

      '; + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Actual ScoreMax ScoreScore %
      General Section Score
      Business Section Score
      Final Remarks Score
      Final PD Score
      + +
      "; + + echo '

      '; + } + // else + // { echo "Score Chart Not Generated"; } + + + + //######################### CHART ########################### + + + // if(isset($dsc_cards['base64_dsc_business'])) + // { + // echo "

      "; + + // echo '

      '; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + // if(isset($dsc_cards['base64_dsc_general'])) + // { + // echo "

      "; + + // echo '

      '; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + + echo "
      "; + //######################### CHART ########################### + + $business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>", "owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>", "stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>"); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>", "value_of_other_assets" => "Asset Value by Loan Amount % >>"); + } else { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>"); + } + + + + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['business'] as $bsk => $business_score) { + + $class = null; + $answer = null; + $per = $business_score['attributed_score'] > 0 && $business_score['max_score'] > 0 ? (($business_score['attributed_score'] / $business_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + // if($bsk == 'business_seasonality') + // { + // echo "BUSINESS"; + // echo $per; + // echo $class; + // echo $per >= 80 ? 'rcorners_green' : 'SOME'; + // die(); + // } + + if ($bsk == 'location_suited_for_busienss') { + $answer = $address_type_remarks_caption[$business_score['answer']]; + } else if ($bsk == 'cerificates') { + $answer = $per > 0 ? 'Yes' : 'No'; + } else if ($bsk == 'no_of_years_business_run') { + $answer = isset($business_score['answer']) ? $business_score['answer'] . ' Yrs' : ''; + } else if ($bsk == 'business_seasonality') { + $answer = isset($business_score['answer']) ? ((!strcasecmp($business_score['answer'], 'yes')) ? 'Seasonal' : 'Not Seasonal') : ''; + } else if ($bsk == 'vintage_of_business_account') { + $answer = isset($business_score['answer']) && $business_score['answer'] != '' ? $business_score['answer'] : 'No'; + } else { + $answer = isset($business_score['answer']) ? $business_score['answer'] : ''; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
      Business Related Parameters Impacting Score Response
      ' . $business_captions[$bsk] . ' ' . '
      ' . ucfirst($answer) . '
      '; + echo '


      '; + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['general'] as $gsk => $general_score) { + $class = null; + $per = $general_score['attributed_score'] > 0 && $general_score['max_score'] > 0 ? (($general_score['attributed_score'] / $general_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + $answer = ucfirst($general_score['answer']); + + if ($gsk == 'value_of_other_assets') { + //print_r($general_score);die(); + $answer = round((($answer / $loan_form['loan_amount']) * 100), 2) . ' %'; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
      Other Parameters Impacting ScoreResponse
      ' . $general_captions[$gsk] . ' ' . '
      ' . $answer . '
      '; + + + // + } //end of is score card enabled for this pd + + ?> + + $address_image_value) { + if ($address_image_value['is_show_report'] == 1) { + $pd_location_approach_img_url = isset($address_image_value['doc_url']) ? $address_image_value['doc_url'] : ''; + //$pd_location_approach_img_location = $address_image_value['location']; + //$pd_location_approach_img_date = date('Y/m/d h:s:i A',$address_image_value['createdon']); + break; + } + } + + $name_board_seen_img_url = ''; + if (isset($pd_processed_forms[13][0])) { + + $first_business_form = json_decode($pd_processed_forms[13][0]['processed_json'], true); + //if($first_business_form['was_the_company_name_board_sighted']=='yes') + //{ + //echo 'YES';die(); + foreach ($pd_images[13] as $image_key => $image_value) { + if ($image_value['pd_document_title'] == 'Name Board Seen') { + + $name_board_seen_img_url = $image_value['doc_url']; + break; + } + } + //} + } + + //echo $name_board_seen_img_url;die(); + //print_r($address_images);die(); + ?> +
      +

      BUSINESS LOCATION

      + +

      Address at which PD was initiated: ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + + echo '
      Address at which PD Visit actually done: ' . $pd_alternative_address['alternative_address'] . ', ' . $pd_alternative_address['city_master'] . ', ' . $pd_alternative_address['state_master'] . ' - ' . $alter_native_pincode . '.'; + + echo '
      Reason for change in PD address:' . $pd_alternative_address['reason_for_alternative_address']; + } else { + + echo 'Business Address : ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + } + + echo '

      GPS Coordinates of Business Address : '; + echo isset($pd_master_details[0]['start_location']) ? $pd_master_details[0]['start_location'] : 'Not Available'; + echo '

      '; + ?> + $com_value) { + if ($com_value['pd_document_title'] == 'satellite') { + $satellite_url = $com_value['doc_url']; + break; + } + } + } + + ?> +  Satellite Image of location of Where PD was Done


      + + + + + + + + + + + + +
      Name Board of Business/Entrance
      + Name Board +
      + +

      +
      +

      Location Summary

      + '; + echo 'The PD was telephonically done with the ' . strtolower($loan_word) . ' applicant(s) at ' . $address_type . 'Address Form - Type of Address . '; + echo 'The ' . $address_type . 'Address Form - Type of Address is ' . $property_owner_type . 'Business Assest Form - Owner of the Property and the business has been in operation from here for the last ' . $yrs_being_run . 'Business Assest Form - Business running Yrs in this premise .'; + echo '

      The ' . $address_type . 'Address Form - Type of Address is located in ' . $locality . 'Address Form - Locality of Address ' . ($estimated_area != 0 ? 'and the estimated area of the ' . $address_type . 'Address Form - Type of Address is ' . $estimated_area . 'Address Form - Estimated Area .' : ''); + // echo '

      The PD location was '. $pd_address['pd_location_master'].'Address Form - Approach to PD location . ' . 'As Per PD Officer, the '.$address_type .'Address Form - Type of Address is situated in '.$comment_locality_master .'Address Form - Comment on locality Locality.'; + // echo '

      The PD officer also made the following observations:' ; + echo '
      '; + + // echo '
    • The location of the '.$address_type.'Address Form - Type of Address is '.$address_type_remarks_caption [ $final_remark_data['is_service_provided'] ].'Final Remarks Form - The location of the busienss suitability for Business to the nature of business.
    • '; + + if ($first_business_form['was_the_company_name_board_sighted'] == 'yes') { + echo '

      The business name board photograph was shared by applicant.Business Form'; + } else { + echo '

      The business name board photograph was not shared by applicant.Business Form'; + } + + if ($address_form['address_proof_provided'] == 'yes') { + echo ' The address proof was shared by applicant.Business Form'; + } else { + echo ' The address proof was not shared by applicant.Business Form'; + } + echo '

      '; + + + // if($business_assets_details['business_assets_for_address'][0]['business_is_pd_visited'] == 'yes') + // { + // echo '
    • Business Activity was seen during visit.Business Assest Form - Busienss activity seen during PD visit
    • '; + // } + // else{ + // echo '
    • No business activity was seen during the PD visit.Business Assest Form - Busienss activity seen during PD visit
    • '; + // } + // if(isset($business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark']) && $business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] != ""){ + // echo '
    • '.$business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] .'Business Assest Form - Busienss Assest Form Remarks
    • ';} + + if (isset($final_remark_data['is_competition'])) { + if ($final_remark_data['is_competition'] == 'yes') { + echo '
    • ' . $final_remark_data['appx_outlet_or_stores'] . ' Units with similar business were sighted in the locality
    • '; + } else { + echo '
    • PD officer did not observe any similar business units in the locality.
    • '; + } + } + if (isset($final_remark_data['demolition_activity'])) { + if ($final_remark_data['demolition_activity'] == 'yes') { + echo '
    • ' . $final_remark_data['comment_of_demolition_activity'] . '
    • '; + echo '
      Demolition Image Not Available'; + } else { + echo '
    • No demolition activity was observed in the locality.
    • '; + } + } + + + if (isset($final_remark_data['sealing_activity'])) { + if ($final_remark_data['sealing_activity'] == 'yes') { + echo '
    • ' . $final_remark_data['comment_of_sealing_activity'] . '
    • '; + echo '
      Demolition Image Not Available'; + } else { + echo '
    • No sealing activity was observed in the locality.
    • '; + } + } + + if (isset($final_remark_data['outlet_location'])) { + if ($final_remark_data['outlet_location'] == 'heavy_footfall') { + echo '
    • Heavy Footfall ( Lots of customer in the locality / market place )
    • '; + } else if ($final_remark_data['outlet_location'] == 'medium_footfall') { + echo '
    • Medium Footfall ( Meduim no of customer in the locality / market place )
    • '; + } else if ($final_remark_data['outlet_location'] == 'low_footfall') { + echo '
    • LOw Footfall ( Few customer in the locality / market place )
    • '; + } + } + + echo "
    "; + + if ($address_form['address_form_remark']) { + echo '' . $address_form['address_form_remark'] . 'Address Form - Address Form Remarks '; + } + echo "

    "; + // echo "
    "; + //die(); + // + ?> + + + + + + +

    DETAILS:

    + The following loan related information was provided by applicant.'; + + $is_current_product_bl = $pd_master_details[0]['prod_catagory'] == "BL" ? true : false; + $is_current_product_lab = $pd_master_details[0]['prod_catagory'] == "LAP" ? true : false; + $is_current_product_laep = $pd_master_details[0]['prod_catagory'] == "LAEP" ? true : false; + // echo $pd_master_details[0]['product_abbr']; + // echo '-bl-'. $is_current_product_bl; + // echo '-lap-'.$is_current_product_lab; + // die(); + $loan_table_dispaly_rows = array(); + + $loan_table_dispaly_rows[] = array('particulars' => ('Total ' . $loan_word . ' Amount applied for'), 'details' => "" . " " . $loan_amount . ' (' . MYUTIL::numtowords($loan_form['loan_amount']) . ')'); + if ($is_current_product_bl || $is_current_product_laep) { + $to_dispaly = !strcasecmp($loan_form['is_there_total_fund'], 'yes disclose') ? ('Disclosed ' . "" . " " . MYUTIL::customIndianNumberFormat($loan_form['fund_amt']) . ' (' . MYUTIL::numtowords($loan_form['fund_amt']) . ')') : 'Not Disclosed'; + $loan_table_dispaly_rows[] = array('particulars' => 'Total Fund Requirement', 'details' => $to_dispaly); + } + $loan_table_dispaly_rows[] = array('particulars' => ($loan_word . ' Tenure expected'), 'details' => $loan_form['loan_tenure'] != "" ? $loan_form['loan_tenure'] . ' Months' : 'Not provided'); + + $end_use = ''; + $to_remove_for = false; + foreach ($loan_form['end_use_master'] as $enduse) { + if (strpos(strval($enduse), 'Others') === false) { + $end_use .= $enduse . ' and '; + } else { + + $to_remove_for = true; + $end_use .= $loan_form['end_use_other'] . ' and'; + } + } + $end_use = substr_replace($end_use, '', strrpos($end_use, 'and'), strlen($end_use)); + //echo substr($end_use,0,3); + + + if (strcasecmp(substr($end_use, 0, 3), 'for')) { + if (!(count($loan_form['end_use_master']) == 1 && $to_remove_for)) { + $end_use = 'For ' . $end_use; + } + } + + $loan_table_dispaly_rows[] = array('particulars' => ($loan_word . ' Purpose'), 'details' => $end_use); + + if (strcasecmp($loan_form['is_transfer'], 'no')) { + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer Amount', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['balance_transfer_amount']) . ' (' . MYUTIL::numtowords($loan_form['balance_transfer_amount']) . ')'); + + $loan_table_dispaly_rows[] = array('particulars' => 'Top Up Amount applied for', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['topup_amount']) . ($loan_form['topup_amount'] ? (' (' . MYUTIL::numtowords($loan_form['topup_amount']) . ')') : '')); + + if ($loan_form['end_use_topup_master']) { + $loan_table_dispaly_rows[] = array('particulars' => 'End Use of Topup', 'details' => (strcasecmp('others', $loan_form['end_use_topup_master'])) ? $loan_form['end_use_topup_master'] : $loan_form['other_end_use_topup']); + } + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer from', 'details' => $loan_form['lender'] == 1 ? $loan_form['other_bt_lender'] : $loan_form['lender_master']); + } else { + //echo 'sdn-'.((!$is_current_product_bl) && !$is_current_product_lab); die(); + if ((!$is_current_product_bl) && !$is_current_product_lab && !$is_current_product_laep) { + $loan_table_dispaly_rows[] = array('particulars' => 'Amount of Own Contribution', 'details' => is_numeric($loan_form['own_contribution']) && $loan_form['own_contribution'] != 0 ? ("" . " " . MYUTIL::customIndianNumberFormat($loan_form['own_contribution']) . ' (' . MYUTIL::numtowords($loan_form['own_contribution']) . ')') : 'Not Provided'); + $source_of_own_contribution = ''; + + foreach ($loan_form['source_of_own_contribution_master'] as $own_source) { + + if (!strcasecmp($own_source, 'others')) { + $source_of_own_contribution .= $loan_form['other_source'] . ' and '; + } else { + $source_of_own_contribution .= $own_source . ' and '; + } + } + + $source_of_own_contribution = substr_replace($source_of_own_contribution, '', strrpos($source_of_own_contribution, ' and '), strlen($source_of_own_contribution)); + + $loan_table_dispaly_rows[] = array('particulars' => 'Source of Own Contribution', 'details' => $source_of_own_contribution); + } + } + if (!($pd_master_details[0]['lender_short_name'] == 'UDAAN' || $pd_master_details[0]['lender_short_name'] == 'CFPL')) { + $loan_table_dispaly_rows[] = array('particulars' => 'EMI Comfortable Paying', 'details' => is_numeric($loan_form['emi_level']) && $loan_form['emi_level'] != 0 ? ($rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emi_level']) . ' (' . MYUTIL::numtowords($loan_form['emi_level']) . ')') : "Not Provided"); + } + + if (!$is_current_product_bl && !$is_current_product_laep) { + + if (isset($loan_form['property_type_master']) && $loan_form['property_type_master'] != "") { + $loan_table_dispaly_rows[] = array('particulars' => 'Type of Property Being Mortgaged', 'details' => substr_count($loan_form['property_type_master'], 'Others') ? $loan_form['property_type_others'] : $loan_form['property_type_master']); + + //print_r($loan_form);die(); + $owners_list = null; + foreach ($loan_form['owners_list_master'] as $owner) { + $owners_list .= $owner . ' and '; + } + ///echo $owners_list; + $owners_list = substr_replace($owners_list, '', strrpos($owners_list, 'and'), strlen($owners_list)); + if ($owners_list == '') { + if (isset($loan_form['owner_name_group'][0]['owner_name'])) { + $owners_list = $loan_form['owner_name_group'][0]['owner_name']['name']; + } + } + $loan_table_dispaly_rows[] = array('particulars' => 'Name of the current / proposed owner(s) of the Property being Mortgaged', 'details' => $owners_list); + + $loan_table_dispaly_rows[] = array('particulars' => 'Status of Construction', 'details' => $loan_form['construction_status_master']); + + $loan_table_dispaly_rows[] = array('particulars' => 'Estimated Market Value of the property being mortgaged', 'details' => ($loan_form['emv_per_customer'] != "" ? $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emv_per_customer']) . ' (' . MYUTIL::numtowords($loan_form['emv_per_customer']) . ')' : 'Not Provided')); + } + } + + if (isset($loan_form['property_seller']) && $loan_form['property_seller'] != '') { + $loan_table_dispaly_rows[] = array('particulars' => 'Current Owner/Seller of the property', 'details' => $loan_form['property_seller']); + } + + if (isset($loan_form['address']) && $loan_form['address'] != '') { + $address_of_owner_seller_property = $loan_form['address'] . (isset($loan_form['city_master']) ? ', ' . $loan_form['city_master'] : '') . (isset($loan_form['state_master']) ? ', ' . $loan_form['state_master'] : '') . (isset($loan_form['pincode_master']) ? ', ' . $loan_form['pincode_master'] : ''); + + $loan_table_dispaly_rows[] = array('particulars' => 'Address of the property', 'details' => $address_of_owner_seller_property); + } + //print_r($loan_table_dispaly_rows); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + ?> +

    + + + + + + + + $row) { + echo '"; + } + ?> + +
    S.No Particulars Particular Details
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    + +
    +

    Anchor Details Section:

    + + + + + + + + $row) { + echo '"; + } + ?> + +
    S.No Particulars Particular Details
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    +
    " . $loan_form['loandetails_remarks']; + ?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + + if ($general_form['companies'][$business_count]['is_active'] == true) { // $temp_show = null; + // if($temp_show == null) + // { + ?> + + .'; + } + $bindEachResult['company_employees'] = ''; + + + // this is for no of employees details + if (isset($businessRow['employees_permanent']) && $businessRow['employees_permanent'] <= 0) { + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent'; + } else { + $bindEachResult['company_employees'] = 'As per loan applicant, there are ' . $businessRow['employees_permanent'] . ' permanent '; + } + + if (isset($businessRow['employees_temporary']) && $businessRow['employees_temporary'] > 0) { + + $bindEachResult['company_employees'] .= 'and ' . $businessRow['employees_temporary'] . ' temporary employee(s) with company.'; + } else { + + $bindEachResult['company_employees'] .= ' and no temporary employees with company.'; + } + + if (($businessRow['employees_permanent'] != "" && $businessRow['employees_permanent'] == 0) && ($businessRow['employees_temporary'] != "" && $businessRow['employees_temporary'] == 0)) { + + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent or temporary employees with the company.'; + } + + if (isset($businessRow['employees_appx_salary']) && $businessRow['employees_appx_salary'] != "") { + $bindEachResult['employees_appx_salary'] = 'Approximately ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($businessRow['employees_appx_salary']) . ' is being paid as salary to employees'; + } + if (isset($businessRow['officer_total']) && $businessRow['officer_total'] > 0) { + $emp = $businessRow['officer_total'] > 1 ? 'employees' : 'employee'; + $bindEachResult['officer_visit_company_employees'] = 'At the time of PD visit, the officer sighted ' . $businessRow['officer_total'] . ' ' . $emp . ' at the business premises.'; + } else { + + $bindEachResult['officer_visit_company_employees'] = ''; + //$bindEachResult['officer_visit_company_employees']='At the time of PD visit, no employees seen at the business premises.'; + } + //this is documents visited + $getDocuments = array(); + if (array_key_exists('shop_eat_act_cert', $businessRow) && strtoupper($businessRow['shop_eat_act_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Shop/Est act Certificate.', 'img' => isset($businessRow['shop_eat_act_cert_pic']) ? $businessRow['shop_eat_act_cert_pic'] : '', 'key_name' => 'shop_eat_act_cert_pic')); + } + if (array_key_exists('gst_Regn_cert', $businessRow) && strtoupper($businessRow['gst_Regn_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'GST Registration.', 'img' => isset($businessRow['gst_Regn_cert_pic']) ? $businessRow['gst_Regn_cert_pic'] : '', 'key_name' => 'gst_Regn_cert_pic')); + } + if (array_key_exists('pf_regn', $businessRow) && strtoupper($businessRow['pf_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'PF Registration.', 'img' => isset($businessRow['pf_regn_pic']) ? $businessRow['pf_regn_pic'] : '', 'key_name' => 'pf_regn_pic')); + } + if (array_key_exists('esic_regn', $businessRow) && strtoupper($businessRow['esic_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'ESIC Registration.', 'img' => isset($businessRow['esic_regn_pic']) ? $businessRow['esic_regn_pic'] : '', 'key_name' => 'esic_regn_pic')); + } + if (array_key_exists('export_import_cert', $businessRow) && strtoupper($businessRow['export_import_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Export/Import Certificate.', 'img' => isset($businessRow['export_import_cert_pic']) ? $businessRow['export_import_cert_pic'] : '', 'key_name' => 'export_import_cert_pic')); + } + if (array_key_exists('factory_cert', $businessRow) && strtoupper($businessRow['factory_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Factory Certificate.', 'img' => isset($businessRow['factory_cert_pic']) ? $businessRow['factory_cert_pic'] : '', 'key_name' => 'factory_cert_pic')); + } + if (array_key_exists('eb_bill', $businessRow) && strtoupper($businessRow['eb_bill']) == 'YES') { + array_push($getDocuments, array('name' => 'Electric Bill.', 'img' => isset($businessRow['eb_bill_pic']) ? $businessRow['eb_bill_pic'] : '', 'key_name' => 'eb_bill_pic')); + } + if (strtoupper($businessRow['other_documents']) == 'YES' && array_key_exists('documents', $businessRow)) { + foreach ($businessRow['documents'] as $docValue) { + array_push($getDocuments, array('name' => $docValue['document'], 'img' => isset($docValue['document_pic']) ? $docValue['document_pic'] : '', 'key_name' => $docValue['document'])); + } + } + + //print_r($getDocuments); + if (count($getDocuments)) { + foreach ($getDocuments as $getDocument_key => $getDocument_value) { + foreach ($pd_images[13] as $img_key => $img_value) { + if (!strcasecmp($getDocument_value['key_name'], $img_value['pd_document_title'])) { + $getDocuments[$getDocument_key]['img'] = $img_value['doc_url']; + break; + } + } + } + } + //print_r($getDocuments);die(); + $bindEachResult['visit_documents'] = $getDocuments; + array_push($businessResult, $bindEachResult); + + + + ?> +

    BUSINESS INFORMATION:

    + $fetchRow) { + //print_r($fetchRow['company_details']);die(); + ?> + +

    +

    +

    + +
    Date of Incorporation :
    + +
    Business Vintage : +

    + + +
    +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    NameShare HoldingNo.of Years in Current BusinessTotal Work Experience(Yrs)Previous ExperienceStarted Business
    + + + 0) { ?> +
    +

    Other Family Members involved in business :

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    NameIndividual RelationshipRelated toRelationship to Company / FirmStarted Business (Yes / No)
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    ' . $process_brief['description'] . '

    '; ?>
    + + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    ServicesArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + 0) { ?> + + +
    + + + + + + + + + + + + + + + +
    Other Business Activity
    +
    ' . $fetchRow['total_per_of_export'] . ' % of total sales is export.
    '; + } + + ?> + + + + + Loan applicant is using Mobile Wallets/UPI for business transactions.

    '; + } //else + //{ + // echo '

    As per person`s met,applicant using Mobile Wallets/UPI for business transactions.

    ' + //} + if (!strcasecmp($fetchRow['applicant_use_pos_machines'], 'yes')) { + echo '

    The applicant has the following POS machines:

    '; + echo ''; + echo ''; + foreach ($fetchRow['pos_machines_details'] as $pos) { + echo ''; + } + echo '
    Name of the Financial Insitution TID Number of POS machine
    ' . ($pos['pos_machines_financial_institution_name'] ? $pos['pos_machines_financial_institution_name'] : 'Not Provided') . ' ' . $pos['tid_no_of_pos_machine'] . '
    '; + } + + + + ?> + + + + + + + + + + + +
    +

    +
    + + + + +

    +

    +

    + + + + +

    The below document images were shared :

    + + + + '; + for ($doc = $from; $doc <= $to; $doc++) { + if (isset($visit_documents[$doc])) { + ?> + + '; + $from_index_increment = $from_index_increment + 2; + } ?> + +
    + +
    + + + + ' . $business_form_common_remarks . '

    '; + } + + ?> + + + + + + + +
    + + + + + + 0 && $is_business_asset_available) { + $bindBusinessAsset['details'] = ASSETSFORM::getBusinessAssetsDetails($businessAssetRow['business_assets_details'], $pd_master_details[0]['pd_id']); + } + array_push($businessAssetResult, $bindBusinessAsset); + + + //print_r($businessAssetResult);die(); + ?> + + + + +
    +
    +
    +

    Assets used in Business

    + $iterateAsset) { ?> +

    + + $value) { + echo ''; + echo ''; + echo $value['header_row']; ?> + +'; + echo '
    '; + echo '
    '; + } + } + } + } else { + echo '

    No other assests used for business.

    '; + } + if ($business_assets_form_remark != "") { + echo '

    ' . $business_assets_form_remark . '

    '; + } + } // ENd of if business assesst available in this current index +?> + + + + + + +
    +↑ /'; + + if (isset($pd_processed_forms[14][$business_count])) { + $baRow = $pd_processed_forms[14][$business_count]; + $businessFinancialRow = json_decode($baRow['processed_json'], true); + //print_r($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']);die(); + $financial_remarks = $businessFinancialRow['financial_remarks']; + $comments_on_financials = isset($businessFinancialRow['financial_reason']) ? $businessFinancialRow['financial_reason'] : ''; + //echo $financial_remarks;die(); + // statementdate_per_financial + if (isset($businessFinancialRow['kuccha_records_shown'])) { + $financial_kuccha_info['kuccha_records_shown'] = $businessFinancialRow['kuccha_records_shown']; + $financial_kuccha_info['kuccha_bill_allowed'] = $businessFinancialRow['kuccha_bill_allowed']; + $financial_kuccha_info['customer_declared_turnover'] = $businessFinancialRow['customer_declared_turnover']; + } + + //only for Indusind Lender + if (isset($businessFinancialRow['tot_business_FY'])) { + $current_business_info['tot_business_FY'] = $businessFinancialRow['tot_business_FY']; + $current_business_info['remarks_tot_business_FY'] = $businessFinancialRow['remarks_tot_business_FY']; + $current_business_info['orders_hand_FY'] = $businessFinancialRow['orders_hand_FY']; + } + + //print_r($financial_kuccha_info);die(); + if (strtoupper($businessFinancialRow['is_financial_statements']) == 'YES' && count($businessFinancialRow['date_per_financial']) > 0) { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + //$bindBusinessFinancial["company_name"] .= count($businessFinancialRow['date_per_financial'])>1 ? ' provided with last '.count($businessFinancialRow['date_per_financial']).' years of financial statements and the snapshot is as below :' : ' we were provided with last '.count($businessFinancialRow['date_per_financial']).' year of financial statements and the snapshot is as below :'; + $bindBusinessFinancial["years_data_provided"] = count($businessFinancialRow['date_per_financial']); + $bindBusinessFinancial['is_statement'] = 1; + $bindBusinessFinancial['statements'] = FINANCIALFORM::getBusinessFinancialDetails($businessFinancialRow['date_per_financial']); + } else { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + $bindBusinessFinancial["years_data_provided"] = 0; + $bindBusinessFinancial['statements'] = array(); + $bindBusinessFinancial['is_statement'] = 0; + } + // customer + if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && (!isset($businessFinancialRow['estimated_value']))) { + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } else if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && count($businessFinancialRow['estimated_value']) > 0) { + + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['is_customer_statement'] = 1; + } else { + + + $bindBusinessFinancial["financial_customer"] = "As per Loan Applicant(s), the actual turnover and net profit of his business is same as disclosed in financial statements."; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } + + + // ############### this section only for CLIX HOUSING FINANCE LENDER + if (isset($businessFinancialRow['is_turnover_validated']) && strtoupper($businessFinancialRow['is_turnover_validated']) == 'YES') { + $bindBusinessFinancial['turnover_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['how_turnover_validated'] = (!strcasecmp(strtolower($businessFinancialRow['how_turnover_validated']), 'others')) ? 'Validated from ' . $businessFinancialRow['turnover_validated_others'] : $businessFinancialRow['how_turnover_validated']; + $bindBusinessFinancial['is_turnover_validated'] = 1; + } + // ############### this section only for CLIX HOUSING FINANCE LENDER + $bindBusinessFinancial['working_capital_receive'] = $businessFinancialRow['receive_the_money_in_days']; + $bindBusinessFinancial['working_capital_pay'] = $businessFinancialRow['pay_the_money_in_days']; + $bindBusinessFinancial['working_capital_unsold_stock'] = is_numeric($businessFinancialRow['unsold_stock_lies_in_days']) ? $businessFinancialRow['unsold_stock_lies_in_days'] : 'Data Not Provided'; + $bindBusinessFinancial['is_working_capital_facility'] = $businessFinancialRow['is_there_working_capital_available']; + if (isset($businessFinancialRow['select_working_capital_facilities_availed'])) { + foreach ($businessFinancialRow['select_working_capital_facilities_availed'] as $k => $v) { + switch ($v['id']) { + case 1: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['name'] = $businessFinancialRow['other_reason_for_working_capital_facilities_availed']; + + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['reason_for_working_capital_facilities_availed']; + break; + + case 2: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['bank_guarantee']; + break; + + case 3: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['cash_credit_limit']; + break; + + case 4: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 5: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 6: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['letter_of_credit']; + break; + case 7: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['od_limit']; + break; + case 8: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['lender_name']; + break; + case 9: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_amount']; + break; + case 10: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_type']; + break; + case 11: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_tenor']; + break; + case 12: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_start_date']; + break; + case 13: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['monthly_emi']; + break; + } + } + } + + $bindBusinessFinancial['working_capital_facilites'] = isset($businessFinancialRow['select_working_capital_facilities_availed']) ? $businessFinancialRow['select_working_capital_facilities_availed'] : null; + + $bindBusinessFinancial['estimate_posmachine_or_cc_annual_sales'] = isset($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']) ? $businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales'] : null; + //print_r($bindBusinessFinancial['select_working_capital_facilities_availed']); //FINANCIALFORM::getAvailableFacilities($businessFinancialRow[-'"working_capital_facilities_availed']); + if ($pd_master_details[0]['lender_short_name'] == 'CFPL') { + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Turnover in last completed Year", 'details' => isset($businessFinancialRow['turnover_lastcomplete_year']) ? $businessFinancialRow['turnover_lastcomplete_year'] : null); + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "YTD turnover (till last month)", 'details' => isset($businessFinancialRow['ytd_turnover']) ? $businessFinancialRow['ytd_turnover'] : null); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall debtor collection period",'details' => isset($businessFinancialRow['deptor_collection_period'])?$businessFinancialRow['deptor_collection_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall Inventory holding period",'details' => isset($businessFinancialRow['inventory_holding_period'])?$businessFinancialRow['inventory_holding_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall creditor payment period",'details' => isset($businessFinancialRow['creditor_payment_period'])?$businessFinancialRow['creditor_payment_period']: null ); + } + array_push($businessFinancialResult, $bindBusinessFinancial); + +?> + + 0) { + + ?> + +

    Financial Information

    + 0) { + ?> +

    Company / Firm Name : " . $iterateFinance['company_name']; ?>

    +

    No of Years of Financial Statements provided : " . $iterateFinance['years_data_provided']; ?>

    +

    Snapshot of Financials as per Books of Account Provided : "; ?>

    + + + + + + " . "FY " . $bfRow['financial_year'] . ""; + } ?> + + + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_sales_revenue']) . ''; + } ?> + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_profit']) . ''; + } else { + echo ''; + } + } ?> + + + + ' . $bfRow['financial_margin_of_profit'] . ' %'; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } ?> + + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + +
    Particulars
    Sales / Revenue (Rs)
    Net Profit / (Net Loss) (Rs) (' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_loss']) . ')
    Net Profit or (Net Loss) to Sales % (' . $bfRow['financial_margin_of_loss'] . ' %)
    % () in Sales over PY' . $bfRow['sale_variation'] . ' %(' . $bfRow['sale_variation'] . ' %)NA
    % () in Net Profit over PY' . $bfRow['profit_variation'] . ' %(' . $bfRow['profit_variation'] . ')NA
    % () in Net Profit % over PY' . $bfRow['financial_profit_to_sale_variation'] . ' %(' . $bfRow['financial_profit_to_sale_variation'] . ' %)NA
    +

    ' . $comments_on_financials . '

    '; + } + } + //else{ echo "

    Financial statements not provided by Loan Applicants to PD officer.

    ";} + ?> + + + +

    + 0) { + //print_r($iterateFinance['customer_statements']); + + ?> + + + +

    As per Applicant(s), the Financials are as below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    As per Loan Applicant(s), the Financials are as below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + + As per Loan Applicant(s) met,' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($iterateFinance['estimate_posmachine_or_cc_annual_sales']) . ' as Annual sales through credit cards / POS machines.

    '; + }; + } ?> + As per Loan Applicant(s) met, the financials figures were not provided.

    "; } + + // ####################### THIS SECTION ONLY FOR CLIX HOUSING FINANCE LENDER ##########################--> + + if (isset($iterateFinance['turnover_statements'])) { + foreach ($iterateFinance['turnover_statements'] as $turnover) { + if (!strcasecmp($turnover['estimate_net_margin_availablity'], 'yes')) { + ?> +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + Turnover and Netprofit was ' . $iterateFinance['how_turnover_validated']; + } + ?> + + + + + + Validation of Customer Declared Financials :

    '; + // echo 'Kuccha Record Seen (Yes/No) : ';echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : 'No Kuccha Records made available to PD officer and therefore validation of customer declared financials was not possible.'; + if ($financial_kuccha_info['kuccha_records_shown'] == 'yes') { + echo '

    Validation of Customer Declared Financials :

    '; + echo 'Kuccha Record Seen (Yes/No) : '; + echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : ''; + echo '

    Photograph of Kuchha Bills Shared (Yes/No) : ' . ($financial_kuccha_info['kuccha_bill_allowed'] == 'yes' ? 'Yes, enclosed with report' : 'No'); + + // echo '

    Number of Kuccha Bills and Values therein, justifies the customer declared turnover (Yes / No): '. ( $financial_kuccha_info['customer_declared_turnover'] == 'yes' ? 'Yes': 'No'); + } + } + + //only for Indusind Lender + if (count($current_business_info)) { + echo '

    Current Business :

    '; + echo 'Approximate Total Business / Sales Done for Current FY as on date is ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($current_business_info['tot_business_FY']); + echo $current_business_info['remarks_tot_business_FY'] != "" ? ' ( ' . $current_business_info['remarks_tot_business_FY'] . ' ) ' : ''; + echo '
    Orders in Hand to be executed in Current FY : ' . $current_business_info['orders_hand_FY']; + } + ?> + + + + + + + + + + + + $facility) { + echo ''; + } ?> + +
    S.NoParticularsDetails
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    S.NoParticularsDays
    1Debtor Days
    2Creditor Days
    3Stock Days
    + + + +

    + + + + + + + + + + + $facility) { + + echo ''; + } ?> + +
    S.NoFacility TypeFacility Details
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + The Loan Applicants have not availed any " . $business_fin_sub_title2 . " from any financial institution.

    "; + } + } + ?> + + ' . $financial_remarks . '

    '; + } + } else { ?> +

    Financial information is not available.

    + + + + + + 0) { + $getEachValues['is_od_cc'] = null; + foreach ($businessBankRow['banking_details'] as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $getEachValues['is_od_cc'] = true; + } + } + $getEachValues['bankDetails'] = BANKINGFORM::getBusinessBankingDetails($businessBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getEachValues); + } + } + + ?> + + Business Banking:'; + if ($is_business_banking_available != null) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant(s), Applicant does not have any business account.

    '; + } + + if ($business_banking_common_remarks != "") { + echo '

    ' . $business_banking_common_remarks . '

    '; + } + } // end of busienss bankDetails available in this currrent index + ?> + + + + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $newBankingResult = array_merge($newBankingResult, $getBuinessEachValues); + } + } + // if(isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) + // { + // if(count($individualBankRow['banking_details'])>0){ + // $getIndividualEachValues=BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'],$pd_master_details[0]['pd_id']); + // $newBankingResult = array_merge($newBankingResult,$getIndividualEachValues); + // } + // } + } + foreach ($newBankingResult as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $is_od_cc = true; + } + } + if (count($newBankingResult) > 0) { + $filteredBankingResult = array(); + $b = 0; + for ($a = 0; $a <= count($newBankingResult); $a++) { + if ($newBankingResult[$a]['account_name'] == $fetchRow['company_details']['company_name'] && $newBankingResult[$a]['str_flag'] == "buiness-company") { + $filteredBankingResult[$b] = $newBankingResult[$a]; + $b++; + } + } + } //forloop ends here. + ?> + Business Banking:'; + if (count($filteredBankingResult) > 0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant, he does not have any business account.

    '; + } + } + ?> + + + 1Product / Service '; + $client_second_row = '2Contact Person '; + $client_third_row = '3Mobile Number '; + $client_fourth_row = '4Landline No'; + $client_fifth_row = '5Payment Terms'; + $client_sixth_row = '6Payment Mode'; + $client_seventh_row = '7No of Days Credit'; + + + // this is for manufacturing + if (array_key_exists('manufacturing_details', $clientRow)) { + + $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] ? $done_on_credit['manufacturing prodcuts'] = $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['manufacturing_details'] as $manuRow) { + + if (isset($manuRow['main_raw_materials'])) { + + //$to_no_of_clients += count($manuRow['main_raw_materials']); + + foreach ($manuRow['main_raw_materials'] as $main_raw_material_key => $main_raw_material) { + + if ($main_raw_material['manufacturing_product_name'] != "" || $main_raw_material['manufacturing_product_name'] != null) { + $to_no_of_clients++; + } + //print_r($main_raw_material); + $client_first_row .= '' . $main_raw_material['manufacturing_product_name'] . ''; + + $client_second_row .= isset($main_raw_material['person_title_name_master']) ? '' . $main_raw_material['person_title_name_master'] . ' ' : ''; + $client_second_row .= $main_raw_material['manufacturing_contact_person_name']; + + $client_second_row .= isset($main_raw_material['person_designation']) && $main_raw_material['person_designation'] == 1 ? ' ' . $main_raw_material['other_person_designation'] : ' '; // + + $client_second_row .= isset($main_raw_material['person_designation_master']) && $main_raw_material['person_designation'] != 1 ? $main_raw_material['person_designation_master'] : ''; + + $client_second_row .= ' ' . $main_raw_material['manufacturing_client_name'] . ''; + + $client_third_row .= '' . ($main_raw_material['manufacturing_contact_person_mobile_number'] ? $main_raw_material['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $main_raw_material['person_stdcode'] && $main_raw_material['person_landline'] ? '' . $main_raw_material['person_stdcode'] . ' ' . $main_raw_material['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($main_raw_material['manufacturing_payment_type_master']) && $main_raw_material['manufacturing_payment_type_master'] ? '' . $main_raw_material['manufacturing_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $main_raw_material['manufacturing_payment_mode'] ? '' . $main_raw_material['manufacturing_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $main_raw_material['manufacturing_credit_days_from'] && $main_raw_material['manufacturing_credit_days_to'] ? '' . $main_raw_material['manufacturing_credit_days_from'] . ' to ' . $main_raw_material['manufacturing_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + + // this is for trading + if (array_key_exists('trade_details', $clientRow)) { + $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] ? $done_on_credit['trading products'] = $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] : ''; + foreach ($clientRow['trade_details'] as $tradeRow) { + + if (isset($tradeRow['trading_products'])) { + + //$to_no_of_clients += count($tradeRow['trading_products']); + + foreach ($tradeRow['trading_products'] as $trading_product_key => $trading_product) { + + if ($trading_product['trade_product_name'] != "" || $trading_product['trade_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $trading_product['trade_product_name'] . ''; + + $client_second_row .= isset($trading_product['person_title_name_master']) ? '' . $trading_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $trading_product['trade_product_contact_person_name']; + + $client_second_row .= isset($trading_product['person_designation']) && $trading_product['person_designation'] == 1 ? ' ' . $trading_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($trading_product['person_designation_master']) & $trading_product['person_designation'] != 1 ? $trading_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $trading_product['trade_client_name'] . ''; + + $client_third_row .= '' . ($trading_product['trade_product_contact_person_mobile_number'] ? $trading_product['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $trading_product['person_stdcode'] && $trading_product['person_landline'] ? '' . $trading_product['person_stdcode'] . ' ' . $trading_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($trading_product['trade_product_payment_type_master']) ? '' . $trading_product['trade_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $trading_product['trade_product_payment_mode'] ? '' . $trading_product['trade_product_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $trading_product['trade_product_credit_days_from'] && $trading_product['trade_product_credit_days_to'] ? '' . $trading_product['trade_product_credit_days_from'] . ' to ' . $trading_product['trade_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + //this is for service + if (array_key_exists('service_provider_details', $clientRow)) { + + $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] ? $done_on_credit['service providing'] = $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['service_provider_details'] as $serviceRow) { + + if (isset($serviceRow['service_products'])) { + + //$to_no_of_clients += count($serviceRow['service_products']); + foreach ($serviceRow['service_products'] as $service_product_key => $service_product) { + + if ($service_product['service_provider_product_name'] != "" || $service_product['service_provider_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $service_product['service_provider_product_name'] . ''; + + $client_second_row .= isset($service_product['person_title_name_master']) ? '' . $service_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $service_product['service_provider_product_contact_person_name']; + + $client_second_row .= isset($service_product['person_designation']) && $service_product['person_designation'] == 1 ? ' ' . $service_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($service_product['person_designation_master']) && $service_product['person_designation'] != 1 ? $service_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $service_product['service_provider_client_name'] . ''; + + $client_third_row .= '' . ($service_product['service_provider_product_contact_person_mobile_number'] ? $service_product['service_provider_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $service_product['person_stdcode'] && $service_product['person_landline'] ? '' . $service_product['person_stdcode'] . ' ' . $service_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= $service_product['service_provider_product_payment_type_master'] ? '' . $service_product['service_provider_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $service_product['service_provider_product_payment_mode'] ? '' . $service_product['service_provider_product_payment_mode'] . '' : 'NA'; + + $client_seventh_row .= $service_product['service_provider_product_credit_days_from'] && $service_product['service_provider_product_credit_days_to'] ? '' . $service_product['service_provider_product_credit_days_from'] . ' to ' . $service_product['service_provider_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + } + + + + $client_first_row .= ''; + $client_second_row .= ''; + $client_third_row .= ''; + $client_fourth_row .= ''; + $client_fifth_row .= ''; + $client_sixth_row .= ''; + $client_seventh_row .= ''; + //echo $client_third_row; + ?> + + Client Details'; + if ($is_client_details_available != null) { + + + + + ?> + + + + + + + + Client $i"; + } ?> + + + + + + + + + + + + + + + + +
    Sr.NoParticulars
    + $value) { + if (count($temp)) { + foreach ($temp as $tk => $tvalue) { + $value == $tvalue ? $all_same = true : $all_same = false; + array_push($temp, $value); + } + } else { + array_push($temp, $value); + } + } + + if ($all_same || count($done_on_credit) == 1) { + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $vals[0] . "% is done on credit.

    "; + } else { + $activities = ''; + foreach ($done_on_credit as $dkey => $dvalue) { + $activities .= $dkey . ' ' . $dvalue . '%, '; + } + $activities = substr_replace($activities, ' ', -2); + $activities = substr_replace($activities, ' and ', strripos($activities, ','), 2); + + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $activities . "are done on credit.

    "; + } + } + + + //CLient Photo Section + // $client_photo_count = $pd_images[2]; + // $client_img_row_count = ceil(count($client_photo_count) / 3); + + // if(count($client_photo_count)){ + // // echo '
    '; + // // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // // echo '
    '; + // echo ''; + + // $client_from_index_increment = 0; + // for($img_row = 1; $img_row <= $client_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $client_from_index_increment; + // $to = ($from + 2); + // for($client_photo_iter = $from; $client_photo_iter <= $to;$client_photo_iter++) + // { + + // if(isset($client_photo_count[$client_photo_iter]) &&$client_photo_count[$client_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $client_from_index_increment = $client_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // } + ?> + ' . $client_form_remarks . '

    '; + } // ENd of client info available in this current index + ?> + + + + + + + 1Item Purchased '; + $supplier_second_row = '2Contact Person '; + $supplier_third_row = '3Mobile Number '; + $supplier_fourth_row = '4Landline No'; + $supplier_fifth_row = '5Payment Terms'; + $supplier_sixth_row = '6Payment Mode'; + $supplier_seventh_row = '7No of Days Credit'; + + if (isset($pd_processed_forms[1][$business_count])) { + + $supplier_details = $pd_processed_forms[1][$business_count]; + $supplierRow = json_decode($supplier_details['processed_json'], true); + //print_r($supplierRow); + $supplier_form_remarks = (isset($supplierRow['supplier_info_form_remark']) ? $supplierRow['supplier_info_form_remark'] : ''); + + if (isset($supplierRow['supplier_info_available']) && $supplierRow['supplier_info_available'] == 1) { + $is_supplier_details_avaialable = 1; + $company_name_for_supplier_form_dispaly = MYUTIL::findCompanyName($all_company_details, $supplierRow['company_id'], 1); + //$supplierResult['company_name'] = $company_name; + $total_no_of_suppliers = 0; + $total_payments_percent_on_credit_for_supplier = 0; + + + foreach ($supplierRow['manufacturing_details'] as $manuRow) { + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit']) ? $supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : 0; + + if (isset($manuRow['main_raw_materials'])) { + + + foreach ($manuRow['main_raw_materials'] as $rawkey => $raw) { + + if ($raw['manufacturing_raw_material_name'] != "" || $raw['manufacturing_raw_material_name'] != null) { + $total_no_of_suppliers++; + } + $supplier_first_row .= '' . $raw['manufacturing_raw_material_name'] . ''; + + $supplier_second_row .= isset($raw['person_title_name_master']) ? '' . $raw['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $raw['manufacturing_contact_person_name']; + + $supplier_second_row .= isset($raw['person_designation']) && $raw['person_designation'] == 1 ? ' ' . $raw['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($raw['person_designation_master']) && $raw['person_designation'] != 1 ? $raw['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $raw['manufacturing_supplier_name'] . ''; + + $supplier_third_row .= '' . ($raw['manufacturing_contact_person_mobile_number'] ? $raw['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $raw['person_stdcode'] && $raw['person_landline'] ? '' . $raw['person_stdcode'] . ' ' . $raw['person_landline'] . '' : '' . 'Not Provided' . ''; + + + + $supplier_fifth_row .= $raw['manufacturing_payment_type_master'] ? '' . $raw['manufacturing_payment_type_master'] . '' : 'NA'; + + + + $supplier_sixth_row .= $raw['manufacturing_payment_mode'] ? '' . $raw['manufacturing_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $raw['manufacturing_credit_days_from'] && $raw['manufacturing_credit_days_to'] ? '' . $raw['manufacturing_credit_days_from'] . ' to ' . $raw['manufacturing_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + } + } + } + // this is for trading + //print_r($supplierRow['trade_details'][0]['trading_products']); + if (isset($supplierRow['trade_details'][0]['trading_products']) && count($supplierRow['trade_details'][0]['trading_products'])) { + $total_payments_percent_on_credit_for_supplier += $supplierRow['trade_details'][0]['trading_products_total_payments_percent_on_credit']; + foreach ($supplierRow['trade_details'][0]['trading_products'] as $tradeRow) { + + if ($tradeRow['trade_product_name'] != "" || $tradeRow['trade_product_name'] != null) { + $total_no_of_suppliers++; + } + + + + + + + $supplier_first_row .= '' . $tradeRow['trade_product_name'] . ''; + $supplier_second_row .= isset($tradeRow['person_title_name_master']) ? '' . $tradeRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $tradeRow['trade_product_contact_person_name']; + + $supplier_second_row .= isset($tradeRow['person_designation']) && $tradeRow['person_designation'] == 1 ? ' ' . $tradeRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($tradeRow['person_designation_master']) && $tradeRow['person_designation'] != 1 ? $tradeRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $tradeRow['trade_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($tradeRow['trade_product_contact_person_mobile_number'] ? $tradeRow['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $tradeRow['person_stdcode'] && $tradeRow['person_landline'] ? '' . $tradeRow['person_stdcode'] . ' ' . $tradeRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + + $supplier_fifth_row .= isset($tradeRow['trade_product_payment_type_master']) ? '' . $tradeRow['trade_product_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $tradeRow['trade_product_payment_mode'] ? '' . $tradeRow['trade_product_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $tradeRow['trade_product_credit_days_from'] && $tradeRow['trade_product_credit_days_to'] ? '' . $tradeRow['trade_product_credit_days_from'] . ' to ' . $tradeRow['trade_product_credit_days_to'] . ' days' : 'NA'; + ///array_push($supplierResult,$temp); + + //} + //} + + } + } + + if (isset($supplierRow['servicing_details'][0]['service_providers']) && count($supplierRow['servicing_details'][0]['service_providers'])) { + + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + //echo isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + + foreach ($supplierRow['servicing_details'][0]['service_providers'] as $serviceRow) { + + + if ($serviceRow['service_provider_name'] != "" || $serviceRow['service_provider_name'] != null) { + $total_no_of_suppliers++; + } + + $supplier_first_row .= '' . $serviceRow['service_provider_name'] . ''; + + + $supplier_second_row .= isset($serviceRow['person_title_name_master']) ? '' . $serviceRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $serviceRow['service_provider_contact_person_name']; + + $supplier_second_row .= isset($serviceRow['person_designation']) && $serviceRow['person_designation'] == 1 ? ' ' . $serviceRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($serviceRow['person_designation_master']) && $serviceRow['person_designation'] != 1 ? $serviceRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $serviceRow['service_provider_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($serviceRow['service_provider_contact_person_mobile_number'] ? $serviceRow['service_provider_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $supplier_fourth_row .= $serviceRow['person_stdcode'] && $serviceRow['person_landline'] ? '' . $serviceRow['person_stdcode'] . ' ' . $serviceRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + $supplier_fifth_row .= isset($serviceRow['service_provider_payment_type_master']) ? '' . $serviceRow['service_provider_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $serviceRow['service_provider_payment_mode'] ? '' . $serviceRow['service_provider_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $serviceRow['service_provider_credit_days_from'] && $serviceRow['service_provider_credit_days_to'] ? '' . $serviceRow['service_provider_credit_days_from'] . ' to ' . $serviceRow['service_provider_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + //} + } //} + + } + + $supplier_first_row .= ''; + $supplier_second_row .= ''; + $supplier_third_row .= ''; + $supplier_fourth_row .= ''; + $supplier_fifth_row .= ''; + $supplier_sixth_row .= ''; + $supplier_seventh_row .= ''; + } + // echo "dsfnsdkfnj**********"; + // print_r($supplierResult);// + + + + echo '

    Supplier Details

    '; + if ($is_supplier_details_avaialable != null) { + ?> + + + $fetchRow){ + //echo '
    Supplier '.($k+1).':

    '; + ?> + + + + + + + + Supplier $i"; + } ?> + + + + + + + +
    Sr.NoParticulars
    + '; + // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // echo '
    '; + // echo ''; + + // $supplier_from_index_increment = 0; + // for($img_row = 1; $img_row <= $supplier_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $supplier_from_index_increment; + // $to = ($from + 2); + // for($supplier_photo_iter = $from; $supplier_photo_iter <= $to;$supplier_photo_iter++) + // { + + // if(isset($supplier_photo_count[$supplier_photo_iter]) &&$supplier_photo_count[$supplier_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $supplier_from_index_increment = $supplier_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // }*/ + + + //End of Supplier Photo section + + //}//End of supplier foreach + ?> + + 0) { + //$company_name = MYUTIL::findCompanyName($all_company_details,$supplierRow['company_id'],1); + echo "

    Out of total purchases done by " . $company_name_for_supplier_form_dispaly . ", " . $total_payments_percent_on_credit_for_supplier . " % is done on credit.

    "; //in advance rest on delivery. + } + } + echo '

    ' . $supplier_form_remarks . '

    '; + } // End of supplier info avilable in this current index + ?> + + + + + + 0 || (is_array($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) > 0)) { + + $is_raw_materials_sufficient_enough = $stockRow['manufacturing_details'][0]['is_sufficiant_raw']; + $is_raw_materials_sufficient_enough_remarks = $stockRow['manufacturing_details'][0]['rawmaterial_remarks']; + $bindStockResult["manufacturing"] = Stockform::getStockManufacturingDetails($stockRow['manufacturing_details'][0]['manufacturing_raw_materials'], $stockRow['manufacturing_details'][0]['manufacturing_finished_goods']); + //print_r($bindStockResult["manufacturing"]); + } else { + $bindStockResult["manufacturing"] = array(); + } + // this is for stock retail details + if (count($stockRow['retail_details'][0]['retail_traded_goods']) > 0) { + $bindStockResult["retail"] = Stockform::getStockRetailDetails($stockRow['retail_details'][0]['retail_traded_goods']); + } else { + $bindStockResult["retail"] = array(); + } + // this is for stock whole sale details + if (count($stockRow['trade_details'][0]['trading_traded_goods']) > 0) { + $bindStockResult["wholesale"] = Stockform::getStockWholesaleDetails($stockRow['trade_details'][0]['trading_traded_goods']); + } else { + $bindStockResult["wholesale"] = array(); + } + + // this is for stock service details + //print_r($stockRow['servicing_details']); + if (count($stockRow['servicing_details'][0]['service_provider']) > 0) { + $bindStockResult["service_stocks"] = Stockform::getStockServiceDetails($stockRow['servicing_details'][0]['service_provider']); + } else { + $bindStockResult["service_stocks"] = array(); + } + //print_r($bindStockResult);die(); + count($bindStockResult['wholesale']) || count($bindStockResult['retail']) || count($bindStockResult['manufacturing']) || count($bindStockResult["service_stocks"]) ? array_push($stockResult, $bindStockResult) : array(); + //echo "**********************"; + //print_r($stockResult);die(); + ?> + +

    Stock Details

    + +

    + + + + + + + + + + + + + 0) { + foreach ($getstRow['manufacturing'] as $pstRow) { + if ($pstRow['name']) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Sr.NoType of StockStock ItemStock Value (Rs)Stock Quantity
    + Considering the size of operations, the stock of finished goods maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_stock_sufficient_enough,'no')){ + // echo '

    Considering the size of operations, the stock of finished goods maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_stock_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_stock_sufficient_enough,'not applicable')) + // { + // echo '

    Finished goods Stock not required to be maintained.

    '; + // } + + // if(!strcasecmp($is_raw_materials_sufficient_enough,'yes')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_raw_materials_sufficient_enough,'no')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_raw_materials_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_raw_materials_sufficient_enough,'not applicable')) + // { + // echo '

    Raw material Stock not required to be maintained.

    '; + // } + + // //serivce + // if(!strcasecmp($is_sufficiant_service_goods,'yes')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_sufficiant_service_goods,'no')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $service_goods_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_sufficiant_service_goods,'not applicable')) + // { + // echo '

    Stock not required to be maintained.

    '; + // } + //echo '

    '.$stock_remarks.'

    '; + + + $stock_photo_count = array_filter($pd_images[11], function ($d) use ($business_count) { + if ($d['company_id'] == ($business_count + 1)) { + return 1; + } else { + return 0; + } + }); + //echo 'stock_photo_count - ' . count($stock_photo_count); + $stock_img_row_count = ceil(count($stock_photo_count) / 3); + if (count($stock_photo_count)) { + echo '
    '; + echo '

    Stock Photograph`s :

    '; + echo '
    '; + echo ''; + + for ($img_row = 0; $img_row < $stock_img_row_count; $img_row++) { + // if($img_row > 0) { break; } + echo ''; + $from = $img_row == 0 ? $img_row : ($img_row + 2); + $to = ($from + 2); + for ($stock_photo_iter = $from; $stock_photo_iter <= $to; $stock_photo_iter++) { + + if (isset($stock_photo_count[$stock_photo_iter]) && $stock_photo_count[$stock_photo_iter]['company_id'] == ($business_count + 1)) { + echo ''; + //unset($stock_photo_count[$stock_photo_iter]); + } + } + //echo "


    "; + echo ''; + } + //echo ''; + echo '
    '; + echo ''; + echo '
    '; + } + // + ?> + + + ' . $stock_form_remarks . '

    '; + //else { + ?> + + + + + + + + +

    Future Plan and Business Environment

    + + + + + + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + + ?> + +
    ParticularsDetails
    USP of the business (How applicant’s business is different from others in the business)' . $future_plan_business_environment['usp_of_the_business'] . '
    Future plan for business expansion' . $future_plan_business_environment['future_plans_for_business_expansion'] . '
    Impact of GST on business' . $future_plan_business_environment['impact_of_gst_on_the_business'] . '
    Key competitors in the business' . $future_plan_business_environment['key_competitors'] . '
    Succession Plan for business' . $future_plan_business_environment['succession_plan'] . '
    Brief of other group concerns/ Business run by the applicant' . $future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'] . '
    + '; + echo '

    ' . $future_plan_business_environment['remarks'] . '

    '; + } + } + + ?> + + + + + + Assessed Income - " . MYUTIL::findCompanyName($all_company_details, ($business_count + 1), 1) . ""; + if (isset($ai_core_details) && count($ai_summary_details_processed)) { + echo '

    ' . $order_dipaly_array[0] . ') Financial Snapshot

    '; + echo ''; + echo ''; + echo $ai_summary_details_processed['ai_table_header_row']; + echo ''; + echo ''; + echo $ai_summary_details_processed['sale_revenue_row']; + echo $ai_summary_details_processed['purchase_row']; + echo $ai_summary_details_processed['gross_profit_loss_row']; + echo $ai_summary_details_processed['gross_profit_loss_per_row']; + echo $ai_summary_details_processed['business_expense_row']; + echo $ai_summary_details_processed['net_profit_loss_row']; + echo $ai_summary_details_processed['house_hold_expense_row']; + echo $ai_summary_details_processed['disposable_income_row']; + echo $ai_summary_details_processed['net_margin_row']; + + echo ''; + echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + array_shift($order_dipaly_array); + } + + + echo '

    '; + //die(); + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '

    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // } + // array_shift($order_dipaly_array); + // echo '

    Detail Available on Annexure A'; + // } + + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '
    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // echo '
    '; + // $row_count = ceil(count($sale_month_wise['months']) / 5); + // //print_r(($sale_month_wise['months'])); + // // echo $row_count; + // //die(); + // echo ''; + + // for($i = 0; $i <= $row_count; $i++) + // { + // $from = $i== 0 ? $i : ($i + 3); + // $to = ($from + 3); + // echo ''; + // for($j = $from ; $j <= $to ;$j++) + // { + // //$sale_month_wise['months'] as $sale_month_data + // //echo ''; + // if(isset($sale_month_wise['months'][$j])) + // { + // echo ''; + // } + // } + // echo ''; + // } + // echo '
    '; + // echo ''; + // echo ''; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // }else if($sale_month_wise['months'][$j]['sales_type'] == 2) + // { + // echo ''; + // } + // echo ''; + + // echo ''; + + // foreach($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) + // { + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($m_key == 20)break; + // else if($sale_month_wise['sales_type'] == 2) + // { + // echo ''; + // } + // } + // echo ''; + + // echo '
    '.$sale_month_wise['months'][$j]['month_to_dispaly'].'
    Date Value
    Frequncy Value
    '.$month['date'] .' '.$month['value'] .'
    '.$month['frequency_name'] .' '.$month['frequency_value'] .'
    '; + // echo '
    '; + // echo '
    '; + + // //} + // } + + // array_shift($order_dipaly_array); + // } + + + $GLOBALS['is_kuccha_records_available'] = null; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + echo '

    ' . $order_dipaly_array[0] . ') Sales Itemwise :

    '; + echo ''; + echo ''; + echo $ai_core_details_processed['sales_calculated_by_itemwise_header']; + echo ''; + echo ''; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sid) { + //print_r($sid); + if ($sid['sales_type'] == 3) { + $GLOBALS['is_kuccha_records_available'] = true; + } + $rate_per_unit = ($sid['rate_per_unit'] != 0 && $sid['rate_per_unit'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['rate_per_unit']) : '-'); + echo ''; + echo ''; + if (isset($sid['margin_per'])) { + echo ''; + } + // if(isset($sid['margin_per_uom'])){echo ''; } + if (isset($sid['margin_final_value'])) { + echo ''; + } + + echo ''; + } + echo ''; + echo '
    ' . ($sid['other_sales_item'] != '' ? $sid['other_sales_item'] : $sid['sale_item']) . '' . $sid['sales_qty'] . '' . $sid['uom'] . '' . $rate_per_unit . '' . $sid['frequency'] . '' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['annual_sale_value']) . ($sid['sales_type'] == 3 ? ' *' : '') . '' . ($sid['margin_per'] != 0 ? $sid['margin_per'] : '-') . ''.($sid['margin_per_uom'] != 0? $sid['margin_per_uom'] : '-').'' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['margin_final_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if ($GLOBALS['is_kuccha_records_available']) { + echo '
    * Assessed From Kuchha Records, Details Available in Annexure A'; + } + + + if (isset($ai_core_details) && count($ai_core_details['sales_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Sales Declared By Customer

    '; + + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) + // { + // echo '

    As per person met, the following Purchase details were shared:

    '; + // } + // else if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + // } + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ) declared as annual sale value.'; + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + $str .= '
    and ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' )' . '( ' . $ai_core_details['sales_declared_by_customer'][0]['margin_per'] . '% sales declared ) as net margin amount.'; + } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) { + echo '

    As per person met, the following Purchase details were shared:

    '; + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + } + + echo '
    '; + if (isset($ai_core_details) && count($ai_core_details['purchase_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Purchase Declared By Customer

    '; + + + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ) declared as annual purchase value.'; + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // $str .= '
    and '.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']).' ( '.MYUTIL::numtowords( $ai_core_details['sales_declared_by_customer'][0]['margin_value']).' )'.'( '.$ai_core_details['sales_declared_by_customer'][0]['margin_per'].'% sales declared ) as net margin amount.'; + // } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 1) { + echo '

    ' . $order_dipaly_array[0] . ') Itemwise Purchase Details :

    '; + + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($ai_core_details_processed['purchase_to_display'] as $dat) { + $rate = $dat['rate'] != 0 && $dat['rate'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['rate']) : '-'; + echo ''; + } + echo ''; + + echo '
    Raw Material/Trading Item Purchase Quantity UOM Rate/Unit of Purchase Frequency Annual Purchase(Rs)
    ' . $dat['material_name'] . ' ' . $dat['qty'] . ' ' . $dat['uom'] . ' ' . $rate . ' ' . $dat['frequency'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['annual_value']) . '
    '; + array_shift($order_dipaly_array); + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 2) { + echo '

    ' . $order_dipaly_array[0] . ') Billwise Purchase Details :

    '; + foreach ($ai_core_details_processed['purchase_to_display'] as $billwise) { + echo '
    '; + echo 'Item name : ' . $billwise['item_name'] . '
    '; + echo '' . $billwise['month_count'] . ' month(s) purchase value : ' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value']) . ' Annual Purchase value:' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value'] * (12 / $billwise['month_count'])) . ''; + echo '
    '; + foreach ($billwise['months'] as $month_data) { + //echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($month_data['month_data'] as $month) { + echo ''; + } + echo ''; + + echo '
    ' . $month_data['month_to_dispaly'] . '
    Date Value
    ' . $month['date'] . ' ' . $month['value'] . '
    '; + //echo '
    '; + } + echo '
    '; + } + array_shift($order_dipaly_array); + } + } + + // + if (isset($ai_core_details) && count($ai_core_details['business_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Business Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['business_expenses_to_diaplay'] as $b_exp) { + if ($b_exp['expense_value'] != 0) { + echo ''; + } + } + echo ''; + echo '
    Business Expense Amount Frequency Annual Expenses
    ' . $b_exp['expense_item'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['expense_value']) . ' ' . $b_exp['frequency_name'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['annual_expenses_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if (isset($ai_core_details) && count($ai_core_details['house_hold_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Household Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['household_expenses_to_diaplay'] as $h_exp) { + echo ''; + } + echo ''; + echo '
    Expense Particulars Amount (Rs) Frequency Annual Expenses(Rs)
    ' . $h_exp['expense_item'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['expense_value']) . ' ' . $h_exp['frequency_name'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['annual_expense_value']) . '
    '; + array_shift($order_dipaly_array); + } + + + // if(isset($ai_core_details) && count($ai_summary_details_processed)) + // { + // echo '

    The Summary of Income :

    '; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['ai_table_header_row']; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['sale_revenue_row']; + // echo $ai_summary_details_processed['purchase_row']; + // echo $ai_summary_details_processed['gross_profit_loss_row']; + // echo $ai_summary_details_processed['business_expense_row']; + // echo $ai_summary_details_processed['net_profit_loss_row']; + // echo $ai_summary_details_processed['house_hold_expense_row']; + // echo $ai_summary_details_processed['disposable_income_row']; + // echo $ai_summary_details_processed['net_margin_row']; + + // echo ''; + // echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + // } + // echo "
    "; + // + + ?> + + + + + + + + + + $oaRow) { + $otherAssetRow = json_decode($oaRow['processed_json'], true); + //print_r($otherAssetRow);die(); + $other_assest_common_remrks = $otherAssetRow['assets_form_remark']; + if (isset($otherAssetRow['asset_info_available']) && $otherAssetRow['asset_info_available'] == 1) { + $is_personal_info_available = 1; + + if (count($otherAssetRow['assets_details']) > 0) { + $otherAssetResult = ASSETSFORM::getOthersAssetsDetails($otherAssetRow['assets_details'], $pd_master_details[0]['pd_id']); + + //print_r($otherAssetResult); + } + } +} +?> + +

    Personal Assets

    + + + + + + + + + + + + + + + $paRow) { + ?> + + + + + + + + + + + +
    Sr.NoAsset TypeAsset DescriptionAsset Owned ByApprox Market Value(Rs)Age of the Assest Again Assest
    ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : (($paRow['approximate_market_value'] != '' && $paRow['approximate_market_value'] != 0 ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : 'Not Provided')); ?>
    + +

    As per Loan applicant, he does not have any other assets.

    +' . $other_assest_common_remrks . '

    '; +} + +?> + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + $ind_banking_common_remarks = $individualBankRow['banking_form_remark']; + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + // $is_personal_banking_available = 1; + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getBuinessEachValues); + } + } + if (isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) { + if (count($individualBankRow['banking_details']) > 0) { + $getIndividualEachValues = BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getIndividualEachValues); + } + } +} +if (count($bankingResult) > 0) { + $filteredPersonalBankingResult = array(); + $x = 0; + for ($y = 0; $y < count($bankingResult); $y++) { + if ($bankingResult[$y]['str_flag'] !== "buiness-company") { + $filteredPersonalBankingResult[$x] = $bankingResult[$y]; + $x++; + } + if ($bankingResult[$y]['same_ac_used_for'] == "Business") { + $stmt_flag++; + } + } +} + + +?> +

    Personal Banking Details:

    + 0) { ?> +

    Below bank account details were shared :

    + + + + + + + + + + + + + + + $bdRow) { + ?> + + + + + + + + + + + + +
    Sr.NoAccount Holder's NameBank NameAccount TypeOD / CC LimitVintage
    + 0) { + echo '

    The personal banking is done through same account used for business banking

    '; +} +if ($ind_banking_common_remarks != '') { + echo '

    ' . $ind_banking_common_remarks . '

    '; +} +if (count($filteredPersonalBankingResult) == 0) { + echo '

    As per loan applicant, he does not have any personal account

    '; +} ?> + + + + + + + $iRow) { + $otherIcomeRow = json_decode($iRow['processed_json'], true); + $other_source_income_common_remarks = $otherIcomeRow['otherincome_remarks']; + //print_r($otherIcomeRow);die(); + + if (strtoupper($otherIcomeRow['other_income']) == 'YES' && count($otherIcomeRow['income_details']) > 0) { + $is_other_income_available = 1; + $otherIncomeResult = OTHERINCOMEFORM::getIncomeDetails($otherIcomeRow['income_details'], $pd_master_details[0]['pd_id']); + } +} +?> +
    +

    Other Sources of Income of Individual Applicants:

    + + + + + + + + + + + + + + $oiRow) { + ?> + + + + + + + + + +
    Sr.NoIncome SourceEarned byAmount(Rs)
    (Details Available in Annexure B)'; + $GLOBALS['is_rental_available'] = 1; + } ?>
    + +

    As per the loan applicants, they do not have any other source of Income.

    +' . $other_source_income_common_remarks . '

    '; +} + +?> + + + + + $fRow) { + $familyRow = json_decode($fRow['processed_json'], true); + //print_r($familyRow);die(); + $other_family_form_common_remarks = $familyRow['family_details_form_remark']; + if (array_key_exists('family_details', $familyRow) && count($familyRow['family_details']) > 0) { + $familyResult = OTHERFAMILYFORM::getFamilyDetails($familyRow['family_details'], $pd_master_details[0]['pd_id']); + } +} +?> + +

    Family Information:

    + 0) { + //print_r($familyResult); +?> + + + $fmValue) { ?> + + ' . $fmValue['selected_person_title'] . $fmValue['selected_person'] . 'Family Information - Select person for capturing family details, who is an applicant in the case, resides at ' . $fmValue['residency_address'] . 'Family Information - Residence Address of Select person .'; + + $residence_text = 'This is a ' . $fmValue['residence_ownership'] . ' Family Information - Ownership of Residence residence, where the applicant has been staying for ' . $fmValue['residence_No_of_years'] . 'Family Information - No of Yrs in current residence .'; + $residence_text .= (!strcasecmp($fmValue['residence_ownership'], 'rented')) ? ' The rent paid ' . $rupee_symbol . ' ' . $fmValue['rent'] . ' per month.' : ''; + + echo '

    ' . $intro_text . '

    '; + echo '

    ' . $residence_text . '

    '; + + ?> + + +

    The table below provides details of other family members of

    + + + + + + + + + + + + + $fmRow) { + ?> + + + + + + + + + + +
    Sr.NoNameRelationAgeEarning StatusOccupation Details
    + ' . $text . '

    '; + } + } ?> + +

    Other Family Members is not available.

    +' . $other_family_form_common_remarks . '

    '; +} + +?> + + + + + + $elRow) { + $otherLoanRow = json_decode($elRow['processed_json'], true); + $existing_loan_form_common_remarks = $otherLoanRow['currentloan_remarks']; + $is_all_loan_details_availble = 'yes'; + $out_standing_loan_info = array(); + if (array_key_exists('loan_info_available', $otherLoanRow)) { + $is_all_loan_details_availble = $otherLoanRow['loan_info_available']; + } + $total_no_of_data = 0; + if (strtoupper($otherLoanRow['existing_loan']) == 'YES' && (!strcasecmp($is_all_loan_details_availble, 'yes') && count($otherLoanRow['loan_details']) > 0)) { + $is_existing_loans_available = 1; + $total_no_of_data = count($otherLoanRow['loan_details']); + $existLoanResult = FINANCIALFORM::getOtherLoanDetails($otherLoanRow['loan_details'], $pd_master_details[0]['pd_id']); + } else if (!strcasecmp($is_all_loan_details_availble, 'no')) { + $out_standing_loan_info['tot_running_loans'] = $otherLoanRow['tot_running_loans']; + $out_standing_loan_info['tot_emi_paid'] = $otherLoanRow['tot_emi_paid']; + $out_standing_loan_info['tot_outstanding_loans'] = $otherLoanRow['tot_outstanding_loans']; + } +} +?> +
    +

    Existing loan obligation

    + + + + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. +

    + $single_table) { + //print_r($single_table);die(); + + if (is_numeric($table_key)) { + ?> + + + + + Loan $pre_loan_no"; + } ?> + + + + + + +
    Particulars
    +
    + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. + + + + + + + + + + + + + + + +
    Total No of Running LoansTotal Outstanding AmountTotal EMI being Paid (Monthly)
    + + +

    As per loan applicant he does not have any existing loan obligations.

    + +' . $existing_loan_form_common_remarks . '

    '; +} +?> + + + + + + + + + + +'; +echo '

    Credit Manager`s Specific Queries:

    '; +//echo '
    '; +if (isset($credit_officier_specific_queries['additional_requirements_processed']) && count($credit_officier_specific_queries['additional_requirements_processed'])) { + + + foreach ($credit_officier_specific_queries['additional_requirements_processed'] as $key => $value) { + echo 'Question - ' . $value['question'] . '
    '; + echo 'Answer - ' . $value['answer']; + echo '

    '; + } +} else { + echo 'There are no specific queries raised by Credit Manager.'; +} + +echo '
    '; +echo '

    Document to be photographed/scanned:

    '; +// +if (isset($credit_officier_specific_queries['docs_to_be_sighted_processed']) && count($credit_officier_specific_queries['docs_to_be_sighted_processed'])) { + + + foreach ($credit_officier_specific_queries['docs_to_be_sighted_processed'] as $doc_key => $doc_value) { + echo 'Document Required : ' . $doc_value['doc_name'] . '
    '; + echo 'Provided ( Yes / No ) : ' . ($doc_value['ans'] == 'yes' ? 'YES, Document available in zipped file enclosed with report' . '
    ' : 'NO
    '); + if ($doc_value['ans'] != 'yes') { + echo 'Reason : ' . $doc_value['reason']; + } + echo '

    '; + } +} else { + echo 'There are no specific documents to be collect.'; +} + +if (isset($credit_officier_specific_queries['covid_section']) && isset($credit_officier_specific_queries['covid_section']['question_info']) && count($credit_officier_specific_queries['covid_section']['question_info'])) { + echo '
    '; + echo '

    Queries related to Covid-19:

    '; + + foreach ($credit_officier_specific_queries['covid_section']['question_info'] as $covid_key => $covid_value) { + if (isset($covid_value['is_subfield']) && !$covid_value['is_subfield']) { + echo 'Question : ' . $covid_value['question'] . '
    '; + $temp_answer = $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (($covid_value['type'] == 1 || $covid_value['type'] == 9) && ($covid_value['field_type'] == 'str&numtoword' || $covid_value['field_type'] == 'num' || $covid_value['field_type'] == 'numtoword') && is_numeric($temp_answer)) { + $temp_answer = MYUTIL::customIndianNumberFormat($temp_answer) . ' (' . MYUTIL::numtowords($temp_answer) . ')'; + } + echo 'Answer : ' . $temp_answer . '
    '; + $sub_field_key = $covid_value['question_key'] . '_' . $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (isset($credit_officier_specific_queries['covid_section'][$sub_field_key])) { + echo 'Reason/Description : ' . $credit_officier_specific_queries['covid_section'][$sub_field_key] . '
    '; + } + + echo '
    '; + } + } +} + +//} + +?> + + + + +
    +
    +

    PD OFFICER`S REMARKS ON CUSTOMER BEHAVIOUR & OVERALL PD STATUS

    + +
    + + '; + echo '

    Personal feedback or market intelligence on the case (if any):

    '; + echo '

    ' . $final_remark_data['market_intelligence'] . '

    '; + echo '
    '; + //echo '
    '; + } + ?> +
      +
    • Customer Behaviour:
    • + +

      + + ✔'; + ?> + + + + + + + + +
      +
      Polite
      +
      +
      +
      Rude
      +
      +
      +
      Others*
      +
      +
      +
      +
      '; + } ?> + + + +
      +
    • PD Officer’s overall assessment:
    • +

      + + + + + + + + + + + + + + + + +
      +
      Positive
      +
      +
      +
      Refer to Credit
      +
      +
      +
      Negative
      +
      +
      +
      Others*
      +
      +
      +
      + +
    +
    + + +

    PD officer recommendation is ' . $fo_diplay . '.

    '; ?> +

    The following key points were considered while arriving at the aforementioned status.

    +"; + foreach ($final_remark_data['recommendation_positive'] as $pos) { + echo "
  • " . $pos['reason_for_positive'] . "
  • "; + } + } else if ($negative) { + echo "
      "; + foreach ($final_remark_data['recommendation_negative'] as $neg) { + echo "
    • " . $neg['reason_for_negative'] . "
    • "; + } + } else if ($refer_to_credit) { + echo "
        "; + foreach ($final_remark_data['recommendation_refer_to_credit'] as $rtc) { + echo "
      • " . $rtc['reason_for_refer_to_credit'] . "
      • "; + } + } + echo "
      "; +?> +" . $other_command_remark . "

      "; + } + + echo '

      ' . $pd_officer_final_remark . '

      ' +?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + if (is_array($assessed_income_details) && count($assessed_income_details) && isset($assessed_income_details[($business_count + 1)]) && count($ai_core_details['sales_calculated_by_itemwise']) && $GLOBALS['is_kuccha_records_available']) { + echo '
      '; + echo '

      Annexure A

      '; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + //echo "
      "; + echo '

      Kuchha Sales Book/Bills Details:

      '; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);//die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sale_month_wise) { + + //echo '
      '; + if ($sale_month_wise['sales_type'] == 3 || $sale_month_wise['sales_type'] == 2) { + //print_r($sale_month_wise);//die(); + echo 'Item name : ' . $sale_month_wise['sale_item'] . '
      '; + if ($sale_month_wise['sales_type'] == 3) { + echo '' . $sale_month_wise['month_count'] . ' month sales value : ' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']) . ' Annual Sales value:' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']))) . ' (i.e. ' . (12 / $sale_month_wise['month_count']) . ' * ' . $sale_month_wise['total_months_value'] . ')'; + } else { + echo 'Annual Sales value:' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'])) . ''; + } + echo '
      '; + echo '
      '; + $row_count = ceil(count($sale_month_wise['months']) / 5); + //print_r(($sale_month_wise['months'])); + // echo $row_count; + //die(); + echo '
      '; + + for ($i = 0; $i <= $row_count; $i++) { + $from = $i == 0 ? $i : ($i + 3); + $to = ($from + 3); + //echo ''; + for ($j = $from; $j <= $to; $j++) { + //$sale_month_wise['months'] as $sale_month_data + //echo ''; + if (isset($sale_month_wise['months'][$j])) { + + //print_r($sale_month_wise['months'][$j]) ;die(); + echo '
      '; + //echo ''; + echo '
      '; + echo ''; + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } else if (($sale_month_wise['sales_type'] == 2)) { + echo ''; + } + echo ''; + + echo ''; + + $month_sub_total = 0; + foreach ($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) { + + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + $month_sub_total += $month['value']; + } + //if($m_key == 20)break; + else if ($sale_month_wise['sales_type'] == 2) { + echo ''; + $month_sub_total += $sale_month_wise['annual_sale_value']; + } + } + echo ''; + $month_sub_total = 0; + echo ''; + + echo '
      ' . $sale_month_wise['months'][$j]['month_to_dispaly'] . '
      Date Value
      Frequncy Value
      ' . $month['date'] . ' ' . $month['value'] . '
      ' . $month['frequency_name'] . ' ' . $month['frequency_value'] . '
      Total ' . MYUTIL::customIndianNumberFormat($month_sub_total) . '
      '; + echo '
      '; + echo '   '; + } + } + //echo ''; + } + echo '
      '; + echo '
      '; + } + } + } + } // end of if AI available in current business count + } //end of total no of business for loop +} +?> + + + + + + $rental_property) { + //echo $rental_property_key; + $current_property = json_decode($rental_property['processed_json'], true); + $rental_data[] = RENTALFORM::getRentalText($current_property); + } + + + if (count($rental_data)) { + echo '
      '; + echo '

      Annexure B : Rental Income Details

      '; + + foreach ($rental_data as $key => $value) { + + echo '
      Property : ' . ($key + 1) . ''; + echo '

      Address of Property : ' . ($value['address_property']) . ''; + echo '

      Type of Property : ' . ($value['type_of_property']) . ''; + echo '

      Name of the Property Owner`s : ' . ($value['property_owners_name']) . ''; + echo '

      Name of the person`s who showing Property : ' . ($value['property_showing_persons_name']) . ''; + echo '

      Property Document Proof Seen : ' . ($value['property_document_proof_visted']) . ''; + if (!strcasecmp($value['property_document_proof_visted'], 'yes')) { + echo '      Type of Property Document Visted : ' . ($value['type_of_document_visited']) . ''; + } + echo '

      Unit Type : ' . ($value['unit_type']) . ''; + echo '

      No of Floors/Units : ' . ($value['no_of_floors']) . ''; + echo '      '; + echo $value['area_coverd'] != "" ? 'Area covered : ' . ($value['area_coverd'] . ' ' . $value['area_uom'] . '') : ''; + + if (isset($value['unit_details']['multistorey']) && count($value['unit_details']['multistorey'])) { + echo '

      Multistorey Details:

      '; + echo ''; + echo ''; + foreach ($value['unit_details']['multistorey'] as $multistorey_key => $multistorey_value) { + echo ''; + } + echo ''; + echo '
      Floor Name No of Units Rent same for
      all Units
      Unit Details Total
      Rent Amount
      ' . $multistorey_value['floor_name'] . ' ' . $multistorey_value['no_units_in_floor'] . '' . $multistorey_value['same_rent'] . '' . $multistorey_value['unit_details'] . '' . $multistorey_value['total_floor_rent'] . '
      Total ' . $rupee_symbol . ' ' . $value['unit_details']['multistorey_over_all_total'] . '
      '; + } + + echo '

      Unit Details:

      '; + foreach ($value['unit_details']['property_core'] as $u_key => $unit_value) { + echo '
      '; + echo $unit_value['unit_name']; + echo ''; + echo $unit_value['header_row']; + echo $unit_value['first_owners_row']; + echo $unit_value['second_lessee_name_row']; + echo $unit_value['third_area_of_unit_row']; + echo $unit_value['fourth_payment_mode_row']; + echo $unit_value['fifth_lease_period_row']; + echo $unit_value['sixth_security_deposit_row']; + echo $unit_value['eigth_current_rent_received_row']; + echo $unit_value['nineth_difference_between_rent_amount_row']; + echo '
      '; + } + + //print_r($value['third_check_details']); + if ($value['third_check_details']['done_third_party_check']) { + echo '
      For property' . ($key + 1) . ' Third Party check was done with ' . $value['third_check_details']['whom_third_party_check_done']; + echo isset($value['third_check_details']['description_third_party_check_done']) ? ' (' . $value['third_check_details']['description_third_party_check_done'] . '). ' : ' '; + if ($value['third_check_details']['rental_rates_third_party_check_done'] != "") { + echo 'Rental rates in the area as per person whom third party check is done is ' . $value['third_check_details']['rental_rates_third_party_check_done']; + } + } else { + + echo '
      For property ' . ($key + 1) . ' Third Party check not done.'; + echo isset($value['third_check_details']['why_third_party_check_not_done']) && $value['third_check_details']['why_third_party_check_not_done'] != "" ? 'Resaon - ' . $value['third_check_details']['why_third_party_check_not_done'] : ''; + } + echo '
      ' . $value['property_remark']; + } + } +} + + +?> + + + + +"; +$footer_lender_stamp = MYUTIL::dispatchDisclaimer($lender_disclaimer, 3); +if (isset($footer_lender_stamp)) { + //$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer,3); + echo '

      '; +} + +$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 2); + +if (isset($footer_lender_disclaimer)) { + echo '

      ' . $footer_lender_disclaimer['disclaimer'] . '

      '; +} +echo "

      "; + +// ########################### End disclaimer end ######################################### +?> + + + + + + +
      '; + echo "

      Detailed Score Card Section

      "; + // *** General Section Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['general'] as $key => $general) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['score_band'] . ')'; + $max_span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['max_score_band'] . ')'; + echo '' . ''; + } + + echo ''; + echo '
      General Questions L1(" . $pd_score['general']['otp_done']['l1_weightage'] . "%) L2 Answer Score Attributed Score Max Score
      ' . $question . '' . $general['l2_weightage'] . '%' . $general['answer'] . + '' . $general['score_band'] . '' . $general['attributed_score'] . '
      ' . $span . '
      ' . $general['max_score'] . '
      ' . $max_span . '
      General Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['general']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['general']['max_score'], 2, '.', ',') . '
      '; + + echo '

      '; + + + // *** Asset Caculation Score Table + echo ''; + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + + + echo '
      Asset Value Calculaitons
      Actual Value Of Assets (a)" . number_format($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets'], 2, '.', ',') . "
      Loan Amount (b)" . number_format($pd_score['score_summary']['asset_calculation_details']['loan_amount'], 2, '.', ',') . "
      Avg Expected Value Of Assets (c)" . round($pd_score['score_summary']['asset_calculation_details']['avg_expected_value_of_assets'], 2) . "%
      Expected Value Of Assets (d = c*b)" . number_format($pd_score['score_summary']['asset_calculation_details']['expected_value_of_assets'], 2, '.', ',') . "
      Actual Value Of Assets Percentage (e = (a/b) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets_percentage'], 2) . "%
      Variance (f = ((e-c)/c) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['variance'], 2) . "%
      Score As per Grid" . round($pd_score['score_summary']['asset_calculation_details']['score'], 2) . "
      '; + + echo '


      '; + // *** Final Remarks Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['final_remarks'] as $key => $final_remark) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + + $span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['score_band'] . ')'; + + $max_span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['max_score_band'] . ')'; + + echo '' . ''; + } + + echo ''; + echo '
      Final Remarks Questions L1(" . $pd_score['final_remarks']['pd_officer_recommandations']['l1_weightage'] . "%) L2Answer ScoreAttributed Score Max Score
      ' . $question . '' . $final_remark['l2_weightage'] . '%' . $final_remark['answer'] . '' . $final_remark['score_band'] . '' . $final_remark['attributed_score'] . '
      ' . $span . '
      ' . $final_remark['max_score'] . '
      ' . $max_span . '
      Final Remarks Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['final_remarks']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['final_remarks']['max_score'], 2, '.', ',') . '
      '; + echo '


      '; + + //print_r($pd_score['business']); + echo ''; + + // *** Business Section Questions Score Table + echo ""; + $certificates = array(); + foreach ($pd_score['business'] as $key => $business) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['score_band'] . ')'; + $max_span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['max_score_band'] . ')'; + + if (($key != 'cerificates') && ($key != 'location_suited_for_busienss')) { + echo '' . ''; + } + + if ($key == 'location_suited_for_busienss') { + echo '' . ''; + } + + if ($key == 'cerificates') { + $certificates = $business; + + echo '' . ''; + } + } + + echo ''; + echo '
      Business Questions L1(" . $pd_score['business']['no_of_years_business_run']['l1_weightage'] . "%) L2Answer Score Attributed ScoreMax Score
      ' . $question . '' . $business['l2_weightage'] . '%' . $business['answer'] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      ' . $question . '' . $business['l2_weightage'] . '%' . $address_type_remarks_caption[$business['answer']] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      Certificates ' . round($business['l2_weightage'], 2) . '%' . 'Refer Cert Table' . '' . $business['score_band'] . '' . $business['attributed_score'] . '' . $business['max_score'] . '
      Business Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['business']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['business']['max_score'], 2, '.', ',') . '
      '; + + + // *** Business Certificates Score Table + + + echo '

      '; + + echo ""; + echo ""; + $index = 0; + // print_r($certificates); + foreach ($certificates as $key => $cerificate) { + $index++; + if ($index <= 7) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['score_band'] . ')'; + + $max_span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['max_score_band'] . ')'; + + echo '' . ''; + } + } + echo "
      Business Certificates Answer Score Attributed Score Max Score
      ' . $question . '' . $cerificate['answer'] . '' . $cerificate['score_band'] . '' . round($cerificate['attributed_score'], 3) . '
      ' . $span . '
      ' . round($cerificate['max_score'], 3) . '
      ' . $max_span . '
      "; +} +// ########################### End Of Score Card Section ######################################### + + + + + + +?> + + + + \ No newline at end of file diff --git a/api/application/views/report_templates/JSONTOREPORT_FI_RV.php b/api/application/views/report_templates/JSONTOREPORT_FI_RV.php new file mode 100644 index 00000000..b98413f4 --- /dev/null +++ b/api/application/views/report_templates/JSONTOREPORT_FI_RV.php @@ -0,0 +1,5194 @@ + + + + + + + + + + + + + + + + + + + + + + + +
      +
      + Powered by PD Genie™ +
      + +
      +
      +
      +
      + + + ₹"; + ?> +
      "; + + echo "
      "; + echo "

      PERSONAL DISCUSSION REPORT

      "; + echo "
      for the case of
      "; + + echo "

      " . $main_applicant_name . "

      "; + echo "
      "; + echo "



      "; + ?> + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + ?> + + + + Loan Amount Applied For :

      "; + //echo '
      PD Initiated Date : ' . $pd_master_details[0]['createdon'] . '
      Tele PD Date : ' . $pd_master_details[0]['pd_visit_date'] . '
      PD Report Date : ' . $pd_master_details[0]['pd_report_generated_date'] . '
      PD Initiated by : ' . $pd_master_details[0]['branch_name'] . ' Branch
      PD Type : Telephonic
      ' . $loan_word . ' Application ID : ' . $pd_master_details[0]['lender_applicant_id'] . '
      Product : ' . $pd_master_details[0]['product_name'] . '
      Customer Segment : ' . (explode('-', $pd_master_details[0]['customer_segment_name'])[0]) . '
      + $pd_initiation_loan_amt = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? $loan_form['loan_amount'] : $loan_form['facility_amount']; + echo ''; + // echo ''; + echo '
      ' . $loan_word . ' Amount
      (As Per PD Initiation)
      : ' . ' ' . MYUTIL::customIndianNumberFormat($pd_master_details[0]['loan_amount']) . '
      (' . MYUTIL::numtowords($pd_master_details[0]['loan_amount']) . ')
      ' . $loan_word . ' Amount
      (As Per ' . $loan_word . ' Applicants during PD)
      : ' . ' ' . MYUTIL::customIndianNumberFormat($pd_initiation_loan_amt) . '
      (' . MYUTIL::numtowords($pd_initiation_loan_amt) . ')
      '.$loan_word.' Amount
      (As Per PD Initiation)
      : ' .' '. MYUTIL::customIndianNumberFormat($pd_master_details[0]['loan_amount']). '
      ('. MYUTIL::numtowords($pd_master_details[0]['loan_amount']) .')
      '.$loan_word.' Amount
      (As Per '.$loan_word.' Applicants during PD)
      : ' .' '. MYUTIL::customIndianNumberFormat($loan_form['loan_amount']). '
      ('. MYUTIL::numtowords($loan_form['loan_amount']) .')
      '; + //echo "
      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + echo "

      "; + + $header_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 1); + if (isset($header_lender_disclaimer['disclaimer']) && $header_lender_disclaimer['disclaimer'] != '' && $header_lender_disclaimer['type'] == 1) { + echo '

      Disclaimer: ' . $header_lender_disclaimer['disclaimer'] . '

      '; + } + + echo '

      Registered / Corporate Office: SineEdge Consulting Private Limited. A-211, Pioneer Urban Square, Golf Course Extension Road, Sector 62, Gurgaon, Haryana - 122002

      '; + ?> + + + + + + $individual) { + //print_r($individual);die(); + if ($individual['is_person_met'] == true) { + //array_push($person_met_images); + $temp_person_met = array(); + $applicant_name = $individual['applicant_name']; + //$applicant_name = array_key_exists('pd_co_applicant_id_master',$individual) ? $individual['pd_co_applicant_id_master'] : "Not Available" ; + //echo '
      '.$individual['applicant_title_name_master'] .' '. $applicant_name.'
      ' ; + $temp_person_met['name'] = $individual['applicant_title_name_master'] . ' ' . $applicant_name; + $temp_person_met['photo'] = ''; + $temp_person_met['id_proof'] = ''; + foreach ($pd_images[18] as $pm_Key => $pm_value) { + + //echo $applicant_name.'-'.$pm_value['pd_document_title']; + if (!strcasecmp(trim($applicant_name), trim($pm_value['pd_document_title']))) { + $temp_person_met['photo'] = $pm_value['doc_url']; + } + + $id = trim($applicant_name) . '-id_proof'; + if (!strcasecmp($id, trim($pm_value['pd_document_title']))) { + $temp_person_met['id_proof'] = $pm_value['doc_url']; + } + } + $company_relationship_data = null; + foreach ($general_form['company_with_relationships'] as $company_with_relationship) { + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name']) { + //FInd Company Name from JSON + $company_relationship_data .= $company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']; + + //$company_relationship_data.='
      and

      '; + $company_relationship_data .= ', '; + } + } + //$temp_person_met['name'] = + //print_r($general_form['persons_with_relationships']); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + if ($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && isset($persons_with_relationship['relationship'])) { + + if (isset($persons_with_relationship['relation_to_master'])) { + //? $persons_with_relationship['relation_to_master'] : " Could Not Find"; + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' Of ' . $RSNA; + //$personal_relationship_data.='
      and

      '; + $personal_relationship_data .= ', '; + } + } + } + } + + $company_relationship_data .= $personal_relationship_data; + $temp_person_met['relations'] = $company_relationship_data; + array_push($person_met_data, $temp_person_met); + } + } + + + //print_r($person_met_data);die(); + echo '
      '; + echo '

      Person(s) Met:

      '; + echo '
      '; + foreach ($person_met_data as $pk => $person) { + $display_for_person_met = $person['relations'] != "" ? substr_replace($person['relations'], '.', strrpos($person['relations'], ','), 1) : ''; + + $person_met_details = $person['name']; + if (strcasecmp($pd_master_details[0]['customer_segment_abbr'], 'SEP_INDV')) { + $person_met_details .= ($display_for_person_met != "" ? ' - ' . $display_for_person_met : ''); + } + echo '

      ' . $person_met_details . '

      '; + + //if($display_for_person_met != "" || $display_for_person_met != null){ + echo '

      '; + //} + if ($person['photo']) { + echo ''; + } + echo '     '; + if ($person['id_proof']) { + echo ''; + } + + //echo count($person_met_data) != ($pk+1)? '
      ':''; + + + } + $faceimage_url = array(); + if (isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) { + foreach ($pd_images['common_images'] as $com_key => $com_value) { + if ($com_value['pd_document_title'] == 'face_api_result_image') { + // $faceimage_url = $com_value['doc_url'];break; + array_push($faceimage_url, $com_value['doc_url']); + } + } + } + if (!empty($faceimage_url)) { + for ($i = 0; $i < count($faceimage_url); $i++) { + echo '     '; + echo ''; + } + } + echo '
      '; + echo '
      '; + ?> + +
      + Face Comparison"; + $notequal_mark = '
      '; + $equal_mark = '
      =
      '; + for ($i = 0; $i < count($ci); $i++) { + $symbol = (round($ci[$i]["Similarity"]) > 50) ? '

      ' . $equal_mark . '

      ' : '

      ' . $notequal_mark . '

      '; + echo '
      +
      + ' . $si[ +
      +
      ' . $symbol . '
      +
      + ' . $ci[$i][ +
      +
      '; + + echo '

      Similarity + ' . round($ci[$i]["Similarity"]) . ' +

      +
      +
      + ' . round($ci[$i]["Similarity"]) . ' +
      +
      '; + } + // ########################### End of Percentage Bar Section ######################################### + } + } + ?> + +

      Applicants:

      + + + + + + + + + + + $individual) { + + if ($individual['is_applicant'] == true && $individual['is_active'] == true) { + + $education_qualification = $individual['qualification_master']; + $education_qualification = $individual['course_name'] != "" || $individual['course_name'] != null ? $education_qualification . '
      (' . $individual['course_name'] . ')' : $education_qualification; + + + $applicant_name = array_key_exists('pd_co_applicant_id_master', $individual) ? $individual['pd_co_applicant_id_master'] : " Could Not Find"; + //echo $applicant_name.'**************************'; + + $title = isset($individual['applicant_title_name_master']) && $individual['applicant_title_name_master'] != "" ? $individual['applicant_title_name_master'] : ''; + + //$kyc_data = ''; + $applicant_name = $title . ' ' . $applicant_name; + if ($ind_key == 0 && array_key_exists('is_kyc', $general_form) && $general_form['is_kyc'] == 'no') { + $applicant_name = 'As per the request received applicant name is ' . $applicant_name . '
      but as per KYC name is ' . $general_form['kyc_and_captur_the_name']; + //$kyc_data = "

      Name noticed as per KYC is ". $general_form['kyc_and_captur_the_name']; + } + echo '"; + } + } + + if (isset($general_form['companies']) && count($general_form['companies'])) { + $business_entity_type_master = array(1 => 'Others', 2 => 'Public Ltd Company', 3 => 'Sole proprietorship', 4 => 'HUF (Hindu Undivided Family)', 5 => 'Partnership', 6 => 'Cooperative', 7 => 'Limited Liability Partnership(LLP)', 8 => 'OPC (One Person Company)', 9 => 'Society', 10 => 'Trust', 11 => 'Private Limited Company'); + foreach ($general_form['companies'] as $comp_key => $ind_company) { + if ($ind_company['is_company_applicant'] != null) { + + echo ''; + } + } + } + ?> + +
      NameAge
      (Yrs/Mns)
      Qualification / Type of EntityRelationships
      ' . $applicant_name . '' . $individual['age'] . '' . $education_qualification . ''; + + $company_relationship_data = null; + //print_r($general_form['company_with_relationships']); + foreach ($general_form['company_with_relationships'] as $crk => $company_with_relationship) { + + //print_r($company_with_relationship); + + if ($individual['pd_co_applicant_id'] == $company_with_relationship['applicant_name'] && $company_with_relationship['company_name'] != '') { + //FInd Company Name from JSON + + //echo "ONCE"; + //echo '### '.$crk.'-ICID'.$individual['pd_co_applicant_id'].'--'.$company_with_relationship['applicant_name'].'-'.$company_with_relationship['company_name']; + $company_relationship_data .= ($company_with_relationship['company_relationship_master'] . ' ' . $company_with_relationship['company_name']); + + $company_relationship_data .= '
      and

      '; + //echo $company_relationship_data; + } + } + //echo $company_relationship_data; + // die(); + $personal_relationship_data = null; + foreach ($general_form['persons_with_relationships'] as $persons_with_relationship) { + + + + if (($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] || !strcasecmp($applicant_name, $persons_with_relationship['applicant_name'])) && isset($persons_with_relationship['relationship'])) { + + + if (isset($persons_with_relationship['relation_to_master'])) { + $RSNA = $persons_with_relationship['relation_to_master']; + if (isset($persons_with_relationship['relationship_master'])) { + $personal_relationship_data .= $persons_with_relationship['relationship_master'] . ' of ' . $RSNA; + + $personal_relationship_data .= '
      and

      '; + } + } + } + } + $company_relationship_data .= $personal_relationship_data; + echo substr_replace($company_relationship_data, '', strrpos($company_relationship_data, '
      and

      '), strlen($company_relationship_data)); + + echo "
      ' . $ind_company['company_name'] . '' . $ind_company['business_years'] . (isset($ind_company['business_month']) ? ' . ' . $ind_company['business_month'] : null) . '' . ($ind_company['business_entity_type'] == 1 ? $ind_company['business_entity_type_other'] : $business_entity_type_master[$ind_company['business_entity_type']]) . ' Not Applicable
      + + + + + ' . $general_form['general_remark'] . '

      '; + } + ?> + + + + + + + 'well suited', 'fairly_suited' => 'fairly suited', 'not_suited' => 'not suited'); + //die(); + if (isset($pd_score) && count($pd_score)) { + echo '
      '; + echo '

      PD Score Summary

      '; + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Actual ScoreMax ScoreScore %
      General Section Score
      Business Section Score
      Final Remarks Score
      Final PD Score
      + +
      "; + + echo '

      '; + } + // else + // { echo "Score Chart Not Generated"; } + + + + //######################### CHART ########################### + + + // if(isset($dsc_cards['base64_dsc_business'])) + // { + // echo "

      "; + + // echo '

      '; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + // if(isset($dsc_cards['base64_dsc_general'])) + // { + // echo "

      "; + + // echo '

      '; + + // } + // else + // { + // //echo "Score Chart Not Generated"; + // } + + + echo "
      "; + //######################### CHART ########################### + + $business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>", "owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>", "stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>"); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>", "value_of_other_assets" => "Asset Value by Loan Amount % >>"); + } else { + $general_captions = array("otp_done" => "OTP authentication done >>", "person_met_is_applicant" => "Is person Met, a loan applicant >>", "qualification" => "Qualification of Loan Applicants >>", "comment_locality" => "Comment on Locality >>", "pd_location_approach" => "Approach to PD location >>", "customer_behaviour" => "Customer Behaviour >>", "neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>", "was_the_company_name_board_sighted" => "Business Board Sighted >>"); + } + + + + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['business'] as $bsk => $business_score) { + + $class = null; + $answer = null; + $per = $business_score['attributed_score'] > 0 && $business_score['max_score'] > 0 ? (($business_score['attributed_score'] / $business_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + // if($bsk == 'business_seasonality') + // { + // echo "BUSINESS"; + // echo $per; + // echo $class; + // echo $per >= 80 ? 'rcorners_green' : 'SOME'; + // die(); + // } + + if ($bsk == 'location_suited_for_busienss') { + $answer = $address_type_remarks_caption[$business_score['answer']]; + } else if ($bsk == 'cerificates') { + $answer = $per > 0 ? 'Yes' : 'No'; + } else if ($bsk == 'no_of_years_business_run') { + $answer = isset($business_score['answer']) ? $business_score['answer'] . ' Yrs' : ''; + } else if ($bsk == 'business_seasonality') { + $answer = isset($business_score['answer']) ? ((!strcasecmp($business_score['answer'], 'yes')) ? 'Seasonal' : 'Not Seasonal') : ''; + } else if ($bsk == 'vintage_of_business_account') { + $answer = isset($business_score['answer']) && $business_score['answer'] != '' ? $business_score['answer'] : 'No'; + } else { + $answer = isset($business_score['answer']) ? $business_score['answer'] : ''; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
      Business Related Parameters Impacting Score Response
      ' . $business_captions[$bsk] . ' ' . '
      ' . ucfirst($answer) . '
      '; + echo '


      '; + + echo ''; + echo ''; + + echo ''; + foreach ($pd_score['general'] as $gsk => $general_score) { + $class = null; + $per = $general_score['attributed_score'] > 0 && $general_score['max_score'] > 0 ? (($general_score['attributed_score'] / $general_score['max_score']) * 100) : 0; + + $class = ($per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red'))); + + $answer = ucfirst($general_score['answer']); + + if ($gsk == 'value_of_other_assets') { + //print_r($general_score);die(); + $answer = round((($answer / $loan_form['loan_amount']) * 100), 2) . ' %'; + } + + if (strcasecmp($answer, 'Not Applicable')) { + echo ''; + } + } + echo ''; + echo '
      Other Parameters Impacting ScoreResponse
      ' . $general_captions[$gsk] . ' ' . '
      ' . $answer . '
      '; + + + // + } //end of is score card enabled for this pd + + ?> + + $address_image_value) { + if ($address_image_value['is_show_report'] == 1) { + $pd_location_approach_img_url = isset($address_image_value['doc_url']) ? $address_image_value['doc_url'] : ''; + //$pd_location_approach_img_location = $address_image_value['location']; + //$pd_location_approach_img_date = date('Y/m/d h:s:i A',$address_image_value['createdon']); + break; + } + } + + $name_board_seen_img_url = ''; + if (isset($pd_processed_forms[13][0])) { + + $first_business_form = json_decode($pd_processed_forms[13][0]['processed_json'], true); + //if($first_business_form['was_the_company_name_board_sighted']=='yes') + //{ + //echo 'YES';die(); + foreach ($pd_images[13] as $image_key => $image_value) { + if ($image_value['pd_document_title'] == 'Name Board Seen') { + + $name_board_seen_img_url = $image_value['doc_url']; + break; + } + } + //} + } + + //echo $name_board_seen_img_url;die(); + //print_r($address_images);die(); + ?> +
      +

      BUSINESS LOCATION

      + +

      Address at which PD was initiated: ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + + echo '
      Address at which PD Visit actually done: ' . $pd_alternative_address['alternative_address'] . ', ' . $pd_alternative_address['city_master'] . ', ' . $pd_alternative_address['state_master'] . ' - ' . $alter_native_pincode . '.'; + + echo '
      Reason for change in PD address:' . $pd_alternative_address['reason_for_alternative_address']; + } else { + + echo 'Business Address : ' . $pd_address['address'] . ', ' . $pd_address['city_master'] . ', ' . $pd_address['state_master'] . ' - ' . $pincode . '.'; + } + + echo '

      GPS Coordinates of Business Address : '; + echo isset($pd_master_details[0]['start_location']) ? $pd_master_details[0]['start_location'] : 'Not Available'; + echo '

      '; + ?> + $com_value) { + if ($com_value['pd_document_title'] == 'satellite') { + $satellite_url = $com_value['doc_url']; + break; + } + } + } + + ?> +  Satellite Image of location of Where PD was Done


      + + + + + + + + + + + + +
      Name Board of Business/Entrance
      + Name Board +
      + +

      +
      +

      Location Summary

      + '; + echo 'The PD was telephonically done with the ' . strtolower($loan_word) . ' applicant(s) at ' . $address_type . 'Address Form - Type of Address . '; + echo 'The ' . $address_type . 'Address Form - Type of Address is ' . $property_owner_type . 'Business Assest Form - Owner of the Property and the business has been in operation from here for the last ' . $yrs_being_run . 'Business Assest Form - Business running Yrs in this premise .'; + echo '

      The ' . $address_type . 'Address Form - Type of Address is located in ' . $locality . 'Address Form - Locality of Address ' . ($estimated_area != 0 ? 'and the estimated area of the ' . $address_type . 'Address Form - Type of Address is ' . $estimated_area . 'Address Form - Estimated Area .' : ''); + // echo '

      The PD location was '. $pd_address['pd_location_master'].'Address Form - Approach to PD location . ' . 'As Per PD Officer, the '.$address_type .'Address Form - Type of Address is situated in '.$comment_locality_master .'Address Form - Comment on locality Locality.'; + // echo '

      The PD officer also made the following observations:' ; + echo '
      '; + + // echo '
    • The location of the '.$address_type.'Address Form - Type of Address is '.$address_type_remarks_caption [ $final_remark_data['is_service_provided'] ].'Final Remarks Form - The location of the busienss suitability for Business to the nature of business.
    • '; + + if ($first_business_form['was_the_company_name_board_sighted'] == 'yes') { + echo '

      The business name board photograph was shared by applicant.Business Form'; + } else { + echo '

      The business name board photograph was not shared by applicant.Business Form'; + } + + if ($address_form['address_proof_provided'] == 'yes') { + echo ' The address proof was shared by applicant.Business Form'; + } else { + echo ' The address proof was not shared by applicant.Business Form'; + } + echo '

      '; + + + // if($business_assets_details['business_assets_for_address'][0]['business_is_pd_visited'] == 'yes') + // { + // echo '
    • Business Activity was seen during visit.Business Assest Form - Busienss activity seen during PD visit
    • '; + // } + // else{ + // echo '
    • No business activity was seen during the PD visit.Business Assest Form - Busienss activity seen during PD visit
    • '; + // } + // if(isset($business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark']) && $business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] != ""){ + // echo '
    • '.$business_assets_details['business_assets_for_address'][0]['business_pd_visited_remark'] .'Business Assest Form - Busienss Assest Form Remarks
    • ';} + + if (isset($final_remark_data['is_competition'])) { + if ($final_remark_data['is_competition'] == 'yes') { + echo '
    • ' . $final_remark_data['appx_outlet_or_stores'] . ' Units with similar business were sighted in the locality
    • '; + } else { + echo '
    • PD officer did not observe any similar business units in the locality.
    • '; + } + } + if (isset($final_remark_data['demolition_activity'])) { + if ($final_remark_data['demolition_activity'] == 'yes') { + echo '
    • ' . $final_remark_data['comment_of_demolition_activity'] . '
    • '; + echo '
      Demolition Image Not Available'; + } else { + echo '
    • No demolition activity was observed in the locality.
    • '; + } + } + + + if (isset($final_remark_data['sealing_activity'])) { + if ($final_remark_data['sealing_activity'] == 'yes') { + echo '
    • ' . $final_remark_data['comment_of_sealing_activity'] . '
    • '; + echo '
      Demolition Image Not Available'; + } else { + echo '
    • No sealing activity was observed in the locality.
    • '; + } + } + + if (isset($final_remark_data['outlet_location'])) { + if ($final_remark_data['outlet_location'] == 'heavy_footfall') { + echo '
    • Heavy Footfall ( Lots of customer in the locality / market place )
    • '; + } else if ($final_remark_data['outlet_location'] == 'medium_footfall') { + echo '
    • Medium Footfall ( Meduim no of customer in the locality / market place )
    • '; + } else if ($final_remark_data['outlet_location'] == 'low_footfall') { + echo '
    • LOw Footfall ( Few customer in the locality / market place )
    • '; + } + } + + echo "
    "; + + if ($address_form['address_form_remark']) { + echo '' . $address_form['address_form_remark'] . 'Address Form - Address Form Remarks '; + } + echo "

    "; + // echo "
    "; + //die(); + // + ?> + + + + + + +

    DETAILS:

    + The following loan related information was provided by applicant.'; + + $is_current_product_bl = $pd_master_details[0]['prod_catagory'] == "BL" ? true : false; + $is_current_product_lab = $pd_master_details[0]['prod_catagory'] == "LAP" ? true : false; + $is_current_product_laep = $pd_master_details[0]['prod_catagory'] == "LAEP" ? true : false; + // echo $pd_master_details[0]['product_abbr']; + // echo '-bl-'. $is_current_product_bl; + // echo '-lap-'.$is_current_product_lab; + // die(); + $loan_table_dispaly_rows = array(); + + $loan_table_dispaly_rows[] = array('particulars' => ('Total ' . $loan_word . ' Amount applied for'), 'details' => "" . " " . $loan_amount . ' (' . MYUTIL::numtowords($loan_form['loan_amount']) . ')'); + if ($is_current_product_bl || $is_current_product_laep) { + $to_dispaly = !strcasecmp($loan_form['is_there_total_fund'], 'yes disclose') ? ('Disclosed ' . "" . " " . MYUTIL::customIndianNumberFormat($loan_form['fund_amt']) . ' (' . MYUTIL::numtowords($loan_form['fund_amt']) . ')') : 'Not Disclosed'; + $loan_table_dispaly_rows[] = array('particulars' => 'Total Fund Requirement', 'details' => $to_dispaly); + } + $loan_table_dispaly_rows[] = array('particulars' => ($loan_word . ' Tenure expected'), 'details' => $loan_form['loan_tenure'] != "" ? $loan_form['loan_tenure'] . ' Months' : 'Not provided'); + + $end_use = ''; + $to_remove_for = false; + foreach ($loan_form['end_use_master'] as $enduse) { + if (strpos(strval($enduse), 'Others') === false) { + $end_use .= $enduse . ' and '; + } else { + + $to_remove_for = true; + $end_use .= $loan_form['end_use_other'] . ' and'; + } + } + $end_use = substr_replace($end_use, '', strrpos($end_use, 'and'), strlen($end_use)); + //echo substr($end_use,0,3); + + + if (strcasecmp(substr($end_use, 0, 3), 'for')) { + if (!(count($loan_form['end_use_master']) == 1 && $to_remove_for)) { + $end_use = 'For ' . $end_use; + } + } + + $loan_table_dispaly_rows[] = array('particulars' => ($loan_word . ' Purpose'), 'details' => $end_use); + + if (strcasecmp($loan_form['is_transfer'], 'no')) { + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer Amount', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['balance_transfer_amount']) . ' (' . MYUTIL::numtowords($loan_form['balance_transfer_amount']) . ')'); + + $loan_table_dispaly_rows[] = array('particulars' => 'Top Up Amount applied for', 'details' => "" . " " . MYUTIL::customIndianNumberFormat($loan_form['topup_amount']) . ($loan_form['topup_amount'] ? (' (' . MYUTIL::numtowords($loan_form['topup_amount']) . ')') : '')); + + if ($loan_form['end_use_topup_master']) { + $loan_table_dispaly_rows[] = array('particulars' => 'End Use of Topup', 'details' => (strcasecmp('others', $loan_form['end_use_topup_master'])) ? $loan_form['end_use_topup_master'] : $loan_form['other_end_use_topup']); + } + + $loan_table_dispaly_rows[] = array('particulars' => 'Balance Transfer from', 'details' => $loan_form['lender'] == 1 ? $loan_form['other_bt_lender'] : $loan_form['lender_master']); + } else { + //echo 'sdn-'.((!$is_current_product_bl) && !$is_current_product_lab); die(); + if ((!$is_current_product_bl) && !$is_current_product_lab && !$is_current_product_laep) { + $loan_table_dispaly_rows[] = array('particulars' => 'Amount of Own Contribution', 'details' => is_numeric($loan_form['own_contribution']) && $loan_form['own_contribution'] != 0 ? ("" . " " . MYUTIL::customIndianNumberFormat($loan_form['own_contribution']) . ' (' . MYUTIL::numtowords($loan_form['own_contribution']) . ')') : 'Not Provided'); + $source_of_own_contribution = ''; + + foreach ($loan_form['source_of_own_contribution_master'] as $own_source) { + + if (!strcasecmp($own_source, 'others')) { + $source_of_own_contribution .= $loan_form['other_source'] . ' and '; + } else { + $source_of_own_contribution .= $own_source . ' and '; + } + } + + $source_of_own_contribution = substr_replace($source_of_own_contribution, '', strrpos($source_of_own_contribution, ' and '), strlen($source_of_own_contribution)); + + $loan_table_dispaly_rows[] = array('particulars' => 'Source of Own Contribution', 'details' => $source_of_own_contribution); + } + } + if (!($pd_master_details[0]['lender_short_name'] == 'UDAAN' || $pd_master_details[0]['lender_short_name'] == 'CFPL')) { + $loan_table_dispaly_rows[] = array('particulars' => 'EMI Comfortable Paying', 'details' => is_numeric($loan_form['emi_level']) && $loan_form['emi_level'] != 0 ? ($rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emi_level']) . ' (' . MYUTIL::numtowords($loan_form['emi_level']) . ')') : "Not Provided"); + } + + if (!$is_current_product_bl && !$is_current_product_laep) { + + if (isset($loan_form['property_type_master']) && $loan_form['property_type_master'] != "") { + $loan_table_dispaly_rows[] = array('particulars' => 'Type of Property Being Mortgaged', 'details' => substr_count($loan_form['property_type_master'], 'Others') ? $loan_form['property_type_others'] : $loan_form['property_type_master']); + + //print_r($loan_form);die(); + $owners_list = null; + foreach ($loan_form['owners_list_master'] as $owner) { + $owners_list .= $owner . ' and '; + } + ///echo $owners_list; + $owners_list = substr_replace($owners_list, '', strrpos($owners_list, 'and'), strlen($owners_list)); + if ($owners_list == '') { + if (isset($loan_form['owner_name_group'][0]['owner_name'])) { + $owners_list = $loan_form['owner_name_group'][0]['owner_name']['name']; + } + } + $loan_table_dispaly_rows[] = array('particulars' => 'Name of the current / proposed owner(s) of the Property being Mortgaged', 'details' => $owners_list); + + $loan_table_dispaly_rows[] = array('particulars' => 'Status of Construction', 'details' => $loan_form['construction_status_master']); + + $loan_table_dispaly_rows[] = array('particulars' => 'Estimated Market Value of the property being mortgaged', 'details' => ($loan_form['emv_per_customer'] != "" ? $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($loan_form['emv_per_customer']) . ' (' . MYUTIL::numtowords($loan_form['emv_per_customer']) . ')' : 'Not Provided')); + } + } + + if (isset($loan_form['property_seller']) && $loan_form['property_seller'] != '') { + $loan_table_dispaly_rows[] = array('particulars' => 'Current Owner/Seller of the property', 'details' => $loan_form['property_seller']); + } + + if (isset($loan_form['address']) && $loan_form['address'] != '') { + $address_of_owner_seller_property = $loan_form['address'] . (isset($loan_form['city_master']) ? ', ' . $loan_form['city_master'] : '') . (isset($loan_form['state_master']) ? ', ' . $loan_form['state_master'] : '') . (isset($loan_form['pincode_master']) ? ', ' . $loan_form['pincode_master'] : ''); + + $loan_table_dispaly_rows[] = array('particulars' => 'Address of the property', 'details' => $address_of_owner_seller_property); + } + //print_r($loan_table_dispaly_rows); + if ($pd_master_details[0]['lender_short_name'] != 'CFPL') { + ?> +

    + + + + + + + + $row) { + echo '"; + } + ?> + +
    S.No Particulars Particular Details
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    + +
    +

    Anchor Details Section:

    + + + + + + + + $row) { + echo '"; + } + ?> + +
    S.No Particulars Particular Details
    ' . ($row_key + 1) . " " . $row['particulars'] . " " . $row['details'] . "
    +
    " . $loan_form['loandetails_remarks']; + ?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + + if ($general_form['companies'][$business_count]['is_active'] == true) { // $temp_show = null; + // if($temp_show == null) + // { + ?> + + .'; + } + $bindEachResult['company_employees'] = ''; + + + // this is for no of employees details + if (isset($businessRow['employees_permanent']) && $businessRow['employees_permanent'] <= 0) { + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent'; + } else { + $bindEachResult['company_employees'] = 'As per loan applicant, there are ' . $businessRow['employees_permanent'] . ' permanent '; + } + + if (isset($businessRow['employees_temporary']) && $businessRow['employees_temporary'] > 0) { + + $bindEachResult['company_employees'] .= 'and ' . $businessRow['employees_temporary'] . ' temporary employee(s) with company.'; + } else { + + $bindEachResult['company_employees'] .= ' and no temporary employees with company.'; + } + + if (($businessRow['employees_permanent'] != "" && $businessRow['employees_permanent'] == 0) && ($businessRow['employees_temporary'] != "" && $businessRow['employees_temporary'] == 0)) { + + $bindEachResult['company_employees'] = 'As per loan applicant, there are no permanent or temporary employees with the company.'; + } + + if (isset($businessRow['employees_appx_salary']) && $businessRow['employees_appx_salary'] != "") { + $bindEachResult['employees_appx_salary'] = 'Approximately ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($businessRow['employees_appx_salary']) . ' is being paid as salary to employees'; + } + if (isset($businessRow['officer_total']) && $businessRow['officer_total'] > 0) { + $emp = $businessRow['officer_total'] > 1 ? 'employees' : 'employee'; + $bindEachResult['officer_visit_company_employees'] = 'At the time of PD visit, the officer sighted ' . $businessRow['officer_total'] . ' ' . $emp . ' at the business premises.'; + } else { + + $bindEachResult['officer_visit_company_employees'] = ''; + //$bindEachResult['officer_visit_company_employees']='At the time of PD visit, no employees seen at the business premises.'; + } + //this is documents visited + $getDocuments = array(); + if (array_key_exists('shop_eat_act_cert', $businessRow) && strtoupper($businessRow['shop_eat_act_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Shop/Est act Certificate.', 'img' => isset($businessRow['shop_eat_act_cert_pic']) ? $businessRow['shop_eat_act_cert_pic'] : '', 'key_name' => 'shop_eat_act_cert_pic')); + } + if (array_key_exists('gst_Regn_cert', $businessRow) && strtoupper($businessRow['gst_Regn_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'GST Registration.', 'img' => isset($businessRow['gst_Regn_cert_pic']) ? $businessRow['gst_Regn_cert_pic'] : '', 'key_name' => 'gst_Regn_cert_pic')); + } + if (array_key_exists('pf_regn', $businessRow) && strtoupper($businessRow['pf_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'PF Registration.', 'img' => isset($businessRow['pf_regn_pic']) ? $businessRow['pf_regn_pic'] : '', 'key_name' => 'pf_regn_pic')); + } + if (array_key_exists('esic_regn', $businessRow) && strtoupper($businessRow['esic_regn']) == 'YES') { + array_push($getDocuments, array('name' => 'ESIC Registration.', 'img' => isset($businessRow['esic_regn_pic']) ? $businessRow['esic_regn_pic'] : '', 'key_name' => 'esic_regn_pic')); + } + if (array_key_exists('export_import_cert', $businessRow) && strtoupper($businessRow['export_import_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Export/Import Certificate.', 'img' => isset($businessRow['export_import_cert_pic']) ? $businessRow['export_import_cert_pic'] : '', 'key_name' => 'export_import_cert_pic')); + } + if (array_key_exists('factory_cert', $businessRow) && strtoupper($businessRow['factory_cert']) == 'YES') { + array_push($getDocuments, array('name' => 'Factory Certificate.', 'img' => isset($businessRow['factory_cert_pic']) ? $businessRow['factory_cert_pic'] : '', 'key_name' => 'factory_cert_pic')); + } + if (array_key_exists('eb_bill', $businessRow) && strtoupper($businessRow['eb_bill']) == 'YES') { + array_push($getDocuments, array('name' => 'Electric Bill.', 'img' => isset($businessRow['eb_bill_pic']) ? $businessRow['eb_bill_pic'] : '', 'key_name' => 'eb_bill_pic')); + } + if (strtoupper($businessRow['other_documents']) == 'YES' && array_key_exists('documents', $businessRow)) { + foreach ($businessRow['documents'] as $docValue) { + array_push($getDocuments, array('name' => $docValue['document'], 'img' => isset($docValue['document_pic']) ? $docValue['document_pic'] : '', 'key_name' => $docValue['document'])); + } + } + + //print_r($getDocuments); + if (count($getDocuments)) { + foreach ($getDocuments as $getDocument_key => $getDocument_value) { + foreach ($pd_images[13] as $img_key => $img_value) { + if (!strcasecmp($getDocument_value['key_name'], $img_value['pd_document_title'])) { + $getDocuments[$getDocument_key]['img'] = $img_value['doc_url']; + break; + } + } + } + } + //print_r($getDocuments);die(); + $bindEachResult['visit_documents'] = $getDocuments; + array_push($businessResult, $bindEachResult); + + + + ?> +

    BUSINESS INFORMATION:

    + $fetchRow) { + //print_r($fetchRow['company_details']);die(); + ?> + +

    +

    +

    + +
    Date of Incorporation :
    + +
    Business Vintage : +

    + + +
    +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    NameShare HoldingNo.of Years in Current BusinessTotal Work Experience(Yrs)Previous ExperienceStarted Business
    + + + 0) { ?> +
    +

    Other Family Members involved in business :

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    NameIndividual RelationshipRelated toRelationship to Company / FirmStarted Business (Yes / No)
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    ' . $process_brief['description'] . '

    '; ?>
    + + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    ServicesArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + + 0) { ?> + +

    Key Products and Area of Operations

    + + + + + + + + + + + + + + + + + + + + + + +
    Key ProductsArea of OperationsArea of Sale / ServiceArea where Max Sale / Service done
    +
    + +
    + + +
    + + +



    +

    Brief of the Business / Service Model

    + + + + + + + + + + + + + + + + +
    Product / ServiceProcess Brief
    + + + + + + 0) { ?> + + +
    + + + + + + + + + + + + + + + +
    Other Business Activity
    +
    ' . $fetchRow['total_per_of_export'] . ' % of total sales is export.
    '; + } + + ?> + + + + + Loan applicant is using Mobile Wallets/UPI for business transactions.

    '; + } //else + //{ + // echo '

    As per person`s met,applicant using Mobile Wallets/UPI for business transactions.

    ' + //} + if (!strcasecmp($fetchRow['applicant_use_pos_machines'], 'yes')) { + echo '

    The applicant has the following POS machines:

    '; + echo ''; + echo ''; + foreach ($fetchRow['pos_machines_details'] as $pos) { + echo ''; + } + echo '
    Name of the Financial Insitution TID Number of POS machine
    ' . ($pos['pos_machines_financial_institution_name'] ? $pos['pos_machines_financial_institution_name'] : 'Not Provided') . ' ' . $pos['tid_no_of_pos_machine'] . '
    '; + } + + + + ?> + + + + + + + + + + + +
    +

    +
    + + + + +

    +

    +

    + + + + +

    The below document images were shared :

    + + + + '; + for ($doc = $from; $doc <= $to; $doc++) { + if (isset($visit_documents[$doc])) { + ?> + + '; + $from_index_increment = $from_index_increment + 2; + } ?> + +
    + +
    + + + + ' . $business_form_common_remarks . '

    '; + } + + ?> + + + + + + + +
    + + + + + + 0 && $is_business_asset_available) { + $bindBusinessAsset['details'] = ASSETSFORM::getBusinessAssetsDetails($businessAssetRow['business_assets_details'], $pd_master_details[0]['pd_id']); + } + array_push($businessAssetResult, $bindBusinessAsset); + + + //print_r($businessAssetResult);die(); + ?> + + + + +
    +
    +
    +

    Assets used in Business

    + $iterateAsset) { ?> +

    + + $value) { + echo ''; + echo ''; + echo $value['header_row']; ?> + +'; + echo '
    '; + echo '
    '; + } + } + } + } else { + echo '

    No other assests used for business.

    '; + } + if ($business_assets_form_remark != "") { + echo '

    ' . $business_assets_form_remark . '

    '; + } + } // ENd of if business assesst available in this current index +?> + + + + + + +
    +↑ /'; + + if (isset($pd_processed_forms[14][$business_count])) { + $baRow = $pd_processed_forms[14][$business_count]; + $businessFinancialRow = json_decode($baRow['processed_json'], true); + //print_r($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']);die(); + $financial_remarks = $businessFinancialRow['financial_remarks']; + $comments_on_financials = isset($businessFinancialRow['financial_reason']) ? $businessFinancialRow['financial_reason'] : ''; + //echo $financial_remarks;die(); + // statementdate_per_financial + if (isset($businessFinancialRow['kuccha_records_shown'])) { + $financial_kuccha_info['kuccha_records_shown'] = $businessFinancialRow['kuccha_records_shown']; + $financial_kuccha_info['kuccha_bill_allowed'] = $businessFinancialRow['kuccha_bill_allowed']; + $financial_kuccha_info['customer_declared_turnover'] = $businessFinancialRow['customer_declared_turnover']; + } + + //only for Indusind Lender + if (isset($businessFinancialRow['tot_business_FY'])) { + $current_business_info['tot_business_FY'] = $businessFinancialRow['tot_business_FY']; + $current_business_info['remarks_tot_business_FY'] = $businessFinancialRow['remarks_tot_business_FY']; + $current_business_info['orders_hand_FY'] = $businessFinancialRow['orders_hand_FY']; + } + + //print_r($financial_kuccha_info);die(); + if (strtoupper($businessFinancialRow['is_financial_statements']) == 'YES' && count($businessFinancialRow['date_per_financial']) > 0) { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + //$bindBusinessFinancial["company_name"] .= count($businessFinancialRow['date_per_financial'])>1 ? ' provided with last '.count($businessFinancialRow['date_per_financial']).' years of financial statements and the snapshot is as below :' : ' we were provided with last '.count($businessFinancialRow['date_per_financial']).' year of financial statements and the snapshot is as below :'; + $bindBusinessFinancial["years_data_provided"] = count($businessFinancialRow['date_per_financial']); + $bindBusinessFinancial['is_statement'] = 1; + $bindBusinessFinancial['statements'] = FINANCIALFORM::getBusinessFinancialDetails($businessFinancialRow['date_per_financial']); + } else { + $bindBusinessFinancial["company_name"] = MYUTIL::findCompanyName($all_company_details, $businessFinancialRow['company_id'], 1); + $bindBusinessFinancial["years_data_provided"] = 0; + $bindBusinessFinancial['statements'] = array(); + $bindBusinessFinancial['is_statement'] = 0; + } + // customer + if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && (!isset($businessFinancialRow['estimated_value']))) { + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } else if (strtoupper($businessFinancialRow['is_financial_customer']) != 'YES' && count($businessFinancialRow['estimated_value']) > 0) { + + $bindBusinessFinancial["financial_customer"] = ""; + //$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are as below :"; + $bindBusinessFinancial['customer_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['estimated_value']); + $bindBusinessFinancial['is_customer_statement'] = 1; + } else { + + + $bindBusinessFinancial["financial_customer"] = "As per Loan Applicant(s), the actual turnover and net profit of his business is same as disclosed in financial statements."; + $bindBusinessFinancial['customer_statements'] = array(); + $bindBusinessFinancial['customer_statements_header'] = array(); + $bindBusinessFinancial['is_customer_statement'] = 0; + } + + + // ############### this section only for CLIX HOUSING FINANCE LENDER + if (isset($businessFinancialRow['is_turnover_validated']) && strtoupper($businessFinancialRow['is_turnover_validated']) == 'YES') { + $bindBusinessFinancial['turnover_statements'] = FINANCIALFORM::getBusinessCustomerFinancialDetails($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['customer_statements_header'] = FINANCIALFORM::getBusinessCustomerHeader($businessFinancialRow['turnover_values']); + $bindBusinessFinancial['how_turnover_validated'] = (!strcasecmp(strtolower($businessFinancialRow['how_turnover_validated']), 'others')) ? 'Validated from ' . $businessFinancialRow['turnover_validated_others'] : $businessFinancialRow['how_turnover_validated']; + $bindBusinessFinancial['is_turnover_validated'] = 1; + } + // ############### this section only for CLIX HOUSING FINANCE LENDER + $bindBusinessFinancial['working_capital_receive'] = $businessFinancialRow['receive_the_money_in_days']; + $bindBusinessFinancial['working_capital_pay'] = $businessFinancialRow['pay_the_money_in_days']; + $bindBusinessFinancial['working_capital_unsold_stock'] = is_numeric($businessFinancialRow['unsold_stock_lies_in_days']) ? $businessFinancialRow['unsold_stock_lies_in_days'] : 'Data Not Provided'; + $bindBusinessFinancial['is_working_capital_facility'] = $businessFinancialRow['is_there_working_capital_available']; + if (isset($businessFinancialRow['select_working_capital_facilities_availed'])) { + foreach ($businessFinancialRow['select_working_capital_facilities_availed'] as $k => $v) { + switch ($v['id']) { + case 1: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['name'] = $businessFinancialRow['other_reason_for_working_capital_facilities_availed']; + + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['reason_for_working_capital_facilities_availed']; + break; + + case 2: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['bank_guarantee']; + break; + + case 3: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['cash_credit_limit']; + break; + + case 4: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 5: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['factoring']; + break; + case 6: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['letter_of_credit']; + break; + case 7: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['od_limit']; + break; + case 8: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['lender_name']; + break; + case 9: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_amount']; + break; + case 10: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_type']; + break; + case 11: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_tenor']; + break; + case 12: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['loan_start_date']; + break; + case 13: + $businessFinancialRow['select_working_capital_facilities_availed'][$k]['details'] = $businessFinancialRow['monthly_emi']; + break; + } + } + } + + $bindBusinessFinancial['working_capital_facilites'] = isset($businessFinancialRow['select_working_capital_facilities_availed']) ? $businessFinancialRow['select_working_capital_facilities_availed'] : null; + + $bindBusinessFinancial['estimate_posmachine_or_cc_annual_sales'] = isset($businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales']) ? $businessFinancialRow['estimated_value'][0]['estimate_posmachine_or_cc_annual_sales'] : null; + //print_r($bindBusinessFinancial['select_working_capital_facilities_availed']); //FINANCIALFORM::getAvailableFacilities($businessFinancialRow[-'"working_capital_facilities_availed']); + if ($pd_master_details[0]['lender_short_name'] == 'CFPL') { + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Turnover in last completed Year", 'details' => isset($businessFinancialRow['turnover_lastcomplete_year']) ? $businessFinancialRow['turnover_lastcomplete_year'] : null); + $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "YTD turnover (till last month)", 'details' => isset($businessFinancialRow['ytd_turnover']) ? $businessFinancialRow['ytd_turnover'] : null); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall debtor collection period",'details' => isset($businessFinancialRow['deptor_collection_period'])?$businessFinancialRow['deptor_collection_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall Inventory holding period",'details' => isset($businessFinancialRow['inventory_holding_period'])?$businessFinancialRow['inventory_holding_period']: null ); + // $bindBusinessFinancial['cfpl_lender_details'][] = array('name' => "Overall creditor payment period",'details' => isset($businessFinancialRow['creditor_payment_period'])?$businessFinancialRow['creditor_payment_period']: null ); + } + array_push($businessFinancialResult, $bindBusinessFinancial); + +?> + + 0) { + + ?> + +

    Financial Information

    + 0) { + ?> +

    Company / Firm Name : " . $iterateFinance['company_name']; ?>

    +

    No of Years of Financial Statements provided : " . $iterateFinance['years_data_provided']; ?>

    +

    Snapshot of Financials as per Books of Account Provided : "; ?>

    + + + + + + " . "FY " . $bfRow['financial_year'] . ""; + } ?> + + + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_sales_revenue']) . ''; + } ?> + + + + ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_profit']) . ''; + } else { + echo ''; + } + } ?> + + + + ' . $bfRow['financial_margin_of_profit'] . ' %'; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } ?> + + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + + + + = 0 ? '' : ''; + } else { + echo ''; + } + } ?> + + +
    Particulars
    Sales / Revenue (Rs)
    Net Profit / (Net Loss) (Rs) (' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($bfRow['financial_net_loss']) . ')
    Net Profit or (Net Loss) to Sales % (' . $bfRow['financial_margin_of_loss'] . ' %)
    % () in Sales over PY' . $bfRow['sale_variation'] . ' %(' . $bfRow['sale_variation'] . ' %)NA
    % () in Net Profit over PY' . $bfRow['profit_variation'] . ' %(' . $bfRow['profit_variation'] . ')NA
    % () in Net Profit % over PY' . $bfRow['financial_profit_to_sale_variation'] . ' %(' . $bfRow['financial_profit_to_sale_variation'] . ' %)NA
    +

    ' . $comments_on_financials . '

    '; + } + } + //else{ echo "

    Financial statements not provided by Loan Applicants to PD officer.

    ";} + ?> + + + +

    + 0) { + //print_r($iterateFinance['customer_statements']); + + ?> + + + +

    As per Applicant(s), the Financials are as below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    As per Loan Applicant(s), the Financials are as below:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + + As per Loan Applicant(s) met,' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($iterateFinance['estimate_posmachine_or_cc_annual_sales']) . ' as Annual sales through credit cards / POS machines.

    '; + }; + } ?> + As per Loan Applicant(s) met, the financials figures were not provided.

    "; } + + // ####################### THIS SECTION ONLY FOR CLIX HOUSING FINANCE LENDER ##########################--> + + if (isset($iterateFinance['turnover_statements'])) { + foreach ($iterateFinance['turnover_statements'] as $turnover) { + if (!strcasecmp($turnover['estimate_net_margin_availablity'], 'yes')) { + ?> +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales %>
    Net Profit / (Net Loss) (Rs) >>>>>
    + + +

    Turnover Validated During PD:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParticularsRange providedFinal Considered
    FromTo
    Sales / Revenue (Rs)
    Net Profit or (Net Loss) to Sales (Rs) >
    Net Profit / (Net Loss)% >>>> >
    + Turnover and Netprofit was ' . $iterateFinance['how_turnover_validated']; + } + ?> + + + + + + Validation of Customer Declared Financials :

    '; + // echo 'Kuccha Record Seen (Yes/No) : ';echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : 'No Kuccha Records made available to PD officer and therefore validation of customer declared financials was not possible.'; + if ($financial_kuccha_info['kuccha_records_shown'] == 'yes') { + echo '

    Validation of Customer Declared Financials :

    '; + echo 'Kuccha Record Seen (Yes/No) : '; + echo $financial_kuccha_info['kuccha_records_shown'] == 'yes' ? 'Yes' : ''; + echo '

    Photograph of Kuchha Bills Shared (Yes/No) : ' . ($financial_kuccha_info['kuccha_bill_allowed'] == 'yes' ? 'Yes, enclosed with report' : 'No'); + + // echo '

    Number of Kuccha Bills and Values therein, justifies the customer declared turnover (Yes / No): '. ( $financial_kuccha_info['customer_declared_turnover'] == 'yes' ? 'Yes': 'No'); + } + } + + //only for Indusind Lender + if (count($current_business_info)) { + echo '

    Current Business :

    '; + echo 'Approximate Total Business / Sales Done for Current FY as on date is ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($current_business_info['tot_business_FY']); + echo $current_business_info['remarks_tot_business_FY'] != "" ? ' ( ' . $current_business_info['remarks_tot_business_FY'] . ' ) ' : ''; + echo '
    Orders in Hand to be executed in Current FY : ' . $current_business_info['orders_hand_FY']; + } + ?> + + + + + + + + + + + + $facility) { + echo ''; + } ?> + +
    S.NoParticularsDetails
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    S.NoParticularsDays
    1Debtor Days
    2Creditor Days
    3Stock Days
    + + + +

    + + + + + + + + + + + $facility) { + + echo ''; + } ?> + +
    S.NoFacility TypeFacility Details
    ' . (++$fk) . '' . $facility['name'] . ' ' . $facility['details'] . '
    + The Loan Applicants have not availed any " . $business_fin_sub_title2 . " from any financial institution.

    "; + } + } + ?> + + ' . $financial_remarks . '

    '; + } + } else { ?> +

    Financial information is not available.

    + + + + + + 0) { + $getEachValues['is_od_cc'] = null; + foreach ($businessBankRow['banking_details'] as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $getEachValues['is_od_cc'] = true; + } + } + $getEachValues['bankDetails'] = BANKINGFORM::getBusinessBankingDetails($businessBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getEachValues); + } + } + + ?> + + Business Banking:'; + if ($is_business_banking_available != null) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant(s), Applicant does not have any business account.

    '; + } + + if ($business_banking_common_remarks != "") { + echo '

    ' . $business_banking_common_remarks . '

    '; + } + } // end of busienss bankDetails available in this currrent index + ?> + + + + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $newBankingResult = array_merge($newBankingResult, $getBuinessEachValues); + } + } + // if(isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) + // { + // if(count($individualBankRow['banking_details'])>0){ + // $getIndividualEachValues=BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'],$pd_master_details[0]['pd_id']); + // $newBankingResult = array_merge($newBankingResult,$getIndividualEachValues); + // } + // } + } + foreach ($newBankingResult as $bd) { + if ($bd['account_type'] == 4 || $bd['account_type'] == 3) { + $is_od_cc = true; + } + } + if (count($newBankingResult) > 0) { + $filteredBankingResult = array(); + $b = 0; + for ($a = 0; $a <= count($newBankingResult); $a++) { + if ($newBankingResult[$a]['account_name'] == $fetchRow['company_details']['company_name'] && $newBankingResult[$a]['str_flag'] == "buiness-company") { + $filteredBankingResult[$b] = $newBankingResult[$a]; + $b++; + } + } + } //forloop ends here. + ?> + Business Banking:'; + if (count($filteredBankingResult) > 0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
    Account NameBank NameAccount TypeAccount VintageOD/CC Limit(Rs)Main Business A/c
    + As per loan applicant, he does not have any business account.

    '; + } + } + ?> + + + 1Product / Service '; + $client_second_row = '2Contact Person '; + $client_third_row = '3Mobile Number '; + $client_fourth_row = '4Landline No'; + $client_fifth_row = '5Payment Terms'; + $client_sixth_row = '6Payment Mode'; + $client_seventh_row = '7No of Days Credit'; + + + // this is for manufacturing + if (array_key_exists('manufacturing_details', $clientRow)) { + + $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] ? $done_on_credit['manufacturing prodcuts'] = $clientRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['manufacturing_details'] as $manuRow) { + + if (isset($manuRow['main_raw_materials'])) { + + //$to_no_of_clients += count($manuRow['main_raw_materials']); + + foreach ($manuRow['main_raw_materials'] as $main_raw_material_key => $main_raw_material) { + + if ($main_raw_material['manufacturing_product_name'] != "" || $main_raw_material['manufacturing_product_name'] != null) { + $to_no_of_clients++; + } + //print_r($main_raw_material); + $client_first_row .= '' . $main_raw_material['manufacturing_product_name'] . ''; + + $client_second_row .= isset($main_raw_material['person_title_name_master']) ? '' . $main_raw_material['person_title_name_master'] . ' ' : ''; + $client_second_row .= $main_raw_material['manufacturing_contact_person_name']; + + $client_second_row .= isset($main_raw_material['person_designation']) && $main_raw_material['person_designation'] == 1 ? ' ' . $main_raw_material['other_person_designation'] : ' '; // + + $client_second_row .= isset($main_raw_material['person_designation_master']) && $main_raw_material['person_designation'] != 1 ? $main_raw_material['person_designation_master'] : ''; + + $client_second_row .= ' ' . $main_raw_material['manufacturing_client_name'] . ''; + + $client_third_row .= '' . ($main_raw_material['manufacturing_contact_person_mobile_number'] ? $main_raw_material['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $main_raw_material['person_stdcode'] && $main_raw_material['person_landline'] ? '' . $main_raw_material['person_stdcode'] . ' ' . $main_raw_material['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($main_raw_material['manufacturing_payment_type_master']) && $main_raw_material['manufacturing_payment_type_master'] ? '' . $main_raw_material['manufacturing_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $main_raw_material['manufacturing_payment_mode'] ? '' . $main_raw_material['manufacturing_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $main_raw_material['manufacturing_credit_days_from'] && $main_raw_material['manufacturing_credit_days_to'] ? '' . $main_raw_material['manufacturing_credit_days_from'] . ' to ' . $main_raw_material['manufacturing_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + + // this is for trading + if (array_key_exists('trade_details', $clientRow)) { + $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] ? $done_on_credit['trading products'] = $clientRow['trade_details'][0]['trading_products_total_payments_percent_on_credit'] : ''; + foreach ($clientRow['trade_details'] as $tradeRow) { + + if (isset($tradeRow['trading_products'])) { + + //$to_no_of_clients += count($tradeRow['trading_products']); + + foreach ($tradeRow['trading_products'] as $trading_product_key => $trading_product) { + + if ($trading_product['trade_product_name'] != "" || $trading_product['trade_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $trading_product['trade_product_name'] . ''; + + $client_second_row .= isset($trading_product['person_title_name_master']) ? '' . $trading_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $trading_product['trade_product_contact_person_name']; + + $client_second_row .= isset($trading_product['person_designation']) && $trading_product['person_designation'] == 1 ? ' ' . $trading_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($trading_product['person_designation_master']) & $trading_product['person_designation'] != 1 ? $trading_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $trading_product['trade_client_name'] . ''; + + $client_third_row .= '' . ($trading_product['trade_product_contact_person_mobile_number'] ? $trading_product['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $trading_product['person_stdcode'] && $trading_product['person_landline'] ? '' . $trading_product['person_stdcode'] . ' ' . $trading_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= isset($trading_product['trade_product_payment_type_master']) ? '' . $trading_product['trade_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $trading_product['trade_product_payment_mode'] ? '' . $trading_product['trade_product_payment_mode'] . '' : 'NA';; + + $client_seventh_row .= $trading_product['trade_product_credit_days_from'] && $trading_product['trade_product_credit_days_to'] ? '' . $trading_product['trade_product_credit_days_from'] . ' to ' . $trading_product['trade_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + + //this is for service + if (array_key_exists('service_provider_details', $clientRow)) { + + $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] ? $done_on_credit['service providing'] = $clientRow['service_provider_details'][0]['service_products_total_payments_percent_on_credit'] : ''; + + foreach ($clientRow['service_provider_details'] as $serviceRow) { + + if (isset($serviceRow['service_products'])) { + + //$to_no_of_clients += count($serviceRow['service_products']); + foreach ($serviceRow['service_products'] as $service_product_key => $service_product) { + + if ($service_product['service_provider_product_name'] != "" || $service_product['service_provider_product_name'] != null) { + $to_no_of_clients++; + } + $client_first_row .= '' . $service_product['service_provider_product_name'] . ''; + + $client_second_row .= isset($service_product['person_title_name_master']) ? '' . $service_product['person_title_name_master'] . ' ' : ''; + $client_second_row .= $service_product['service_provider_product_contact_person_name']; + + $client_second_row .= isset($service_product['person_designation']) && $service_product['person_designation'] == 1 ? ' ' . $service_product['other_person_designation'] : ' '; // + + $client_second_row .= isset($service_product['person_designation_master']) && $service_product['person_designation'] != 1 ? $service_product['person_designation_master'] : ''; + + $client_second_row .= ' ' . $service_product['service_provider_client_name'] . ''; + + $client_third_row .= '' . ($service_product['service_provider_product_contact_person_mobile_number'] ? $service_product['service_provider_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $client_fourth_row .= $service_product['person_stdcode'] && $service_product['person_landline'] ? '' . $service_product['person_stdcode'] . ' ' . $service_product['person_landline'] . '' : '' . 'Not Provided' . ''; + + $client_fifth_row .= $service_product['service_provider_product_payment_type_master'] ? '' . $service_product['service_provider_product_payment_type_master'] . '' : 'NA'; + + $client_sixth_row .= $service_product['service_provider_product_payment_mode'] ? '' . $service_product['service_provider_product_payment_mode'] . '' : 'NA'; + + $client_seventh_row .= $service_product['service_provider_product_credit_days_from'] && $service_product['service_provider_product_credit_days_to'] ? '' . $service_product['service_provider_product_credit_days_from'] . ' to ' . $service_product['service_provider_product_credit_days_to'] . ' days' . '' : ' NIL '; + } + } + } + } + } + + + + $client_first_row .= ''; + $client_second_row .= ''; + $client_third_row .= ''; + $client_fourth_row .= ''; + $client_fifth_row .= ''; + $client_sixth_row .= ''; + $client_seventh_row .= ''; + //echo $client_third_row; + ?> + + Client Details'; + if ($is_client_details_available != null) { + + + + + ?> + + + + + + + + Client $i"; + } ?> + + + + + + + + + + + + + + + + +
    Sr.NoParticulars
    + $value) { + if (count($temp)) { + foreach ($temp as $tk => $tvalue) { + $value == $tvalue ? $all_same = true : $all_same = false; + array_push($temp, $value); + } + } else { + array_push($temp, $value); + } + } + + if ($all_same || count($done_on_credit) == 1) { + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $vals[0] . "% is done on credit.

    "; + } else { + $activities = ''; + foreach ($done_on_credit as $dkey => $dvalue) { + $activities .= $dkey . ' ' . $dvalue . '%, '; + } + $activities = substr_replace($activities, ' ', -2); + $activities = substr_replace($activities, ' and ', strripos($activities, ','), 2); + + echo "

    Out of total sales done by " . $name_of_the_company . ", " . $activities . "are done on credit.

    "; + } + } + + + //CLient Photo Section + // $client_photo_count = $pd_images[2]; + // $client_img_row_count = ceil(count($client_photo_count) / 3); + + // if(count($client_photo_count)){ + // // echo '
    '; + // // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // // echo '
    '; + // echo ''; + + // $client_from_index_increment = 0; + // for($img_row = 1; $img_row <= $client_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $client_from_index_increment; + // $to = ($from + 2); + // for($client_photo_iter = $from; $client_photo_iter <= $to;$client_photo_iter++) + // { + + // if(isset($client_photo_count[$client_photo_iter]) &&$client_photo_count[$client_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $client_from_index_increment = $client_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // } + ?> + ' . $client_form_remarks . '

    '; + } // ENd of client info available in this current index + ?> + + + + + + + 1Item Purchased '; + $supplier_second_row = '2Contact Person '; + $supplier_third_row = '3Mobile Number '; + $supplier_fourth_row = '4Landline No'; + $supplier_fifth_row = '5Payment Terms'; + $supplier_sixth_row = '6Payment Mode'; + $supplier_seventh_row = '7No of Days Credit'; + + if (isset($pd_processed_forms[1][$business_count])) { + + $supplier_details = $pd_processed_forms[1][$business_count]; + $supplierRow = json_decode($supplier_details['processed_json'], true); + //print_r($supplierRow); + $supplier_form_remarks = (isset($supplierRow['supplier_info_form_remark']) ? $supplierRow['supplier_info_form_remark'] : ''); + + if (isset($supplierRow['supplier_info_available']) && $supplierRow['supplier_info_available'] == 1) { + $is_supplier_details_avaialable = 1; + $company_name_for_supplier_form_dispaly = MYUTIL::findCompanyName($all_company_details, $supplierRow['company_id'], 1); + //$supplierResult['company_name'] = $company_name; + $total_no_of_suppliers = 0; + $total_payments_percent_on_credit_for_supplier = 0; + + + foreach ($supplierRow['manufacturing_details'] as $manuRow) { + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit']) ? $supplierRow['manufacturing_details'][0]['main_raw_materials_total_payments_percent_on_credit'] : 0; + + if (isset($manuRow['main_raw_materials'])) { + + + foreach ($manuRow['main_raw_materials'] as $rawkey => $raw) { + + if ($raw['manufacturing_raw_material_name'] != "" || $raw['manufacturing_raw_material_name'] != null) { + $total_no_of_suppliers++; + } + $supplier_first_row .= '' . $raw['manufacturing_raw_material_name'] . ''; + + $supplier_second_row .= isset($raw['person_title_name_master']) ? '' . $raw['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $raw['manufacturing_contact_person_name']; + + $supplier_second_row .= isset($raw['person_designation']) && $raw['person_designation'] == 1 ? ' ' . $raw['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($raw['person_designation_master']) && $raw['person_designation'] != 1 ? $raw['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $raw['manufacturing_supplier_name'] . ''; + + $supplier_third_row .= '' . ($raw['manufacturing_contact_person_mobile_number'] ? $raw['manufacturing_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $raw['person_stdcode'] && $raw['person_landline'] ? '' . $raw['person_stdcode'] . ' ' . $raw['person_landline'] . '' : '' . 'Not Provided' . ''; + + + + $supplier_fifth_row .= $raw['manufacturing_payment_type_master'] ? '' . $raw['manufacturing_payment_type_master'] . '' : 'NA'; + + + + $supplier_sixth_row .= $raw['manufacturing_payment_mode'] ? '' . $raw['manufacturing_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $raw['manufacturing_credit_days_from'] && $raw['manufacturing_credit_days_to'] ? '' . $raw['manufacturing_credit_days_from'] . ' to ' . $raw['manufacturing_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + } + } + } + // this is for trading + //print_r($supplierRow['trade_details'][0]['trading_products']); + if (isset($supplierRow['trade_details'][0]['trading_products']) && count($supplierRow['trade_details'][0]['trading_products'])) { + $total_payments_percent_on_credit_for_supplier += $supplierRow['trade_details'][0]['trading_products_total_payments_percent_on_credit']; + foreach ($supplierRow['trade_details'][0]['trading_products'] as $tradeRow) { + + if ($tradeRow['trade_product_name'] != "" || $tradeRow['trade_product_name'] != null) { + $total_no_of_suppliers++; + } + + + + + + + $supplier_first_row .= '' . $tradeRow['trade_product_name'] . ''; + $supplier_second_row .= isset($tradeRow['person_title_name_master']) ? '' . $tradeRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $tradeRow['trade_product_contact_person_name']; + + $supplier_second_row .= isset($tradeRow['person_designation']) && $tradeRow['person_designation'] == 1 ? ' ' . $tradeRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($tradeRow['person_designation_master']) && $tradeRow['person_designation'] != 1 ? $tradeRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $tradeRow['trade_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($tradeRow['trade_product_contact_person_mobile_number'] ? $tradeRow['trade_product_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + + + $supplier_fourth_row .= $tradeRow['person_stdcode'] && $tradeRow['person_landline'] ? '' . $tradeRow['person_stdcode'] . ' ' . $tradeRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + + $supplier_fifth_row .= isset($tradeRow['trade_product_payment_type_master']) ? '' . $tradeRow['trade_product_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $tradeRow['trade_product_payment_mode'] ? '' . $tradeRow['trade_product_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $tradeRow['trade_product_credit_days_from'] && $tradeRow['trade_product_credit_days_to'] ? '' . $tradeRow['trade_product_credit_days_from'] . ' to ' . $tradeRow['trade_product_credit_days_to'] . ' days' : 'NA'; + ///array_push($supplierResult,$temp); + + //} + //} + + } + } + + if (isset($supplierRow['servicing_details'][0]['service_providers']) && count($supplierRow['servicing_details'][0]['service_providers'])) { + + $total_payments_percent_on_credit_for_supplier += isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + //echo isset($supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit']) ? $supplierRow['servicing_details'][0]['service_providers_total_payments_percent_on_credit'] : 0; + + foreach ($supplierRow['servicing_details'][0]['service_providers'] as $serviceRow) { + + + if ($serviceRow['service_provider_name'] != "" || $serviceRow['service_provider_name'] != null) { + $total_no_of_suppliers++; + } + + $supplier_first_row .= '' . $serviceRow['service_provider_name'] . ''; + + + $supplier_second_row .= isset($serviceRow['person_title_name_master']) ? '' . $serviceRow['person_title_name_master'] . ' ' : '' . ''; + $supplier_second_row .= $serviceRow['service_provider_contact_person_name']; + + $supplier_second_row .= isset($serviceRow['person_designation']) && $serviceRow['person_designation'] == 1 ? ' ' . $serviceRow['other_person_designation'] : ' '; // + + $supplier_second_row .= isset($serviceRow['person_designation_master']) && $serviceRow['person_designation'] != 1 ? $serviceRow['person_designation_master'] : ''; + + $supplier_second_row .= ' ' . $serviceRow['service_provider_supplier_name'] . ''; + //$supplier_second_row .= $supplier_second_row; + + $supplier_third_row .= '' . ($serviceRow['service_provider_contact_person_mobile_number'] ? $serviceRow['service_provider_contact_person_mobile_number'] . '' : 'Not Provided' . ''); + + $supplier_fourth_row .= $serviceRow['person_stdcode'] && $serviceRow['person_landline'] ? '' . $serviceRow['person_stdcode'] . ' ' . $serviceRow['person_landline'] . '' : '' . 'Not Provided' . ''; + + $supplier_fifth_row .= isset($serviceRow['service_provider_payment_type_master']) ? '' . $serviceRow['service_provider_payment_type_master'] . '' : 'NA'; + + $supplier_sixth_row .= $serviceRow['service_provider_payment_mode'] ? '' . $serviceRow['service_provider_payment_mode'] . '' : 'NA'; + + $supplier_seventh_row .= $serviceRow['service_provider_credit_days_from'] && $serviceRow['service_provider_credit_days_to'] ? '' . $serviceRow['service_provider_credit_days_from'] . ' to ' . $serviceRow['service_provider_credit_days_to'] . ' days' : 'NA'; + //array_push($supplierResult,$temp); + + //} + } //} + + } + + $supplier_first_row .= ''; + $supplier_second_row .= ''; + $supplier_third_row .= ''; + $supplier_fourth_row .= ''; + $supplier_fifth_row .= ''; + $supplier_sixth_row .= ''; + $supplier_seventh_row .= ''; + } + // echo "dsfnsdkfnj**********"; + // print_r($supplierResult);// + + + + echo '

    Supplier Details

    '; + if ($is_supplier_details_avaialable != null) { + ?> + + + $fetchRow){ + //echo '
    Supplier '.($k+1).':

    '; + ?> + + + + + + + + Supplier $i"; + } ?> + + + + + + + +
    Sr.NoParticulars
    + '; + // echo '

    Supplier '.($k+1).' Photograph`s :

    '; + // echo '
    '; + // echo ''; + + // $supplier_from_index_increment = 0; + // for($img_row = 1; $img_row <= $supplier_img_row_count; $img_row++) + // { + + // echo ''; + // $from = $supplier_from_index_increment; + // $to = ($from + 2); + // for($supplier_photo_iter = $from; $supplier_photo_iter <= $to;$supplier_photo_iter++) + // { + + // if(isset($supplier_photo_count[$supplier_photo_iter]) &&$supplier_photo_count[$supplier_photo_iter]['company_id'] == ($business_count+1)) + // { + // echo ''; + // //unset($stock_photo_count[$stock_photo_iter]); + // } + + // } + // //echo "


    "; + // echo ''; + // $supplier_from_index_increment = $supplier_from_index_increment + 3; + // } + // //echo ''; + // echo '
    '; + // echo ''; + // echo '
    '; + // }*/ + + + //End of Supplier Photo section + + //}//End of supplier foreach + ?> + + 0) { + //$company_name = MYUTIL::findCompanyName($all_company_details,$supplierRow['company_id'],1); + echo "

    Out of total purchases done by " . $company_name_for_supplier_form_dispaly . ", " . $total_payments_percent_on_credit_for_supplier . " % is done on credit.

    "; //in advance rest on delivery. + } + } + echo '

    ' . $supplier_form_remarks . '

    '; + } // End of supplier info avilable in this current index + ?> + + + + + + 0 || (is_array($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stockRow['manufacturing_details'][0]['manufacturing_finished_goods']) > 0)) { + + $is_raw_materials_sufficient_enough = $stockRow['manufacturing_details'][0]['is_sufficiant_raw']; + $is_raw_materials_sufficient_enough_remarks = $stockRow['manufacturing_details'][0]['rawmaterial_remarks']; + $bindStockResult["manufacturing"] = Stockform::getStockManufacturingDetails($stockRow['manufacturing_details'][0]['manufacturing_raw_materials'], $stockRow['manufacturing_details'][0]['manufacturing_finished_goods']); + //print_r($bindStockResult["manufacturing"]); + } else { + $bindStockResult["manufacturing"] = array(); + } + // this is for stock retail details + if (count($stockRow['retail_details'][0]['retail_traded_goods']) > 0) { + $bindStockResult["retail"] = Stockform::getStockRetailDetails($stockRow['retail_details'][0]['retail_traded_goods']); + } else { + $bindStockResult["retail"] = array(); + } + // this is for stock whole sale details + if (count($stockRow['trade_details'][0]['trading_traded_goods']) > 0) { + $bindStockResult["wholesale"] = Stockform::getStockWholesaleDetails($stockRow['trade_details'][0]['trading_traded_goods']); + } else { + $bindStockResult["wholesale"] = array(); + } + + // this is for stock service details + //print_r($stockRow['servicing_details']); + if (count($stockRow['servicing_details'][0]['service_provider']) > 0) { + $bindStockResult["service_stocks"] = Stockform::getStockServiceDetails($stockRow['servicing_details'][0]['service_provider']); + } else { + $bindStockResult["service_stocks"] = array(); + } + //print_r($bindStockResult);die(); + count($bindStockResult['wholesale']) || count($bindStockResult['retail']) || count($bindStockResult['manufacturing']) || count($bindStockResult["service_stocks"]) ? array_push($stockResult, $bindStockResult) : array(); + //echo "**********************"; + //print_r($stockResult);die(); + ?> + +

    Stock Details

    + +

    + + + + + + + + + + + + + 0) { + foreach ($getstRow['manufacturing'] as $pstRow) { + if ($pstRow['name']) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Sr.NoType of StockStock ItemStock Value (Rs)Stock Quantity
    + Considering the size of operations, the stock of finished goods maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_stock_sufficient_enough,'no')){ + // echo '

    Considering the size of operations, the stock of finished goods maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_stock_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_stock_sufficient_enough,'not applicable')) + // { + // echo '

    Finished goods Stock not required to be maintained.

    '; + // } + + // if(!strcasecmp($is_raw_materials_sufficient_enough,'yes')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_raw_materials_sufficient_enough,'no')) + // { + // echo '

    Considering the size of operations, the stock of raw materials maintained is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $is_raw_materials_sufficient_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_raw_materials_sufficient_enough,'not applicable')) + // { + // echo '

    Raw material Stock not required to be maintained.

    '; + // } + + // //serivce + // if(!strcasecmp($is_sufficiant_service_goods,'yes')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is sufficient as per the PD Officer’s observations.

    '; + // }else if(!strcasecmp($is_sufficiant_service_goods,'no')) + // { + // echo '

    Considering the size of operations, the stock maintained for service providing is not sufficient as per the PD Officer’s observations.

    '; + // echo '

    '. $service_goods_enough_remarks.'

    '; + // } + // else if(!strcasecmp($is_sufficiant_service_goods,'not applicable')) + // { + // echo '

    Stock not required to be maintained.

    '; + // } + //echo '

    '.$stock_remarks.'

    '; + + + $stock_photo_count = array_filter($pd_images[11], function ($d) use ($business_count) { + if ($d['company_id'] == ($business_count + 1)) { + return 1; + } else { + return 0; + } + }); + //echo 'stock_photo_count - ' . count($stock_photo_count); + $stock_img_row_count = ceil(count($stock_photo_count) / 3); + if (count($stock_photo_count)) { + echo '
    '; + echo '

    Stock Photograph`s :

    '; + echo '
    '; + echo ''; + + for ($img_row = 0; $img_row < $stock_img_row_count; $img_row++) { + // if($img_row > 0) { break; } + echo ''; + $from = $img_row == 0 ? $img_row : ($img_row + 2); + $to = ($from + 2); + for ($stock_photo_iter = $from; $stock_photo_iter <= $to; $stock_photo_iter++) { + + if (isset($stock_photo_count[$stock_photo_iter]) && $stock_photo_count[$stock_photo_iter]['company_id'] == ($business_count + 1)) { + echo ''; + //unset($stock_photo_count[$stock_photo_iter]); + } + } + //echo "


    "; + echo ''; + } + //echo ''; + echo '
    '; + echo ''; + echo '
    '; + } + // + ?> + + + ' . $stock_form_remarks . '

    '; + //else { + ?> + + + + + + + + +

    Future Plan and Business Environment

    + + + + + + + + + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + + ?> + +
    ParticularsDetails
    USP of the business (How applicant’s business is different from others in the business)' . $future_plan_business_environment['usp_of_the_business'] . '
    Future plan for business expansion' . $future_plan_business_environment['future_plans_for_business_expansion'] . '
    Impact of GST on business' . $future_plan_business_environment['impact_of_gst_on_the_business'] . '
    Key competitors in the business' . $future_plan_business_environment['key_competitors'] . '
    Succession Plan for business' . $future_plan_business_environment['succession_plan'] . '
    Brief of other group concerns/ Business run by the applicant' . $future_plan_business_environment['brief_of_other_group_concerns_or_businesses_run_by_the_applicants'] . '
    + '; + echo '

    ' . $future_plan_business_environment['remarks'] . '

    '; + } + } + + ?> + + + + + + Assessed Income - " . MYUTIL::findCompanyName($all_company_details, ($business_count + 1), 1) . ""; + if (isset($ai_core_details) && count($ai_summary_details_processed)) { + echo '

    ' . $order_dipaly_array[0] . ') Financial Snapshot

    '; + echo ''; + echo ''; + echo $ai_summary_details_processed['ai_table_header_row']; + echo ''; + echo ''; + echo $ai_summary_details_processed['sale_revenue_row']; + echo $ai_summary_details_processed['purchase_row']; + echo $ai_summary_details_processed['gross_profit_loss_row']; + echo $ai_summary_details_processed['gross_profit_loss_per_row']; + echo $ai_summary_details_processed['business_expense_row']; + echo $ai_summary_details_processed['net_profit_loss_row']; + echo $ai_summary_details_processed['house_hold_expense_row']; + echo $ai_summary_details_processed['disposable_income_row']; + echo $ai_summary_details_processed['net_margin_row']; + + echo ''; + echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + array_shift($order_dipaly_array); + } + + + echo '

    '; + //die(); + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '

    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // } + // array_shift($order_dipaly_array); + // echo '

    Detail Available on Annexure A'; + // } + + + // if(isset($ai_core_details) && count($ai_core_details['sales_items_by_monthwise'])) + // { + // echo "
    "; + // echo '

    '.$order_dipaly_array[0].') Kuchha Sales Book/Bills :

    '; + // foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise) + // { + // // if($sale_month_wise['sales_type'] == 1) + // // { + // echo '
    '; + // echo 'Item name : ' . $sale_month_wise['sales_item'].'
    '; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''.$sale_month_wise['month_count'].' month sales value : '.$rupee_symbol.''.MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']).' Annual Sales value:'.$rupee_symbol.'' .MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']) )).''; + // } + // else + // { + // echo 'Annual Sales value:'. $rupee_symbol.' '.MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] )).''; + // } + // echo '
    '; + // $row_count = ceil(count($sale_month_wise['months']) / 5); + // //print_r(($sale_month_wise['months'])); + // // echo $row_count; + // //die(); + // echo ''; + + // for($i = 0; $i <= $row_count; $i++) + // { + // $from = $i== 0 ? $i : ($i + 3); + // $to = ($from + 3); + // echo ''; + // for($j = $from ; $j <= $to ;$j++) + // { + // //$sale_month_wise['months'] as $sale_month_data + // //echo ''; + // if(isset($sale_month_wise['months'][$j])) + // { + // echo ''; + // } + // } + // echo ''; + // } + // echo '
    '; + // echo ''; + // echo ''; + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // }else if($sale_month_wise['months'][$j]['sales_type'] == 2) + // { + // echo ''; + // } + // echo ''; + + // echo ''; + + // foreach($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) + // { + // if($sale_month_wise['sales_type'] == 1) + // { + // echo ''; + // } + // if($m_key == 20)break; + // else if($sale_month_wise['sales_type'] == 2) + // { + // echo ''; + // } + // } + // echo ''; + + // echo '
    '.$sale_month_wise['months'][$j]['month_to_dispaly'].'
    Date Value
    Frequncy Value
    '.$month['date'] .' '.$month['value'] .'
    '.$month['frequency_name'] .' '.$month['frequency_value'] .'
    '; + // echo '
    '; + // echo '
    '; + + // //} + // } + + // array_shift($order_dipaly_array); + // } + + + $GLOBALS['is_kuccha_records_available'] = null; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + echo '

    ' . $order_dipaly_array[0] . ') Sales Itemwise :

    '; + echo ''; + echo ''; + echo $ai_core_details_processed['sales_calculated_by_itemwise_header']; + echo ''; + echo ''; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sid) { + //print_r($sid); + if ($sid['sales_type'] == 3) { + $GLOBALS['is_kuccha_records_available'] = true; + } + $rate_per_unit = ($sid['rate_per_unit'] != 0 && $sid['rate_per_unit'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['rate_per_unit']) : '-'); + echo ''; + echo ''; + if (isset($sid['margin_per'])) { + echo ''; + } + // if(isset($sid['margin_per_uom'])){echo ''; } + if (isset($sid['margin_final_value'])) { + echo ''; + } + + echo ''; + } + echo ''; + echo '
    ' . ($sid['other_sales_item'] != '' ? $sid['other_sales_item'] : $sid['sale_item']) . '' . $sid['sales_qty'] . '' . $sid['uom'] . '' . $rate_per_unit . '' . $sid['frequency'] . '' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['annual_sale_value']) . ($sid['sales_type'] == 3 ? ' *' : '') . '' . ($sid['margin_per'] != 0 ? $sid['margin_per'] : '-') . ''.($sid['margin_per_uom'] != 0? $sid['margin_per_uom'] : '-').'' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($sid['margin_final_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if ($GLOBALS['is_kuccha_records_available']) { + echo '
    * Assessed From Kuchha Records, Details Available in Annexure A'; + } + + + if (isset($ai_core_details) && count($ai_core_details['sales_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Sales Declared By Customer

    '; + + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) + // { + // echo '

    As per person met, the following Purchase details were shared:

    '; + // } + // else if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + // } + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['sales_declared_by_customer']) . ' ) declared as annual sale value.'; + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + $str .= '
    and ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' ( ' . MYUTIL::numtowords($ai_core_details['sales_declared_by_customer'][0]['margin_value']) . ' )' . '( ' . $ai_core_details['sales_declared_by_customer'][0]['margin_per'] . '% sales declared ) as net margin amount.'; + } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1) { + echo '

    As per person met, the following Purchase details were shared:

    '; + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) { + echo '

    As per person met, Purchase details were not shared, income calculated by Net margin percentage.

    '; + } + + echo '
    '; + if (isset($ai_core_details) && count($ai_core_details['purchase_declared_by_customer'])) { + + echo '

    ' . $order_dipaly_array[0] . ') Purchase Declared By Customer

    '; + + + + + $str = 'As per person met, ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ( ' . MYUTIL::numtowords($ai_core_details['purchase_declared_by_customer'][0]['purchase_declared_by_customer']) . ' ) declared as annual purchase value.'; + // if($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 2) + // { + // $str .= '
    and '.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($ai_core_details['sales_declared_by_customer'][0]['margin_value']).' ( '.MYUTIL::numtowords( $ai_core_details['sales_declared_by_customer'][0]['margin_value']).' )'.'( '.$ai_core_details['sales_declared_by_customer'][0]['margin_per'].'% sales declared ) as net margin amount.'; + // } + + echo $str; + echo '


    '; + array_shift($order_dipaly_array); + } + + + + if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 1) { + echo '

    ' . $order_dipaly_array[0] . ') Itemwise Purchase Details :

    '; + + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($ai_core_details_processed['purchase_to_display'] as $dat) { + $rate = $dat['rate'] != 0 && $dat['rate'] != '' ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['rate']) : '-'; + echo ''; + } + echo ''; + + echo '
    Raw Material/Trading Item Purchase Quantity UOM Rate/Unit of Purchase Frequency Annual Purchase(Rs)
    ' . $dat['material_name'] . ' ' . $dat['qty'] . ' ' . $dat['uom'] . ' ' . $rate . ' ' . $dat['frequency'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($dat['annual_value']) . '
    '; + array_shift($order_dipaly_array); + } else if ($ai_core_details['gross_profit_calculation_type'][0]['mode'] == 1 && $ai_core_details['gross_profit_calculation_type'][0]['purchase_type'] == 2) { + echo '

    ' . $order_dipaly_array[0] . ') Billwise Purchase Details :

    '; + foreach ($ai_core_details_processed['purchase_to_display'] as $billwise) { + echo '
    '; + echo 'Item name : ' . $billwise['item_name'] . '
    '; + echo '' . $billwise['month_count'] . ' month(s) purchase value : ' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value']) . ' Annual Purchase value:' . MYUTIL::customIndianNumberFormat($billwise['annual_purchase_value'] * (12 / $billwise['month_count'])) . ''; + echo '
    '; + foreach ($billwise['months'] as $month_data) { + //echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + foreach ($month_data['month_data'] as $month) { + echo ''; + } + echo ''; + + echo '
    ' . $month_data['month_to_dispaly'] . '
    Date Value
    ' . $month['date'] . ' ' . $month['value'] . '
    '; + //echo '
    '; + } + echo '
    '; + } + array_shift($order_dipaly_array); + } + } + + // + if (isset($ai_core_details) && count($ai_core_details['business_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Business Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['business_expenses_to_diaplay'] as $b_exp) { + if ($b_exp['expense_value'] != 0) { + echo ''; + } + } + echo ''; + echo '
    Business Expense Amount Frequency Annual Expenses
    ' . $b_exp['expense_item'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['expense_value']) . ' ' . $b_exp['frequency_name'] . ' ' . $rupee_symbol . " " . MYUTIL::customIndianNumberFormat($b_exp['annual_expenses_value']) . '
    '; + array_shift($order_dipaly_array); + } + + if (isset($ai_core_details) && count($ai_core_details['house_hold_expenses'])) { + echo '

    ' . $order_dipaly_array[0] . ') Household Expenses Details :

    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($ai_core_details_processed['household_expenses_to_diaplay'] as $h_exp) { + echo ''; + } + echo ''; + echo '
    Expense Particulars Amount (Rs) Frequency Annual Expenses(Rs)
    ' . $h_exp['expense_item'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['expense_value']) . ' ' . $h_exp['frequency_name'] . ' ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($h_exp['annual_expense_value']) . '
    '; + array_shift($order_dipaly_array); + } + + + // if(isset($ai_core_details) && count($ai_summary_details_processed)) + // { + // echo '

    The Summary of Income :

    '; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['ai_table_header_row']; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['sale_revenue_row']; + // echo $ai_summary_details_processed['purchase_row']; + // echo $ai_summary_details_processed['gross_profit_loss_row']; + // echo $ai_summary_details_processed['business_expense_row']; + // echo $ai_summary_details_processed['net_profit_loss_row']; + // echo $ai_summary_details_processed['house_hold_expense_row']; + // echo $ai_summary_details_processed['disposable_income_row']; + // echo $ai_summary_details_processed['net_margin_row']; + + // echo ''; + // echo '
    '; + + // echo '
    '; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo ''; + // echo $ai_summary_details_processed['considered_sales_revenue_row']; + // echo $ai_summary_details_processed['considered_net_profit_row']; + // echo $ai_summary_details_processed['considered_net_margint_row']; + // echo ''; + // echo '
    Particulars Details
    '; + // } + // echo "
    "; + // + + ?> + + + + + + + + + + $oaRow) { + $otherAssetRow = json_decode($oaRow['processed_json'], true); + //print_r($otherAssetRow);die(); + $other_assest_common_remrks = $otherAssetRow['assets_form_remark']; + if (isset($otherAssetRow['asset_info_available']) && $otherAssetRow['asset_info_available'] == 1) { + $is_personal_info_available = 1; + + if (count($otherAssetRow['assets_details']) > 0) { + $otherAssetResult = ASSETSFORM::getOthersAssetsDetails($otherAssetRow['assets_details'], $pd_master_details[0]['pd_id']); + + //print_r($otherAssetResult); + } + } +} +?> + +

    Personal Assets

    + + + + + + + + + + + + + + + $paRow) { + ?> + + + + + + + + + + + +
    Sr.NoAsset TypeAsset DescriptionAsset Owned ByApprox Market Value(Rs)Age of the Assest Again Assest
    ' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : (($paRow['approximate_market_value'] != '' && $paRow['approximate_market_value'] != 0 ? $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat($paRow['approximate_market_value']) : 'Not Provided')); ?>
    + +

    As per Loan applicant, he does not have any other assets.

    +' . $other_assest_common_remrks . '

    '; +} + +?> + + + $ibRow) { + $individualBankRow = json_decode($ibRow['processed_json'], true); + $ind_banking_common_remarks = $individualBankRow['banking_form_remark']; + if (isset($individualBankRow['bank_info_available_business']) && $individualBankRow['bank_info_available_business'] == 1) { + // $is_personal_banking_available = 1; + if (count($individualBankRow['business_details']) > 0) { + $getBuinessEachValues = BANKINGFORM::getNewBuinessBankingDetails($individualBankRow['business_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getBuinessEachValues); + } + } + if (isset($individualBankRow['bank_info_available']) && $individualBankRow['bank_info_available'] == 1) { + if (count($individualBankRow['banking_details']) > 0) { + $getIndividualEachValues = BANKINGFORM::getIndividualBankingDetails($individualBankRow['banking_details'], $pd_master_details[0]['pd_id']); + $bankingResult = array_merge($bankingResult, $getIndividualEachValues); + } + } +} +if (count($bankingResult) > 0) { + $filteredPersonalBankingResult = array(); + $x = 0; + for ($y = 0; $y < count($bankingResult); $y++) { + if ($bankingResult[$y]['str_flag'] !== "buiness-company") { + $filteredPersonalBankingResult[$x] = $bankingResult[$y]; + $x++; + } + if ($bankingResult[$y]['same_ac_used_for'] == "Business") { + $stmt_flag++; + } + } +} + + +?> +

    Personal Banking Details:

    + 0) { ?> +

    Below bank account details were shared :

    + + + + + + + + + + + + + + + $bdRow) { + ?> + + + + + + + + + + + + +
    Sr.NoAccount Holder's NameBank NameAccount TypeOD / CC LimitVintage
    + 0) { + echo '

    The personal banking is done through same account used for business banking

    '; +} +if ($ind_banking_common_remarks != '') { + echo '

    ' . $ind_banking_common_remarks . '

    '; +} +if (count($filteredPersonalBankingResult) == 0) { + echo '

    As per loan applicant, he does not have any personal account

    '; +} ?> + + + + + + + $iRow) { + $otherIcomeRow = json_decode($iRow['processed_json'], true); + $other_source_income_common_remarks = $otherIcomeRow['otherincome_remarks']; + //print_r($otherIcomeRow);die(); + + if (strtoupper($otherIcomeRow['other_income']) == 'YES' && count($otherIcomeRow['income_details']) > 0) { + $is_other_income_available = 1; + $otherIncomeResult = OTHERINCOMEFORM::getIncomeDetails($otherIcomeRow['income_details'], $pd_master_details[0]['pd_id']); + } +} +?> +
    +

    Other Sources of Income of Individual Applicants:

    + + + + + + + + + + + + + + $oiRow) { + ?> + + + + + + + + + +
    Sr.NoIncome SourceEarned byAmount(Rs)
    (Details Available in Annexure B)'; + $GLOBALS['is_rental_available'] = 1; + } ?>
    + +

    As per the loan applicants, they do not have any other source of Income.

    +' . $other_source_income_common_remarks . '

    '; +} + +?> + + + + + $fRow) { + $familyRow = json_decode($fRow['processed_json'], true); + //print_r($familyRow);die(); + $other_family_form_common_remarks = $familyRow['family_details_form_remark']; + if (array_key_exists('family_details', $familyRow) && count($familyRow['family_details']) > 0) { + $familyResult = OTHERFAMILYFORM::getFamilyDetails($familyRow['family_details'], $pd_master_details[0]['pd_id']); + } +} +?> + +

    Family Information:

    + 0) { + //print_r($familyResult); +?> + + + $fmValue) { ?> + + ' . $fmValue['selected_person_title'] . $fmValue['selected_person'] . 'Family Information - Select person for capturing family details, who is an applicant in the case, resides at ' . $fmValue['residency_address'] . 'Family Information - Residence Address of Select person .'; + + $residence_text = 'This is a ' . $fmValue['residence_ownership'] . ' Family Information - Ownership of Residence residence, where the applicant has been staying for ' . $fmValue['residence_No_of_years'] . 'Family Information - No of Yrs in current residence .'; + $residence_text .= (!strcasecmp($fmValue['residence_ownership'], 'rented')) ? ' The rent paid ' . $rupee_symbol . ' ' . $fmValue['rent'] . ' per month.' : ''; + + echo '

    ' . $intro_text . '

    '; + echo '

    ' . $residence_text . '

    '; + + ?> + + +

    The table below provides details of other family members of

    + + + + + + + + + + + + + $fmRow) { + ?> + + + + + + + + + + +
    Sr.NoNameRelationAgeEarning StatusOccupation Details
    + ' . $text . '

    '; + } + } ?> + +

    Other Family Members is not available.

    +' . $other_family_form_common_remarks . '

    '; +} + +?> + + + + + + $elRow) { + $otherLoanRow = json_decode($elRow['processed_json'], true); + $existing_loan_form_common_remarks = $otherLoanRow['currentloan_remarks']; + $is_all_loan_details_availble = 'yes'; + $out_standing_loan_info = array(); + if (array_key_exists('loan_info_available', $otherLoanRow)) { + $is_all_loan_details_availble = $otherLoanRow['loan_info_available']; + } + $total_no_of_data = 0; + if (strtoupper($otherLoanRow['existing_loan']) == 'YES' && (!strcasecmp($is_all_loan_details_availble, 'yes') && count($otherLoanRow['loan_details']) > 0)) { + $is_existing_loans_available = 1; + $total_no_of_data = count($otherLoanRow['loan_details']); + $existLoanResult = FINANCIALFORM::getOtherLoanDetails($otherLoanRow['loan_details'], $pd_master_details[0]['pd_id']); + } else if (!strcasecmp($is_all_loan_details_availble, 'no')) { + $out_standing_loan_info['tot_running_loans'] = $otherLoanRow['tot_running_loans']; + $out_standing_loan_info['tot_emi_paid'] = $otherLoanRow['tot_emi_paid']; + $out_standing_loan_info['tot_outstanding_loans'] = $otherLoanRow['tot_outstanding_loans']; + } +} +?> +
    +

    Existing loan obligation

    + + + + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. +

    + $single_table) { + //print_r($single_table);die(); + + if (is_numeric($table_key)) { + ?> + + + + + Loan $pre_loan_no"; + } ?> + + + + + + +
    Particulars
    +
    + + The table below lists the details of Existing Loan Obligations of the Loan Applicants. + + + + + + + + + + + + + + + +
    Total No of Running LoansTotal Outstanding AmountTotal EMI being Paid (Monthly)
    + + +

    As per loan applicant he does not have any existing loan obligations.

    + +' . $existing_loan_form_common_remarks . '

    '; +} +?> + + + + + + + + + + +'; +echo '

    Credit Manager`s Specific Queries:

    '; +//echo '
    '; +if (isset($credit_officier_specific_queries['additional_requirements_processed']) && count($credit_officier_specific_queries['additional_requirements_processed'])) { + + + foreach ($credit_officier_specific_queries['additional_requirements_processed'] as $key => $value) { + echo 'Question - ' . $value['question'] . '
    '; + echo 'Answer - ' . $value['answer']; + echo '

    '; + } +} else { + echo 'There are no specific queries raised by Credit Manager.'; +} + +echo '
    '; +echo '

    Document to be photographed/scanned:

    '; +// +if (isset($credit_officier_specific_queries['docs_to_be_sighted_processed']) && count($credit_officier_specific_queries['docs_to_be_sighted_processed'])) { + + + foreach ($credit_officier_specific_queries['docs_to_be_sighted_processed'] as $doc_key => $doc_value) { + echo 'Document Required : ' . $doc_value['doc_name'] . '
    '; + echo 'Provided ( Yes / No ) : ' . ($doc_value['ans'] == 'yes' ? 'YES, Document available in zipped file enclosed with report' . '
    ' : 'NO
    '); + if ($doc_value['ans'] != 'yes') { + echo 'Reason : ' . $doc_value['reason']; + } + echo '

    '; + } +} else { + echo 'There are no specific documents to be collect.'; +} + +if (isset($credit_officier_specific_queries['covid_section']) && isset($credit_officier_specific_queries['covid_section']['question_info']) && count($credit_officier_specific_queries['covid_section']['question_info'])) { + echo '
    '; + echo '

    Queries related to Covid-19:

    '; + + foreach ($credit_officier_specific_queries['covid_section']['question_info'] as $covid_key => $covid_value) { + if (isset($covid_value['is_subfield']) && !$covid_value['is_subfield']) { + echo 'Question : ' . $covid_value['question'] . '
    '; + $temp_answer = $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (($covid_value['type'] == 1 || $covid_value['type'] == 9) && ($covid_value['field_type'] == 'str&numtoword' || $covid_value['field_type'] == 'num' || $covid_value['field_type'] == 'numtoword') && is_numeric($temp_answer)) { + $temp_answer = MYUTIL::customIndianNumberFormat($temp_answer) . ' (' . MYUTIL::numtowords($temp_answer) . ')'; + } + echo 'Answer : ' . $temp_answer . '
    '; + $sub_field_key = $covid_value['question_key'] . '_' . $credit_officier_specific_queries['covid_section'][$covid_value['question_key']]; + if (isset($credit_officier_specific_queries['covid_section'][$sub_field_key])) { + echo 'Reason/Description : ' . $credit_officier_specific_queries['covid_section'][$sub_field_key] . '
    '; + } + + echo '
    '; + } + } +} + +//} + +?> + + + + +
    +
    +

    PD OFFICER`S REMARKS ON CUSTOMER BEHAVIOUR & OVERALL PD STATUS

    + +
    + + '; + echo '

    Personal feedback or market intelligence on the case (if any):

    '; + echo '

    ' . $final_remark_data['market_intelligence'] . '

    '; + echo '
    '; + //echo '
    '; + } + ?> +
      +
    • Customer Behaviour:
    • + +

      + + ✔'; + ?> + + + + + + + + +
      +
      Polite
      +
      +
      +
      Rude
      +
      +
      +
      Others*
      +
      +
      +
      +
      '; + } ?> + + + +
      +
    • PD Officer’s overall assessment:
    • +

      + + + + + + + + + + + + + + + + +
      +
      Positive
      +
      +
      +
      Refer to Credit
      +
      +
      +
      Negative
      +
      +
      +
      Others*
      +
      +
      +
      + +
    +
    + + +

    PD officer recommendation is ' . $fo_diplay . '.

    '; ?> +

    The following key points were considered while arriving at the aforementioned status.

    +"; + foreach ($final_remark_data['recommendation_positive'] as $pos) { + echo "
  • " . $pos['reason_for_positive'] . "
  • "; + } + } else if ($negative) { + echo "
      "; + foreach ($final_remark_data['recommendation_negative'] as $neg) { + echo "
    • " . $neg['reason_for_negative'] . "
    • "; + } + } else if ($refer_to_credit) { + echo "
        "; + foreach ($final_remark_data['recommendation_refer_to_credit'] as $rtc) { + echo "
      • " . $rtc['reason_for_refer_to_credit'] . "
      • "; + } + } + echo "
      "; +?> +" . $other_command_remark . "

      "; + } + + echo '

      ' . $pd_officer_final_remark . '

      ' +?> + + + + + + 0) { + for ($business_count = 0; $business_count < $total_no_of_business; $business_count++) { + if (is_array($assessed_income_details) && count($assessed_income_details) && isset($assessed_income_details[($business_count + 1)]) && count($ai_core_details['sales_calculated_by_itemwise']) && $GLOBALS['is_kuccha_records_available']) { + echo '
      '; + echo '

      Annexure A

      '; + if (isset($ai_core_details) && count($ai_core_details['sales_calculated_by_itemwise'])) { + //echo "
      "; + echo '

      Kuchha Sales Book/Bills Details:

      '; + //print_r($ai_core_details_processed['sales_item_wise_to_diaplay']);//die(); + foreach ($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sale_month_wise) { + + //echo '
      '; + if ($sale_month_wise['sales_type'] == 3 || $sale_month_wise['sales_type'] == 2) { + //print_r($sale_month_wise);//die(); + echo 'Item name : ' . $sale_month_wise['sale_item'] . '
      '; + if ($sale_month_wise['sales_type'] == 3) { + echo '' . $sale_month_wise['month_count'] . ' month sales value : ' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat($sale_month_wise['total_months_value']) . ' Annual Sales value:' . $rupee_symbol . '' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'] * (12 / $sale_month_wise['month_count']))) . ' (i.e. ' . (12 / $sale_month_wise['month_count']) . ' * ' . $sale_month_wise['total_months_value'] . ')'; + } else { + echo 'Annual Sales value:' . $rupee_symbol . ' ' . MYUTIL::customIndianNumberFormat(($sale_month_wise['total_months_value'])) . ''; + } + echo '
      '; + echo '
      '; + $row_count = ceil(count($sale_month_wise['months']) / 5); + //print_r(($sale_month_wise['months'])); + // echo $row_count; + //die(); + echo '
      '; + + for ($i = 0; $i <= $row_count; $i++) { + $from = $i == 0 ? $i : ($i + 3); + $to = ($from + 3); + //echo ''; + for ($j = $from; $j <= $to; $j++) { + //$sale_month_wise['months'] as $sale_month_data + //echo ''; + if (isset($sale_month_wise['months'][$j])) { + + //print_r($sale_month_wise['months'][$j]) ;die(); + echo '
      '; + //echo ''; + echo '
      '; + echo ''; + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + } else if (($sale_month_wise['sales_type'] == 2)) { + echo ''; + } + echo ''; + + echo ''; + + $month_sub_total = 0; + foreach ($sale_month_wise['months'][$j]['month_data'] as $m_key => $month) { + + if ($sale_month_wise['sales_type'] == 3) { + echo ''; + $month_sub_total += $month['value']; + } + //if($m_key == 20)break; + else if ($sale_month_wise['sales_type'] == 2) { + echo ''; + $month_sub_total += $sale_month_wise['annual_sale_value']; + } + } + echo ''; + $month_sub_total = 0; + echo ''; + + echo '
      ' . $sale_month_wise['months'][$j]['month_to_dispaly'] . '
      Date Value
      Frequncy Value
      ' . $month['date'] . ' ' . $month['value'] . '
      ' . $month['frequency_name'] . ' ' . $month['frequency_value'] . '
      Total ' . MYUTIL::customIndianNumberFormat($month_sub_total) . '
      '; + echo '
      '; + echo '   '; + } + } + //echo ''; + } + echo '
      '; + echo '
      '; + } + } + } + } // end of if AI available in current business count + } //end of total no of business for loop +} +?> + + + + + + $rental_property) { + //echo $rental_property_key; + $current_property = json_decode($rental_property['processed_json'], true); + $rental_data[] = RENTALFORM::getRentalText($current_property); + } + + + if (count($rental_data)) { + echo '
      '; + echo '

      Annexure B : Rental Income Details

      '; + + foreach ($rental_data as $key => $value) { + + echo '
      Property : ' . ($key + 1) . ''; + echo '

      Address of Property : ' . ($value['address_property']) . ''; + echo '

      Type of Property : ' . ($value['type_of_property']) . ''; + echo '

      Name of the Property Owner`s : ' . ($value['property_owners_name']) . ''; + echo '

      Name of the person`s who showing Property : ' . ($value['property_showing_persons_name']) . ''; + echo '

      Property Document Proof Seen : ' . ($value['property_document_proof_visted']) . ''; + if (!strcasecmp($value['property_document_proof_visted'], 'yes')) { + echo '      Type of Property Document Visted : ' . ($value['type_of_document_visited']) . ''; + } + echo '

      Unit Type : ' . ($value['unit_type']) . ''; + echo '

      No of Floors/Units : ' . ($value['no_of_floors']) . ''; + echo '      '; + echo $value['area_coverd'] != "" ? 'Area covered : ' . ($value['area_coverd'] . ' ' . $value['area_uom'] . '') : ''; + + if (isset($value['unit_details']['multistorey']) && count($value['unit_details']['multistorey'])) { + echo '

      Multistorey Details:

      '; + echo ''; + echo ''; + foreach ($value['unit_details']['multistorey'] as $multistorey_key => $multistorey_value) { + echo ''; + } + echo ''; + echo '
      Floor Name No of Units Rent same for
      all Units
      Unit Details Total
      Rent Amount
      ' . $multistorey_value['floor_name'] . ' ' . $multistorey_value['no_units_in_floor'] . '' . $multistorey_value['same_rent'] . '' . $multistorey_value['unit_details'] . '' . $multistorey_value['total_floor_rent'] . '
      Total ' . $rupee_symbol . ' ' . $value['unit_details']['multistorey_over_all_total'] . '
      '; + } + + echo '

      Unit Details:

      '; + foreach ($value['unit_details']['property_core'] as $u_key => $unit_value) { + echo '
      '; + echo $unit_value['unit_name']; + echo ''; + echo $unit_value['header_row']; + echo $unit_value['first_owners_row']; + echo $unit_value['second_lessee_name_row']; + echo $unit_value['third_area_of_unit_row']; + echo $unit_value['fourth_payment_mode_row']; + echo $unit_value['fifth_lease_period_row']; + echo $unit_value['sixth_security_deposit_row']; + echo $unit_value['eigth_current_rent_received_row']; + echo $unit_value['nineth_difference_between_rent_amount_row']; + echo '
      '; + } + + //print_r($value['third_check_details']); + if ($value['third_check_details']['done_third_party_check']) { + echo '
      For property' . ($key + 1) . ' Third Party check was done with ' . $value['third_check_details']['whom_third_party_check_done']; + echo isset($value['third_check_details']['description_third_party_check_done']) ? ' (' . $value['third_check_details']['description_third_party_check_done'] . '). ' : ' '; + if ($value['third_check_details']['rental_rates_third_party_check_done'] != "") { + echo 'Rental rates in the area as per person whom third party check is done is ' . $value['third_check_details']['rental_rates_third_party_check_done']; + } + } else { + + echo '
      For property ' . ($key + 1) . ' Third Party check not done.'; + echo isset($value['third_check_details']['why_third_party_check_not_done']) && $value['third_check_details']['why_third_party_check_not_done'] != "" ? 'Resaon - ' . $value['third_check_details']['why_third_party_check_not_done'] : ''; + } + echo '
      ' . $value['property_remark']; + } + } +} + + +?> + + + + +"; +$footer_lender_stamp = MYUTIL::dispatchDisclaimer($lender_disclaimer, 3); +if (isset($footer_lender_stamp)) { + //$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer,3); + echo '

      '; +} + +$footer_lender_disclaimer = MYUTIL::dispatchDisclaimer($lender_disclaimer, 2); + +if (isset($footer_lender_disclaimer)) { + echo '

      ' . $footer_lender_disclaimer['disclaimer'] . '

      '; +} +echo "

      "; + +// ########################### End disclaimer end ######################################### +?> + + + + + + +
      '; + echo "

      Detailed Score Card Section

      "; + // *** General Section Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['general'] as $key => $general) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['score_band'] . ')'; + $max_span = '(' . $general['l1_weightage'] . '% * ' . $general['l2_weightage'] . '% * ' . $general['max_score_band'] . ')'; + echo '' . ''; + } + + echo ''; + echo '
      General Questions L1(" . $pd_score['general']['otp_done']['l1_weightage'] . "%) L2 Answer Score Attributed Score Max Score
      ' . $question . '' . $general['l2_weightage'] . '%' . $general['answer'] . + '' . $general['score_band'] . '' . $general['attributed_score'] . '
      ' . $span . '
      ' . $general['max_score'] . '
      ' . $max_span . '
      General Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['general']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['general']['max_score'], 2, '.', ',') . '
      '; + + echo '

      '; + + + // *** Asset Caculation Score Table + echo ''; + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + + + echo '
      Asset Value Calculaitons
      Actual Value Of Assets (a)" . number_format($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets'], 2, '.', ',') . "
      Loan Amount (b)" . number_format($pd_score['score_summary']['asset_calculation_details']['loan_amount'], 2, '.', ',') . "
      Avg Expected Value Of Assets (c)" . round($pd_score['score_summary']['asset_calculation_details']['avg_expected_value_of_assets'], 2) . "%
      Expected Value Of Assets (d = c*b)" . number_format($pd_score['score_summary']['asset_calculation_details']['expected_value_of_assets'], 2, '.', ',') . "
      Actual Value Of Assets Percentage (e = (a/b) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['actual_value_of_assets_percentage'], 2) . "%
      Variance (f = ((e-c)/c) * 100)" . round($pd_score['score_summary']['asset_calculation_details']['variance'], 2) . "%
      Score As per Grid" . round($pd_score['score_summary']['asset_calculation_details']['score'], 2) . "
      '; + + echo '


      '; + // *** Final Remarks Questions Score Table + echo ''; + echo ""; + foreach ($pd_score['final_remarks'] as $key => $final_remark) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + + $span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['score_band'] . ')'; + + $max_span = '(' . $final_remark['l1_weightage'] . '% * ' . $final_remark['l2_weightage'] . '% * ' . $final_remark['max_score_band'] . ')'; + + echo '' . ''; + } + + echo ''; + echo '
      Final Remarks Questions L1(" . $pd_score['final_remarks']['pd_officer_recommandations']['l1_weightage'] . "%) L2Answer ScoreAttributed Score Max Score
      ' . $question . '' . $final_remark['l2_weightage'] . '%' . $final_remark['answer'] . '' . $final_remark['score_band'] . '' . $final_remark['attributed_score'] . '
      ' . $span . '
      ' . $final_remark['max_score'] . '
      ' . $max_span . '
      Final Remarks Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['final_remarks']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['final_remarks']['max_score'], 2, '.', ',') . '
      '; + echo '


      '; + + //print_r($pd_score['business']); + echo ''; + + // *** Business Section Questions Score Table + echo ""; + $certificates = array(); + foreach ($pd_score['business'] as $key => $business) { + + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['score_band'] . ')'; + $max_span = '(' . $business['l1_weightage'] . '% * ' . $business['l2_weightage'] . '% * ' . $business['max_score_band'] . ')'; + + if (($key != 'cerificates') && ($key != 'location_suited_for_busienss')) { + echo '' . ''; + } + + if ($key == 'location_suited_for_busienss') { + echo '' . ''; + } + + if ($key == 'cerificates') { + $certificates = $business; + + echo '' . ''; + } + } + + echo ''; + echo '
      Business Questions L1(" . $pd_score['business']['no_of_years_business_run']['l1_weightage'] . "%) L2Answer Score Attributed ScoreMax Score
      ' . $question . '' . $business['l2_weightage'] . '%' . $business['answer'] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      ' . $question . '' . $business['l2_weightage'] . '%' . $address_type_remarks_caption[$business['answer']] . '' . $business['score_band'] . '' . $business['attributed_score'] . '
      ' . $span . '
      ' . $business['max_score'] . '
      ' . $max_span . '
      Certificates ' . round($business['l2_weightage'], 2) . '%' . 'Refer Cert Table' . '' . $business['score_band'] . '' . $business['attributed_score'] . '' . $business['max_score'] . '
      Business Section Sum of Attributed Score | Sum of Max Score ' . number_format($pd_score['score_summary']['business']['actual_score'], 2, '.', ',') . ' ' . number_format($pd_score['score_summary']['business']['max_score'], 2, '.', ',') . '
      '; + + + // *** Business Certificates Score Table + + + echo '

      '; + + echo ""; + echo ""; + $index = 0; + // print_r($certificates); + foreach ($certificates as $key => $cerificate) { + $index++; + if ($index <= 7) { + $question = MYUTIL::findQuestionByKey($score_questions_display, $key); + $span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['score_band'] . ')'; + + $max_span = '(' . $cerificate['l1_weightage'] . '% * ' . $cerificate['l2_weightage'] . '% * ' . $cerificate['max_score_band'] . ')'; + + echo '' . ''; + } + } + echo "
      Business Certificates Answer Score Attributed Score Max Score
      ' . $question . '' . $cerificate['answer'] . '' . $cerificate['score_band'] . '' . round($cerificate['attributed_score'], 3) . '
      ' . $span . '
      ' . round($cerificate['max_score'], 3) . '
      ' . $max_span . '
      "; +} +// ########################### End Of Score Card Section ######################################### + + + + + + +?> + + + + \ No newline at end of file From b371f6493a1aba144816ad3a79cd066c6bc21554 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 22 Sep 2022 18:06:03 +0530 Subject: [PATCH 088/132] PDF and Zip Fixes : ps --- api/application/controllers/PD_Controller.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index bd474cd8..e5b8c114 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -9679,6 +9679,17 @@ class PD_Controller extends REST_Controller if ($smc_lender_id == $current_lender_id && isset($agency_id) && $agency_id != null && $records['is_smc_vendor'] == true) { if (isset($records['vendor_status']) && ($records['vendor_status'] == QC_COMPLETED)) { $fields_to_update['pd_status'] = COMPLETED; //Here vendor_status is (QC_COMPLETED) means i have to update the Normal Status as COMPLETED. + $this->load->helper('smc_creditpd'); + if(isset($records['random_string'])){ + $random_string = $records['random_string']; + }else{ + $random_string = $this->PD_Model->selectCustomRecords(array('random_string'),array('pd_id' => $pd_details['pd_id']),PDTRIGGER); + $random_string = $random_string[0]['random_string'];} + + $ZIP = smc_creditpd::covertSMCImgs2ZIP($records['pd_id'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE ZIP = '.$ZIP); + $PDF = smc_creditpd::covertSMCImgs2PDF($records['pd_id'],$random_string,array(),0); + log_message('ERROR','####COMPLETE SMC IMAGE PDF = '.$PDF); } // else{ $fields_to_update['vendor_status'] = $records['pd_status']; } } From b1af7013ec56884794d6b63886229d17ffe94371 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 22 Sep 2022 21:21:26 +0530 Subject: [PATCH 089/132] FI Report : ps --- .../JSONTOREPORT_FI_OV_DI.php | 5147 ++--------------- .../JSONTOREPORT_FI_OV_SAL.php | 5118 ++-------------- .../report_templates/JSONTOREPORT_FI_RV.php | 5119 ++-------------- 3 files changed, 1369 insertions(+), 14015 deletions(-) diff --git a/api/application/views/report_templates/JSONTOREPORT_FI_OV_DI.php b/api/application/views/report_templates/JSONTOREPORT_FI_OV_DI.php index f2c23dba..194db9cc 100644 --- a/api/application/views/report_templates/JSONTOREPORT_FI_OV_DI.php +++ b/api/application/views/report_templates/JSONTOREPORT_FI_OV_DI.php @@ -55,32 +55,10 @@ defined('BASEPATH') or exit('No direct script access allowed'); /*line-height: 35px;*/ } - .non-editable { background-color: #99ff99; } - .table2 { - border: 1px solid black; - width: 100%; - } - - .table2 td { - border: 1px solid black; - height: 50px; - text-align: center; - } - - .table2 th { - border: 1px solid black; - height: 50px; - text-align: center; - } - - .table2 { - border-collapse: collapse; - } - tfoot { color: #e00201; } @@ -92,35 +70,8 @@ defined('BASEPATH') or exit('No direct script access allowed'); border-collapse: collapse; } - /* ######### Mini Score Card Table Styles######### */ - - .mini_scorecard_table { - width: 100%; - page-break-inside: avoid; - } - - .mini_scorecard_table td, - .mini_scorecard_table th { - - page-break-inside: avoid; - } - - .mini_scorecard_table th { - padding-top: 5px; - padding-bottom: 5px; - text-align: center; - background-color: #0191ed; - color: white; - page-break-inside: avoid; - - } - - /* #########End of Mini Score Card Table Styles######### */ - - /* #########End of Mini Score Card Div Styles######### */ #rcorners_green { - background: #33cc33; padding: 3px; width: 75px; @@ -128,7 +79,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); } #rcorners_red { - background: red; padding: 3px; width: 75px; @@ -136,7 +86,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); } #rcorners_light_green { - background: #99ff66; padding: 3px; width: 75px; @@ -144,7 +93,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); } #rcorners_amber { - background: #ff9900; padding: 3px; width: 75px; @@ -153,11 +101,7 @@ defined('BASEPATH') or exit('No direct script access allowed'); /* #########End of Mini Score Card DIv Styles######### */ - - - /* #########Score Card Table Styles######### */ - .scorecard_table { /* font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/ /*font-family: Merriweather;*/ @@ -234,151 +178,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); /* #########End of Score Card Table Styles######### */ - /* #########Score Card2 Table Styles######### */ - - .scorecard_table2 { - /* font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/ - /*font-family: Merriweather;*/ - border-collapse: collapse; - width: 100%; - - } - - .scorecard_table2 td, - .scorecard_table2 th { - border: 1px solid #000; - padding: 8px; - - - } - - .scorecard_table2 tr:nth-child(even) { - background-color: #f2f2f2; - } - - .scorecard_table2 tr:hover { - background-color: #ddd; - } - - .scorecard_table2 th { - padding-top: 8px; - padding-bottom: 8px; - text-align: center; - background-color: #0191ed; - color: white; - - } - - /* #########End of Score Card2 Table Styles######### */ - - - .customth { - width: 10%; - } - - /* #########billwise Table Styles######### */ - .customtd { - text-align: center; - } - - .customtd_leftalign { - text-align: left; - } - - .customtd_rightalign { - text-align: right; - } - - .billwise_table { - /* font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/ - /*font-family: Merriweather;*/ - border-collapse: collapse; - width: auto; - - } - - .billwise_table td, - .billwise_table th { - border: 1px solid #000; - padding: 4px; - - } - - .billwise_table tr:nth-child(even) { - background-color: #f2f2f2; - } - - .billwise_table tr:hover { - background-color: #ddd; - } - - .billwise_table th { - padding-top: 4px; - padding-bottom: 4px; - text-align: center; - background-color: #0191ed; - color: white; - } - - /* #########billwise Table Styles######### */ - - - /* #########Annexure table ######### */ - - .annexure_table { - /* font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/ - /*font-family: Merriweather;*/ - border-collapse: collapse; - width: auto; - - } - - .annexure_table td, - .annexure_table th { - border: 1px solid #000; - - } - - .annexure_table tr:nth-child(even) { - background-color: #f2f2f2; - } - - .annexure_table tr:hover { - background-color: #ddd; - } - - .annexure_table th { - /*padding-top: 4px;*/ - /*padding-bottom: 4px;*/ - text-align: center; - background-color: #0191ed; - color: white; - } - - /* #########Annexure######### */ - - - .customtd { - text-align: center; - } - - .customtd_leftalign { - text-align: left; - } - - .customtd_rightalign { - text-align: right; - } - - - #boxstyle1 { - box-sizing: border-box; - width: 60px; - height: 20px; - padding: 5px; - border: 2px outset black; - } - #boxstyle2 { box-sizing: border-box; width: 200px; @@ -396,15 +195,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); border: 2px outset black; } - #billwise { - box-sizing: content-box; - /*disply:inline;*/ - width: 100%; - height: auto; - padding: 10px; - border: 1px solid #0191ed; - } - #first_div { width: 150px; height: 25px; @@ -545,20 +335,6 @@ defined('BASEPATH') or exit('No direct script access allowed'); /*margin: 10px;*/ } - .facecrop { - box-sizing: border-box; - } - - .facecrop_row { - display: flex; - } - - /* Create three equal columns that sits next to each other */ - .facecrop_column { - flex: 33.33%; - padding: 5px; - } - /* ######### TOOLTIP CSS END ######### */ diff --git a/api/application/views/report_templates/JSONTOREPORT_RI.php b/api/application/views/report_templates/JSONTOREPORT_RI.php index 3714d300..c15eb7db 100644 --- a/api/application/views/report_templates/JSONTOREPORT_RI.php +++ b/api/application/views/report_templates/JSONTOREPORT_RI.php @@ -4,11 +4,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); ?> - + - - - + +
      +
      +

      Similarty

      +
      +
      + 70% +
      +
      +

      Similarty

      +
      +
      + 55% +
      +
      +

      Similarty

      +
      +
      + 67% +
      +
      +

      Similarty

      +
      +
      + 37 +
      +
      +
      + + + \ No newline at end of file From be034c8d7471abd7d5660448b51a862d6093de26 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 6 Oct 2022 09:35:49 +0530 Subject: [PATCH 101/132] FaceMark alignment fixes : ps --- .../report_templates/JSONTOREPORT_CLIX.php | 26 +++++----- .../JSONTOREPORT_CLIX_SMARTPD.php | 25 +++++----- .../JSONTOREPORT_CLIX_TELE_PD.php | 27 +++++------ .../report_templates/JSONTOREPORT_DI_AI.php | 47 +++++++++++-------- .../JSONTOREPORT_DI_AI_ADDON.php | 14 ++---- .../JSONTOREPORT_DI_AI_SMARTPD.php | 26 +++++----- .../JSONTOREPORT_DI_AI_TELE_PD.php | 8 ++-- .../report_templates/JSONTOREPORT_RI.php | 26 +++++----- .../JSONTOREPORT_RI_SMARTPD.php | 26 +++++----- .../JSONTOREPORT_RI_TELE_PD.php | 26 +++++----- .../report_templates/JSONTOREPORT_SAL.php | 27 +++++------ .../JSONTOREPORT_SAL_SMARTPD.php | 24 +++++----- .../JSONTOREPORT_SAL_TELE_PD.php | 28 +++++------ 13 files changed, 156 insertions(+), 174 deletions(-) diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX.php b/api/application/views/report_templates/JSONTOREPORT_CLIX.php index f780fa32..9b3b1952 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX.php @@ -715,15 +715,10 @@ defined('BASEPATH') OR exit('No direct script access allowed'); } $faceimage_url = array(); - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; } } if(!empty($faceimage_url)){ @@ -749,8 +744,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $notequal_mark ='
      '; $equal_mark ='
      =
      '; for ($i = 0; $i < count($ci); $i++) { - $symbol = ($similarity > 50) ? '

      '.$equal_mark.'

      ': '

      '.$notequal_mark.'

      '; $similarity = round($ci[$i]["Similarity"]); + $symbol = ($similarity > 50) ? '

      '.$equal_mark.'

      ': '

      '.$notequal_mark.'

      '; if ($similarity > 80) { // above 81 green $progress_bar_class = 'rcorners_green'; } else if ($similarity <= 80 && $similarity > 60) { // in between 61 to 80 orange @@ -768,10 +763,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
    '; - echo '

    Similarity - '.$similarity.' % -

    '; - echo '
    '; + echo'
    + Similarity + '.$similarity.' % +
    +
    '; + echo '

    '; } // ########################### End of Percentage Bar Section ######################################### @@ -1140,6 +1137,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); { foreach($pd_images['common_images'] as $com_key => $com_value) { + // if($com_value['image_key'] == 'face_mark'){ array_push($faceimage_url,$com_value['doc_url']);} if($com_value['pd_document_title'] == 'satellite') { $satellite_url = $com_value['doc_url'];break; diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php index 57218b20..029a7781 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX_SMARTPD.php @@ -722,15 +722,10 @@ font-weight: bolder;; } $faceimage_url = array(); - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; } } if(!empty($faceimage_url)){ @@ -756,8 +751,8 @@ font-weight: bolder;; $notequal_mark ='
    '; $equal_mark ='
    =
    '; for ($i = 0; $i < count($ci); $i++) { - $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; $similarity = round($ci[$i]["Similarity"]); + $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; if ($similarity > 80) { // above 81 green $progress_bar_class = 'rcorners_green'; } else if ($similarity <= 80 && $similarity > 60) { // in between 61 to 80 orange @@ -775,10 +770,12 @@ font-weight: bolder;;
    '; - echo '

    Similarity - '.$similarity.' % -

    '; - echo '
    '; + echo'
    + Similarity + '.$similarity.' % +
    +
    '; + echo '

    '; } // ########################### End of Percentage Bar Section ######################################### diff --git a/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php b/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php index d24ba836..1b3e70f7 100644 --- a/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php +++ b/api/application/views/report_templates/JSONTOREPORT_CLIX_TELE_PD.php @@ -716,16 +716,10 @@ defined('BASEPATH') OR exit('No direct script access allowed'); } $faceimage_url = array(); - - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; } } if(!empty($faceimage_url)){ @@ -752,8 +746,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $notequal_mark ='
    '; $equal_mark ='
    =
    '; for ($i = 0; $i < count($ci); $i++) { - $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; $similarity = round($ci[$i]["Similarity"]); + $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; if ($similarity > 80) { // above 81 green $progress_bar_class = 'rcorners_green'; } else if ($similarity <= 80 && $similarity > 60) { // in between 61 to 80 orange @@ -771,10 +765,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
    '; - echo '

    Similarity - '.$similarity.' % -

    '; - echo '
    '; + echo'
    + Similarity + '.$similarity.' % +
    +
    '; + echo '

    '; } // ########################### End of Percentage Bar Section ######################################### @@ -1141,6 +1137,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); { foreach($pd_images['common_images'] as $com_key => $com_value) { + // if($com_value['image_key'] == 'face_mark'){ array_push($faceimage_url,$com_value['doc_url']);} if($com_value['pd_document_title'] == 'satellite') { $satellite_url = $com_value['doc_url'];break; diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php index a13ddc25..5a92f771 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php @@ -718,9 +718,15 @@ if ( isset($pdf) ) { } - // $faceimage_url = ''; $faceimage_url = array(); - // $all_applicant_details + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; + } + } + // $faceimage_url = ''; + // $faceimage_url = array(); // for ($i = 0; $i < count($all_applicant_details); $i++) { // if($all_applicant_details[$j]['facemark_image_generated'] == 1){ // $faceimage_url = $com_value['doc_url']; @@ -730,17 +736,17 @@ if ( isset($pdf) ) { // if(isset($pd_images['common_images']) && count($pd_images['common_images'])) // if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['facemark_image_generated'] == 1 && $pd_master_details[0]['is_face_api_enabled'] == 1) // print_r($pd_images['common_images']);die(); - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } - } - } + // if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) + // { + // foreach($pd_images['common_images'] as $com_key => $com_value) + // { + // if($com_value['pd_document_title'] == 'face_api_result_image') + // { + // // $faceimage_url = $com_value['doc_url'];break; + // array_push($faceimage_url,$com_value['doc_url']); + // } + // } + // } // print_r($faceimage_url);die(); if(!empty($faceimage_url)){ for ($i = 0; $i < count($faceimage_url); $i++) { @@ -765,8 +771,8 @@ if ( isset($pdf) ) { $notequal_mark ='
    '; $equal_mark ='
    =
    '; for ($i = 0; $i < count($ci); $i++) { - $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; $similarity = round($ci[$i]["Similarity"]); + $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; if ($similarity > 80) { // above 81 green $progress_bar_class = 'rcorners_green'; } else if ($similarity <= 80 && $similarity > 60) { // in between 61 to 80 orange @@ -784,10 +790,12 @@ if ( isset($pdf) ) { '; - echo '

    Similarity - '.$similarity.' % -

    '; - echo '
    '; + echo'
    + Similarity + '.$similarity.' % +
    +
    '; + echo '

    '; } // ########################### End of Percentage Bar Section ######################################### @@ -1170,11 +1178,12 @@ if ( isset($pdf) ) { echo '

    '; ?> $com_value) { + // if($com_value['image_key'] == 'face_mark'){ array_push($faceimage_url,$com_value['doc_url']);} if($com_value['pd_document_title'] == 'satellite') { $satellite_url = $com_value['doc_url'];break; diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI_ADDON.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI_ADDON.php index aa4418b8..bf6d91c4 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI_ADDON.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI_ADDON.php @@ -695,15 +695,10 @@ defined('BASEPATH') OR exit('No direct script access allowed'); } $faceimage_url = array(); - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; } } if(!empty($faceimage_url)){ @@ -1370,6 +1365,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); { foreach($pd_images['common_images'] as $com_key => $com_value) { + // if($com_value['image_key'] == 'face_mark'){ array_push($faceimage_url,$com_value['doc_url']);} if($com_value['pd_document_title'] == 'satellite') { $satellite_url = $com_value['doc_url'];break; diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI_SMARTPD.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI_SMARTPD.php index 69d0e059..cd5a2e50 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI_SMARTPD.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI_SMARTPD.php @@ -716,15 +716,10 @@ if ( isset($pdf) ) { } $faceimage_url = array(); - if(isset($pd_images['common_images']) && count($pd_images['common_images']) && $pd_master_details[0]['is_face_api_enabled'] == 1) - { - foreach($pd_images['common_images'] as $com_key => $com_value) - { - if($com_value['pd_document_title'] == 'face_api_result_image') - { - // $faceimage_url = $com_value['doc_url'];break; - array_push($faceimage_url,$com_value['doc_url']); - } + for ($i = 0; $i < count($all_applicant_details); $i++) { + if($all_applicant_details[$j]['facemark_image_generated'] == 1){ + $faceimage_url = $com_value['doc_url']; + break; } } if(!empty($faceimage_url)){ @@ -750,8 +745,8 @@ if ( isset($pdf) ) { $notequal_mark ='
    '; $equal_mark ='
    =
    '; for ($i = 0; $i < count($ci); $i++) { - $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; $similarity = round($ci[$i]["Similarity"]); + $symbol = ($similarity > 50) ? '

    '.$equal_mark.'

    ': '

    '.$notequal_mark.'

    '; if ($similarity > 80) { // above 81 green $progress_bar_class = 'rcorners_green'; } else if ($similarity <= 80 && $similarity > 60) { // in between 61 to 80 orange @@ -769,10 +764,12 @@ if ( isset($pdf) ) { '; - echo '

    Similarity - '.$similarity.' % -

    '; - echo '
    '; + echo'
    + Similarity + '.$similarity.' % +
    +
    '; + echo '

    '; } // ########################### End of Percentage Bar Section ######################################### @@ -1149,6 +1146,7 @@ if ( isset($pdf) ) { { foreach($pd_images['common_images'] as $com_key => $com_value) { + // if($com_value['image_key'] == 'face_mark'){ array_push($faceimage_url,$com_value['doc_url']);} if($com_value['pd_document_title'] == 'satellite') { $satellite_url = $com_value['doc_url'];break; diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI_TELE_PD.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI_TELE_PD.php index 52bacdb6..ebb5eae9 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI_TELE_PD.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI_TELE_PD.php @@ -10,8 +10,8 @@ $loan_word = $pd_master_details[0]['lender_short_name'] != 'CFPL' ? 'Loan' : 'Fa -