From c7e1d506f086b91ed2cb28a719d8e7d8ed37be2c Mon Sep 17 00:00:00 2001 From: sanjeev Date: Mon, 10 Jan 2022 10:59:22 +0530 Subject: [PATCH] Supplier question filter done : ps --- .../Template_Management_Controller.php | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index e20d5893..a85ac107 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -1314,6 +1314,8 @@ class Template_Management_Controller extends REST_Controller { }else{ $map_id = $_GET['map_id']; $form_id = $_GET['form_id']; + // Using global keyword + // global $global_form_id; $fields = array('json'); $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); @@ -1329,8 +1331,8 @@ class Template_Management_Controller extends REST_Controller { $filter_arr = array(); //try 4 if(!empty($quest)){ - $arr1 = $this->call_arr1($quest); - $arr2 = $this->call_arr2($quest); + $arr1 = $this->call_arr1($quest,$_GET['form_id']); + $arr2 = $this->call_arr2($quest,$_GET['form_id']); $filter_arr = $this->merged_arr($arr1,$arr2); } @@ -1358,7 +1360,7 @@ class Template_Management_Controller extends REST_Controller { } //Step 1 : Question Filter Only - public function call_arr1($quest){ + public function call_arr1($quest,$fid){ $return_arr = array(); $i = 0 ; if((!empty($quest)) && (is_array($quest) || is_object($quest)) ) @@ -1375,7 +1377,7 @@ class Template_Management_Controller extends REST_Controller { } //Step 2 : Onchange fns - Question Filter - public function call_arr2($quest){ + public function call_arr2($quest,$fid){ $return_arr = array(); $i = 0 ; if(!empty($quest) && is_array($quest) || is_object($quest)){ @@ -1386,16 +1388,24 @@ 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']){ - 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); + if(count($value1['questions']) > 1 && ($fid == 1 || $fid == 2)){ + for($j = 0 ;$j < count($value1['questions']);$j++){ + $temp[$i] = $this->call_arr1($value1['questions'][$j]['question'],$fid); + $arr2 = $this->call_arr2($value1['questions'][$j]['question'],$fid); + $return_arr[$i] = $this->merged_arr($temp[$i],$arr2); + } + }else{ + if(isset($value1['questions'][0]['question_key'])){ + $temp[$i] = $this->call_arr1($value1['questions'],$fid); + $arr2 = $this->call_arr2($value1['questions'],$fid); + // $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'],$fid); + $arr2 = $this->call_arr2($value1['questions'][0]['question'],$fid); + $return_arr[$i] = $this->merged_arr($temp[$i],$arr2); + } } // foreach($value1['question'] as $key2 => $value2){ // $temp2[$i] = $this->call_arr1($value2['question']);