Dynamic Template : ps
This commit is contained in:
parent
f6e7dccac2
commit
10a1ec3b39
@ -337,4 +337,6 @@ $route['getTemplateFormsV2'] = 'Template_Management_Controller/getTemplateFormsV
|
||||
$route['saveTemplateMappingDetailsV2'] = 'Template_Management_Controller/saveTemplateV2';
|
||||
$route['saveAndUpdateTemplateFormsV2'] = 'Template_Management_Controller/saveTemplateFormsV2';
|
||||
$route['deleteTemplateV2'] = 'Template_Management_Controller/deleteTemplateV2';
|
||||
// $route['updateTemplateFormsV2'] = 'Template_Management_Controller/updateTemplateFormsV2';
|
||||
// $route['updateTemplateFormsV2'] = 'Template_Management_Controller/updateTemplateFormsV2';
|
||||
$route['loadFullTemplateV2'] = 'Template_Management_Controller/loadFullTemplateV2';
|
||||
$route['formWiseJSONTemplateV2'] = 'Template_Management_Controller/formWiseJSONTemplateV2';
|
||||
@ -17,6 +17,7 @@ class Template_Management_Controller extends REST_Controller {
|
||||
{
|
||||
// Construct the parent class
|
||||
parent::__construct();
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->model('Template_Management_Model');
|
||||
|
||||
}
|
||||
@ -1131,5 +1132,77 @@ class Template_Management_Controller extends REST_Controller {
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
//API 6 :
|
||||
public function loadFullTemplateV2_get()
|
||||
{
|
||||
|
||||
$pd_id = "";
|
||||
$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->getTemplateForPDV2($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
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_BAD_REQUEST;
|
||||
$data['msg'] = 'No Param Available';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
//API 7
|
||||
public function formWiseJSONTemplateV2_get(){
|
||||
|
||||
if( (!isset($_GET['map_id'])) && (!isset($_GET['form_id'])) )
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'Key Missing! Please Check again map-id and form-id';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}else{
|
||||
|
||||
$map_id = $_GET['map_id'];
|
||||
$form_id = $_GET['form_id'];
|
||||
$fields = array('json');
|
||||
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);
|
||||
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
||||
if(count($json_table)>0){
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['json'] = $json_table[0]['json'];
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
||||
$data['msg'] = 'Something Went Wrong! Try again Later';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2328,5 +2328,269 @@ class PD_Model extends SPARQ_Model {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getTemplateForPDV2($pdid,$client,$random_string,$api = 'WEB')
|
||||
{
|
||||
$map_id = "";
|
||||
//Get PD Master Details including Template id @param $pd_id
|
||||
$pd_master_detials = $this->getPDMasterDetails($pdid,$random_string);
|
||||
$pd_additional_requirements = $this->getPDAdditionalRequirements($pdid);
|
||||
$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)){
|
||||
$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.entity_id',$pd_master_detials[0]['fk_lender_id']);
|
||||
$this->db->WHERE('TEMPLATE_MAP_V2.product_id',$pd_master_detials[0]['fk_product_id']);
|
||||
$this->db->WHERE('TEMPLATE_MAP_V2.customer_segment_id',$pd_master_detials[0]['fk_customer_segment']);
|
||||
$row = $this->db->get()->row();
|
||||
if (isset($row)) {
|
||||
$map_id = $row->id;
|
||||
} else {
|
||||
$map_id = "";
|
||||
}
|
||||
}
|
||||
$this->db->SELECT('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');
|
||||
$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);
|
||||
$this->db->WHERE('TEMPLATE_JSON_V2.map_id',$map_id);
|
||||
$this->db->ORDER_BY('PDFORMS.pd_form_order');
|
||||
$template_forms = $this->db->GET()->result_array();
|
||||
|
||||
// print_r($template_forms);die();
|
||||
$level_one_status = 0;
|
||||
$level_one_total = 0;
|
||||
$level_two_status = 0;
|
||||
$level_two_total = 0;
|
||||
|
||||
if($pd_master_detials[0]['is_child'] == 0)
|
||||
{
|
||||
|
||||
//echo "parent";
|
||||
foreach($template_forms as $template_key => $value)
|
||||
{
|
||||
$this->db->SELECT('count(*) as count');
|
||||
$this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON');
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pdid);
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$value['form_id']);
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.isactive',1);
|
||||
$template_forms_count = 0;
|
||||
$template_forms_count = $this->db->GET()->result_array();
|
||||
//if($value['form_id'] == 4){print_r($template_forms_count);}
|
||||
|
||||
if(count($template_forms_count) && $template_forms_count[0]['count'] != 0)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswered'] = true;
|
||||
if($value['pd_form_level_order'] == 1){$level_one_status++; $level_one_total++;}
|
||||
else if($value['pd_form_level_order'] == 2){$level_two_status++; $level_two_total++;}
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_forms[$template_key]['isAnswered'] = false;
|
||||
if($value['pd_form_level_order'] == 1){ $level_one_total++;}
|
||||
else if($value['pd_form_level_order'] == 2){$level_two_total++;}
|
||||
}
|
||||
|
||||
if($value['form_id'] == 26)
|
||||
{
|
||||
if(is_array($over_all_photocount) && count($over_all_photocount) > 1){
|
||||
$template_forms[$template_key]['isAnswered'] = true;
|
||||
}else{
|
||||
$template_forms[$template_key]['isAnswered'] = false;
|
||||
}
|
||||
|
||||
}
|
||||
if($value['pd_form_level_order'] == 1)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
else if($value['pd_form_level_order'] == 2)
|
||||
{
|
||||
if($level_one_status != $level_one_total)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
}
|
||||
else if($value['pd_form_level_order'] == 3)
|
||||
{
|
||||
if($level_two_status != $level_two_total)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else // FOr addtional PD
|
||||
{
|
||||
//echo "child";
|
||||
$parent_forms = $this->config->item('parent_forms');
|
||||
|
||||
foreach($template_forms as $template_key => $value)
|
||||
{
|
||||
$is_answered = 0;
|
||||
$this->db->SELECT('count(*) as count');
|
||||
$this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON');
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pdid);
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$value['form_id']);
|
||||
$this->db->WHERE('PDFORMDETAILSJSON.isactive',1);
|
||||
$template_forms_count = 0;
|
||||
$template_forms_count = $this->db->GET()->result_array();
|
||||
//if($value['form_id'] == 19){ print_r($template_forms_count); }//die();
|
||||
if(count($template_forms_count) && $template_forms_count[0]['count'] != 0)
|
||||
{
|
||||
//echo $value['form_id'];
|
||||
$is_answered = 1;
|
||||
$template_forms[$template_key]['isAnswered'] = true;
|
||||
if($value['pd_form_level_order'] == 1){
|
||||
$level_one_status++;
|
||||
$level_one_total++;}
|
||||
else if($value['pd_form_level_order'] == 2){$level_two_status++; $level_two_total++;}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$template_forms[$template_key]['isAnswered'] = false;
|
||||
|
||||
if($value['pd_form_level_order'] == 1){ $level_one_total++;}
|
||||
else if($value['pd_form_level_order'] == 2){$level_two_total++;}
|
||||
}
|
||||
|
||||
if($value['pd_form_level_order'] == 1)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
else if($value['pd_form_level_order'] == 2)
|
||||
{
|
||||
if($level_one_status != $level_one_total)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
}
|
||||
else if($value['pd_form_level_order'] == 3)
|
||||
{
|
||||
|
||||
if($level_two_status != $level_two_total)
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( array_search($value['form_id'],$parent_forms) )
|
||||
{
|
||||
|
||||
$template_forms[$template_key]['isAnswered'] = true;
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($is_answered == 0)
|
||||
{
|
||||
//echo $value['form_id'];
|
||||
$template_forms[$template_key]['isAnswered'] = false;
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//$template_forms[$template_key]['isAnswered'] = false;
|
||||
$template_forms[$template_key]['isAnswerable'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//FOr smart PD Purpose Filter PD forms
|
||||
if($pd_master_detials[0]['fk_pd_type'] == 2 && $client == 1)
|
||||
{
|
||||
|
||||
//$temp_array = array(3,5,10,13);
|
||||
foreach($template_forms as $key => $form)
|
||||
{
|
||||
if($form['form_id'] != 3 && $form['form_id'] != 5 && $form['form_id'] != 10 && $form['form_id'] != 13)
|
||||
{
|
||||
unset($template_forms[$key]) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//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)
|
||||
{
|
||||
$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))
|
||||
{
|
||||
$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['vendor_form_status'] = $this->getVendorFormStatus($pdid);
|
||||
}
|
||||
|
||||
// $result_data['template_forms'] = json_decode(json_encode($template_forms), true);//$template_forms;
|
||||
$result_data['template_forms'] = array_values($template_forms);
|
||||
|
||||
|
||||
|
||||
return $result_data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user