template id Implementation for dyn forms : ps

This commit is contained in:
sanjeev 2022-02-26 22:10:50 +05:30
parent 7fca98f1d7
commit d6dd38398e
3 changed files with 27 additions and 10 deletions

View File

@ -2768,6 +2768,7 @@ public function assignPDTempalate($data)
$records = $this->post('records');
$pdid = $records['pdid'];
$formid = $records['formid'];
$templateid = isset($records['template_id'])?$records['template_id']:null;
$createdby = $records['fk_createdby'];
$company_id = null;
$processed_json = null;
@ -2975,7 +2976,7 @@ public function assignPDTempalate($data)
}
$temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id);
$temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id,'template_id'=>$templateid);
$id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON);

View File

@ -942,13 +942,20 @@ class Template_Management_Controller extends REST_Controller {
foreach($result_array as $inx => $arr)
{
if($arr['map_id'] != null || $arr['map_id'] != ""){
$result_array[$inx]["forms"] = $this->Template_Management_Model->getTemplateFormsV2($arr['map_id']);
$completed_details = $this->Template_Management_Model->getTemplateFormsV2($arr['map_id'],1); ### 1 means completed
$draft_or_approve_details = $this->Template_Management_Model->getTemplateFormsV2($arr['map_id'],2); ### 2 means draft or approved
$details = ((count($completed_details)>0)
?$completed_details
:((count($draft_or_approve_details)>0)
?$draft_or_approve_details
:array()));
$result_array[$inx]["forms"] = $details;
}else{
$result_array[$inx]["forms"] = array();
}
array_push($result_array[$inx]["forms"],array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1","pd_form_order"=>"5"));
array_push($result_array[$inx]["forms"],array("form_id"=> "18","form_name"=> "General Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"2"));
array_push($result_array[$inx]["forms"],array("form_id"=> "26","form_name"=> "Photograph","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"24"));
array_push($result_array[$inx]["forms"],array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1","pd_form_order"=>"5","is_form_status"=>null));
array_push($result_array[$inx]["forms"],array("form_id"=> "18","form_name"=> "General Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"2","is_form_status"=>null));
array_push($result_array[$inx]["forms"],array("form_id"=> "26","form_name"=> "Photograph","json"=> "","is_form_disabled"=> "0","is_business_form"=> "0","is_group_form"=> "0","pd_form_order"=>"24","is_form_status"=>null));
// $buiness_arr = array("form_id"=> "13","form_name"=> "Business Information","json"=> "","is_form_disabled"=> "0","is_business_form"=> "1","is_group_form"=> "1");
// array_push($result_array[$inx]["forms"],$buiness_arr);
}
@ -1226,7 +1233,7 @@ class Template_Management_Controller extends REST_Controller {
$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);
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1,"is_form_status"=>"COMPLETED");
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
if(count($json_table)>0){
$data['dataStatus'] = true;
@ -1257,7 +1264,7 @@ class Template_Management_Controller extends REST_Controller {
$form_id = $record['form_id'];
$is_form_disabled = $record['is_form_disabled'];
$fields = array('id');
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1,"is_form_status"=>"COMPLETED");
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
if(count($json_table)>0){
// $data['dataStatus'] = true;
@ -1354,6 +1361,7 @@ class Template_Management_Controller extends REST_Controller {
// global $global_form_id;
$fields = array('json');
$where_condition_array = array('map_id'=>$map_id,"form_id"=>$form_id,"isactive"=>1);
// "is_form_status"=>
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
if(count($json_table)>0){
$json = json_decode($json_table[0]['json'],true);

View File

@ -313,12 +313,20 @@ class Template_Management_Model extends SPARQ_Model {
return $result;
}
public function getTemplateFormsV2($value){
$this->db->SELECT('TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_name as form_name,TEMPLATE_JSON_V2.json,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form,PDFORMS.pd_form_order,TEMPLATE_JSON_V2.is_form_status');
public function getTemplateFormsV2($value,$flag){
$this->db->SELECT('TEMPLATE_JSON_V2.id as template_id,TEMPLATE_JSON_V2.form_id,PDFORMS.pd_form_name as form_name,TEMPLATE_JSON_V2.json,TEMPLATE_JSON_V2.is_form_disabled,PDFORMS.is_business_form,TEMPLATE_JSON_V2.is_group_form,PDFORMS.pd_form_order,TEMPLATE_JSON_V2.is_form_status');
$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',$value);
if($flag == 1){
$this->db->WHERE('TEMPLATE_JSON_V2.is_form_status',"COMPLETED");
}else if($flag == 2){
// $this->db->WHERE("(TEMPLATE_JSON_V2.is_form_status = 'APPROVED' or TEMPLATE_JSON_V2.is_form_status = 'DRAFT')");
$this->db->WHERE('TEMPLATE_JSON_V2.is_form_status', "APPROVED");
$this->db->OR_WHERE("TEMPLATE_JSON_V2.is_form_status", "DRAFT");
}
$this->db->WHERE('PDFORMS.is_business_form',0);
$this->db->ORDER_BY('PDFORMS.pd_form_order');
$result = $this->db->GET()->result_array();
@ -346,7 +354,7 @@ class Template_Management_Model extends SPARQ_Model {
}
public function getBuinessGroupForms($map_id){
$this->db->SELECT('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->SELECT('TEMPLATE_JSON_V2.id as template_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');
if(!empty($map_id)){
$this->db->SELECT('TEMPLATE_JSON_V2.map_id,TEMPLATE_JSON_V2.json');
$this->db->FROM(TEMPLATE_JSON_V2.' as TEMPLATE_JSON_V2');