@extends('adminlte::page') @section('title', 'HOD Budget Actions') @section('content_header')

HOD – Approved Budgets Ready for Withdrawal

@stop @section('content')
{{-- Messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Compute summary totals --}} @php $summary = [ 'approved' => 0, 'used' => 0, 'rejected' => 0, 'partially_approved' => 0, ]; $summaryCounts = [ 'approved' => 0, 'used' => 0, 'rejected' => 0, 'partially_approved' => 0, ]; foreach ($budgets as $budget) { foreach ($summary as $status => &$amount) { $items = $budget->items->where('status', $status); $amount += $items->sum('price'); $summaryCounts[$status] += $items->count(); } } $statusColors = [ 'approved' => 'success', 'withdrawn' => 'warning', 'rejected' => 'danger', 'partially_approved' => 'info', ]; @endphp {{-- Grand Totals Summary Cards --}}
@foreach($summary as $status => $amount)

{{ number_format($amount, 2) }} TZS

{{ ucfirst(str_replace('_',' ',$status)) }} Amount

{{ $summaryCounts[$status] }} items
@endforeach
@forelse($budgets as $budget)

Budget #{{ $budget->id }} | {{ $budget->department->name ?? 'N/A' }} Department

{{-- Budget Info --}}
Submitted By: {{ $budget->staff->name ?? 'N/A' }}
Month / Year: {{ $budget->month }} / {{ $budget->year }}
Status: {{ ucfirst(str_replace('_',' ',$budget->status)) }}
Note: {{ $budget->note ?? '-' }}
{{-- Budget Item Summary Boxes --}}
@foreach(['approved','used','rejected','partially_approved'] as $stat)

{{ $budget->items->where('status', $stat)->count() }}

{{ ucfirst(str_replace('_',' ',$stat)) }}

@endforeach
{{-- Items Table --}}
@foreach($budget->items as $item) @endforeach {{-- Totals per budget --}}
# Item Description Price (TZS) Status Withdraw
{{ $loop->iteration }} {{ $item->item }} {{ $item->description ?? '-' }} {{ number_format($item->price, 2) }} {{ ucfirst(str_replace('_',' ',$item->status)) }} @if($item->status === 'approved')
@csrf
@else - @endif
Total Amount: {{ number_format($budget->items->sum('price'), 2) }}
Total Approved Amount: {{ number_format($budget->items->where('status','approved')->sum('price'), 2) }}
@empty
No approved budgets available for HOD withdrawal.
@endforelse {{-- Grand Totals Table --}}

Grand Totals Summary

@foreach($summary as $status => $amount) @endforeach
Status Total Amount (TZS) Total Items
{{ ucfirst(str_replace('_',' ',$status)) }} {{ number_format($amount, 2) }} {{ $summaryCounts[$status] }}
@stop