@extends('layouts.app') @section('title', 'Manager Approval Center') @section('css') @endsection @section('content')

Manager Approval Center

Approve waiting POS requests from every branch and review the permanent decision history.

{{ $pendingRequests->count() }} waiting POS {{ Str::plural('request', $pendingRequests->count()) }}
This queue covers all branches. It refreshes automatically when a new request arrives.
@forelse($pendingRequests as $reference => $requestLogs) @php $approvalRequest = $requestLogs->first(); $requestContext = is_array($approvalRequest->context) ? $approvalRequest->context : []; $salePreview = is_array($requestContext['sale_preview'] ?? null) ? $requestContext['sale_preview'] : []; $requestActions = $requestLogs->pluck('action_type')->unique(); $approvalDetailsId = 'manager-approval-details-'.$approvalRequest->id; $transactionLabel = optional($approvalRequest->transaction)->invoice_no ?: ($salePreview['invoice_no'] ?? null) ?: ($approvalRequest->transaction_id ? '#'.$approvalRequest->transaction_id : 'New POS sale'); @endphp
Total
{{ isset($requestContext['final_total']) ? number_format((float) $requestContext['final_total'], 2) : '-' }}
Items
{{ isset($requestContext['product_count']) ? number_format((float) $requestContext['product_count'], 2) : '-' }}
Expires
{{ optional($approvalRequest->expires_at)->format('M d, Y h:i A') ?: '-' }}
Approval needed
@foreach($requestActions as $action) {{ $actionLabels[$action] ?? ucfirst(str_replace('_', ' ', $action)) }} @endforeach
@if(!empty($salePreview['products']))
Sale details @if(!empty($salePreview['invoice_no'])) — Invoice {{ $salePreview['invoice_no'] }} @endif
Customer: {{ $salePreview['customer_name'] ?? (!empty($salePreview['customer_id']) ? 'Customer #'.$salePreview['customer_id'] : 'Walk-in customer') }}
@foreach($salePreview['products'] as $product) @php $lineDiscount = (float) ($product['discount_amount'] ?? 0); $lineDiscountType = $product['discount_type'] ?? 'fixed'; @endphp @endforeach
Product SKU Quantity Unit price Line discount Line total
{{ $product['name'] ?? 'Product' }} {{ !empty($product['sku']) ? $product['sku'] : '-' }} {{ number_format((float) ($product['quantity'] ?? 0), 2) }} {{ number_format((float) ($product['unit_price'] ?? 0), 2) }} @if($lineDiscount > 0) {{ number_format($lineDiscount, 2) }}{{ $lineDiscountType === 'percentage' ? '%' : '' }} @else - @endif {{ number_format((float) ($product['line_total'] ?? 0), 2) }}
Items subtotal {{ number_format((float) ($salePreview['subtotal'] ?? 0), 2) }}
Invoice discount @php $invoiceDiscount = (float) ($salePreview['invoice_discount_amount'] ?? 0); $invoiceDiscountType = $salePreview['invoice_discount_type'] ?? 'fixed'; @endphp @if($invoiceDiscount > 0) {{ number_format($invoiceDiscount, 2) }}{{ $invoiceDiscountType === 'percentage' ? '%' : '' }} @else - @endif
Final total {{ isset($salePreview['final_total']) ? number_format((float) $salePreview['final_total'], 2) : '-' }}
@else
The itemized sale preview is unavailable for this older request.
@endif
@if($canDecide) @endif
@empty

No POS requests are waiting for approval.

@endforelse

History filters

{!! Form::open(['route' => 'manager-approvals.index', 'method' => 'get']) !!}
{!! Form::label('location_id', 'Branch') !!} {!! Form::select('location_id', $locations, request('location_id'), ['class' => 'form-control select2', 'placeholder' => 'All branches', 'style' => 'width:100%']) !!}
{!! Form::label('action_type', 'Approval type') !!} {!! Form::select('action_type', ['' => 'All approvals'] + $actionLabels, request('action_type'), ['class' => 'form-control']) !!}
{!! Form::label('start_date', 'From') !!} {!! Form::date('start_date', request('start_date'), ['class' => 'form-control']) !!}
{!! Form::label('end_date', 'To') !!} {!! Form::date('end_date', request('end_date'), ['class' => 'form-control']) !!}
{!! Form::close() !!}

Decision history

@forelse($logs as $log) @php $statusClass = $log->status === 'approved' ? 'label-success' : ($log->status === 'rejected' ? 'label-danger' : 'label-default'); $decisionUser = $log->status === 'rejected' ? $log->rejector : $log->approver; $decisionTime = $log->approved_at ?: ($log->rejected_at ?: $log->updated_at); @endphp @empty @endforelse
Time Status Action Transaction Branch Requested by Decision by Reference
{{ optional($decisionTime)->format('M d, Y h:i A') }} {{ strtoupper($log->status) }} {{ $actionLabels[$log->action_type] ?? ucfirst(str_replace('_', ' ', $log->action_type)) }} @if(!empty($log->transaction)) {{ $log->transaction->invoice_no ?: '#'.$log->transaction_id }} @else {{ $log->transaction_id ? '#'.$log->transaction_id : '-' }} @endif {{ $log->location->name ?? 'Not assigned' }} {{ optional($log->requester)->user_full_name ?: 'Unknown user' }} {{ optional($decisionUser)->user_full_name ?: '-' }} {{ $log->approval_reference }}
No manager approval history matches the selected filters.
{{ $logs->links() }}
@endsection @section('javascript') @endsection