@extends('layouts.app', ['class' => 'g-sidenav-show bg-gray-100']) {{-- section content --}} @section('content') @if (empty($selected_detail_month)) @include('layouts.navbars.auth.topnav', ['title' => '']) @endif
Komposisi Dibiayakan Berdasarkan Divisi
@if (!empty($selected_detail_month))
Data Bulan: {{ \Carbon\Carbon::createFromFormat('Y-m', $selected_detail_month)->translatedFormat('F Y') }}
@endif
@php $grandTotal = 0; @endphp @foreach ($zrawByMatkl as $divisi => $items) @php $divisiId = Str::slug($divisi ?? 'Unknown', '_'); $divisiTotal = $items->sum('total_value'); $grandTotal += $divisiTotal; @endphp @endforeach
Divisi Curr Total
{{ $divisi ?? 'Tidak Diketahui' }} ({{ $items->count() }} item) IDR {{ number_format($divisiTotal) }}
@foreach ($items as $row) @endforeach
- {{ $row->SHORT_TEXT ?? '-' }} {{ number_format($row->total_value) }}
TOTAL IDR {{ number_format($grandTotal) }}
Dibiayakan - Grafik Nilai per Bulan
{{-- CARD 2: Summary Bulanan --}}
Summary Dibiayakan - {{ \Carbon\Carbon::createFromFormat('Ym', $yearMonth)->format('Y') }}
@foreach ($months as $m) @endforeach {{-- 🔹 Tambahan --}} {{-- 🔹 Tambahan --}} @php $grandTotals = []; $grandTotalPrev = 0; $grandTotalAktif = 0; @endphp @foreach ($monthlySummary as $divisi => $monthValues) @continue(str_contains($divisi, '__DETAIL')) @php $excludedDivisi = [ 'Stock Gudang Supporting', 'Stock Gudang Packaging', 'Stock Gudang Raw Material', ]; if (in_array($divisi, $excludedDivisi)) { continue; } $totalAktif = collect($monthValues) ->filter(fn($v, $key) => $key <= $yearMonth) ->map(fn($v) => (float) $v) ->sum(); $monthsYTD = collect($months)->filter(fn($m) => $m <= $yearMonth)->count(); $avgYTD = $monthsYTD > 0 ? $totalAktif / $monthsYTD : 0; $totalSebelumnya = $prevYearData[$divisi] ?? 0; $ratio = $totalSebelumnya > 0 ? ($totalAktif / $totalSebelumnya) * 100 : null; // Total keseluruhan foreach ($months as $m) { $grandTotals[$m] = ($grandTotals[$m] ?? 0) + ($monthValues[$m] ?? 0); } $grandTotalPrev += $totalSebelumnya; $grandTotalAktif += $totalAktif; $groupId = Str::slug($divisi); $hasDetail = isset($monthlySummary[$divisi . '__DETAIL']); @endphp {{-- ROW UTAMA --}} @foreach ($months as $m) @endforeach {{-- ROW DETAIL --}} @if ($hasDetail) @foreach ($monthlySummary[$divisi . '__DETAIL'] as $childDiv => $childVals) @php $childPrev = $prevYearData[$divisi . '__DETAIL'][$childDiv] ?? 0; $childAktif = collect($childVals) ->filter(fn($v, $k) => $k <= $yearMonth) ->sum(); $childMonthsYTD = collect($months) ->filter(fn($m) => $m <= $yearMonth) ->count(); $childAvgYTD = $childMonthsYTD > 0 ? $childAktif / $childMonthsYTD : 0; $childRatio = $childPrev > 0 ? ($childAktif / $childPrev) * 100 : null; @endphp @foreach ($months as $m) @endforeach {{-- 🔹 Total YTD --}} {{-- 🔹 AVG YTD --}} @endforeach @endif @endforeach {{-- TOTAL --}} @php $monthsYTD = collect($months)->filter(fn($m) => $m <= $yearMonth)->count(); $grandAvgYTD = $monthsYTD > 0 ? $grandTotalAktif / $monthsYTD : 0; $grandRatioYTD = $grandTotalPrev > 0 ? number_format(($grandTotalAktif / $grandTotalPrev) * 100, 2) . '%' : '-'; @endphp @foreach ($months as $m) @endforeach {{-- 🔹 Total YTD --}} {{-- 🔹 AVG YTD --}}
Divisi Curr {{ \Carbon\Carbon::createFromFormat('Ymd', $m . '01')->translatedFormat('F Y') }} Total YTDAVG YTDTotal {{ $yearPrev }} Ratio YTD
{{ $divisi }} IDR {{ number_format($monthValues[$m] ?? 0) }} {{ number_format($totalAktif) }} {{ number_format($avgYTD, 0) }} {{ number_format($totalSebelumnya) }} {{ $ratio !== null ? number_format($ratio, 2) . '%' : '-' }}
{{ $childDiv }} IDR{{ number_format($childVals[$m] ?? 0) }}{{ number_format($childAktif) }}{{ number_format($childAvgYTD, 0) }}{{ number_format($childPrev) }} {{ $childRatio !== null ? number_format($childRatio, 2) . '%' : '-' }}
TOTAL IDR{{ number_format($grandTotals[$m] ?? 0) }}{{ number_format($grandTotalAktif) }}{{ number_format($grandAvgYTD, 0) }}{{ number_format($grandTotalPrev) }} {{ $grandRatioYTD }}
HR & GA - Per Kategori
@foreach ($months as $month) @endforeach @php $totalAvg = 0; $totalPerMonth = array_fill_keys($months, 0); @endphp @foreach ($pivot as $kategori => $values) @php $totalAvg += $avg[$kategori] ?? 0; foreach ($months as $month) { $totalPerMonth[$month] += $values[$month] ?? 0; } @endphp @foreach ($months as $month) @endforeach @endforeach {{-- Row Total --}} @foreach ($months as $month) @endforeach
Kategori AVG {{ $yearPrev }} {{ \Carbon\Carbon::createFromFormat('Ymd', $month . '01')->translatedFormat('F Y') }}
{{ $kategori }} {{ number_format($avg[$kategori] ?? 0, 0) }} {{ number_format($values[$month] ?? 0, 0) }}
TOTAL {{ number_format($totalAvg, 0) }} {{ number_format($totalPerMonth[$month] ?? 0, 0) }}
Dibiayakan Full Data ({{ \Carbon\Carbon::createFromFormat('Ymd', $yearMonth . '01')->format('F Y') }})
@php $grandTotal = 0; $topDivisi = $dibiayakanFullData->take(5); $moreDivisi = $dibiayakanFullData->slice(5); @endphp @foreach ($topDivisi as $divisi => $items) @php $divisiId = 'top-' . Str::slug($divisi ?? 'Unknown', '_'); $divisiTotal = $items->sum('total_value'); $grandTotal += $divisiTotal; @endphp @endforeach @if ($moreDivisi->count()) @endif @if ($moreDivisi->count()) @foreach ($moreDivisi as $divisi => $items) @php $divisiId = 'more-' . Str::slug($divisi ?? 'Unknown', '_'); $divisiTotal = $items->sum('total_value'); $grandTotal += $divisiTotal; @endphp @endforeach @endif
Kategori Curr Total
@foreach ($items as $row) @endforeach
- {{ $row->SHORT_TEXT ?? '-' }} {{ number_format($row->total_value) }}
@foreach ($items as $row) @endforeach
- {{ $row->SHORT_TEXT ?? '-' }} {{ number_format($row->total_value) }}
TOTAL IDR {{ number_format($grandTotal) }}
HR & GA Full Data ({{ \Carbon\Carbon::createFromFormat('Ymd', $yearMonth . '01')->format('F Y') }})
@php $grandTotal = 0; $topDivisi = $hrgaFullData->take(5); $moreDivisi = $hrgaFullData->slice(5); @endphp @foreach ($topDivisi as $divisi => $items) @php $divisiId = 'hrga-top-' . Str::slug($divisi ?? 'Unknown', '_'); $divisiTotal = $items->sum('total_value'); $grandTotal += $divisiTotal; @endphp @endforeach @if ($moreDivisi->count()) @endif @if ($moreDivisi->count()) @foreach ($moreDivisi as $divisi => $items) @php $divisiId = 'hrga-more-' . Str::slug($divisi ?? 'Unknown', '_'); $divisiTotal = $items->sum('total_value'); $grandTotal += $divisiTotal; @endphp @endforeach @endif
Kategori Curr Total
@foreach ($items as $row) @endforeach
- {{ $row->SHORT_TEXT ?? '-' }} {{ number_format($row->total_value) }}
@foreach ($items as $row) @endforeach
- {{ $row->SHORT_TEXT ?? '-' }} {{ number_format($row->total_value) }}
TOTAL IDR {{ number_format($grandTotal) }}
@endsection @push('js') @endpush