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)
+