MIF_E31230820/resources/views/riwayat.blade.php

231 lines
5.4 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<title>Riwayat Prediksi</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-green-50 p-10">
<div class="max-w-6xl mx-auto bg-white p-8 rounded-xl shadow">
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-green-700">
<a href="/export-pdf"
class="bg-red-600 text-white px-4 py-2 rounded">
Download PDF
</a>
Riwayat Prediksi
</h1>
<form method="GET"
class="flex flex-col md:flex-row gap-4 my-6">
<!-- Search -->
<input type="text"
name="search"
placeholder="Cari penyakit..."
value="{{ request('search') }}"
class="border border-gray-300 rounded-xl px-4 py-3 w-full">
<!-- Filter -->
<select name="filter"
class="border border-gray-300 rounded-xl px-4 py-3">
<option value="">Semua Penyakit</option>
<option value="Blast"
{{ request('filter') == 'Blast' ? 'selected' : '' }}>
Blast
</option>
<option value="Blight"
{{ request('filter') == 'Blight' ? 'selected' : '' }}>
Blight
</option>
<option value="Tungro"
{{ request('filter') == 'Tungro' ? 'selected' : '' }}>
Tungro
</option>
<option value="Healthy"
{{ request('filter') == 'Healthy' ? 'selected' : '' }}>
Healthy
</option>
</select>
<button type="submit"
class="bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-xl">
Cari
</button>
</form>
<a href="/"
class="bg-green-600 text-white px-4 py-2 rounded">
Kembali
</a>
</div>
<table class="w-full border-collapse">
<thead>
<tr class="bg-green-600 text-white">
<th class="p-3">No</th>
<th class="p-3">Gambar</th>
<th class="p-3">Penyakit</th>
<th class="p-3">Confidence</th>
<th class="p-3">Tanggal</th>
<th class="p-3">Aksi</th>
</tr>
</thead>
<tbody>
@foreach($data as $item)
<tr class="border-b text-center">
<td class="p-3">
{{ $loop->iteration }}
</td>
<td class="p-3">
<img src="{{ asset('uploads/' . $item->gambar) }}"
class="w-24 h-24 object-cover rounded mx-auto">
</td>
<td class="p-3">
@if($item->penyakit == 'Blast')
<span class="bg-red-100 text-red-700 px-4 py-2 rounded-full font-semibold">
Blast
</span>
@elseif($item->penyakit == 'Blight')
<span class="bg-yellow-100 text-yellow-700 px-4 py-2 rounded-full font-semibold">
Blight
</span>
@elseif($item->penyakit == 'Tungro')
<span class="bg-orange-100 text-orange-700 px-4 py-2 rounded-full font-semibold">
Tungro
</span>
@else
<span class="bg-green-100 text-green-700 px-4 py-2 rounded-full font-semibold">
Healthy
</span>
@endif
</td>
<td class="p-3">
{{ $item->confidence }}%
</td>
<td class="p-3">
{{ $item->created_at }}
</td>
<td class="p-3">
<form action="/hapus/{{ $item->id }}"
method="POST"
class="formHapus">>
@csrf
@method('DELETE')
<button type="submit"
class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg">
Hapus
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@if(session('success'))
<script>
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: '{{ session('success') }}',
timer: 2000,
showConfirmButton: false
});
</script>
@endif
<script>
const forms = document.querySelectorAll('.formHapus');
forms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
Swal.fire({
title: 'Yakin?',
text: "Data prediksi akan dihapus!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#16a34a',
cancelButtonColor: '#dc2626',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
}
});
});
});
</script>
</body>
</html>