diff --git a/api/application/config/constants.php b/api/application/config/constants.php index bac9e8dc..752e3c48 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -674,5 +674,7 @@ defined('RCM_STATE_MAPPING') OR define('RCM_STATE_MAPPING','t_rcm_state_mapping' defined('AGENCYLIST') OR define('AGENCYLIST','t_smc_agency_list'); +defined('TEMPLATE_JSON_V2') OR define('TEMPLATE_JSON_V2',"m_template_json_v2"); +defined('TEMPLATE_MAP_V2') OR define('TEMPLATE_MAP_V2',"m_template_mapping_v2"); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index c914e2a9..4b7caf8f 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -330,4 +330,8 @@ $route['downloadDataDump'] = 'Request_DataDump_Controller/downloadDataDump2'; $route['getSMCVendorList'] = 'SMC_Credit_PD_Controller/getCityWiseAgency'; $route['getSMCVendorPDOfficersList'] = 'SMC_Credit_PD_Controller/getSMCVendorPDOfficersList'; -$route['getShortenURL'] = 'PD_Controller/getShortenURL'; \ No newline at end of file + +//Template V2 (Dynamical) +$route['getTemplateFormsV2'] = 'Template_Management_Controller/getTemplateFormsV2'; +$route['saveAndUpdateTemplateFormsV2'] = 'Template_Management_Controller/saveTemplateFormsV2'; +// $route['updateTemplateFormsV2'] = 'Template_Management_Controller/updateTemplateFormsV2'; \ No newline at end of file diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index ded1a68c..1ecefd4c 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -11351,60 +11351,6 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() return $pd_details; } - function getShortenURL_get(){ - $url = $this->get('url'); - $this->load->helper('video_grabber_helper'); - $concat_url = "127.0.0.1:5000/sh_url?url=".$url; - // 1 - $client = new \GuzzleHttp\Client(); - $res = $client->get($concat_url,['headers'=>['Content-Type' => 'application/json']]); - if($res && $res->getStatusCode() == 200) - { - $result_data = json_decode($res->getBody()->getContents()); - }else{ - $result_data = array(); - } - // print_r($result_data);die(); - // 2 - // $ch = curl_init(); - // $timeout = 5; - // $headers = array('Content-type: application/json'); - // curl_setopt( $ch,CURLOPT_URL, $concat_url ); - // curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); - // curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); - // curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); - // $result = curl_exec($ch ); - // curl_close( $ch ); - // print_r($result); - // $client = new GuzzleHttp\Client(); - // $res = $client->request('GET',$concat_url); - // echo $res->getStatusCode(); - // // "200" - // echo $res->getHeader('content-type')[0]; - // // 'application/json; charset=utf8' - // echo $res->getBody(); - // {"type":"User"...' - // Send an asynchronous request. - // $request = new \GuzzleHttp\Psr7\Request('GET',$concat_url); - // $promise = $client->sendAsync($request)->then(function ($response) { - // echo 'I completed! ' . $response->getBody(); - // }); - // $promise->wait(); - - if(!empty($result_data) && $result_data->datastatus == 200) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['shorten_url'] = $result_data->data; - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Something Wrong. Try Later!'; - } - $this->response($data,REST_Controller::HTTP_OK); - } function getAdditionalRequirements_get(){ $pdid = $this->get('pdid'); diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 5f940307..74fd23fe 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -893,8 +893,90 @@ class Template_Management_Controller extends REST_Controller { + } + + //Module : Template V2.0 (Dynamic Form Template). + //Get Form Template Details V2.0 : ps 20/12/2021 + public function getTemplateFormsV2_post(){ + $records = $this->post("records"); + $result_array = $this->Template_Management_Model->getTemplateFormsV2($records); + 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 + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Data Available'; + $this->response($data,REST_Controller::HTTP_OK); + + } + } - + //Save and Update Form Template Details V2.0 : ps 20/12/2021 + // "entity_id": "42", + // "product_id": "24", + // "customer_segment_id": "5", + // "json": "{ \"section_id\":\"5\", \"section_name\":\"Address details\", \"onsubmit\":null, \"questions\":[ { \"question\":\"Address at which PD was initiated\", \"question_key\":\"initiated_address\", \"type\":\"7\", \"disable\":false, \"field_width\":\"100\", \"title\":\"Address Details\", \"answers\":true, \"api_properties\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"State\", \"question_key\":\"State_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"STATE\" }, \"fields\":[ \"state_id\", \"name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"City\", \"question_key\":\"City_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfStatesAndCities\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"state_id\" }, \"fields\":[ \"city_id\", \"city_name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Pincode\", \"question_key\":\"Pincode_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfStatesAndCities\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"pincode\" }, \"fields\":[ \"pincode\", \"pincode_id\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Is this the address where PD is done ?\", \"question_key\":\"is_pd_done_on_initiated_address\", \"type\":\"2\", \"disable\":false, \"field_width\":\"100\", \"onchange_properties\": [{ \"purpose\":\"FORM_CTRL\", \"form_controls\":[ { \"insert_index\":\"is_pd_done_on_initiated_address\", \"expression\":\"(String('is_pd_done_on_initiated_address') == String('No'))\", \"value_keys\":[ \"is_pd_done_on_initiated_address\" ], \"questions\":[ { \"question\":\"Reason for change in PD visit address\", \"question_key\":\"end_use\", \"type\":\"1\", \"field_width\":\"100\", \"api_properties\":null, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ ] }, { \"question\":\"Pincode\", \"question_key\":\"Pincode_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"City\", \"question_key\":\"City_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"State\", \"question_key\":\"State_list\", \"type\":\"3\", \"disable\":false, \"field_width\":\"25\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"STATE\" }, \"fields\":[ \"state_id\", \"name\" ] }, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Enter actual PD address\", \"question_key\":\"actual_pd_address\", \"type\":\"1\", \"field_width\":\"100\", \"api_properties\":null, \"answers\":null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ ] } ] } ] }], \"api_properties\":null, \"answers\":[ { \"answer_id\":\"Yes\", \"answer\":\"Yes\" }, { \"answer_id\":\"No\", \"answer\":\"No\" } ], \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Address Type\", \"question_key\":\"Address_Type\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"ADDRESSTYPE\" }, \"fields\":[ \"address_type_id\", \"address_type\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Locality\", \"question_key\":\"Locality\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"LOCALITY\" }, \"fields\":[ \"locality_id\", \"locality_name\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Approach to PD location*\", \"question_key\":\"Approach_to_PD_location\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"PDLOCATIONAPPROACH\" }, \"fields\":[ \"pd_location_approach_id\", \"description\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Comment on Locality\", \"question_key\":\"Comment_on_Locality\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"COMMENTSONLOCALITY\" }, \"fields\":[ \"comments_on_locality_id\", \"rating\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] }, { \"question\":\"Unit of Measurement\", \"question_key\":\"Unit_of_Measurement\", \"type\":\"3\", \"disable\":false, \"field_width\":\"45\", \"api_properties\":{ \"api\":\"getListOfMaster\", \"api_method\":\"POST\", \"params\":{ \"master_name\":\"UOM\" }, \"fields\":[ \"uom_id\", \"name\" ] }, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] },{ \"question\":\"Estimate area of the Residence\", \"question_key\":\"Estimate_area_of_the_Residence\", \"type\":\"1\", \"disable\":false, \"field_width\":\"45\", \"api_properties\": null, \"answers\": null, \"onchange_properties\":null, \"is_repeatable\":null, \"validations\":[ { \"name\":\"required\", \"isactive\":\"1\", \"validator\":\"Validators.required\", \"message\":\"Field Required\", \"value\":null } ] } ] }", + // "form_id": "5" + + public function saveTemplateFormsV2_post(){ + $records = $this->post("records"); + $json = json_encode($records['json'],true); + $fields = array('id'); + $where_condition_array = array('entity_id'=>$records['entity_id'],'product_id'=>$records['product_id'],'customer_segment_id'=>$records['customer_segment_id'],"isactive"=>1); + $mapping_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_MAP_V2); + // print_r($mapping_table);die(); + if(count($mapping_table)>0){ + $map_id = $mapping_table[0]['id']; + //in-active existing Entries here using Map ID and Form ID means + $fields = array('id'); + $where_condition_array = array('map_id'=>$map_id,"form_id"=>$records['form_id'],"isactive"=>1); + $json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2); + if(count($json_table)>0){ + $this->db->where('id',$json_table[0]['id']); + $this->db->set('isactive',0); + $this->db->update(TEMPLATE_JSON_V2); + } + // insert json here. + $fields = array('isactive' => 1,'form_id' => $records['form_id'],'json' => $json,'map_id'=>$map_id); + $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2); + } + else{ + // insert map & its json here. + $fields = array('entity_id'=>$records['entity_id'],'product_id'=>$records['product_id'],'customer_segment_id'=>$records['customer_segment_id'],"isactive"=>1); + $map_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_MAP_V2); + if($map_pk_id){ + $fields = array('isactive' => 1,'form_id' => $records['form_id'],'json' => $json,'map_id'=>$map_pk_id); + $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2); + } + } + + if($json_pk_id) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = "Sucessfully Inserted"; + $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); + } + + } + + //Update Form Template Details V2.0 : ps 20/12/2021 + public function updateTemplateFormsV2_post(){ + + } } \ No newline at end of file diff --git a/api/application/models/Template_Management_Model.php b/api/application/models/Template_Management_Model.php index b3ceca78..d8997fb5 100644 --- a/api/application/models/Template_Management_Model.php +++ b/api/application/models/Template_Management_Model.php @@ -279,4 +279,53 @@ class Template_Management_Model extends SPARQ_Model { } + public function getTemplateFormsV2($records){ + $this->db->SELECT('TEMPLATE_MAP_V2.id, TEMPLATE_MAP_V2.entity_id, TEMPLATE_MAP_V2.product_id, TEMPLATE_MAP_V2.customer_segment_id, TEMPLATE_MAP_V2.isactive,TEMPLATE_JSON_V2.form_id,TEMPLATE_JSON_V2.json'); + $this->db->FROM(TEMPLATE_MAP_V2.' as TEMPLATE_MAP_V2'); + $this->db->JOIN(TEMPLATE_JSON_V2.' as TEMPLATE_JSON_V2','TEMPLATE_MAP_V2.id = TEMPLATE_JSON_V2.map_id','LEFT'); + if(isset($records['entity_id'])) + { + $this->db->WHERE('TEMPLATE_MAP_V2.entity_id',$records['entity_id']); + } + if(isset($records['product_id'])) + { + $this->db->WHERE('TEMPLATE_MAP_V2.product_id',$records['product_id']); + } + if(isset($records['customer_segment_id'])) + { + $this->db->WHERE('TEMPLATE_MAP_V2.customer_segment_id',$records['customer_segment_id']); + } + $result = $this->db->GET()->result_array(); + return $result; + } + + public function saveTemplateMapping($records,$table){ + $this->db->insert($table, $records); + $insert_id = $this->db->insert_id(); + return $insert_id; + } + + + + + public function updateTemplateFormsV2($records){ + // $this->db->SELECT('TEMPLATE_JSON_V2.id, TEMPLATE_JSON_V2.entity_id, TEMPLATE_JSON_V2.product_id, TEMPLATE_JSON_V2.customer_segment_id, TEMPLATE_JSON_V2.isactive,TEMPLATE_MAP_V2.json, TEMPLATE_MAP_V2.form_id'); + // $this->db->FROM(TEMPLATE_JSON_V2.' as TEMPLATE_JSON_V2'); + // $this->db->JOIN(TEMPLATE_MAP_V2.' as TEMPLATE_MAP_V2','TEMPLATE_MAP_V2.map_id = TEMPLATE_JSON_V2.id','LEFT'); + // if(isset($records['entity_id'])) + // { + // $this->db->WHERE('TEMPLATE_JSON_V2.entity_id',$records['entity_id']); + // } + // if(isset($records['product_id'])) + // { + // $this->db->WHERE('TEMPLATE_JSON_V2.product_id',$records['product_id']); + // } + // if(isset($records['customer_segment_id'])) + // { + // $this->db->WHERE('TEMPLATE_JSON_V2.customer_segment_id',$records['customer_segment_id']); + // } + // $result = $this->db->GET()->result_array(); + // return $result; + } + } \ No newline at end of file