@php use App\Enums\ReportOption; use App\Enums\TaxType; 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 @if(in_array($input['show_content'], [ReportOption::QUANTITY->value, ReportOption::ALL->value]))
{{-- quantity --}} @foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @foreach($totals['quantity'] as $key => $value) @endforeach @if($countPeriods > 1) @endif
{{ __('validation.attributes.sku') }} {{ __('validation.attributes.description') }} {{ __('validation.attributes.quantity') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{ __('general.grand_total') }}{{ accounting_format($value) }}{{ accounting_format($totals['quantity']['total'] / $countPeriods) }}
@endif @if(in_array($input['show_content'], [ReportOption::AMOUNT->value, ReportOption::ALL->value]))
{{-- amount --}} @foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @foreach($totals['amount'] as $key => $value) @endforeach @if($countPeriods > 1) @endif
{{ __('validation.attributes.code') }} {{ __('general.customer') }} {{ __('validation.attributes.amount') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{ __('general.grand_total') }}{{ accounting_format($value) }}{{ accounting_format($totals['amount']['total'] / $countPeriods) }}
@endif @if(in_array($input['show_content'], [ReportOption::QUANTITY->value, ReportOption::ALL->value]))
{{-- quantity --}} @foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @php $grandTotal = []; @endphp @foreach ($data2 as $keyBranch => $branch) @php $totalPerBranch = []; @endphp @foreach ($branch as $keyCustomer => $customer) @php $totalPerCustomer = []; @endphp @foreach ($customer as $keyCateogry => $category) @foreach ($category['periods']['quantity'] as $keyQty => $qty) @php if(!isset($totalPerCustomer[$keyQty])){ $totalPerCustomer[$keyQty] = 0; } if(!isset($totalPerBranch[$keyQty])){ $totalPerBranch[$keyQty] = 0; } if(!isset($grandTotal[$keyQty])){ $grandTotal[$keyQty] = 0; } $totalPerCustomer[$keyQty]+= $qty; $totalPerBranch[$keyQty]+= $qty; $grandTotal[$keyQty]+= $qty; @endphp @endforeach @if ($countPeriods > 1) @endif @endforeach @foreach ($totalPerCustomer as $subtotal) @endforeach @if ($countPeriods > 1) @endif @endforeach @foreach ($totalPerBranch as $subtotal) @endforeach @if ($countPeriods > 1) @endif @endforeach @foreach ($grandTotal as $subtotal) @endforeach @if ($countPeriods > 1) @endif
{{ __('validation.attributes.description') }} {{ __('validation.attributes.quantity') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{$keyBranch}}
{{$keyCustomer}}
{{$keyCateogry}} {{$qty==0 ? '-' : number_format($qty)}} {{number_format($category['periods']['quantity']['total'] / $countPeriods)}}
{{ __('validation.attributes.subtotal')}} {{$keyCustomer}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($totalPerCustomer['total'] / $countPeriods)}}
{{ __('validation.attributes.subtotal')}} {{$keyBranch}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($totalPerBranch['total'] / $countPeriods)}}
{{ __('general.grand_total')}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($grandTotal['total'] / $countPeriods)}}
@endif @if(in_array($input['show_content'], [ReportOption::AMOUNT->value, ReportOption::ALL->value]))
{{-- quantity --}} @foreach($periods as $period) @endforeach @if($countPeriods > 1) @endif @php $counterGrandTotal=0; $grandTotal = []; @endphp @foreach ($data2 as $keyBranch => $branch) @php $totalPerBranch = []; @endphp @foreach ($branch as $keyCustomer => $customer) @php $totalPerCustomer = []; @endphp @foreach ($customer as $keyCateogry => $category) @foreach ($category['periods']['amount'] as $keyQty => $qty) @php if(!isset($totalPerCustomer[$keyQty])){ $totalPerCustomer[$keyQty] = 0; } if(!isset($totalPerBranch[$keyQty])){ $totalPerBranch[$keyQty] = 0; } if(!isset($grandTotal[$keyQty])){ $grandTotal[$keyQty] = 0; } $totalPerCustomer[$keyQty]+= $qty; $totalPerBranch[$keyQty]+= $qty; $grandTotal[$keyQty]+= $qty; @endphp @endforeach @if ($countPeriods > 1) @endif @endforeach @foreach ($totalPerCustomer as $subtotal) @endforeach @if ($countPeriods > 1) @endif @endforeach @php $counterGrandTotal++; @endphp @foreach ($totalPerBranch as $subtotal) @endforeach @if ($countPeriods > 1) @endif @endforeach @foreach ($grandTotal as $subtotal) @endforeach @if ($countPeriods > 1) @endif
{{ __('validation.attributes.description') }} {{ __('validation.attributes.amount') }}
{{ Carbon::make($period)->format('M-Y') }}{{ __('general.total') }} {{ __('general.avg') }}
{{$keyBranch}}
{{$keyCustomer}}
{{$keyCateogry}} {{$qty==0 ? '-' : number_format($qty)}} {{number_format($category['periods']['amount']['total'] / $countPeriods)}}
{{ __('validation.attributes.subtotal')}} {{$keyCustomer}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($totalPerCustomer['total'] / $countPeriods)}}
{{ __('validation.attributes.subtotal')}} {{$keyBranch}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($totalPerBranch['total'] / $countPeriods)}}
{{ __('general.grand_total')}} {{$subtotal==0 ? '-' : number_format($subtotal)}} {{number_format($grandTotal['total'] / $countPeriods)}}
@endif @if(empty($data1) || empty($data2))
{{ __('messages.report.not-found') }}
@endif
@endsection