@php $kpiList = [ 'Retail Target(All Model)', 'Retail Achieved(All)', 'Ach %', 'Retail Target(Focus Model)', 'Retail Achieved(Focus)', 'Ach % (Focus)', 'Extended Warranty', 'EW Penetration', 'CCP Sale', 'CCP Penetration', 'Smart Finance', 'SF penetration', 'Exchange', 'Ex Penetration', 'Accessory Sale', 'Accessory/Retail', 'Net Promoter Score', 'MSIL Complaint', 'Penalty Amount', 'Absent/Leave days' ]; @endphp @foreach ($kpisEvaluations as $groupKey => $evaluations) @php $first = $evaluations->first(); @endphp @foreach ($kpiList as $kpiName) @for ($m = 1; $m <= 12; $m++) @php $monthKpis = $evaluations->filter(fn($item) => $item->month == $m)->keyBy('kpi_name'); $retailTargetAll = $monthKpis->get('Retail Target(All Model)')->value ?? null; $retailAchieved = $monthKpis->get('Retail Achieved(All)')->value ?? null; $retailTargetFocus = $monthKpis->get('Retail Target(Focus Model)')->value ?? null; $retailAchievedFocus = $monthKpis->get('Retail Achieved(Focus)')->value ?? null; $ew = $monthKpis->get('Extended Warranty')->value ?? null; $ccp = $monthKpis->get('CCP Sale')->value ?? null; $sf = $monthKpis->get('Smart Finance')->value ?? null; $exchange = $monthKpis->get('Exchange')->value ?? null; $accessory = $monthKpis->get('Accessory Sale')->value ?? null; switch (trim($kpiName)) { case 'Ach %': $value = ($retailTargetAll && $retailAchieved) ? round(($retailAchieved / $retailTargetAll) * 100, 2) . '%' : '-'; break; case 'Ach % (Focus)': $value = ($retailTargetFocus && $retailAchievedFocus) ? round(($retailAchievedFocus / $retailTargetFocus) * 100, 2) . '%' : '-'; break; case 'EW Penetration': $value = ($retailAchieved && $ew) ? round(($ew / $retailAchieved) * 100, 2) . '%' : '-'; break; case 'CCP Penetration': $value = ($retailAchieved && $ccp) ? round(($ccp / $retailAchieved) * 100, 2) . '%' : '-'; break; case 'SF penetration': $value = ($retailAchieved && $sf) ? round(($sf / $retailAchieved) * 100, 2) . '%' : '-'; break; case 'Ex Penetration': $value = ($retailAchieved && $exchange) ? round(($exchange / $retailAchieved) * 100, 2) . '%' : '-'; break; case 'Accessory/Retail': $value = ($retailAchieved && $accessory) ? round(($accessory / $retailAchieved) * 100, 2) . '%' : '-'; break; case 'Absent/Leave days': $records = $attendanceSummary[$first->employee_id][$first->year][$m] ?? collect(); $absent = $records->sum('total_absent'); $leave = $records->sum('total_leave'); $value = ($absent || $leave) ? "{$absent}/{$leave}" : '-'; break; default: $value = $monthKpis->get($kpiName)->value ?? '-'; } @endphp @endfor @endforeach @endforeach
RM Name: {{ @$first->employee->hod->name}} || Employee Name: {{ $first->employee->name }} ({{ $first->employee->employee_code }}) || Year: {{ $first->year }}
S.No. Kpi Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
{{ $loop->iteration }} {{ $kpiName }}{{ $value }}
{{ count($kpiList) + 1 }} Warning Letters {{ optional($warningLetters->get($first->employee_id))->get($first->year) ?? 0 }}
{{ count($kpiList) + 2 }} Certificates {{ optional($appreciationLetters->get($first->employee_id))->get($first->year) ?? 0 }}