Changes : ps
This commit is contained in:
parent
e61a932bb0
commit
078f5af917
@ -341,7 +341,7 @@ $route['deleteTemplateV2'] = 'Template_Management_Controller/deleteTemplateV2';
|
||||
$route['loadFullTemplateV2'] = 'Template_Management_Controller/loadFullTemplateV2';
|
||||
$route['formWiseJSONTemplateV2'] = 'Template_Management_Controller/formWiseJSONTemplateV2';
|
||||
$route['disableformV2'] = 'Template_Management_Controller/disableformV2';
|
||||
// $route['questionsV2'] = 'Template_Management_Controller/JSONquestionFilterV2';
|
||||
$route['questionsV2'] = 'Template_Management_Controller/JSONquestionFilterV2';
|
||||
$route['getBuinessGroupForms'] = 'Template_Management_Controller/getBuinessGroupForms';
|
||||
|
||||
$route['PDjson'] = 'PD_Controller/PDjson';
|
||||
|
||||
@ -1027,7 +1027,7 @@ class Template_Management_Controller extends REST_Controller {
|
||||
public function saveTemplateV2_post(){
|
||||
$records = $this->post("records");
|
||||
// print_r($records);die();
|
||||
if( (!isset($records['entity_id'])) && (!isset($records['product_id'])) && (!isset($records['customer_segment_id'])) )
|
||||
if( (!isset($records['entity_id'])) || (!isset($records['product_id'])) || (!isset($records['customer_segment_id'])) )
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
@ -1208,16 +1208,18 @@ class Template_Management_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function disableformV2_get(){
|
||||
if( (!isset($_GET['map_id'])) && (!isset($_GET['form_id'])) )
|
||||
public function disableformV2_post(){
|
||||
$record = $this->post("records");
|
||||
if( (!isset($record['map_id'])) || (!isset($record['form_id'])) || (!isset($record['is_form_disabled'])) )
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'Key Missing! Please Check again both map-id and form-id';
|
||||
$data['msg'] = 'Key Missing! Please Check again map-id,is_form_disabled and form-id';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
} else{
|
||||
$map_id = $_GET['map_id'];
|
||||
$form_id = $_GET['form_id'];
|
||||
$map_id = $record['map_id'];
|
||||
$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);
|
||||
$json_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATE_JSON_V2);
|
||||
@ -1226,16 +1228,21 @@ class Template_Management_Controller extends REST_Controller {
|
||||
// $data['status'] = REST_Controller::HTTP_OK;
|
||||
// $data['json'] = $json_table[0]['json'];
|
||||
// $this->response($data,REST_Controller::HTTP_OK);
|
||||
$res = $this->Template_Management_Model->updateRecords(array('is_form_disabled' => 1),TEMPLATE_JSON_V2,$where_condition_array);
|
||||
$res = $this->Template_Management_Model->updateRecords(array('is_form_disabled' => $is_form_disabled),TEMPLATE_JSON_V2,$where_condition_array);
|
||||
if($res){
|
||||
$fields = array('pd_form_name');
|
||||
$where_condition_array = array("pd_form_id"=>$form_id);
|
||||
$form_table = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,PDFORMS);
|
||||
if($is_form_disabled == 1) $msg = $form_table[0]['pd_form_name'].' Successfully Disabled' ;
|
||||
if($is_form_disabled == 0) $msg = $form_table[0]['pd_form_name'].' Successfully Enabled' ;
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = 'Successfully Disabled';
|
||||
$data['msg'] = $msg;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
||||
$data['msg'] = 'Something Went Wrong! Try again Later';
|
||||
$data['msg'] = 'There is No Changes..';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@ -1312,14 +1319,73 @@ class Template_Management_Controller extends REST_Controller {
|
||||
$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);
|
||||
// print_r($json['questions']);die();
|
||||
$quest = $json['questions'];
|
||||
$filter_arr = array();
|
||||
$key_arr = array();
|
||||
//try 1;
|
||||
// for($i= 0;$i<count($quest);$i++){
|
||||
// array_push($filter_arr,$quest[$i]['question']);
|
||||
// $filter_arr[$i] = $quest[$i]['question'];
|
||||
// $question_key = $quest[$i]['question_key'];
|
||||
// $onchange_properties = $quest[$i]['onchange_properties'];
|
||||
// for($j= 0;$j<count(array($onchange_properties));$j++){
|
||||
// $form_controls = isset($onchange_properties[$j]['form_controls'])?$onchange_properties[$j]['form_controls']:[];
|
||||
// for($k= 0;$k<count($form_controls);$k++){
|
||||
// $question_index = $form_controls[$k]['insert_index'];
|
||||
// if($question_key == $question_index){
|
||||
// $sub_quest = $form_controls[$k]['questions'];
|
||||
// for($l= 0;$l<count($sub_quest);$l++){
|
||||
// // array_push($filter_arr,$sub_quest[$l]['question']);
|
||||
// $filter_arr[$i][$quest[$i]['question']] = $sub_quest[$l]['question'];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//try 2;
|
||||
// $i=0;
|
||||
// if(!empty($quest)){
|
||||
// foreach ($quest as $key => $value) {
|
||||
// // $filter_arr[$i] = $value['question'];
|
||||
// // $key_arr[$i] = $value['question_key'];
|
||||
// $onchange_properties = isset($value['onchange_properties'][0]['form_controls']) ? $value['onchange_properties'][0]['form_controls'] : array();
|
||||
// $count = isset($onchange_properties) ? count($onchange_properties) : 0 ;
|
||||
// if($count>0){
|
||||
// foreach ($onchange_properties as $key1 => $value1) {
|
||||
// // print_r($onchange_properties);
|
||||
// $question_index = $value1['insert_index'];
|
||||
// if($value1['insert_index'] == $value['question_key']){
|
||||
// $sub_quest = $value1['questions'];
|
||||
// $filter_sub_arr = array();
|
||||
// for($l= 0;$l<count($sub_quest);$l++){
|
||||
// // print_r($sub_quest);
|
||||
// array_push($filter_sub_arr,$sub_quest[$l]['question']);
|
||||
// }
|
||||
// if(!empty($filter_sub_arr)){
|
||||
// $filter_arr[] = array($value['question']=>$filter_sub_arr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// $filter_arr[] = $value['question'];
|
||||
// }
|
||||
// // $i++;
|
||||
// }}
|
||||
//try 3;
|
||||
$arr =array();
|
||||
if(!empty($quest)){
|
||||
$a1 = $this->fns1($quest);//filter only question and question_key
|
||||
$arr = $this->fns2($quest,$a1); // filter the onchange;
|
||||
}
|
||||
|
||||
print_r($json['questions']);die();
|
||||
|
||||
if($res){
|
||||
//end
|
||||
if(!empty($arr)){
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['question'] = '';
|
||||
$data['json'] = $json_table;
|
||||
$data['available_question'] = $arr;
|
||||
$data['json'] = $quest;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
@ -1337,4 +1403,74 @@ class Template_Management_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public function Auto($quest){
|
||||
// // return 1;
|
||||
// $return_arr = array();
|
||||
// if(!empty($quest)){
|
||||
// foreach ($quest as $key => $value) {
|
||||
// $return_arr = $value['question'] && $var['question_key'];
|
||||
// }
|
||||
// }
|
||||
// return $return_arr;
|
||||
// }
|
||||
|
||||
public function fns1($quest){
|
||||
// return $key == 'question' && $key == 'question_key';
|
||||
// $new_array = array_filter($quest, function($var) use ($filter){
|
||||
// return ($var['question'] && $var['question_key']);
|
||||
// });
|
||||
// $filtered = array_filter($quest, function($v) { return ($v['question']); });
|
||||
$return_arr = array();
|
||||
$i = 0 ;
|
||||
if(!empty($quest)){
|
||||
foreach ($quest as $key => $value) {
|
||||
$return_arr[$i] = array('question'=> $value['question'],'question_key'=>$value['question_key']);
|
||||
// $return_arr[$i]['question'] = $value['question'];
|
||||
// $return_arr[$i]['question_key'] = $value['question_key'];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $return_arr;
|
||||
}
|
||||
|
||||
public function fns2($quest,$arr1){
|
||||
$arr2 = array();
|
||||
$i = 0;
|
||||
foreach ($quest as $key => $value) {
|
||||
if((isset($value['onchange_properties'])) && (!empty($value['onchange_properties'])) && ($value['onchange_properties'] != null)){
|
||||
$onchange_properties = isset($value['onchange_properties'][0]['form_controls']) ? $value['onchange_properties'][0]['form_controls'] : array();
|
||||
$count = isset($onchange_properties) ? count($onchange_properties) : 0 ;
|
||||
if($count>0 && !empty($onchange_properties)){
|
||||
foreach ($onchange_properties as $key1 => $value1) {
|
||||
if($value1['insert_index'] == $value['question_key']){
|
||||
// $arr2[$i]['child'] = $this->fns1($value1['questions']);
|
||||
$try2 = $this->fns1($value1['questions']);
|
||||
$arr2[$i]['child'] = self::fns2($value1,$try2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// else{}
|
||||
$i++;
|
||||
}
|
||||
// $arr1 = $this->fns1($quest);
|
||||
$final_result = array();
|
||||
foreach($arr1 as $key=>$val){ // Loop though one array
|
||||
if (array_key_exists($key, $arr2))
|
||||
{
|
||||
$val2 = $arr2[$key]; // Get the values from the other array
|
||||
$final_result[$key] = $val + $val2; // combine 'em
|
||||
}
|
||||
else
|
||||
{
|
||||
$final_result[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $final_result;
|
||||
// }
|
||||
// $return_arr = $this->fns1($quest);
|
||||
// return $return_arr;
|
||||
|
||||
}
|
||||
}
|
||||
@ -347,11 +347,12 @@ 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');
|
||||
if(!empty($map_id)){
|
||||
$this->db->SELECT('TEMPLATE_JSON_V2.map_id');
|
||||
$this->db->SELECT('TEMPLATE_JSON_V2.map_id,TEMPLATE_JSON_V2.json');
|
||||
$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.map_id',$map_id);
|
||||
}else{
|
||||
$this->db->SELECT('TEMPLATE_JSON_V2.map_id,PDFORMS.form_template as json');
|
||||
$this->db->FROM(PDFORMS.' as PDFORMS');
|
||||
$this->db->JOIN(TEMPLATE_JSON_V2.' as TEMPLATE_JSON_V2','TEMPLATE_JSON_V2.form_id = PDFORMS.pd_form_id','LEFT');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user