diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 5305a046..d68ab6bf 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -1223,16 +1223,18 @@ class Template_Management_Controller extends REST_Controller { $client = ""; $random_string = ""; $api = ""; + $fi_id = ""; 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($this->get('fi_id')) {$fi_id = $this->get('fi_id');} if($pd_id != "" || $pd_id != null) { - $template_details = $this->PD_Model->getTemplateForPDV2($pd_id,$client,$random_string,$api); + $template_details = $this->PD_Model->getTemplateForPDV2($pd_id,$client,$random_string,$api,$fi_id); if(count($template_details)) { $data['dataStatus'] = true; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index cd8f9377..3308f5fb 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -2550,7 +2550,7 @@ class PD_Model extends SPARQ_Model { return $result; } - public function getTemplateForPDV2($pdid,$client,$random_string,$api = 'WEB') + public function getTemplateForPDV2($pdid,$client,$random_string,$api = 'WEB',$fi_id) { $map_id = ""; //Get PD Master Details including Template id @param $pd_id @@ -2559,7 +2559,7 @@ class PD_Model extends SPARQ_Model { $docs_to_be_collected = $this->getDocsToBeCollected($pdid); $over_all_photocount = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid,'isactive' => 1),PDDOCUMENTS); $pd_applicants_detials = $this->getApplicantsDetails($pdid); - if(count($pd_master_detials)){ + if(count($pd_master_detials) && $fi_id == ""){ $this->db->SELECT('TEMPLATE_MAP_V2.id'); $this->db->FROM(TEMPLATE_MAP_V2.' as TEMPLATE_MAP_V2'); $this->db->WHERE('TEMPLATE_MAP_V2.isactive',1); @@ -2574,8 +2574,26 @@ class PD_Model extends SPARQ_Model { return []; // msg = 'There is no Template Registered With Us Please check With TemplateV2 Screen'; } + }else if(!empty($fi_id)){ + $this->db->SELECT('TEMPLATE_MAP_V2.id'); + $this->db->FROM(TEMPLATE_MAP_V2.' as TEMPLATE_MAP_V2'); + $this->db->WHERE('TEMPLATE_MAP_V2.isactive',1); + $this->db->WHERE('TEMPLATE_MAP_V2.fi_type_id',$fi_id); + $row = $this->db->get()->row(); + if (isset($row)) { + $map_id = $row->id; + } else { + $map_id = ""; + return []; + // msg = 'There is no Template Registered With DB because FI PDTYPE'; + } + } + $this->db->SELECT('TEMPLATE_JSON_V2.id as template_id,TEMPLATE_JSON_V2.map_id,TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_order,PDFORMS.pd_form_level_order,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form'); + if($fi_id == ''){ + $this->db->SELECT('PDFORMS.pd_form_name as form_name'); + }else if($fi_id != ""){ + $this->db->SELECT('PDFORMS.pd_form_name,REPLACE(PDFORMS.pd_form_name,"FI ","") as form_name'); } - $this->db->SELECT('TEMPLATE_JSON_V2.id as template_id,TEMPLATE_JSON_V2.map_id,TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_order,PDFORMS.pd_form_level_order,PDFORMS.pd_form_name as form_name,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form'); $this->db->FROM(TEMPLATE_JSON_V2.' as TEMPLATE_JSON_V2'); $this->db->JOIN(PDFORMS.' as PDFORMS','TEMPLATE_JSON_V2.form_id = PDFORMS.pd_form_id','LEFT'); $this->db->WHERE('TEMPLATE_JSON_V2.isactive',1); @@ -2584,10 +2602,13 @@ class PD_Model extends SPARQ_Model { $this->db->ORDER_BY('PDFORMS.pd_form_order'); $template_forms = $this->db->GET()->result_array(); //here Hard-coded - if(count($template_forms) > 0){ + if(count($template_forms) > 0 && $fi_id == ""){ array_push($template_forms,Array('map_id'=>$map_id,'form_id' => '18','pd_form_order' => '2','pd_form_level_order' => '1','form_name' => 'General Information','is_form_disabled'=>0,"template_id"=>null)); array_push($template_forms,Array('map_id'=>$map_id,'form_id' => '26','pd_form_order' => '24','pd_form_level_order' => '1','form_name' => 'Photograph','is_form_disabled'=>0,"template_id"=>null)); } + else if(count($template_forms) > 0 && $fi_id != ""){ + array_push($template_forms,Array('map_id'=>$map_id,'form_id' => '31','pd_form_order' => '5','pd_form_level_order' => '2','form_name' => 'Credit Manager Queries','is_form_disabled'=>0,"template_id"=>null)); + } $buiness_related_form = array(22,14,1,2,11,16); if(!strcasecmp($pd_master_detials[0]['lender_short_name'], 'CLIX')){ array_push($buiness_related_form,21);//buiness banking form id pushed for filter. @@ -2605,6 +2626,7 @@ class PD_Model extends SPARQ_Model { // $template_forms[$i]['is_group_form'] = 0; // } // } + if($fi_id == ""){ for($j=0;$jselectCustomRecords(array('*'),array('fk_pd_id' => $pdid),XTRA_CHECK); - $result_data['salary_check'] = count($sal_check) ? $sal_check[0] : 1; - $sal_flag = is_array($result_data['salary_check']) ? $result_data['salary_check']['flag'] : $result_data['salary_check']; - //echo $pd_master_detials[0]['customer_segment_abbr'].$api.$sal_flag;die(); - if($pd_master_detials[0]['customer_segment_abbr'] == 'SAL' && $api == 'MOB' && $sal_flag == 1) - { - foreach($template_forms as $key => $form) - { - if($form['form_id'] != 18 && $form['form_id'] != 5 && $form['form_id'] != 12) - { - unset($template_forms[$key]) ; - } - else - { - $template_forms[ $key ]['isAnswerable'] = true; - } - } - } - - //change loan form name to facility form name if lender id cFPL - // print_r($pd_master_detials);die(); - if($pd_master_detials[0]['lender_short_name'] == 'CFPL') - { + if($pd_master_detials[0]['fk_pd_type'] != 4){ + //this one get sal case custom check - remove all forms except gen,add, employee + $sal_check = $this->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid),XTRA_CHECK); + $result_data['salary_check'] = count($sal_check) ? $sal_check[0] : 1; + $sal_flag = is_array($result_data['salary_check']) ? $result_data['salary_check']['flag'] : $result_data['salary_check']; + //echo $pd_master_detials[0]['customer_segment_abbr'].$api.$sal_flag;die(); + if($pd_master_detials[0]['customer_segment_abbr'] == 'SAL' && $api == 'MOB' && $sal_flag == 1) + { + foreach($template_forms as $key => $form) + { + if($form['form_id'] != 18 && $form['form_id'] != 5 && $form['form_id'] != 12) + { + unset($template_forms[$key]) ; + } + else + { + $template_forms[ $key ]['isAnswerable'] = true; + } + } + } + //change loan form name to facility form name if lender id cFPL + // print_r($pd_master_detials);die(); + if($pd_master_detials[0]['lender_short_name'] == 'CFPL') + { - foreach ($template_forms as $k => $val) - { - if($val['form_id'] == 10) + foreach ($template_forms as $k => $val) + { + if($val['form_id'] == 10) + { + $template_forms[$k]['form_name'] = 'Facility & Anchor Details Section'; + break; + } + } + } + // print_r($template_forms);die(); + } + $result_data['question_answers'] = array();; + $result_data['counts'] = array(); + if(count($pd_master_detials)) { - $template_forms[$k]['form_name'] = 'Facility & Anchor Details Section'; - break; + $result_data['pdmaster_details'] = $pd_master_detials[0]; } - } - } - // print_r($template_forms);die(); - - $result_data['question_answers'] = array();; - $result_data['counts'] = array(); - if(count($pd_master_detials)) - { - $result_data['pdmaster_details'] = $pd_master_detials[0]; - } - $result_data['pdapplicants_detials'] = $pd_applicants_detials; - if($pd_master_detials[0]['fk_pd_type'] == 2 && !$pd_master_detials[0]['is_vendor_visit_disabled']) + $result_data['pdapplicants_detials'] = $pd_applicants_detials; + if($pd_master_detials[0]['fk_pd_type'] == 2 && !$pd_master_detials[0]['is_vendor_visit_disabled']) { $result_data['vendor_form_status'] = $this->getVendorFormStatus($pdid); } @@ -2844,8 +2866,6 @@ class PD_Model extends SPARQ_Model { // $result_data['template_forms'] = json_decode(json_encode($template_forms), true);//$template_forms; $result_data['template_forms'] = array_values($template_forms); - - return $result_data; }