templatev2 form displayed issues fixes : ps

This commit is contained in:
VE10-Sanjeev 2022-04-06 23:05:20 +05:30
parent da2db735b5
commit b479e7f99a
2 changed files with 42 additions and 7 deletions

View File

@ -939,6 +939,7 @@ class Template_Management_Controller extends REST_Controller {
$records['customer_segment_id'] = $this->get("customer_segment_id");}
$result_array = $this->Template_Management_Model->getTemplateMappingDetailsV2($records);
// print_r($result_array);die();
if(!empty($result_array))
foreach($result_array as $inx => $arr)
{
@ -1045,6 +1046,7 @@ class Template_Management_Controller extends REST_Controller {
$this->response($data,REST_Controller::HTTP_OK);
}else{
$fields = array('id');
$flag=0;
$where_condition_array = $records;
$where_condition_array['isactive'] = 1;
$map_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_MAP_V2);
@ -1052,19 +1054,34 @@ class Template_Management_Controller extends REST_Controller {
// $this->db->where('id',$map_table[0]['id']);
// $this->db->set('isactive',0);
// $this->db->update(TEMPLATE_MAP_V2);
$map_pk_id = (int)$map_table[0]['id'];
$msg = "Data Already Available For Given Params";
// $map_pk_id = (int)$map_table[0]['id'];
$msg = "Data Already Available For Given Params / MAPID => ".(int)$map_table[0]['id'];
$STScode = REST_Controller::HTTP_ACCEPTED;
$flag++;
}else{
// form Template is declare as gobally in m_pd_forms table @form_template column using CustomerSegmentID.
$form_template = $this->Template_Management_Model->GetFormTemplate($records['customer_segment_id']);
$map_pk_id = $this->Template_Management_Model->saveTemplateMapping($records,TEMPLATE_MAP_V2);
$c = "JSON ID Are =>"; //concate;
for($i=0; $i<count($form_template); $i++){
$template = $form_template[$i]['form_template'];
if($template != null || $template != ""){
$fields = array('form_id' => $form_template[$i]['form_id'],'json' => $template,'map_id'=>$map_pk_id,'is_form_status'=>"DRAFT");
$json_pk_id = $this->Template_Management_Model->saveTemplateMapping($fields,TEMPLATE_JSON_V2);
$c = $c." ".$json_pk_id;
}
}
$msg = "Sucessfully Inserted";
$flag++;
$STScode = REST_Controller::HTTP_CREATED;
}
if($map_pk_id)
if($flag>0)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['map_id'] = $map_pk_id;
$data['status'] = $STScode;
if(isset($map_pk_id)){$data['map_id'] = $map_pk_id;}
if(isset($c)){$data['json_id'] = $c;}
$data['msg'] = $msg;
$this->response($data,REST_Controller::HTTP_OK);
}

View File

@ -310,6 +310,7 @@ class Template_Management_Model extends SPARQ_Model {
}
}
$result = $this->db->GET()->result_array();
// print_r($this->db->last_query());die();
return $result;
}
@ -332,7 +333,7 @@ class Template_Management_Model extends SPARQ_Model {
FROM `m_template_json_v2` as `TEMPLATE_JSON_V2`
LEFT JOIN `m_pd_forms` as `PDFORMS` ON `TEMPLATE_JSON_V2`.`form_id` = `PDFORMS`.`pd_form_id`
WHERE `TEMPLATE_JSON_V2`.`isactive` = 1
AND `TEMPLATE_JSON_V2`.`map_id` = ".$value."
AND `TEMPLATE_JSON_V2`.`id` = ".$value."
AND `PDFORMS`.`is_business_form` = 0
AND
`TEMPLATE_JSON_V2`.`is_form_status` = 'COMPLETED'
@ -341,6 +342,7 @@ class Template_Management_Model extends SPARQ_Model {
or
`TEMPLATE_JSON_V2`.`is_form_status` = 'DRAFT'
ORDER BY `PDFORMS`.`pd_form_order`";
// print_r($sql_query);die();
return $this->db->query($sql_query)->result_array();
}
@ -407,4 +409,20 @@ class Template_Management_Model extends SPARQ_Model {
}
public function getFormTemplate($csID){
// $sql_query = "'DRAFT'";
$sql_query = "SELECT m_template_forms.form_id,m_pd_forms.form_template
FROM m_template_forms
JOIN m_template
on m_template_forms.fk_template_id = m_template.template_id and m_template_forms.isactive = 1
JOIN m_pd_forms
on m_pd_forms.pd_form_id = m_template_forms.form_id and m_pd_forms.isactive = 1
WHERE fk_customer_segment like '%`".$csID."`%' and m_template.isactive = 1 ";
// and form_template != ''";
$result = $this->db->query($sql_query)->result_array();
// print_r($result);
// print_r($sql_query);die();
return $result;
}
}