MIF_E31222596/website/resources/views/absensis/index.blade.php

139 lines
9.5 KiB
PHP

<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Daftar absensi') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-2xl">
<div class="p-8">
<!-- Header Section -->
<div class="mb-8">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Rekap Absensi</h2>
<p class="text-gray-600">Kelola dan pantau kehadiran santri dengan mudah</p>
</div>
<!-- Filter Form -->
<div class="bg-gray-50 rounded-xl p-6 mb-8">
<form method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-4 items-end">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Kelas</label>
<select name="kelas_id" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" required>
<option value="">Pilih Kelas</option>
@foreach($kelasList as $k)
<option value="{{ $k->id }}" {{ $kelasId==$k->id?'selected':'' }}>{{ $k->nama_kelas }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Tanggal</label>
<input type="date" name="tanggal" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" value="{{ $tanggal }}">
</div>
<div>
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition-colors duration-200 flex items-center justify-center">
<i class="fas fa-search mr-2"></i>
Tampilkan
</button>
</div>
<!-- <div>
@if($kelasId)
<a href="{{ route('absensis.create', ['kelas_id'=>$kelasId, 'tanggal'=>$tanggal]) }}" class="w-full bg-green-600 hover:bg-green-700 text-white font-medium py-3 px-6 rounded-lg transition-colors duration-200 flex items-center justify-center">
<i class="fas fa-plus mr-2"></i>
Input Absensi
</a>
@endif
</div> -->
</form>
</div>
<!-- Data Table -->
@if($santris->count())
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gradient-to-r from-green-600 to-yellow-400 text-white">
<tr>
<th class="px-6 py-4 text-left text-sm font-semibold">No</th>
<th class="px-6 py-4 text-left text-sm font-semibold">Nama Santri</th>
<th class="px-6 py-4 text-left text-sm font-semibold">Status</th>
<th class="px-6 py-4 text-left text-sm font-semibold">Keterangan</th>
<th class="px-6 py-4 text-center text-sm font-semibold">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@foreach($santris as $i => $santri)
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-6 py-4 text-sm text-gray-900">{{ $i+1 }}</td>
<td class="px-6 py-4">
<div class="flex items-center">
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center mr-3">
<span class="text-green-600 font-semibold text-sm">{{ substr($santri->nama, 0, 1) }}</span>
</div>
<span class="font-medium text-gray-900">{{ $santri->nama }}</span>
</div>
</td>
<td class="px-6 py-4">
@if(isset($absensis[$santri->id]))
@php
$status = $absensis[$santri->id]->status;
$statusColors = [
'hadir' => 'bg-green-100 text-green-800',
'izin' => 'bg-yellow-100 text-yellow-800',
'sakit' => 'bg-orange-100 text-orange-800',
'alfa' => 'bg-red-100 text-red-800'
];
$color = $statusColors[$status] ?? 'bg-gray-100 text-gray-800';
@endphp
<span class="inline-flex px-3 py-1 text-xs font-semibold rounded-full {{ $color }}">
{{ ucfirst($status) }}
</span>
@else
<span class="text-gray-400">-</span>
@endif
</td>
<td class="px-6 py-4 text-sm text-gray-600">
{{ $absensis[$santri->id]->keterangan ?? '-' }}
</td>
<td class="px-6 py-4 text-center">
@if(isset($absensis[$santri->id]))
<div class="flex items-center justify-center space-x-2">
<a href="{{ route('absensis.edit', $absensis[$santri->id]->id) }}" class="inline-flex items-center px-3 py-2 text-sm font-medium text-yellow-900 bg-yellow-300 rounded-lg hover:bg-yellow-400 transition-colors">
<i class="fas fa-edit mr-1"></i>
Edit
</a>
<form action="{{ route('absensis.destroy', $absensis[$santri->id]->id) }}" method="POST" class="inline-block" onsubmit="return confirm('Yakin hapus absensi ini?')">
@csrf
@method('DELETE')
<button type="submit" class="inline-flex items-center px-3 py-2 text-sm font-medium text-red-600 bg-red-100 rounded-lg hover:bg-red-200 transition-colors">
<i class="fas fa-trash mr-1"></i>
Hapus
</button>
</form>
</div>
@else
<span class="text-gray-400 text-sm">Belum ada data</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@elseif($kelasId)
<div class="text-center py-12">
<div class="w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-exclamation-triangle text-yellow-600 text-2xl"></i>
</div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Tidak ada data santri</h3>
<p class="text-gray-600">Tidak ada data santri di kelas yang dipilih.</p>
</div>
@endif
</div>
</div>
</div>
</div>
</x-app-layout>