@extends('layouts.app', ['class' => 'g-sidenav-show bg-gray-100']) @section('content') @include('layouts.navbars.auth.topnav', ['title' => ''])
{{ $title_menu }} - {{ $report_title }}
@include('components.alert')

@if (!empty($isCompactView) && $isCompactView) {{-- Compact view for all periods (12 months) --}} @foreach ($monthHeaders as $header) @endforeach @forelse ($detailedData as $positionGroup) {{-- Position Header Row --}} {{-- Loop through employees in this position --}} @foreach ($positionGroup['employees'] as $employee) {{-- Employee Name Header Row --}} @php $standardItems = []; $monthlyData = []; // Organize by standard (order) foreach ($employee['months'] as $monthKey => $monthData) { foreach ($monthData['items'] as $item) { if (!isset($standardItems[$item->order_no])) { $standardItems[$item->order_no] = [ 'name' => $item->standard_name, 'weight' => $item->weight, ]; } $monthlyData[$item->order_no][$monthKey] = [ 'final_score' => $item->final_score, 'weighted_score' => $item->weighted_score, ]; } } ksort($standardItems); ksort($monthlyData); @endphp @foreach ($standardItems as $order => $standard) @foreach ($monthsKeys as $monthKey) @php $monthData = $monthlyData[$order][$monthKey] ?? null; $weightedScore = $monthData['weighted_score'] ?? 0; @endphp @endforeach @endforeach {{-- Total Row for this Employee --}} @php $grandTotals = array_fill(0, count($monthsKeys ?? []), 0); foreach ($monthlyData as $itemData) { foreach ($monthsKeys ?? [] as $idx => $mKey) { if (isset($itemData[$mKey])) { $grandTotals[$idx] += $itemData[$mKey]['weighted_score']; } } } @endphp @foreach ($grandTotals as $total) @endforeach @endforeach @empty @endforelse
No # Standar Bobot{{ $header['name'] }}
{{ $positionGroup['position_name'] ?? '-' }}
{{ $employee['employee_name'] }}
{{ $order }} {{ $standard['name'] }} {{ round($standard['weight']) }} {{ $weightedScore > 0 ? number_format($weightedScore, 1) : '-' }}
Total {{ $total > 0 ? rtrim(rtrim(number_format($total, 2), '0'), '.') : '-' }}
Tidak ada Data.
@else {{-- Detailed view for specific periods (3 months) --}} @if (!empty($monthHeaders)) @foreach ($monthHeaders as $header) @endforeach @else @endif @if (!empty($monthHeaders)) @foreach ($monthHeaders as $header) @endforeach @else @endif @forelse ($detailedData as $positionGroup) {{-- Position Header Row --}} {{-- Loop through employees in this position --}} @foreach ($positionGroup['employees'] as $employee) {{-- Employee Name Header Row --}} @php $standardItems = []; $monthlyData = []; // Organize by standard (order) foreach ($employee['months'] as $monthKey => $monthData) { foreach ($monthData['items'] as $item) { // NOTE: $item is stdClass from query—access with -> if (!isset($standardItems[$item->order_no])) { $standardItems[$item->order_no] = [ 'name' => $item->standard_name, 'weight' => $item->weight, ]; } $monthlyData[$item->order_no][$monthKey] = [ 'final_score' => $item->final_score, 'original_score' => $item->original_score, 'weighted_score' => $item->weighted_score, 'reason' => $item->revision_reason, 'is_revised' => $item->is_revised, 'weight' => $item->weight, // Add weight here for month-specific access ]; } } ksort($standardItems); ksort($monthlyData); @endphp @foreach ($standardItems as $order => $standard) @php $monthTotals = []; @endphp @foreach ($monthsKeys as $monthKey) @php $monthData = $monthlyData[$order][$monthKey] ?? null; // Use month-specific weight instead of standard weight $weight = $monthData && isset($monthData['weight']) ? round($monthData['weight']) : '-'; $finalScore = $monthData['final_score'] ?? 0; $originalScore = $monthData['original_score'] ?? 0; $isRevised = $monthData['is_revised'] ?? false; $weightedScore = $monthData['weighted_score'] ?? 0; $reason = $monthData['reason'] ?? ''; $scoreDisplay = $finalScore; if ($isRevised && $originalScore != $finalScore) { $scoreDisplay = $finalScore . ' (' . $originalScore . ')'; } $monthTotals[] = $weightedScore; @endphp @endforeach @endforeach {{-- Total Row for this Employee --}} @php $grandTotals = array_fill(0, count($monthsKeys ?? []), 0); foreach ($monthlyData as $itemData) { foreach ($monthsKeys ?? [] as $idx => $mKey) { if (isset($itemData[$mKey])) { $grandTotals[$idx] += $itemData[$mKey]['weighted_score']; } } } @endphp @foreach ($grandTotals as $index => $total) @if ($index === 0) {{-- First month: colspan for No#, Standar, Bobot, Nilai --}} @else {{-- Other months: colspan for Bobot, Nilai --}} @endif @endforeach {{-- # column --}} @endforeach @empty @endforelse
No # Standar{{ $header['name'] }}No Data
Bobot Nilai Total #Bobot Nilai Total #
{{ $positionGroup['position_name'] ?? '-' }}
{{ $employee['employee_name'] }}
{{ $order }} {{ $standard['name'] }}{{ $weight }} {{ $scoreDisplay ?: '-' }} {{ $weightedScore > 0 ? rtrim(rtrim(number_format($weightedScore, 2), '0'), '.') : '-' }} {{ $reason }}
Total {{ rtrim(rtrim(number_format($total, 2), '0'), '.') }} Total {{ rtrim(rtrim(number_format($total, 2), '0'), '.') }}
Tidak ada Data.
@endif
@endsection @push('js') @endpush