@php use App\Enums\ReportOption; use Carbon\Carbon; @endphp @extends('layouts.print') @push('styles') @if(isset($output) && $output === 'screen') @vite(['resources/scss/main.scss', 'resources/scss/print.scss']) @else @endif @endpush @section('content') @php $routeName = request()->route()->getName(); @endphp

@php $countPeriods = count($periods); $colsCount = $countPeriods > 1 ? ($countPeriods + 2) : $countPeriods; @endphp {{-- Tampilkan bagian Quantity --}} @if(!empty($data_per_branch) && in_array($input['show_content'], [ReportOption::QUANTITY->value, ReportOption::ALL->value]))
@foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @php $grandTotal = []; @endphp @foreach ($data_per_branch as $branchName => $customers) @php $subtotalBranch = []; @endphp @foreach ($customers as $customerKey => $customer) @php $periodQty = $customer['periods']['quantity'] ?? []; @endphp @foreach ($periods as $p) @php $val = $periodQty[$p] ?? 0; $subtotalBranch[$p] = ($subtotalBranch[$p] ?? 0) + $val; $grandTotal[$p] = ($grandTotal[$p] ?? 0) + $val; @endphp @endforeach @if ($countPeriods > 1) @php $total = array_sum($periodQty); $avg = $total / $countPeriods; @endphp @endif @endforeach @foreach ($periods as $p) @endforeach @if ($countPeriods > 1) @php $totalBranch = array_sum($subtotalBranch); @endphp @endif @endforeach @foreach ($periods as $p) @endforeach @if ($countPeriods > 1) @php $totalGrand = array_sum($grandTotal); @endphp @endif
{{ __('validation.attributes.description') }} {{ __('validation.attributes.quantity') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{ $branchName }}
{{ $customer['customer_details']['name'] ?? $customerKey }}{{ $val == 0 ? '-' : number_format($val) }}{{ number_format($total) }} {{ number_format($avg, 2) }}
{{ __('validation.attributes.subtotal') }} {{ $branchName }}{{ number_format($subtotalBranch[$p] ?? 0) }}{{ number_format($totalBranch) }} {{ number_format($totalBranch / $countPeriods, 2) }}
{{ __('general.grand_total') }}{{ number_format($grandTotal[$p] ?? 0) }}{{ number_format($totalGrand) }} {{ number_format($totalGrand / $countPeriods, 2) }}
@endif {{-- Tampilkan bagian Amount --}} @if(!empty($data_per_branch) && in_array($input['show_content'], [ReportOption::AMOUNT->value, ReportOption::ALL->value]))
@foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @php $grandTotal = []; @endphp @foreach ($data_per_branch as $branchName => $customers) @php $subtotalBranch = []; @endphp @foreach ($customers as $customerKey => $customer) @php $periodAmt = $customer['periods']['amount'] ?? []; @endphp @foreach ($periods as $p) @php $val = $periodAmt[$p] ?? 0; $subtotalBranch[$p] = ($subtotalBranch[$p] ?? 0) + $val; $grandTotal[$p] = ($grandTotal[$p] ?? 0) + $val; @endphp @endforeach @if ($countPeriods > 1)s @php $total = array_sum($periodAmt); $avg = $total / $countPeriods; @endphp @endif @endforeach @foreach ($periods as $p) @endforeach @if ($countPeriods > 1) @php $totalBranch = array_sum($subtotalBranch); @endphp @endif @endforeach @foreach ($periods as $p) @endforeach @if ($countPeriods > 1) @php $totalGrand = array_sum($grandTotal); @endphp @endif
{{ __('validation.attributes.description') }} {{ __('validation.attributes.amount') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{ $branchName }}
{{ $customer['customer_details']['name'] ?? $customerKey }}{{ $val == 0 ? '-' : number_format($val, 2) }}{{ number_format($total, 2) }} {{ number_format($avg, 2) }}
{{ __('validation.attributes.subtotal') }} {{ $branchName }}{{ number_format($subtotalBranch[$p] ?? 0, 2) }}{{ number_format($totalBranch, 2) }} {{ number_format($totalBranch / $countPeriods, 2) }}
{{ __('general.grand_total') }}{{ number_format($grandTotal[$p] ?? 0, 2) }}{{ number_format($totalGrand, 2) }} {{ number_format($totalGrand / $countPeriods, 2) }}
@endif {{-- Jika tidak ada data --}} @if(empty($data_per_branch))
{{ __('messages.report.not-found') }}
@endif
@endsection