@extends('layouts.app') @section('title', 'Reception & Search - ICMIS') @section('content')
{{-- Page guide: what this screen is for --}}
Reception & Search. "Reception Search" is the Reception Documentation stage: pick a category tab below, pull up prisoners captured at the gate who are awaiting documentation, and complete their admission wizard. The dashboard further down manages prisoners already admitted — transfers, temporary release, knock in/out, escapes.
{{-- HEADER --}}

Reception Search — Documentation

Admit prisoners captured at the gate through the category-specific documentation wizard
@can('prison.gate-entry.add') New Gate Entry @endcan
{{-- =================================================================== RECEPTION DOCUMENTATION (Phase 2) — category tabs, Add New Admission, resumable in-progress admissions. This IS "Reception Search". =================================================================== --}}
{{-- Add New Admission --}}
Add New Admission — captured at gate, not yet admitted
@forelse ($awaitingGateEntries as $ge) @empty @endforelse
Prison No. Name Court Case No. Court Decision Gate Date
{{ $ge->prison_number }} {{ $ge->prisoner->name ?? 'N/A' }} {{ $ge->case_number }} {{ $ge->court_decision }} {{ optional($ge->admission_date_gate)->format('d M Y') }}
@csrf
No prisoners awaiting documentation in this category.
{{-- Resume in-progress admissions --}}
In-Progress Admissions — resume where you left off
@forelse ($inProgressAdmissions as $adm) @empty @endforelse
Prison No. Name Step
{{ $adm->prison_number }} {{ $adm->prisoner->name ?? 'N/A' }} {{ $adm->current_step ?? $adm->wizardSteps()->first()->step_key }} Resume
Nothing in progress.
{{-- =================================================================== BELOW: existing movement / custody dashboard for prisoners already admitted — stats, transfers, temporary release, knock in/out, escapes, and the searchable reception log. Unchanged. =================================================================== --}}
Custody & Movement
{{-- STATS CARDS --}}
Today's Receptions

{{ $today ?? 0 }}

Pending Verification

{{ $pending ?? 0 }}

Verified

{{ $verified ?? 0 }}

Knocked Out

{{ $knockedOut ?? 0 }}

Re-arrested

{{ $reArrested ?? 0 }}

Denied

{{ $denied ?? 0 }}

Total Receptions

{{ $total ?? 0 }}

{{-- INCOMING TRANSFERS CARD - Only shows transfers to current branch --}}
Incoming Transfers

@php $incomingCount = \App\Models\Reception::where('transfer_to_branch_id', auth()->user()->branch_id) ->where('transfer_status', 'in_transit') ->count(); @endphp {{ $incomingCount }}

{{-- INCOMING TRANSFERS SECTION - Shows only transfers to current branch --}} @php $incomingTransfers = \App\Models\Reception::where('transfer_to_branch_id', auth()->user()->branch_id) ->where('transfer_status', 'in_transit') ->with(['prisoner', 'transferFromBranch']) ->orderBy('transfer_date', 'desc') ->get(); @endphp @if($incomingTransfers->count() > 0)
Pending Incoming Transfers (Need Your Attention)
@foreach($incomingTransfers as $transfer) @endforeach
Prisoner Number Name From Branch Transfer Date Action
{{ $transfer->prisoner_number }} {{ $transfer->prisoner->prisoner_number ?? 'N/A' }} {{ $transfer->prisoner->name ?? 'N/A' }} @php $fromBranch = \App\Models\Branch::find($transfer->transfer_from_branch_id); @endphp {{ $fromBranch->branch_name ?? 'Unknown' }} @if($fromBranch && $fromBranch->city)
{{ $fromBranch->city }} @endif
{{ \Carbon\Carbon::parse($transfer->transfer_date)->format('Y-m-d') }} Receive & Admit
@endif {{-- Currently Out on Temporary Release (Excluding Transfers) --}}
Currently Out on Temporary Release
(Court, Hospital, Parole - Excludes Transfers)
@php $currentlyOut = \App\Models\Reception::whereNotNull('knocked_out_at') ->whereNull('knocked_in_at') ->where('knocked_out_reason', '!=', 'transfer') // EXCLUDE TRANSFERS ->where('knocked_out_reason', '!=', 'Transfer to another facility') // EXCLUDE TRANSFERS ->with('prisoner') ->get(); @endphp @if($currentlyOut->count() > 0)
@foreach($currentlyOut as $out) @endforeach
Name Release Type Released Expected Return Action
{{ $out->prisoner->name ?? 'N/A' }} {{ ucfirst(str_replace('_', ' ', $out->knocked_out_reason ?? 'Unknown')) }} {{ \Carbon\Carbon::parse($out->knocked_out_at)->diffForHumans() }} @if($out->expected_return_date) {{ \Carbon\Carbon::parse($out->expected_return_date)->format('Y-m-d') }} @else Not set @endif
@csrf
@else

No prisoners currently out on temporary release.

@endif
{{-- FILTERS --}}
{{-- TABLE --}}
@forelse($receptions as $key=>$rec) {{-- TRANSFER MODAL WITH BRANCH SELECTION --}} {{-- TEMPORARY RELEASE MODAL — reasons are category-specific (e.g. Convicted: Work Release; Remand: Court Appearance) --}} @php $categoryReasons = optional($rec->prisonerCategory)->knockoutReasons; if (!$categoryReasons || $categoryReasons->isEmpty()) { $categoryReasons = collect([ (object) ['action_key' => 'hospital_visit', 'action_label' => 'Hospital Visit'], (object) ['action_key' => 'court_appearance', 'action_label' => 'Court Appearance'], (object) ['action_key' => 'other', 'action_label' => 'Other'], ]); } @endphp {{-- RETURN FROM RELEASE MODAL (Knock In) --}} @if($rec->knocked_out_at && !$rec->knocked_in_at) @endif {{-- ESCAPE MODAL --}} {{-- RECAPTURE MODAL --}} {{-- DENY MODAL --}} @empty @endforelse
# Reception # Prisoner No Name Source Status Location Detention Date Actions
{{ $key+1 }} #{{ $rec->reception_number ?? 1 }} @if(($rec->reception_number ?? 1) > 1) RE-ARREST @endif {{ $rec->prisoner->prisoner_number ?? 'N/A' }} {{ $rec->prisoner->name ?? 'N/A' }} {{ $rec->source ?? 'N/A' }} {{ $rec->status ?? 'N/A' }} @if($rec->prisonerCategory) {{ $rec->prisonerCategory->name }} @endif @if($rec->knocked_out_reason == 'transfer' && $rec->transfer_status == 'in_transit') TRANSFERRED To: @php $toBranch = \App\Models\Branch::find($rec->transfer_to_branch_id); @endphp {{ $toBranch->branch_name ?? 'Unknown' }} IN TRANSIT @elseif($rec->knocked_out_at && is_null($rec->knocked_in_at)) KNOCKED OUT {{ ucfirst(str_replace('_', ' ', $rec->knocked_out_reason ?? 'Unknown')) }} AWAITING RETURN @elseif($rec->knocked_in_at && is_null($rec->knocked_out_at)) IN CUSTODY @elseif(!$rec->admitted_flag) AWAITING DOCUMENTATION @else PENDING @endif {{ $rec->detention_count ?? 0 }} @if(($rec->detention_count ?? 0) >= 3) ⚠️ @endif {{ $rec->created_at ? $rec->created_at->format('Y-m-d') : 'N/A' }}
No reception records found
{{ $receptions->links() }}
@endsection