From ac69831c078eb7ba705ab0315aa0a5e21bc4236b Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 20 Sep 2022 23:08:06 +0530 Subject: [PATCH] FI changes 2 : ps --- api/application/config/routes.php | 6 + .../Template_Management_Controller.php | 139 +++++++++++- api/application/models/PD_Model.php | 208 ++++++++++++++++++ 3 files changed, 352 insertions(+), 1 deletion(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 85415d7f..bba26e60 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -340,6 +340,12 @@ $route['disableformV2'] = 'Template_Management_Controller/disableformV2'; $route['questionsV2'] = 'Template_Management_Controller/JSONquestionFilterV2'; $route['getBuinessGroupForms'] = 'Template_Management_Controller/getBuinessGroupFormsV2'; $route['getCompaniesListsForBusinessV2'] = 'PD_Controller/getCompaniesListsFromGeneralFormRawJSONV2'; + +// $route['getFIPDTemplate'] = 'Template_Management_Controller/getFIPDTemplate'; +$route['getFIPDFormsDetails'] = 'Template_Management_Controller/getFIPDFormsDetails'; +$route['FIformWiseTemplate'] = 'Template_Management_Controller/FIformWiseTemplate'; +$route['loadFiTemplate'] = 'Template_Management_Controller/loadFiTemplate'; + ## PDjson developers Testing Purposer $route['PDjson'] = 'PD_Controller/PDjson'; diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index dc14adbb..5ae913e1 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -1268,7 +1268,6 @@ class Template_Management_Controller extends REST_Controller { $map_id = $_GET['map_id']; $form_id = $_GET['form_id']; - $form_id = $_GET['form_id']; $template_id = isset($_GET['template_id'])?$_GET['template_id']:null; $fields = array('id','json'); // if($template_id){$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"is_form_status"=>"COMPLETED","id"=>$template_id);} @@ -1612,4 +1611,142 @@ class Template_Management_Controller extends REST_Controller { $form_template = $this->Template_Management_Model->getBuinessFormTemplate($form_id); return $form_template; } + + public function loadFITemplate_get() + { + $pd_id = ""; + $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->getFITemplateForPD($pd_id, $client, $random_string, $api,$FI_id); + 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); + } + } + + public function FIformWiseTemplate_get(){ + if((!isset($_GET['form_id'])) ) + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Key Missing! Please Check again both form-id'; + $this->response($data,REST_Controller::HTTP_OK); + }else{ + + $form_id = $_GET['form_id']; + $fields = array('pd_form_id','pd_form_name','form_template'); + + $where_condition_array = array("form_id"=>$form_id,'isactive'=>1); + $json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,PDFORMS); + if(count($json_table)>0){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['json'] = $json_table[0]['json']; + $data['template_id'] = $json_table[0]['id']; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'FI-PD JSON Not Available for Given Form ID ! '; + $this->response($data,REST_Controller::HTTP_OK); + } + } + } + + public function getFIPDForms_get() + { + + $PDtype_id = $this->get('pd_type_id'); + $FItype_id = $this->get('fi_id'); + if($PDtype_id == 4){ + if(!empty($FItype_id)){ + // $field_investigation = array(array("field_investigation_id"=> 1,"field_investigation"=> "Office Visit (DI)"),array("field_investigation_id"=> 2,"field_investigation"=> "Office Visit (Sal)"),array("field_investigation_id"=> 3,"field_investigation"=> "Residence Visit")); + if($FItype_id == 1){ + + }else if($FItype_id == 2){ + + }else if($FItype_id == 3){ + + } + + } + else{ + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Field Investigation id is Not available'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + else{ + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Its not a FI PD Type'; + $this->response($data,REST_Controller::HTTP_OK); + } + + $fields = array('form_id'); + $where_condition_array = array('fk_template_id'=>$template_id,'isactive'=>1); + $result_array = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATEFORMS); + //print_r($this->db->last_query()); + $temp = array(); + foreach($result_array as $r) + { + $formid = $r['form_id']; + $temp = array_merge($temp,array($formid)); + } + + if(count($result_array)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $temp; + $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); + + } + + + } } \ No newline at end of file diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index c39b23f6..cd8f9377 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1507,6 +1507,214 @@ class PD_Model extends SPARQ_Model { return $result_data; } + // This pd type 4 only because in template form there is no product and customer segment thats why i can't get data in template table. + public function getFITemplateForPD($pdid,$client,$random_string,$api = 'WEB',$fi_id) + { + + $template_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); + + $FIForm = array(); + if(!empty($fi_id)){ + if($fi_id == 1){ + $FIForm = array(27,28,29,31,32,33,34); + }else if($fi_id == 2){ + $FIForm = array(27,28,29,31,33,34); + }else if($fi_id == 3){ + $FIForm = array(27,28,30,31,33,34); + } + // else{ + + // } + } + $this->db->SELECT('PDFORMS.pd_form_id as form_id,PDFORMS.pd_form_order,PDFORMS.pd_form_level_order,PDFORMS.pd_form_name,REPLACE(PDFORMS.pd_form_name,"FI ","") as form_name'); + $this->db->FROM(PDFORMS.' as PDFORMS'); + $this->db->WHERE_IN('PDFORMS.pd_form_id',$FIForm); + $this->db->ORDER_BY('PDFORMS.pd_form_order'); + $template_forms = $this->db->GET()->result_array(); + $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++;} + } + //make photo section always answerable true + //if($value['form_id'] == 26) + //{ + // $template_forms[$template_key]['isAnswered'] = true; + //} + 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; + } + } + } + } + + + + $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; + $result_data['template_forms'] = array_values($template_forms); + return $result_data; + } public function getAnswersForPD($question_id,$pd_id,$template_id,$category_id) {