@php // on 25th Sept '21, for ReportType==3 $userdetails = Auth::user(); $LoggedUser = $userdetails->name; $DateFormat = $userdetails->DateFormat; $TimeZone = $userdetails->TimeZone; $TimeFormat = $userdetails->TimeFormat; $GmtOffSet = $userdetails->GmtOffSet; $total_count=count($header); $columns = array(); $loopcount=0; $results_obj = json_decode($results); //echo "
";
    //print_r($GetDropdownLists);
//    print_r($results_obj);
//    echo "
Header:
"; // print_r($header); //echo "
"; foreach($header as $fields) { $grand_total_count=0; foreach ($results_obj as $k) { foreach ($k as $value => $values) { if($value==$fields) { //echo "
$fields
"; @endphp

{{$fields}}

@php $display_value=""; $total_count=0; @endphp
@php foreach($values as $display) { //echo "
Name: $display->Name "; //echo " Count: $display->Count
"; $display_name=$display->Name; $results_dd=array(); $results_dd = multiKeyExists($GetDropdownLists, $display_name); if($display_name!="") { if(is_array($results_dd) && array_key_exists($display_name,$results_dd[0])) $display_value=$results_dd[0][$display_name]; else $display_value=$display_name; // kabali on 22-03-22 } if($display_name!="") { $total_count+=$display->Count; @endphp

{{$display->Count}}

{{$display_value}}
@php } // xtra validation on 29th Sept '21 else if($display_value=="" && $display->Count!=0) { $total_count+=$display->Count; if(is_array($results_dd) && array_key_exists($display_name,$results_dd[0])) $display_value=$results_dd[0][$display_name]; else $display_value=$display_name; // kabali on 22-03-22 //added else statement on 29-03-22 by kabali @endphp

{{$display->Count}}

(EMPTY)
@php } } @endphp

{{$total_count}}

Total

@php } $grand_total_count+=$total_count; } } } @endphp
Total: {{$grand_total_count}}
@php function multiKeyExists(array $arr, $key) { // is in base array? if (array_key_exists($key, $arr)) { $results[] = $arr; return $results; } // check arrays contained in this array foreach ($arr as $element) { if (is_array($element)) { if (multiKeyExists($element, $key)) { //return true; $results[] = $element; return $results; } } } return false; } @endphp