233 lines
14 KiB
PHP
233 lines
14 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Rekod Kerusi Roda')
|
|
|
|
@section('content')
|
|
<div class="page-heading">
|
|
<div class="eyebrow">Admin</div>
|
|
<div class="d-flex justify-content-between flex-column flex-lg-row gap-3">
|
|
<div>
|
|
<h1 class="h3 mb-1">Rekod Kerusi Roda</h1>
|
|
<p class="text-secondary mb-0">{{ $allocation->pusatMengundi?->code }} — {{ $allocation->pusatMengundi?->name }}</p>
|
|
</div>
|
|
<div><a class="btn btn-outline-secondary" href="{{ route('admin.management.wheelchairs.index') }}">Kembali</a></div>
|
|
</div>
|
|
</div>
|
|
|
|
@include('admin.management._nav')
|
|
|
|
@php
|
|
$taken = $service->takenQuantity($allocation);
|
|
$returned = $service->returnedQuantity($allocation);
|
|
$outstanding = $service->outstandingQuantity($allocation);
|
|
$available = $service->availableQuantity($allocation);
|
|
@endphp
|
|
|
|
<div class="row g-3 mb-4">
|
|
@foreach ([
|
|
['label' => 'Peruntukan', 'value' => $allocation->allocated_quantity, 'tone' => 'primary'],
|
|
['label' => 'Diambil', 'value' => $taken, 'tone' => 'info'],
|
|
['label' => 'Dipulang', 'value' => $returned, 'tone' => 'success'],
|
|
['label' => 'Belum dipulang', 'value' => $outstanding, 'tone' => 'warning'],
|
|
['label' => 'Baki boleh diambil','value' => $available, 'tone' => 'secondary'],
|
|
] as $card)
|
|
<div class="col-12 col-sm-6 col-xl">
|
|
<div class="stat-card h-100">
|
|
<div class="text-secondary small">{{ $card['label'] }}</div>
|
|
<div class="fs-3 fw-bold mt-2 text-{{ $card['tone'] }}">{{ $card['value'] }}</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
|
|
<div class="row g-3">
|
|
{{-- Kiri: 3 panel borang --}}
|
|
<div class="col-12 col-xl-5">
|
|
|
|
{{-- Kemaskini Peruntukan --}}
|
|
<div class="content-panel p-3 p-md-4 mb-3">
|
|
<h2 class="h5 mb-3">Kemaskini Peruntukan</h2>
|
|
<form method="POST" action="{{ route('admin.management.wheelchairs.update', $allocation) }}">
|
|
@csrf @method('PATCH')
|
|
<input type="hidden" name="election_id" value="{{ $allocation->election_id }}">
|
|
<input type="hidden" name="pusat_mengundi_id" value="{{ $allocation->pusat_mengundi_id }}">
|
|
<div class="mb-3">
|
|
<label class="form-label" for="allocated_quantity">Jumlah Peruntukan</label>
|
|
<input class="form-control @error('allocated_quantity') is-invalid @enderror"
|
|
id="allocated_quantity" name="allocated_quantity" type="number" min="{{ $outstanding }}"
|
|
value="{{ old('allocated_quantity', $allocation->allocated_quantity) }}" required>
|
|
<div class="form-text">Minimum {{ $outstanding }} (kerusi belum dipulang).</div>
|
|
@error('allocated_quantity') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label" for="notes">Nota</label>
|
|
<textarea class="form-control" id="notes" name="notes" rows="2">{{ old('notes', $allocation->notes) }}</textarea>
|
|
</div>
|
|
<div class="d-flex justify-content-end">
|
|
<button class="btn btn-primary" type="submit"><i class="bi bi-save me-1"></i>Simpan</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{{-- Rekod Ambil --}}
|
|
<div class="content-panel p-3 p-md-4 mb-3 border-start border-4 border-info">
|
|
<h2 class="h5 mb-1">Rekod Ambil</h2>
|
|
<p class="text-secondary small mb-3">Baki boleh diambil: <strong class="text-info">{{ $available }}</strong></p>
|
|
|
|
@if ($available === 0)
|
|
<div class="alert alert-secondary py-2 mb-0">Tiada baki kerusi roda untuk diambil.</div>
|
|
@else
|
|
<form method="POST" action="{{ route('admin.management.wheelchairs.ambil', $allocation) }}">
|
|
@csrf
|
|
<div class="row g-3">
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="taken_quantity">Jumlah Ambil</label>
|
|
<input class="form-control @error('quantity') is-invalid @enderror"
|
|
id="taken_quantity" name="quantity" type="number" min="1" max="{{ $available }}"
|
|
value="{{ old('quantity') }}" required>
|
|
<div class="form-text">Maks: {{ $available }}</div>
|
|
@error('quantity') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="taken_at">Masa Ambil</label>
|
|
<input class="form-control @error('taken_at') is-invalid @enderror"
|
|
id="taken_at" name="taken_at" type="datetime-local"
|
|
value="{{ old('taken_at', now()->format('Y-m-d\TH:i')) }}">
|
|
@error('taken_at') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="taken_by_name">Diambil Oleh <span class="text-danger">*</span></label>
|
|
<input class="form-control @error('taken_by_name') is-invalid @enderror"
|
|
id="taken_by_name" name="taken_by_name"
|
|
value="{{ old('taken_by_name') }}" required>
|
|
@error('taken_by_name') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="taken_notes">Nota</label>
|
|
<textarea class="form-control" id="taken_notes" name="notes" rows="2">{{ old('notes') }}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex justify-content-end mt-3">
|
|
<button class="btn btn-info text-white" type="submit"><i class="bi bi-box-arrow-up-right me-1"></i>Rekod Ambil</button>
|
|
</div>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
|
|
{{-- Rekod Pulang --}}
|
|
<div class="content-panel p-3 p-md-4 border-start border-4 border-success">
|
|
<h2 class="h5 mb-1">Rekod Pulang</h2>
|
|
<p class="text-secondary small mb-3">Belum dipulang: <strong class="text-warning">{{ $outstanding }}</strong></p>
|
|
|
|
@if ($outstanding === 0)
|
|
<div class="alert alert-secondary py-2 mb-0">Tiada kerusi roda yang perlu dipulangkan.</div>
|
|
@else
|
|
<form method="POST" action="{{ route('admin.management.wheelchairs.pulang', $allocation) }}">
|
|
@csrf
|
|
<div class="row g-3">
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="return_quantity">Jumlah Pulang</label>
|
|
<input class="form-control @error('quantity') is-invalid @enderror"
|
|
id="return_quantity" name="quantity" type="number" min="1" max="{{ $outstanding }}"
|
|
value="{{ old('quantity') }}" required>
|
|
<div class="form-text">Maks: {{ $outstanding }}</div>
|
|
@error('quantity') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="returned_at">Masa Pulang</label>
|
|
<input class="form-control @error('returned_at') is-invalid @enderror"
|
|
id="returned_at" name="returned_at" type="datetime-local"
|
|
value="{{ old('returned_at', now()->format('Y-m-d\TH:i')) }}">
|
|
@error('returned_at') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="returned_by_name">Dipulang Oleh <span class="text-danger">*</span></label>
|
|
<input class="form-control @error('returned_by_name') is-invalid @enderror"
|
|
id="returned_by_name" name="returned_by_name"
|
|
value="{{ old('returned_by_name') }}" required>
|
|
@error('returned_by_name') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-md-12">
|
|
<label class="form-label" for="return_condition">Keadaan <span class="text-danger">*</span></label>
|
|
<select class="form-select @error('return_condition') is-invalid @enderror"
|
|
id="return_condition" name="return_condition" required>
|
|
<option value="">Pilih keadaan</option>
|
|
<option value="baik" @selected(old('return_condition') === 'baik')>Baik</option>
|
|
<option value="rosak" @selected(old('return_condition') === 'rosak')>Rosak</option>
|
|
</select>
|
|
@error('return_condition') <div class="invalid-feedback">{{ $message }}</div> @enderror
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="return_notes">Nota</label>
|
|
<textarea class="form-control" id="return_notes" name="notes" rows="2">{{ old('notes') }}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex justify-content-end mt-3">
|
|
<button class="btn btn-success" type="submit"><i class="bi bi-box-arrow-in-down-left me-1"></i>Rekod Pulang</button>
|
|
</div>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Kanan: Sejarah transaksi --}}
|
|
<div class="col-12 col-xl-7">
|
|
<div class="content-panel p-0 overflow-hidden">
|
|
<div class="p-3 border-bottom fw-semibold">Sejarah Transaksi</div>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>Jenis</th>
|
|
<th>Jml</th>
|
|
<th>Masa</th>
|
|
<th>Nama</th>
|
|
<th>Keadaan</th>
|
|
<th>Direkod Oleh</th>
|
|
<th>Nota</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse ($allocation->transactions->sortByDesc('created_at') as $tx)
|
|
<tr>
|
|
<td>
|
|
@if ($tx->transaction_type === 'taken')
|
|
<span class="badge text-bg-info">Ambil</span>
|
|
@else
|
|
<span class="badge text-bg-success">Pulang</span>
|
|
@endif
|
|
</td>
|
|
<td class="fw-semibold">{{ $tx->quantity }}</td>
|
|
<td class="small">
|
|
{{ ($tx->taken_at ?? $tx->returned_at)?->format('d/m/Y H:i') ?? '-' }}
|
|
</td>
|
|
<td class="small">
|
|
@if ($tx->transaction_type === 'taken')
|
|
{{ $tx->taken_by_name ?: '-' }}
|
|
@else
|
|
{{ $tx->returned_by_name ?: '-' }}
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if ($tx->transaction_type === 'returned' && $tx->return_condition)
|
|
<span class="badge {{ $tx->return_condition === 'baik' ? 'text-bg-success' : 'text-bg-danger' }}">
|
|
{{ ucfirst($tx->return_condition) }}
|
|
</span>
|
|
@else
|
|
<span class="text-secondary">—</span>
|
|
@endif
|
|
</td>
|
|
<td class="small text-secondary">{{ $tx->recordedBy?->name ?: '-' }}</td>
|
|
<td class="small text-secondary">{{ $tx->notes ?: '-' }}</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="7" class="text-center text-secondary py-4">Tiada transaksi direkodkan.</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|