@extends('layouts.app') @section('content')

Edit Disbursement

@if($disbursement->status == 'Pending') Pending @elseif($disbursement->status == 'Approved') Approved @else {{ $disbursement->status }} @endif
@if ($errors->any()) @endif
@csrf @method('PUT')
Disbursement date cannot be changed
UGX
Amount with automatic comma formatting
Balance after this disbursement
Provide a detailed reason for this disbursement
This will be saved in the audit trail
Disbursement Information
Created By:

{{ $disbursement->user->name ?? 'N/A' }}

Created At:

{{ $disbursement->created_at->format('d-M-Y H:i:s') }}

Last Updated:

{{ $disbursement->updated_at->format('d-M-Y H:i:s') }}

@if($disbursement->status == 'Pending') @endif
Cancel
@if(isset($audits) && $audits->count() > 0)
Audit Trail
@foreach($audits as $audit) @endforeach
Date/Time User Action Changes Remarks
{{ $audit->created_at->format('d-M-Y') }}
{{ $audit->created_at->format('H:i:s') }}
{{ $audit->user->name ?? 'System' }} @php $badgeClass = 'secondary'; $icon = 'circle'; switch($audit->action) { case 'created': $badgeClass = 'success'; $icon = 'plus-circle'; break; case 'updated': $badgeClass = 'info'; $icon = 'edit'; break; case 'deleted': $badgeClass = 'danger'; $icon = 'trash-alt'; break; case 'approved': $badgeClass = 'primary'; $icon = 'check-circle'; break; } @endphp {{ ucfirst($audit->action) }} @if($audit->action == 'updated' && $audit->old_values && $audit->new_values) @php $changes = []; foreach($audit->new_values as $key => $newValue) { $oldValue = $audit->old_values[$key] ?? null; if($oldValue != $newValue) { $changes[$key] = ['old' => $oldValue, 'new' => $newValue]; } } @endphp @foreach($changes as $field => $change)
{{ ucfirst(str_replace('_', ' ', $field)) }}:
@if($field == 'amount') {{ number_format($change['old'], 2) }} @elseif($field == 'supplier_id') @php $oldSupplier = \App\Models\Supplier::find($change['old']); @endphp {{ $oldSupplier ? $oldSupplier->name : 'Supplier ID: ' . $change['old'] }} @elseif($field == 'personel_id') @php $oldPersonel = \App\Models\Personel::find($change['old']); @endphp {{ $oldPersonel ? $oldPersonel->name : 'Personnel ID: ' . $change['old'] }} @else {{ $change['old'] }} @endif
@if($field == 'amount') {{ number_format($change['new'], 2) }} @elseif($field == 'supplier_id') @php $newSupplier = \App\Models\Supplier::find($change['new']); @endphp {{ $newSupplier ? $newSupplier->name : 'Supplier ID: ' . $change['new'] }} @elseif($field == 'personel_id') @php $newPersonel = \App\Models\Personel::find($change['new']); @endphp {{ $newPersonel ? $newPersonel->name : 'Personnel ID: ' . $change['new'] }} @else {{ $change['new'] }} @endif
@endforeach
@elseif($audit->action == 'created' && $audit->new_values) Initial amount: {{ number_format($audit->new_values['amount'] ?? 0, 2) }} @elseif($audit->action == 'deleted' && $audit->old_values) Deleted amount: {{ number_format($audit->old_values['amount'] ?? 0, 2) }} @else No changes recorded @endif
{{ $audit->remarks ?? '-' }}
@endif
@endsection @section('customcss') @endsection @section('customjs') @endsection