TKK_E3220375/resources/views/admin/jurusan/index.blade.php

154 lines
8.6 KiB
PHP

@extends('layouts.dashboard')
@section('title', 'Smart School | Manajemen Jurusan')
@section('content')
<div class="container mx-auto px-4 py-6">
<!-- Header Section -->
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4">
<div>
<h1 class="text-2xl font-bold text-gray-800">Manajemen Jurusan</h1>
<p class="text-sm text-gray-600">Kelola data jurusan sekolah</p>
</div>
<a href="{{ route('admin.jurusan.create') }}"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center transition duration-300 shadow-md hover:shadow-lg">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd" />
</svg>
Tambah Jurusan
</a>
</div>
<!-- Stats Card -->
<div class="grid grid-cols-1 gap-4 mb-6">
<div class="bg-white rounded-xl shadow-md p-5 border-l-4 border-blue-500">
<div class="flex items-center">
<div class="p-3 rounded-full bg-blue-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
</svg>
</div>
<div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Total Jurusan</h3>
<p class="text-lg font-semibold text-gray-700">{{ $jurusan->count() }}</p>
</div>
</div>
</div>
</div>
<!-- Table Section -->
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<!-- Filter and Search -->
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
<form action="{{ route('admin.jurusan.index') }}" method="GET" class="flex flex-wrap items-center gap-4 w-full md:w-auto">
<!-- Search Box -->
<div class="w-full md:w-auto flex-grow">
<label for="search" class="block text-sm font-medium text-gray-700 mb-1">Cari Jurusan</label>
<div class="relative">
<input type="text" id="search" name="search" placeholder="Cari nama jurusan..."
value="{{ request('search') }}"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 pl-10">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
</svg>
</div>
</div>
</div>
@if(request('search'))
<div class="flex items-end">
<a href="{{ route('admin.jurusan.index') }}" class="text-sm text-blue-600 hover:underline flex items-center mt-1">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
</svg>
Reset Filter
</a>
</div>
@endif
</form>
</div>
</div>
<!-- Jurusan Table -->
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">No</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nama Jurusan</th>
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($jurusan as $index => $item)
<tr class="hover:bg-gray-50 transition duration-150">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $index + 1 }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $item->nama_jurusan }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<div class="flex justify-end space-x-2">
<a href="{{ route('admin.jurusan.edit', $item->id) }}"
class="text-yellow-600 hover:text-yellow-900 inline-flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg>
</a>
<form action="{{ route('admin.jurusan.destroy', $item->id) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="button" onclick="confirmDelete('{{ $item->nama_jurusan }}', this.form)"
class="text-red-600 hover:text-red-900 inline-flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="px-6 py-4 text-center text-gray-500">Belum ada data jurusan</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination -->
@if($jurusan->hasPages())
<div class="px-6 py-4 border-t border-gray-200">
{{ $jurusan->links() }}
</div>
@endif
</div>
</div>
<!-- Include SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function confirmDelete(name, form) {
Swal.fire({
title: 'Hapus Jurusan?',
html: `Anda akan menghapus jurusan <strong>${name}</strong>`,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
}
});
}
</script>
@endsection