@extends('layouts.main_frontend') @section('title','RCSA - Approval Questionaire') @section('main-content') @php if(count($risks)<1){ $risks = [json_decode(json_encode(['id'=>1,'reference_no'=>'12345']))]; } $matrix = $matrix_data['matrix_labels']; $matrix = $matrix[$matrix_data['matrix_length']]; $matrix_types = [1=>'likelihood',2=>'impact',3=>'control_effectiveness',4=>'control_design']; $matrix_controls = $matrix_data['matrix_layout']['controls']; $matrix_risk = $matrix_data['matrix_layout']['risk']; $matrix_calc = json_decode($matrix_data['matrix_layout']['calc'], true); $thresold = $matrix_data['matrix_layout']['thresold']; $avg_risk_likelyhood = explode(',', $aggregated_rcsa_detail->avg_risk_likelyhood); $avg_risk_impact = explode(',', $aggregated_rcsa_detail->avg_risk_impact); $avg_risk_control_design = explode(',', $aggregated_rcsa_detail->avg_risk_control_design); $avg_risk_control_performance = explode(',', $aggregated_rcsa_detail->avg_risk_control_performance); $avg_risk_perceived = explode(',', $aggregated_rcsa_detail->avg_risk_perceived); $avg_risk_residual = explode(',', $aggregated_rcsa_detail->avg_risk_residual); $avg_risk_residual_likelyhood = explode(',', $aggregated_rcsa_detail->avg_risk_residual_likelyhood); $avg_risk_control = explode(',', $aggregated_rcsa_detail->avg_risk_control); $mergeIR = $mergeCtrl = $mergeResdual = array(); foreach ($avg_risk_likelyhood as $k => $val) { if (!isset($mergeIR[$val][$avg_risk_impact[$k]])) { $mergeIR[$val][$avg_risk_impact[$k]] = 1; } else { $mergeIR[$val][$avg_risk_impact[$k]] += 1; } //$mergeIR[$val][$avg_risk_impact[$k]] = 1; } foreach ($avg_risk_control_design as $c => $ctl) { if (!isset($mergeCtrl[$ctl][$avg_risk_control_performance[$c]])) { $mergeCtrl[$ctl][$avg_risk_control_performance[$c]] = 1; } else { $mergeCtrl[$ctl][$avg_risk_control_performance[$c]] += 1; } //$mergeCtrl[$ctl][$avg_risk_control_performance[$k]] = 1; } foreach ($avg_risk_residual_likelyhood as $r => $val) { if (!isset($mergeResdual[$val][$avg_risk_control[$r]])) { $mergeResdual[$val][$avg_risk_control[$r]] = 1; } else { $mergeResdual[$val][$avg_risk_control[$r]] += 1; } //$mergeIR[$val][$avg_risk_impact[$k]] = 1; } $final_likelihood = array_sum($avg_risk_likelyhood)/count($avg_risk_likelyhood); $final_impact = array_sum($avg_risk_impact)/count($avg_risk_impact); $final_likelihood = number_format((float)$final_likelihood, 2, '.', ''); $final_impact = number_format((float)$final_impact, 2, '.', ''); if($final_likelihood <= $thresold[1]) { $final_likelihood = 1; } else if($final_likelihood > $thresold[1] && $final_likelihood <= $thresold[2]) { $final_likelihood = 2; } else if($final_likelihood > $thresold[2] && $final_likelihood <= $thresold[3]) { $final_likelihood = 3; } else if($final_likelihood > $thresold[3] && $final_likelihood <= $thresold[4]) { $final_likelihood = 4; } else if($final_likelihood > $thresold[4]) { $final_likelihood = 5; } if($final_impact <= $thresold[1]) { $final_impact = 1; } else if($final_impact > $thresold[1] && $final_impact <= $thresold[2]) { $final_impact = 2; } else if($final_impact > $thresold[2] && $final_impact <= $thresold[3]) { $final_impact = 3; } else if($final_impact > $thresold[3] && $final_impact <= $thresold[4]) { $final_impact = 4; } else if($final_impact > $thresold[4]) { $final_impact = 5; } $final_design = array_sum($avg_risk_control_design)/count($avg_risk_control_design); $final_performance = array_sum($avg_risk_control_performance)/count($avg_risk_control_performance); $final_design = number_format((float)$final_design, 2, '.', ''); $final_performance = number_format((float)$final_performance, 2, '.', ''); if($final_design <= $thresold[1]) { $final_design = 1; } else if($final_design > $thresold[1] && $final_design <= $thresold[2]) { $final_design = 2; } else if($final_design > $thresold[2] && $final_design <= $thresold[3]) { $final_design = 3; } else if($final_design > $thresold[3] && $final_design <= $thresold[4]) { $final_design = 4; } else if($final_design > $thresold[4]) { $final_design = 5; } if($final_performance <= $thresold[1]) { $final_performance = 1; } else if($final_performance > $thresold[1] && $final_performance <= $thresold[2]) { $final_performance = 2; } else if($final_performance > $thresold[2] && $final_performance <= $thresold[3]) { $final_performance = 3; } else if($final_performance > $thresold[3] && $final_performance <= $thresold[4]) { $final_performance = 4; } else if($final_performance > $thresold[4]) { $final_performance = 5; } //dd($matrix); //$intersect_residual = $matrix_risk[$final_likelihood][$final_impact]; $intersect_residual = $matrix_risk[$final_impact][$final_likelihood]; //$intersect_control = $matrix_controls[$final_design][$final_performance]; $intersect_control = $matrix_controls[$final_performance][$final_design]; $final_likelihood_label = @ucwords($matrix['likelihood'][$final_likelihood]); $final_impact_label = @ucwords($matrix['impact'][$final_impact]); $final_res_risk = $matrix_calc[$intersect_residual][$intersect_control]; $final_res_risk_label = @ucwords($matrix['residual_risk'][$final_res_risk]); $final_risk_perceived = round(array_sum($avg_risk_perceived)/count($avg_risk_perceived)); $final_risk_perceived_label = @ucwords($matrix['residual_risk'][$final_risk_perceived]); $avg_risk_residual_score = array_count_values($avg_risk_residual); //get total count of aray values and return new array $final_residual_score = array(); foreach ($avg_risk_residual_score as $r => $s) { $final_residual_score[] = $r * $s; } $final_residual_score_result = number_format(array_sum($final_residual_score)/count($avg_risk_residual), 2, '.', ''); if($final_residual_score_result <= $thresold[1]) { $temp_final_residual_score_result = 1; } else if($final_residual_score_result > $thresold[1] && $final_residual_score_result <= $thresold[2]) { $temp_final_residual_score_result = 2; } else if($final_residual_score_result > $thresold[2] && $final_residual_score_result <= $thresold[3]) { $temp_final_residual_score_result = 3; } else if($final_residual_score_result > $thresold[3] && $final_residual_score_result <= $thresold[4]) { $temp_final_residual_score_result = 4; } else if($final_residual_score_result > $thresold[4]) { $temp_final_residual_score_result = 5; } $final_residual_score_label = @ucwords($matrix['residual_risk'][$temp_final_residual_score_result]); //dd($mergeCtrl); @endphp Questionaire Approval @if ($errors->any()) @foreach ($errors->all() as $error) {{ $error }} @endforeach @endif @if(!empty($risks)) @foreach($risks as $key=>$risk) 0) style="display:none" @endif data-index="{{$key}}"> Organization Department Name / Business Entity / Process RCSA Ref. No Risk Ref. No. Risk Event Name {{-- Risk Description {{$risk->description ?? ''}} --}} Inherent Risk (Aggregated) {{-- Likelihood @foreach($inherentLikelyhood as $key => $val) inherent_risk_likelyhood) ? $model->inherent_risk_likelyhood : old('inherent_risk_likelyhood')) == $key ? 'selected' : '' }}>{{ ucwords($val) }} @endforeach Impact @foreach($inherentImpact as $key => $val) inherent_risk_impact) ? $model->inherent_risk_impact : old('inherent_risk_impact')) == $key ? 'selected' : '' }}>{{ ucwords($val) }} @endforeach --}} @php $i=1; $colours = $matrix_data['matrix_layout']['colours']; @endphp @foreach($matrix_data['matrix_layout']['risk'] as $key=>$row) @if($i == 1) Impact @endif {{@ucwords($matrix['impact'][$key])}} @foreach($row as $key2=>$column) @if(isset($mergeIR[$key2][$key])) {{ $mergeIR[$key2][$key] }} @else {{-- '0' --}} @endif @endforeach @php $i++; @endphp @endforeach @foreach($matrix['likelihood'] as $level) {{ucwords($level)}} @endforeach Likelihood Control Matrix (Aggregated) {{-- Control Ref No. --}} @php $i=1; @endphp @foreach($matrix_data['matrix_layout']['controls'] as $key=>$row) @if($i == 1) Control Performance @endif {{@ucwords($matrix['control_performance'][$key])}} @foreach($row as $key2=>$column) @if(isset($mergeCtrl[$key2][$key])) {{ $mergeCtrl[$key2][$key] }} @else {{-- '0' --}} @endif @endforeach @php $i++; @endphp @endforeach @foreach($matrix['control_design'] as $level) {{ucwords($level)}} @endforeach Control Design Residual Risk Matrix {{-- Likelihood Impact --}} @php $i=1; @endphp @foreach($matrix_data['matrix_layout']['controls'] as $key=>$row) @if($i == 1) Inherent Risk Assesment @endif {{@ucwords($matrix['impact'][$key])}} @foreach($row as $key2=>$column) @if(isset($mergeResdual[$key][$key2])) {{ $mergeResdual[$key][$key2] }} @else {{-- '0' --}} @endif @endforeach @php $i++; @endphp @endforeach @foreach($matrix['control_design'] as $level) {{ucwords($level)}} @endforeach Control Assesment Residual Risk {{-- {{'1001'}} ---}} Residual Risk Score Residual Risk Level {{-- Perceived Residual Risk --}} Approval Status status) && $model->status=="yes") ? "checked" : "" }} /> Yes status) && $model->status=="no") ? "checked" : "" }} /> No Cancel @can('approve_questionnaire.edit') Submit @endcan @endforeach @else Please select risk for this RCSA planner @endif @endsection @section('additionaljs') @endsection
Yes
No