Files
eCert-MBIP/resources/views/admin/programs/index.blade.php
Saufi d0be749f29 feat: program management
- ProgramController: full CRUD, publish, close, delete (guarded if attendance exists)
- StoreProgramRequest + UpdateProgramRequest with Malay attribute names
- AuditLogService: logs admin actions, redacts sensitive fields (no_kp, token, password)
- Program index: search, status filter, pagination (Bootstrap 5)
- Program create/edit: shared _form partial with all fields (dates, sessions, walk-in toggle)
- Program show: tab layout (participants, qr, template, questionnaire, statistics)
- Bootstrap 5 pagination via Paginator::useBootstrapFive()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:31:00 +08:00

176 lines
7.6 KiB
PHP

@extends('layouts.admin')
@section('title', 'Senarai Program')
@section('header', 'Senarai Program')
@section('breadcrumb')
<li class="breadcrumb-item active">Program</li>
@endsection
@section('header-actions')
<a href="{{ route('admin.programs.create') }}" class="btn btn-primary btn-sm">
<i class="bi bi-plus-lg me-1"></i> Program Baru
</a>
@endsection
@section('content')
{{-- Filter Bar --}}
<div class="card border-0 shadow-sm mb-4">
<div class="card-body py-3">
<form method="GET" class="row g-2 align-items-end">
<div class="col-sm-6 col-md-5">
<label class="form-label small text-muted mb-1">Carian</label>
<div class="input-group input-group-sm">
<span class="input-group-text"><i class="bi bi-search"></i></span>
<input type="text" name="search" class="form-control"
placeholder="Nama program, penganjur, lokasi..."
value="{{ request('search') }}">
</div>
</div>
<div class="col-sm-4 col-md-3">
<label class="form-label small text-muted mb-1">Status</label>
<select name="status" class="form-select form-select-sm">
<option value="">Semua Status</option>
<option value="draft" {{ request('status') === 'draft' ? 'selected' : '' }}>Draf</option>
<option value="published" {{ request('status') === 'published' ? 'selected' : '' }}>Diterbitkan</option>
<option value="closed" {{ request('status') === 'closed' ? 'selected' : '' }}>Ditutup</option>
</select>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary btn-sm">Tapis</button>
@if(request()->hasAny(['search', 'status']))
<a href="{{ route('admin.programs.index') }}" class="btn btn-outline-secondary btn-sm ms-1">Reset</a>
@endif
</div>
</form>
</div>
</div>
{{-- Table --}}
<div class="card border-0 shadow-sm">
<div class="card-body p-0">
@if($programs->isEmpty())
<div class="text-center py-5 text-muted">
<i class="bi bi-calendar-x fs-1 d-block mb-2 opacity-25"></i>
@if(request()->hasAny(['search', 'status']))
Tiada program sepadan dengan carian.
@else
Belum ada program. <a href="{{ route('admin.programs.create') }}">Tambah sekarang</a>
@endif
</div>
@else
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Nama Program</th>
<th>Tarikh</th>
<th class="text-center">Kehadiran</th>
<th class="text-center">Peserta</th>
<th>Status</th>
<th class="text-end">Tindakan</th>
</tr>
</thead>
<tbody>
@foreach($programs as $program)
<tr>
<td>
<div class="fw-medium">{{ $program->title }}</div>
<small class="text-muted">
<i class="bi bi-geo-alt me-1"></i>{{ Str::limit($program->location, 40) }}
</small>
</td>
<td style="min-width:130px;">
<div class="small">{{ $program->start_date->format('d M Y') }}</div>
@if($program->start_date->ne($program->end_date))
<div class="small text-muted">- {{ $program->end_date->format('d M Y') }}</div>
@endif
</td>
<td class="text-center">
<span class="badge bg-light text-dark border">
{{ $program->attendances_count }}
</span>
</td>
<td class="text-center">
<span class="badge bg-light text-dark border">
{{ $program->program_participants_count }}
</span>
</td>
<td>
@include('admin.partials.program-status-badge', ['status' => $program->status])
</td>
<td class="text-end">
<div class="btn-group btn-group-sm">
<a href="{{ route('admin.programs.show', $program) }}"
class="btn btn-outline-primary" title="Lihat">
<i class="bi bi-eye"></i>
</a>
@if($program->status === 'draft')
<a href="{{ route('admin.programs.edit', $program) }}"
class="btn btn-outline-secondary" title="Edit">
<i class="bi bi-pencil"></i>
</a>
@endif
@if($program->status === 'draft' && $program->attendances_count === 0)
<button type="button" class="btn btn-outline-danger"
title="Padam"
onclick="confirmDelete('{{ $program->title }}', '{{ route('admin.programs.destroy', $program) }}')">
<i class="bi bi-trash"></i>
</button>
@endif
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
{{-- Pagination --}}
@if($programs->hasPages())
<div class="px-3 py-3 border-top">
{{ $programs->links() }}
</div>
@endif
@endif
</div>
</div>
{{-- Delete Confirm Modal --}}
<div class="modal fade" id="deleteModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header border-0">
<h6 class="modal-title fw-semibold">Sahkan Pemadaman</h6>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<p>Adakah anda pasti untuk memadam program <strong id="deleteTitle"></strong>?</p>
<p class="text-muted small mb-0">Tindakan ini tidak boleh dibatalkan.</p>
</div>
<div class="modal-footer border-0">
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Batal</button>
<form id="deleteForm" method="POST">
@csrf @method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">
<i class="bi bi-trash me-1"></i> Ya, Padam
</button>
</form>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
function confirmDelete(title, url) {
document.getElementById('deleteTitle').textContent = '"' + title + '"';
document.getElementById('deleteForm').action = url;
new bootstrap.Modal(document.getElementById('deleteModal')).show();
}
</script>
@endpush