Files
2026-06-03 08:51:22 +08:00

97 lines
6.3 KiB
PHP

@extends('layouts.app')
@section('title', 'Wakil Agensi')
@section('content')
<div class="page-heading">
<div class="eyebrow">Admin</div>
<h1 class="h3 mb-1">Wakil Polis, KKM dan JKM</h1>
<p class="text-secondary mb-0">Kemasukan manual wakil agensi untuk Pusat Mengundi dan Saluran.</p>
</div>
@include('admin.management._nav')
<div class="content-panel p-3 p-md-4 mb-4">
<h2 class="h5 mb-3">Tambah Wakil</h2>
<form method="POST" action="{{ route('admin.management.representatives.store') }}">
@csrf
<div class="row g-3">
<div class="col-md-3">
<label class="form-label" for="type">Jenis</label>
<select class="form-select" id="type" name="type" required>
<option value="police">Polis Pengiring</option>
<option value="kkm">Wakil KKM</option>
<option value="jkm">Wakil JKM</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label" for="election_id">Pilihanraya</label>
<select class="form-select" id="election_id" name="election_id" required>
@foreach ($elections as $election)
<option value="{{ $election->id }}">{{ $election->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<label class="form-label" for="pusat_mengundi_id">Pusat</label>
<select class="form-select" id="pusat_mengundi_id" name="pusat_mengundi_id" required>
@foreach ($pusats as $pusat)
<option value="{{ $pusat->id }}">{{ $pusat->code }} - {{ $pusat->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<label class="form-label" for="saluran_mengundi_id">Saluran Polis</label>
<select class="form-select" id="saluran_mengundi_id" name="saluran_mengundi_id">
<option value="">Tiada / Pusat level</option>
@foreach ($salurans as $saluran)
<option value="{{ $saluran->id }}">{{ $saluran->pusatMengundi?->code }} - Saluran {{ $saluran->number }}</option>
@endforeach
</select>
</div>
<div class="col-md-4"><label class="form-label" for="name">Nama</label><input class="form-control" id="name" name="name" required></div>
<div class="col-md-4"><label class="form-label" for="ic_number">No. IC</label><input class="form-control" id="ic_number" name="ic_number" maxlength="12"></div>
<div class="col-md-4"><label class="form-label" for="phone_number">Telefon</label><input class="form-control" id="phone_number" name="phone_number"></div>
<div class="col-md-4"><label class="form-label" for="rank">Pangkat Polis</label><input class="form-control" id="rank" name="rank"></div>
<div class="col-md-4"><label class="form-label" for="station">Balai Polis</label><input class="form-control" id="station" name="station"></div>
<div class="col-md-4"><label class="form-label" for="agency">Agensi</label><input class="form-control" id="agency" name="agency"></div>
<div class="col-md-6"><label class="form-label" for="notes">Nota Operasi</label><textarea class="form-control" id="notes" name="notes" rows="2"></textarea></div>
<div class="col-md-6"><label class="form-label" for="note">Catatan Admin</label><textarea class="form-control" id="note" name="note" rows="2" placeholder="Wajib selepas tempoh pendaftaran ditutup"></textarea></div>
</div>
<div class="d-flex justify-content-end mt-3"><button class="btn btn-primary" type="submit"><i class="bi bi-save me-1"></i>Simpan</button></div>
</form>
</div>
@foreach ([['title' => 'Polis Pengiring', 'items' => $policeEscorts, 'type' => 'police'], ['title' => 'Wakil KKM', 'items' => $kkmRepresentatives, 'type' => 'kkm'], ['title' => 'Wakil JKM', 'items' => $jkmRepresentatives, 'type' => 'jkm']] as $section)
<div class="content-panel p-0 overflow-hidden mb-4">
<div class="p-3 border-bottom fw-semibold">{{ $section['title'] }}</div>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead><tr><th>Nama</th><th>Pusat</th><th>Telefon</th><th>Nota</th><th class="text-end no-sort">Tindakan</th></tr></thead>
<tbody>
@forelse ($section['items'] as $item)
<tr>
<td>{{ $item->name }}<div class="small text-secondary">{{ $item->ic_number ?: '-' }}</div></td>
<td>{{ $item->pusatMengundi?->code }} @if($section['type'] === 'police' && $item->saluranMengundi) · Saluran {{ $item->saluranMengundi->number }} @endif</td>
<td>{{ $item->phone_number ?: '-' }}</td>
<td>{{ $item->notes ?: '-' }}</td>
<td class="text-end">
<form method="POST" action="{{ route('admin.management.representatives.destroy', [$section['type'], $item->id]) }}" onsubmit="return confirm('Padam rekod ini?')">
@csrf
@method('DELETE')
<input type="hidden" name="note" value="Dipadam oleh Admin.">
<button class="btn btn-sm btn-outline-danger" type="submit"><i class="bi bi-trash"></i></button>
</form>
</td>
</tr>
@empty
<tr><td colspan="5" class="text-center text-secondary py-4">Tiada rekod.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="p-3">{{ $section['items']->links() }}</div>
</div>
@endforeach
@endsection