217 lines
13 KiB
PHP
217 lines
13 KiB
PHP
<x-layout>
|
|
<x-slot:title>{{ $title}}</x-slot>
|
|
|
|
<!-- Tombol Tambah Kelompok Tani -->
|
|
<button data-modal-target="tambahKelompokModal" data-modal-toggle="tambahKelompokModal"
|
|
class="text-white bg-[#388E3C] hover:bg-green-900 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 mb-5">
|
|
Tambah Kelompok
|
|
</button>
|
|
|
|
<div class="flex items-center justify-center">
|
|
<div class="overflow-x-auto w-full">
|
|
<table class="w-full text-sm text-left text-[#1B5E20] border border-[#C8E6C9]">
|
|
<thead class="text-xs text-white uppercase bg-[#388E3C]">
|
|
<tr>
|
|
<th scope="col" class="px-6 py-3">Nama Kelompok Tani</th>
|
|
<th scope="col" class="px-6 py-3">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse ($kelompokTani as $item)
|
|
<tr class="bg-[#f9f9f9] border-b border-[#ddd] hover:bg-[#e2e2e2]">
|
|
<td class="px-6 py-4">{{ $item->nama }}</td>
|
|
<td class="px-6 py-4">
|
|
<!-- Tombol Edit Modal -->
|
|
<button type="button"
|
|
data-modal-target="editKelompokModal{{ $item->id }}"
|
|
data-modal-toggle="editKelompokModal{{ $item->id }}"
|
|
class="bg-white border border-blue-600 p-1 rounded cursor-pointer
|
|
text-blue-600 hover:bg-blue-600 hover:text-white transition-colors
|
|
inline-flex items-center justify-center">
|
|
<!-- Icon Edit -->
|
|
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
|
|
viewBox="0 0 24 24">
|
|
<path fill-rule="evenodd"
|
|
d="M11.32 6.176H5c-1.105 0-2 .949-2 2.118v10.588C3 20.052 3.895 21 5 21h11c1.105 0 2-.948 2-2.118v-7.75l-3.914 4.144A2.46 2.46 0 0 1 12.81 16l-2.681.568c-1.75.37-3.292-1.263-2.942-3.115l.536-2.839c.097-.512.335-.983.684-1.352l2.914-3.086Z"
|
|
clip-rule="evenodd" />
|
|
<path fill-rule="evenodd"
|
|
d="M19.846 4.318a2.148 2.148 0 0 0-.437-.692 2.014 2.014 0 0 0-.654-.463 1.92 1.92 0 0 0-1.544 0 2.014 2.014 0 0 0-.654.463l-.546.578 2.852 3.02.546-.579a2.14 2.14 0 0 0 .437-.692 2.244 2.244 0 0 0 0-1.635ZM17.45 8.721 14.597 5.7 9.82 10.76a.54.54 0 0 0-.137.27l-.536 2.84c-.07.37.239.696.588.622l2.682-.567a.492.492 0 0 0 .255-.145l4.778-5.06Z"
|
|
clip-rule="evenodd" />
|
|
</svg>
|
|
</button>
|
|
|
|
<!-- Tombol Hapus Modal -->
|
|
<button type="button"
|
|
data-modal-target="hapusKelompokModal{{ $item->id }}"
|
|
data-modal-toggle="hapusKelompokModal{{ $item->id }}"
|
|
class="bg-white border border-red-600 p-1 rounded cursor-pointer
|
|
text-red-600 hover:bg-red-600 hover:text-white transition-colors">
|
|
<!-- Icon Delete -->
|
|
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
|
|
viewBox="0 0 24 24">
|
|
<path fill-rule="evenodd"
|
|
d="M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z"
|
|
clip-rule="evenodd" />
|
|
</svg>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="2" class="text-center py-4 text-gray-500">Tidak ada data kelompok tani.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tombol Kembali ke User Setting -->
|
|
<a href="{{ route('usersetting.index') }}"
|
|
class="mt-5 inline-flex items-center text-white bg-[#388E3C] hover:bg-green-900 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm px-4 py-2 text-center max-w-xs">
|
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"></path>
|
|
</svg>
|
|
Kembali ke Pengaturan User
|
|
</a>
|
|
|
|
@foreach ($kelompokTani as $item)
|
|
<div id="hapusKelompokModal{{ $item->id }}" tabindex="-1" aria-hidden="true"
|
|
class="hidden fixed top-0 left-0 right-0 z-50 w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-modal md:h-full">
|
|
<div class="relative w-full max-w-md h-full md:h-auto">
|
|
<div class="relative bg-[#388E3C] rounded-lg shadow">
|
|
<div class="p-6 text-center">
|
|
<svg class="mx-auto mb-4 text-white w-12 h-12"
|
|
fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12"></path>
|
|
</svg>
|
|
<h3 class="mb-5 text-lg font-normal text-white">
|
|
Yakin ingin menghapus <strong>{{ $item->nama }}</strong>?
|
|
</h3>
|
|
<form action="{{ route('kelompoktani.destroy', $item->id) }}" method="POST">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit"
|
|
class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300
|
|
dark:focus:ring-red-800 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center mr-2">
|
|
Ya, Hapus
|
|
</button>
|
|
<button type="button"
|
|
class="text-black bg-white hover:bg-gray-300 focus:ring-4 focus:outline-none focus:ring-gray-200
|
|
rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900
|
|
focus:z-10"
|
|
data-modal-hide="hapusModal{{ $item->id }}">
|
|
Batal
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
|
|
<!-- Modal Tambah Kelompok -->
|
|
<div id="tambahKelompokModal" tabindex="-1" aria-hidden="true"
|
|
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full inset-0 h-[calc(100%-1rem)] max-h-full items-center justify-center">
|
|
<div class="relative p-4 w-full max-w-2xl max-h-full">
|
|
<div class="relative bg-[#388E3C] rounded-lg shadow">
|
|
<div class="flex items-center justify-between p-4 border-b rounded-t border-gray-600">
|
|
<h3 class="text-xl font-semibold text-white">
|
|
Tambah Kelompok Tani
|
|
</h3>
|
|
<button type="button" class="text-gray-400 bg-transparent hover:text-white"
|
|
data-modal-hide="tambahKelompokModal">
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd"
|
|
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
|
clip-rule="evenodd" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<form action="{{ route('kelompoktani.store') }}" method="POST" class="p-6 space-y-6">
|
|
@csrf
|
|
<div>
|
|
<label for="nama" class="block mb-2 text-sm font-medium text-white">Nama Kelompok Tani</label>
|
|
<input type="text" id="nama" name="nama" required placeholder="Contoh: Kelompok Tani B"
|
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-green-500 focus:border-green-500 block w-full p-2.5">
|
|
</div>
|
|
|
|
<button type="submit"
|
|
class="text-white bg-green-900 hover:bg-green-950 font-medium rounded-lg text-sm px-5 py-2.5 text-center">
|
|
Simpan
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if(session('success'))
|
|
<div id="success-alert" class="flex items-center p-4 mb-4 text-sm text-green-800 border border-green-300 rounded-lg bg-green-50 mt-4" role="alert">
|
|
<svg class="shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
|
|
</svg>
|
|
<span class="font-medium">{{ session('success') }}</span>
|
|
</div>
|
|
<script>
|
|
setTimeout(() => {
|
|
const alert = document.getElementById('success-alert');
|
|
alert.style.transition = 'opacity 1s';
|
|
alert.style.opacity = '0';
|
|
setTimeout(() => alert.remove(), 1000);
|
|
}, 2000);
|
|
</script>
|
|
@endif
|
|
|
|
@if ($errors->any())
|
|
<div class="text-red-500">
|
|
<ul>
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
@foreach ($kelompokTani as $sub)
|
|
<div id="editKelompokModal{{ $sub->id }}" tabindex="-1" aria-hidden="true"
|
|
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full inset-0 h-[calc(100%-1rem)] max-h-full items-center justify-center bg-black/30">
|
|
<div class="relative p-4 w-full max-w-2xl max-h-full">
|
|
<div class="relative bg-[#388E3C] rounded-lg shadow">
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between p-4 border-b rounded-t border-gray-600">
|
|
<h3 class="text-xl font-semibold text-white">
|
|
Edit Nama Kelompok Tani
|
|
</h3>
|
|
<button type="button" class="text-gray-400 bg-transparent hover:text-white"
|
|
data-modal-hide="editKelompokModal{{ $sub->id }}">
|
|
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd"
|
|
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
|
clip-rule="evenodd" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Form Edit -->
|
|
<form action="{{ route('kelompoktani.update', $sub->id) }}" method="POST" class="p-6 space-y-6">
|
|
@csrf
|
|
@method('PUT')
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<div>
|
|
<label for="nama{{ $sub->id }}" class="block mb-2 text-sm font-medium text-white">Nama Kelompok Tani</label>
|
|
<input type="text" id="nama{{ $sub->id }}" name="nama" value="{{ $sub->nama }}" required
|
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-green-500 focus:border-green-500 block w-full p-2.5">
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="text-white bg-green-900 hover:bg-green-950 font-medium rounded-lg text-sm px-5 py-2.5 text-center">
|
|
Simpan Perubahan
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</x-layout> |