code committed : ps

This commit is contained in:
sanjeev 2022-03-08 13:02:58 +05:30
parent 0a17993fe6
commit 73a71e5a09

View File

@ -1108,16 +1108,25 @@ class Template_Management_Controller extends REST_Controller {
// $json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
if($status == "DRAFT"){
if(count($json_table)>0 && $status == "COMPLETED"){
if(count($json_table)>0){
if($status == "COMPLETED"){
$this->db->where_in('id',$json_table[0]['id']);
$this->db->set('isactive',0);
$this->db->where('is_form_status',"COMPLETED");
$this->db->update(TEMPLATE_JSON_V2);
}
//draft means insert.
}else{
$json_pk_id = $json_table[0]['id'];
$data = array('json' => json_encode($records['json'],true),'is_form_status' => $status);
$this->db->where('isactive',1);
$this->db->where('id',$json_pk_id);
$this->db->update(TEMPLATE_JSON_V2,$data);
$msg = "Sucessfully Updated";
}
}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);
$msg = "Sucessfully Inserted";
$msg = "Sucessfully Inserted";}
}else if($status == "APPROVED" || $status == "COMPLETED"){
//approve and completed status means just update the status only.
$json_pk_id = $json_table[0]['id'];