templated json : ps

This commit is contained in:
sanjeev 2022-02-24 20:10:49 +05:30
parent a2a363d0c7
commit 026093d21a

View File

@ -1089,26 +1089,50 @@ class Template_Management_Controller extends REST_Controller {
$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);
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")){
$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);
### Don't Delete Because First Requirement..... multiple draft mode and multiple approve mode but when completed means inactive the draft json and approve json
// 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")){
// $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($status == "DRAFT"){
if(count($json_table)>0 && $status == "COMPLETED"){
$this->db->where_in('id',$json_table[0]['id']);
$this->db->set('isactive',0);
$this->db->update(TEMPLATE_JSON_V2);
}
//draft means insert
$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);
$msg = "Sucessfully Inserted";
}else if($status == "APPROVED" || $status == "COMPLETED"){
//status means update
$json_pk_id = $json_table[0]['id'];
$this->db->where('isactive',1);
$this->db->where('id',$json_pk_id);
$this->db->set('is_form_status',$status);
$this->db->update(TEMPLATE_JSON_V2);
$msg = "Sucessfully Updated";
}
$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;
$data['status'] = REST_Controller::HTTP_OK;
$data['json_id'] = $json_pk_id;
$data['msg'] = "Sucessfully Inserted";
$data['msg'] = $msg;
$this->response($data,REST_Controller::HTTP_OK);
}
else