From a345bb3305b071315cebc0ee4ae2291b0513e726 Mon Sep 17 00:00:00 2001 From: sanjeev Date: Sat, 8 Jan 2022 21:55:01 +0530 Subject: [PATCH] ut-1 quest filter : ps --- .../Template_Management_Controller.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 9ff49ecc..6dac3fb4 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -1319,9 +1319,12 @@ 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); - $quest = $json['questions']; - if($form_id == 19) $quest = $json['questions'][0]['question']; - // ch(1,2,22,20,11,13) + if(isset($value1['questions'][0]['question_key']) ){ + $quest = $json['questions']; + }else{ + $quest = $json['questions'][0]['question']; + } + // re-check (1,2) // done (5,19,14,24,20,22) //ok-but-doubt (13,11) // print_r($quest);die(); $filter_arr = array(); //try 4 @@ -1358,7 +1361,8 @@ class Template_Management_Controller extends REST_Controller { public function call_arr1($quest){ $return_arr = array(); $i = 0 ; - if(!empty($quest)){ + if((!empty($quest)) && (is_array($quest) || is_object($quest)) ) + { foreach ($quest as $key => $value) { // $return_arr[$i] = array('question'=> $value['question'],'question_key'=>$value['question_key']); // $return_arr[$i]['question'] = $value['question']; @@ -1374,7 +1378,7 @@ class Template_Management_Controller extends REST_Controller { public function call_arr2($quest){ $return_arr = array(); $i = 0 ; - if(!empty($quest)){ + if(!empty($quest) && is_array($quest) || is_object($quest)){ 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(); @@ -1382,11 +1386,17 @@ class Template_Management_Controller extends REST_Controller { if($count>0 && !empty($onchange_properties)){ foreach ($onchange_properties as $key1 => $value1) { if($value1['insert_index'] == $value['question_key']){ - $temp[$i] = $this->call_arr1($value1['questions']); - $arr2 = $this->call_arr2($value1['questions']); - // $arr1 = $this->call_arr1($value1['questions']); - // $arr2[$i]['child'] = $this->call_arr2($temp[$i],$arr2); - $return_arr[$i] = $this->merged_arr($temp[$i],$arr2); + if(isset($value1['questions'][0]['question_key'])){ + $temp[$i] = $this->call_arr1($value1['questions']); + $arr2 = $this->call_arr2($value1['questions']); + // $arr1 = $this->call_arr1($value1['questions']); + // $arr2[$i]['child'] = $this->call_arr2($temp[$i],$arr2); + $return_arr[$i] = $this->merged_arr($temp[$i],$arr2); + }else{ + $temp[$i] = $this->call_arr1($value1['questions'][0]['question']); + $arr2 = $this->call_arr2($value1['questions'][0]['question']); + $return_arr[$i] = $this->merged_arr($temp[$i],$arr2); + } // foreach($value1['question'] as $key2 => $value2){ // $temp2[$i] = $this->call_arr1($value2['question']); // $arr3 = $this->call_arr2($value2['question']);