@extends('Admin.layout') @section('content') @php /* |-------------------------------------------------------------------------- | Person Dropdown Options |-------------------------------------------------------------------------- | Closure prevents Cannot redeclare errors in compiled Blade views. */ $renderPersonOptions = function ($staffs, $users, $selectedId, $selectedRole) { $selectedVal = ''; $isCustom = false; if ($selectedId !== null && $selectedId !== '') { $roleLower = strtolower($selectedRole ?? ''); $found = false; if ($roleLower === 'user' || $roleLower === 'admin') { foreach ($users as $user) { if ($user->id == $selectedId) { $selectedVal = 'user:' . $user->id; $found = true; break; } } } elseif ($roleLower === 'staff' || $roleLower === '') { foreach ($staffs as $staff) { if ($staff->id == $selectedId) { $selectedVal = 'staff:' . $staff->id; $found = true; break; } } } if (!$found) { if ($roleLower === 'other' || !is_numeric($selectedId)) { $selectedVal = 'custom:' . $selectedId; $isCustom = true; } else { foreach ($staffs as $staff) { if ($staff->id == $selectedId) { $selectedVal = 'staff:' . $staff->id; $found = true; break; } } if (!$found) { foreach ($users as $user) { if ($user->id == $selectedId) { $selectedVal = 'user:' . $user->id; $found = true; break; } } } if (!$found) { $selectedVal = 'custom:' . $selectedId; $isCustom = true; } } } } if ($isCustom) { echo ''; } foreach ($staffs as $staff) { $val = 'staff:' . $staff->id; $selected = ($val === $selectedVal) ? 'selected' : ''; $label = $staff->staff_name . ' (' . ($staff->role ?? 'Staff') . ')'; echo ''; } foreach ($users as $user) { $val = 'user:' . $user->id; $selected = ($val === $selectedVal) ? 'selected' : ''; $label = $user->name . ' (Admin)'; echo ''; } }; /* |-------------------------------------------------------------------------- | Prepare Cheque History |-------------------------------------------------------------------------- */ $chequeHistory = $cheque->cheque_history ?? []; if (is_string($chequeHistory)) { $chequeHistory = json_decode($chequeHistory, true) ?? []; } if (!is_array($chequeHistory)) { $chequeHistory = []; } $historyCount = count($chequeHistory); $previousHistory = []; if ($historyCount > 1) { $latestHistoryIndex = array_key_last($chequeHistory); foreach ($chequeHistory as $historyIndex => $historyRound) { if ($historyIndex !== $latestHistoryIndex) { $previousHistory[$historyIndex] = $historyRound; } } } @endphp
{{-- PAGE HEADER --}}

Edit Cheque Record #{{ $cheque->cheque_number }}

@csrf {{-- ===================================================== --}} {{-- PREVIOUS TRANSACTION HISTORY --}} {{-- ===================================================== --}}
Previous Transaction History
@if(count($previousHistory) > 0)
Edit previous transactions here. These changes will not overwrite your current transaction.
@foreach($previousHistory as $historyIndex => $historyRound) @php $roundStatus = $historyRound['status'] ?? 'Pending'; $historyIn = $historyRound['in'] ?? []; $historyOut = $historyRound['out'] ?? []; if (!is_array($historyIn)) { $historyIn = []; } if (!is_array($historyOut)) { $historyOut = []; } $inTakenId = $historyIn['in_taken_by'] ?? ''; $inTakenRole = $historyIn['in_taken_by_role'] ?? ''; $inGivenId = $historyIn['in_given_by'] ?? ''; $inGivenRole = $historyIn['in_given_by_role'] ?? ''; $outTakenId = $historyOut['out_taken_by'] ?? ''; $outTakenRole = $historyOut['out_taken_role'] ?? $historyOut['out_taken_by_role'] ?? ''; $outGivenId = $historyOut['out_given_by'] ?? ''; $outGivenRole = $historyOut['out_given_role'] ?? $historyOut['out_given_by_role'] ?? ''; $inDate = $historyIn['in_date_time'] ?? ''; if (!empty($inDate)) { try { $inDate = \Carbon\Carbon::parse($inDate)->format('Y-m-d\TH:i'); } catch (\Throwable $e) { $inDate = ''; } } $outDate = $historyOut['out_date_time'] ?? ''; if (!empty($outDate)) { try { $outDate = \Carbon\Carbon::parse($outDate)->format('Y-m-d\TH:i'); } catch (\Throwable $e) { $outDate = ''; } } @endphp
Transaction {{ $historyRound['round'] ?? ($historyIndex + 1) }}
@if($roundStatus === 'Completed') Completed @elseif($roundStatus === 'Pending') Pending @else {{ $roundStatus }} @endif
{{-- ================= IN DETAILS ================= --}}
IN DETAILS
{{-- IN TAKEN BY --}}
{{-- IN GIVEN BY --}}
{{-- ================= OUT DETAILS ================= --}}
OUT DETAILS
{{-- OUT TAKEN BY --}}
{{-- OUT GIVEN BY --}}
@endforeach @else
No previous transactions available. Your first/current transaction can be edited using the form below.
@endif {{-- ===================================================== --}} {{-- CURRENT TRANSACTION / CHEQUE OWNER DETAILS --}} {{-- ===================================================== --}}
Current Transaction - Cheque & Owner Details
{{-- OWNER TYPE --}}
@php $isStandardOwnerType = in_array( $cheque->check_owner_type, ['Customer', 'Company', 'Staff', 'Other'] ); $currentOwnerType = $isStandardOwnerType ? $cheque->check_owner_type : 'Other'; $otherOwnerTypeValue = $isStandardOwnerType ? '' : $cheque->check_owner_type; @endphp
{{-- ===================================================== --}} {{-- CURRENT IN DETAILS --}} {{-- ===================================================== --}}
Current Transaction - In Details
{{-- CURRENT IN TAKEN BY --}}
{{-- CURRENT IN GIVEN BY --}}
{{-- ===================================================== --}} {{-- CURRENT OUT DETAILS --}} {{-- ===================================================== --}}
Current Transaction - Out Details
{{-- CURRENT OUT TAKEN BY --}}
{{-- CURRENT OUT GIVEN BY --}}
{{-- ===================================================== --}} {{-- FORM BUTTONS --}} {{-- ===================================================== --}}
Cancel
@endsection