Dynamic template : ps

This commit is contained in:
sanjeev 2022-02-24 16:26:31 +05:30
parent babe069c39
commit a2a363d0c7
2 changed files with 14 additions and 18 deletions

View File

@ -1088,25 +1088,21 @@ class Template_Management_Controller extends REST_Controller {
$fields = array('id');
$status = strtoupper(str_replace(' ', '',$records['form_status']));
$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 && $status == "COMPLETED"){
$this->db->where('id',$json_table[0]['id']);
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
foreach ($json_table as $value) $id_array[] = $value['id'];
if(count($json_table)>0 && $status == "COMPLETED"){
$this->db->where_in('id',$id_array);
$this->db->set('isactive',0);
$this->db->update(TEMPLATE_JSON_V2);
}else if(count($json_table)>0 && ($status == "DRAFT" || $status == "APPROVED" )){
$json = json_encode($records['json'],true);
$this->db->where('id',$json_table[0]['id']);
$this->db->where('map_id',$map_id);
$this->db->where('form_id',$form_id);
$this->db->where('is_form_status',$status);
$this->db->set('json',$json);
$this->db->update(TEMPLATE_JSON_V2);
$json_pk_id = $json_table[0]['id'];
}else{
$json = json_encode($records['json'],true);
$fields = array('form_id' => $form_id,'json' => $json,'map_id'=>$map_id,'is_form_status'=>$status);
$json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
}
}else if(count($json_table)>0 && ($status == "DRAFT" || $status == "APPROVED")){
$this->db->where('is_form_status',"COMPLETED");
$this->db->where_in('id',$id_array);
$this->db->set('isactive',0);
$this->db->update(TEMPLATE_JSON_V2);
}
$json = json_encode($records['json'],true);
$fields = array('form_id' => $form_id,'json' => $json,'map_id'=>$map_id,'is_form_status'=>$status);
$json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
if($json_pk_id)
{
$data['dataStatus'] = true;

View File

@ -314,7 +314,7 @@ class Template_Management_Model extends SPARQ_Model {
}
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');
$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');
$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);