Initial commit: Struktur aplikasi ilycats

This commit is contained in:
Dwi F Sukmana
2026-02-08 15:16:35 +07:00
commit 0921901aed
235 changed files with 29016 additions and 0 deletions
@@ -0,0 +1,43 @@
<x-app-layout>
<div class="max-w-2xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4">
<a href="{{ route('categories.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Master Kategori</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Penyesuaian Kata Kunci Smart Categorization</p>
</div>
</div>
<form action="{{ route('categories.update', $category->id) }}" method="POST" class="space-y-6">
@csrf
@method('PATCH')
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Kategori</label>
<input type="text" name="name" value="{{ old('name', $category->name) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Kata Kunci Deteksi (Koma Terpisah)</label>
<textarea name="keywords" rows="4" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none"
placeholder="contoh: amoxicillin, clavamox, doxycycline">{{ old('keywords', $category->keywords) }}</textarea>
<div class="bg-indigo-50 p-4 rounded-2xl border border-indigo-100 mt-2">
<p class="text-[10px] text-indigo-600 font-bold leading-relaxed">
<i class="fas fa-lightbulb mr-1"></i> Tips: Masukkan nama obat atau fragmen kata yang unik. Sistem akan otomatis menetapkan kategori ini jika nama obat mengandung salah satu kata kunci di atas.
</p>
</div>
</div>
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-[2rem] shadow-xl hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-3">
<i class="fas fa-save text-lg"></i> PERBARUI KATEGORI & SINKRONISASI
</button>
</form>
</div>
</x-app-layout>
@@ -0,0 +1,187 @@
<x-app-layout>
<div class="max-w-6xl mx-auto space-y-6 pb-12">
{{-- HEADER SECTION --}}
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 px-2">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1">Kategori Manager</h2>
<p class="text-sm text-slate-500 font-medium italic">Master data Smart Categorization ilycats.</p>
</div>
<div class="flex items-center gap-3">
{{-- FITUR KHUSUS ADMIN: Sinkronisasi Massal --}}
@if(auth()->user()->role === 'admin')
<div class="flex items-center gap-2">
<button type="button" onclick="confirmRecategorize()" class="inline-flex items-center px-5 py-2.5 bg-emerald-50 text-emerald-600 border border-emerald-100 text-[10px] font-black rounded-xl hover:bg-emerald-600 hover:text-white transition-all shadow-sm active:scale-95">
<i class="fas fa-sync-alt mr-2"></i> RE-CATEGORIZE ALL
</button>
<form id="form-recategorize" action="{{ route('categories.recategorize') }}" method="POST" class="hidden">
@csrf
</form>
</div>
@endif
{{-- PROTEKSI CREATE: Mengikuti matriks izin modul categories --}}
@can('check-access', ['categories', 'create'])
<button onclick="toggleCreateForm()" class="inline-flex items-center px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-xl transition-all shadow-lg active:scale-95">
<i class="fas fa-plus-circle mr-2"></i> TAMBAH KATEGORI
</button>
@endcan
</div>
</div>
{{-- FORM TAMBAH KATEGORI (Proteksi Ganda dengan @can) --}}
@can('check-access', ['categories', 'create'])
<div id="create-form" class="hidden bg-white border border-slate-200 rounded-[2rem] p-8 shadow-sm animate-fade-in-down mx-2">
<form action="{{ route('categories.store') }}" method="POST" class="grid grid-cols-1 md:grid-cols-7 gap-6">
@csrf
<div class="md:col-span-2 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Kategori</label>
<input type="text" name="name" required placeholder="Contoh: Antibiotik" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="md:col-span-3 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Kata Kunci (Pisah Koma)</label>
<input type="text" name="keywords" required placeholder="amoxicillin, doxy, antibiotic" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="md:col-span-2 flex items-end">
<button type="submit" class="w-full py-3.5 bg-indigo-600 text-white font-black rounded-xl text-[10px] uppercase tracking-widest shadow-lg shadow-indigo-100 transition-all active:scale-95">
SIMPAN MASTER DATA
</button>
</div>
</form>
</div>
@endcan
{{-- DATA TABLE SECTION --}}
<div class="bg-white border border-slate-200 rounded-[2.5rem] overflow-hidden shadow-sm mx-2">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse table-fixed">
<thead class="bg-slate-50/80 border-b border-slate-100">
<tr>
<th class="w-56 px-6 py-5 text-[10px] font-black text-slate-400 uppercase tracking-widest">Informasi Kategori</th>
<th class="w-auto px-6 py-5 text-[10px] font-black text-slate-400 uppercase tracking-widest">Kata Kunci Deteksi</th>
<th class="w-32 px-6 py-5 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($categories as $cat)
<tr class="hover:bg-slate-50/30 transition-all">
<td class="px-6 py-5 overflow-hidden">
<div class="flex items-center gap-4">
<div class="w-10 h-10 rounded-xl bg-indigo-50 flex items-center justify-center text-indigo-500 shrink-0 border border-indigo-100">
<i class="fas fa-tag text-xs"></i>
</div>
<div class="min-w-0">
<div class="text-sm font-black text-slate-800 truncate">{{ $cat->name }}</div>
</div>
</div>
</td>
<td class="px-6 py-5">
<div class="flex flex-wrap gap-1.5 max-w-full">
@foreach(explode(',', $cat->keywords) as $word)
<span class="px-2.5 py-1 bg-slate-50 text-slate-500 text-[9px] font-bold rounded-lg border border-slate-200/60 uppercase whitespace-nowrap">
{{ trim($word) }}
</span>
@endforeach
</div>
</td>
<td class="px-6 py-5">
<div class="flex justify-center gap-2">
{{-- PROTEKSI EDIT: Mengikuti matriks permission --}}
@can('check-access', ['categories', 'update'])
<a href="{{ route('categories.edit', $cat->id) }}"
class="w-8 h-8 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm shadow-amber-100"
title="Edit Kategori">
<i class="fas fa-edit text-[10px]"></i>
</a>
@endcan
{{-- PROTEKSI DELETE: Syarat manual 'admin' dihapus agar mengikuti matriks sepenuhnya --}}
@can('check-access', ['categories', 'delete'])
<button type="button"
onclick="confirmDelete({{ $cat->id }}, '{{ addslashes($cat->name) }}')"
class="w-8 h-8 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-600 hover:text-white rounded-xl transition-all shadow-sm shadow-rose-100"
title="Hapus Kategori">
<i class="fas fa-trash-alt text-[10px]"></i>
</button>
<form id="delete-form-{{ $cat->id }}" action="{{ route('categories.destroy', $cat->id) }}" method="POST" class="hidden">
@csrf @method('DELETE')
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="px-8 py-20 text-center text-slate-400 italic text-xs font-bold uppercase tracking-widest">
Belum ada kategori yang dikonfigurasi.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
{{-- SCRIPTS SECTION --}}
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function toggleCreateForm() {
const form = document.getElementById('create-form');
if (form) form.classList.toggle('hidden');
}
function confirmRecategorize() {
Swal.fire({
title: 'Recategorize All?',
text: "Sistem akan memindai seluruh obat berdasarkan kata kunci terbaru.",
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#10b981',
confirmButtonText: 'Ya, Sinkronkan!',
cancelButtonText: 'Batal',
customClass: { popup: 'rounded-[1.5rem]' }
}).then((result) => {
if (result.isConfirmed) {
const form = document.getElementById('form-recategorize');
if (form) form.submit();
}
});
}
function confirmDelete(id, name) {
Swal.fire({
title: 'Hapus Kategori?',
text: `Kategori "${name}" akan dihapus permanen. Data obat terkait akan kembali ke status "Umum".`,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#f43f5e',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
customClass: { popup: 'rounded-[1.5rem]' }
}).then((result) => {
if (result.isConfirmed) {
const form = document.getElementById(`delete-form-${id}`);
if (form) form.submit();
}
});
}
{{-- Toast Notifikasi Sukses --}}
@if(session('success'))
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: "{{ session('success') }}",
showConfirmButton: false,
timer: 2500,
customClass: { popup: 'rounded-[1.5rem]' },
iconColor: '#4f46e5'
});
@endif
</script>
@endpush
</x-app-layout>
@@ -0,0 +1,74 @@
<x-app-layout>
<div class="py-12 bg-slate-50">
<div class="max-w-6xl mx-auto sm:px-6 lg:px-8">
<div class="mb-6">
<a href="{{ route('inventory.foods') }}" class="inline-flex items-center text-sm font-medium text-slate-500 hover:text-slate-700 transition">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg>
Kembali ke Daftar
</a>
</div>
<div class="bg-white overflow-hidden shadow-sm rounded-[2rem] p-8 md:p-12">
<form action="{{ route('foods.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="mb-10">
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-4">FOTO PRODUK / KEMASAN</label>
<div class="flex flex-col md:flex-row items-center gap-6">
<div class="w-32 h-32 flex-shrink-0 bg-slate-50 border-2 border-dashed border-slate-200 rounded-[1.5rem] flex items-center justify-center">
<svg class="w-10 h-10 text-slate-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
</div>
<div class="flex-grow w-full">
<input type="file" name="foto_produk" class="block w-full text-sm text-slate-500 file:mr-4 file:py-2 file:px-6 file:rounded-full file:border-0 file:text-xs file:font-bold file:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200 border border-slate-100 rounded-full bg-slate-50 p-1 focus:outline-none">
<p class="mt-3 text-[11px] text-slate-400 flex items-center">
<svg class="w-3 h-3 mr-2 text-indigo-400" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
Rekomendasi: Gunakan foto kemasan yang jelas agar staf medis tidak salah mengambil pakan.
</p>
</div>
</div>
</div>
<div class="mb-8">
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">NAMA PAKAN / MAKANAN</label>
<input type="text" name="nama_makanan" placeholder="Contoh: Royal Canin Kitten" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 transition shadow-sm">
<p class="mt-2 text-[11px] text-indigo-400 italic flex items-center">
<svg class="w-3 h-3 mr-2" fill="currentColor" viewBox="0 0 20 20"><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"></path></svg>
Sistem akan menentukan kategori secara otomatis berdasarkan nama.
</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div>
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">JUMLAH STOK AWAL</label>
<input type="number" name="qty" placeholder="0" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">SATUAN (UNIT)</label>
<input type="text" name="unit" placeholder="Pcs / Kg" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
</div>
<div class="mb-10">
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">TANGGAL KADALUARSA (EXPIRED)</label>
<input type="date" name="expired_date" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
<div class="flex justify-end items-center gap-4 pt-6 mt-8 border-t border-slate-100">
<button type="reset" class="text-[11px] font-bold text-slate-400 hover:text-slate-600 uppercase tracking-widest transition-colors">
Reset Form
</button>
<button type="submit" class="inline-flex items-center justify-center whitespace-nowrap bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2.5 px-10 rounded-full text-[11px] uppercase tracking-widest shadow-md shadow-indigo-100 transition-all transform active:scale-95 flex-shrink-0 w-auto">
<svg class="w-3.5 h-3.5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"></path>
</svg>
<span>Simpan Data</span>
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,68 @@
<x-app-layout>
<div class="max-w-3xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4 px-2">
<a href="{{ route('inventory.foods.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Stok Makanan</h2>
<p class="text-sm text-slate-500 font-medium italic">Pembaruan nutrisi untuk {{ $food->nama_makanan }}.</p>
</div>
</div>
<form action="{{ route('inventory.foods.update', $food->id) }}" method="POST" enctype="multipart/form-data" class="space-y-6 mx-2">
@csrf
@method('PATCH')
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="md:col-span-2 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Produk Makanan</label>
<input type="text" name="nama_makanan" value="{{ old('nama_makanan', $food->nama_makanan) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah Stok</label>
<input type="number" step="any" name="qty" value="{{ old('qty', (float)$food->qty) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Satuan (Unit)</label>
<input type="text" name="unit" value="{{ old('unit', $food->unit) }}" required placeholder="kg, pouch, can"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Kadaluarsa</label>
<input type="date" name="expired_date" min="{{ date('Y-m-d') }}" value="{{ old('expired_date', $food->expired_date ? $food->expired_date->format('Y-m-d') : '') }}"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Ganti Foto Produk</label>
<input type="file" name="foto_produk"
class="w-full px-5 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-xs font-bold text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100">
</div>
</div>
@if($food->foto_produk)
<div class="pt-4 border-t border-slate-100 flex items-center gap-4">
<div>
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-3">Foto Saat Ini</p>
<div class="w-24 h-24 rounded-2xl border-4 border-white shadow-md overflow-hidden bg-slate-50">
<img src="{{ asset('storage/' . $food->foto_produk) }}" class="w-full h-full object-cover">
</div>
</div>
<div class="text-[10px] text-slate-400 italic">Foto lama akan dihapus otomatis jika Anda mengunggah foto baru.</div>
</div>
@endif
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-[2rem] shadow-xl shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-3">
<i class="fas fa-save text-lg"></i> SIMPAN PERUBAHAN STOK
</button>
</form>
</div>
</x-app-layout>
@@ -0,0 +1,166 @@
<x-app-layout>
<div class="max-w-7xl mx-auto space-y-6 pb-12">
{{-- SECTION 1: Header --}}
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 px-2">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1">Stok Makanan</h2>
<p class="text-sm text-slate-500 font-medium italic">Manajemen nutrisi Ily Cattery.</p>
</div>
{{-- PROTEKSI CREATE: Mengikuti matriks izin modul foods --}}
@can('check-access', ['foods', 'create'])
<div class="flex items-center gap-3">
<a href="{{ route('inventory.foods.create') }}" class="inline-flex items-center px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-xl transition-all shadow-lg active:scale-95">
<i class="fas fa-plus-circle mr-2"></i> TAMBAH MAKANAN
</a>
</div>
@endcan
</div>
{{-- SECTION 2: Batch Import (HANYA MUNCUL UNTUK ROLE ADMIN) --}}
@if(auth()->user()->role === 'admin')
<div class="bg-indigo-50/50 border border-indigo-100 rounded-[2rem] p-6 shadow-sm mx-2">
<div class="flex flex-col lg:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-white rounded-xl flex items-center justify-center text-indigo-600 shadow-sm">
<i class="fas fa-file-excel text-lg"></i>
</div>
<div>
<h4 class="text-xs font-black text-indigo-900 uppercase tracking-widest">Batch Import Makanan</h4>
<p class="text-[9px] text-indigo-400 font-bold italic">Update stok massal via file .xlsx.</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<a href="{{ route('inventory.foods.template') }}" class="px-3 py-2 bg-white border border-indigo-200 text-indigo-600 text-[9px] font-black rounded-lg hover:bg-indigo-100 transition-all shadow-sm">
<i class="fas fa-download mr-1"></i> TEMPLATE EXCEL
</a>
<form action="{{ route('inventory.foods.batch') }}" method="POST" enctype="multipart/form-data" class="flex items-center gap-2">
@csrf
<div class="relative">
<input type="file" name="file_excel" required class="text-[9px] w-48 file:mr-2 file:py-1 file:px-2 file:rounded-md file:border-0 file:text-[9px] file:font-black file:bg-indigo-600 file:text-white hover:file:bg-indigo-700 cursor-pointer">
</div>
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white text-[9px] font-black rounded-lg uppercase shadow-md hover:bg-indigo-700 active:scale-95 transition-all">
UPLOAD SEKARANG
</button>
</form>
</div>
</div>
</div>
@endif
{{-- SECTION 3: Tabel Utama --}}
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm mx-2">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse table-fixed">
<thead class="bg-slate-50/80 border-b border-slate-100">
<tr>
<th class="w-auto px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest">Informasi Produk</th>
<th class="w-32 px-4 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Stok</th>
<th class="w-28 px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($foods as $f)
<tr class="hover:bg-slate-50/40 transition-all group">
<td class="px-6 py-4">
<div class="flex items-center gap-4">
<div class="w-12 h-12 rounded-2xl bg-slate-50 border border-slate-100 overflow-hidden shrink-0 flex items-center justify-center">
@if($f->foto_produk)
<img src="{{ asset('storage/' . $f->foto_produk) }}" class="w-full h-full object-cover">
@else
<i class="fas fa-bowl-food text-slate-200 text-lg"></i>
@endif
</div>
<div class="min-w-0">
<div class="text-sm font-black text-slate-800 truncate">{{ $f->nama_makanan }}</div>
<span class="text-[8px] font-black text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100 uppercase italic">
{{ $f->kategori }}
</span>
</div>
</div>
</td>
<td class="px-4 py-4 text-center">
<span class="inline-flex px-3 py-1.5 rounded-xl text-[10px] font-black border {{ $f->qty < 5 ? 'bg-rose-50 text-rose-600 border-rose-100' : 'bg-emerald-50 text-emerald-600 border-emerald-100' }}">
{{ (float)$f->qty }} {{ $f->unit }}
</span>
</td>
<td class="px-6 py-4">
<div class="flex justify-center gap-2">
{{-- PROTEKSI EDIT: Mengikuti matriks permission --}}
@can('check-access', ['foods', 'update'])
<a href="{{ route('inventory.foods.edit', $f->id) }}" class="w-8 h-8 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm shadow-amber-100">
<i class="fas fa-edit text-[10px]"></i>
</a>
@endcan
{{-- PROTEKSI DELETE: Syarat role admin dihapus agar mengikuti matriks permission sepenuhnya --}}
@can('check-access', ['foods', 'delete'])
<button onclick="confirmDeleteFood({{ $f->id }}, '{{ addslashes($f->nama_makanan) }}')" class="w-8 h-8 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-600 hover:text-white rounded-xl transition-all shadow-sm shadow-rose-100">
<i class="fas fa-trash-alt text-[10px]"></i>
</button>
<form id="delete-food-{{ $f->id }}" action="{{ route('inventory.foods.destroy', $f->id) }}" method="POST" class="hidden">
@csrf @method('DELETE')
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr><td colspan="3" class="px-6 py-16 text-center text-slate-400 text-xs italic">Data makanan kosong.</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
{{-- SECTION 4: Scripts --}}
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
// Dialog Konfirmasi Hapus (TETAP UTUH)
function confirmDeleteFood(id, name) {
Swal.fire({
title: 'Hapus Stok Makanan?',
text: `Yakin ingin menghapus "${name}"? Tindakan ini tidak dapat dibatalkan.`,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#f43f5e',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
customClass: {
popup: 'rounded-[1.5rem]'
}
}).then((result) => {
if (result.isConfirmed) document.getElementById(`delete-food-${id}`).submit();
});
}
// Notifikasi Sukses
@if(session('success'))
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: "{{ session('success') }}",
timer: 2500,
showConfirmButton: false,
customClass: { popup: 'rounded-[1.5rem]' },
iconColor: '#4f46e5'
});
@endif
// Notifikasi Error
@if(session('error'))
Swal.fire({
icon: 'error',
title: 'Gagal!',
text: "{{ session('error') }}",
confirmButtonColor: '#4f46e5',
customClass: { popup: 'rounded-[1.5rem]' }
});
@endif
</script>
@endpush
</x-app-layout>
@@ -0,0 +1,87 @@
<x-app-layout>
<div class="max-w-2xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4">
<a href="{{ route('inventory.medicines.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Tambah Stok Obat</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Pendaftaran Inventori Medis Baru</p>
</div>
</div>
<form action="{{ route('inventory.medicines.store') }}" method="POST" enctype="multipart/form-data" class="space-y-6">
@csrf
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-8">
<div class="space-y-4">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Foto Produk / Kemasan</label>
<div class="flex flex-col md:flex-row items-center gap-6">
<div id="image-preview" class="w-32 h-32 rounded-[2rem] bg-slate-50 border-2 border-dashed border-slate-200 flex items-center justify-center overflow-hidden shrink-0">
<i class="fas fa-camera text-slate-300 text-3xl"></i>
</div>
<div class="flex-1 w-full">
<input type="file" name="foto_produk" id="foto_produk" accept="image/*" onchange="previewImage(event)"
class="w-full text-xs text-slate-500 file:mr-4 file:py-2.5 file:px-6 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100 transition-all cursor-pointer border border-slate-100 p-2 rounded-2xl">
<p class="text-[9px] text-slate-400 mt-3 italic leading-relaxed">
<i class="fas fa-info-circle mr-1"></i> Rekomendasi: Gunakan foto kemasan yang jelas agar staf medis tidak salah mengambil obat.
</p>
</div>
</div>
</div>
<hr class="border-slate-50">
<div class="space-y-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Obat / Vitamin</label>
<input type="text" name="nama_obat" value="{{ old('nama_obat') }}" required placeholder="Contoh: Amoxicillin"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
<p class="text-[9px] text-indigo-500 font-bold italic px-1 animate-pulse">
<i class="fas fa-magic mr-1"></i> Sistem akan menentukan kategori secara otomatis berdasarkan nama.
</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah Stok Awal</label>
<input type="number" name="qty" value="{{ old('qty', 0) }}" step="0.01" min="0" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-black text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Satuan (Unit)</label>
<input type="text" name="unit" value="{{ old('unit', 'Pcs') }}" required placeholder="ML, Kapsul, dll"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
</div>
<div class="space-y-2">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Kadaluarsa (Expired)</label>
<input type="date" name="expired_date" value="{{ old('expired_date') }}"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
</div>
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-[2rem] shadow-xl hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-3">
<i class="fas fa-check-circle text-lg"></i> DAFTARKAN OBAT KE INVENTORI
</button>
</form>
</div>
@push('scripts')
<script>
function previewImage(event) {
const reader = new FileReader();
reader.onload = function(){
const output = document.getElementById('image-preview');
output.innerHTML = `<img src="${reader.result}" class="w-full h-full object-cover">`;
output.classList.remove('border-dashed');
output.classList.add('border-solid', 'border-indigo-100');
};
reader.readAsDataURL(event.target.files[0]);
}
</script>
@endpush
</x-app-layout>
@@ -0,0 +1,65 @@
<x-app-layout>
<div class="max-w-3xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4 px-2">
<a href="{{ route('inventory.medicines.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Data Obat</h2>
<p class="text-sm text-slate-500 font-medium italic">Pembaruan stok medis {{ $medicine->nama_obat }}.</p>
</div>
</div>
<form action="{{ route('inventory.medicines.update', $medicine->id) }}" method="POST" enctype="multipart/form-data" class="space-y-6 mx-2">
@csrf
@method('PATCH')
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="md:col-span-2 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Produk Medis</label>
<input type="text" name="nama_obat" value="{{ old('nama_obat', $medicine->nama_obat) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah Stok (QTY)</label>
<input type="number" step="any" name="qty" value="{{ old('qty', (float)$medicine->qty) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Satuan (Unit)</label>
<input type="text" name="unit" value="{{ old('unit', $medicine->unit) }}" required placeholder="Contoh: Tablet, ml, Bottle"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Tanggal Kadaluarsa</label>
<input type="date" name="expired_date" value="{{ old('expired_date', $medicine->expired_date ? $medicine->expired_date->format('Y-m-d') : '') }}"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Foto Produk (Opsional)</label>
<input type="file" name="foto_produk"
class="w-full px-5 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-xs font-bold text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100">
</div>
</div>
@if($medicine->foto_produk)
<div class="pt-4 border-t border-slate-100">
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-3">Foto Saat Ini</p>
<div class="w-32 h-32 rounded-2xl border-4 border-white shadow-md overflow-hidden bg-slate-50">
<img src="{{ asset('storage/' . $medicine->foto_produk) }}" class="w-full h-full object-cover">
</div>
</div>
@endif
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-[2rem] shadow-xl shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-3">
<i class="fas fa-save text-lg"></i> SIMPAN PERUBAHAN OBAT
</button>
</form>
</div>
</x-app-layout>
@@ -0,0 +1,190 @@
<x-app-layout>
<div class="space-y-6 pb-12">
{{-- SECTION 1: Header --}}
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1">Inventori Obat & Vitamin</h2>
<p class="text-sm text-slate-500 font-medium italic">Manajemen stok medis Ily Cattery.</p>
</div>
{{-- PROTEKSI CREATE: Mengikuti matriks izin modul medicines --}}
@can('check-access', ['medicines', 'create'])
<a href="{{ route('inventory.medicines.create') }}" class="inline-flex items-center px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-xl shadow-lg transition-all active:scale-95">
<i class="fas fa-plus-circle mr-2"></i> TAMBAH OBAT /VITAMIN
</a>
@endcan
</div>
{{-- SECTION 2: Batch Import (HANYA MUNCUL UNTUK ROLE ADMIN) --}}
@if(auth()->user()->role === 'admin')
<div class="bg-indigo-50/50 border border-indigo-100 rounded-[2rem] p-6 shadow-sm">
<div class="flex flex-col lg:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-white rounded-xl flex items-center justify-center text-indigo-600 shadow-sm">
<i class="fas fa-file-excel text-lg"></i>
</div>
<div>
<h4 class="text-xs font-black text-indigo-900 uppercase">Batch Import</h4>
<p class="text-[9px] text-indigo-400 font-bold italic">Update stok via .xlsx.</p>
</div>
</div>
<div class="flex items-center gap-3">
<a href="{{ route('inventory.medicines.template') }}" class="px-3 py-2 bg-white border border-indigo-200 text-indigo-600 text-[9px] font-black rounded-lg hover:bg-indigo-100 transition-all">
TEMPLATE
</a>
<form action="{{ route('inventory.medicines.batch') }}" method="POST" enctype="multipart/form-data" class="flex items-center gap-2">
@csrf
<input type="file" name="file_excel" class="text-[9px] w-40">
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white text-[9px] font-black rounded-lg uppercase">Upload</button>
</form>
</div>
</div>
</div>
@endif
{{-- SECTION 3: Tabel Utama --}}
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse table-fixed">
<thead class="bg-slate-50/80 border-b border-slate-100">
<tr>
<th class="w-auto px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest">Informasi Produk</th>
<th class="w-32 px-4 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Stok</th>
<th class="w-40 px-4 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Kadaluarsa</th>
<th class="w-28 px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($medicines as $m)
<tr class="hover:bg-slate-50/40 transition-all group">
{{-- Informasi Produk --}}
<td class="px-6 py-4 overflow-hidden">
<div class="flex items-center gap-4">
<div class="w-12 h-12 rounded-2xl bg-slate-50 border border-slate-100 overflow-hidden shrink-0 flex items-center justify-center">
@if($m->foto_produk)
<img src="{{ asset('storage/' . $m->foto_produk) }}" class="w-full h-full object-cover">
@else
<i class="fas fa-pills text-slate-200 text-lg"></i>
@endif
</div>
<div class="min-w-0">
<div class="text-sm font-black text-slate-800 truncate">{{ $m->nama_obat }}</div>
<div class="flex items-center gap-2 mt-1">
<span class="text-[8px] font-black text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100 uppercase italic">
{{ $m->kategori ?? 'Umum' }}
</span>
<span class="text-[8px] font-bold text-slate-400 uppercase">/ {{ $m->unit }}</span>
</div>
</div>
</div>
</td>
{{-- Stok --}}
<td class="px-4 py-4 text-center">
<span class="inline-flex px-3 py-1.5 rounded-xl text-[10px] font-black border {{ $m->qty < 5 ? 'bg-rose-50 text-rose-600 border-rose-100' : 'bg-emerald-50 text-emerald-600 border-emerald-100' }}">
{{ (float)$m->qty }}
</span>
</td>
{{-- Kadaluarsa --}}
<td class="px-4 py-4 text-center">
@if($m->expired_date)
<div class="flex flex-col items-center">
<span class="text-[10px] font-black {{ $m->expired_date->isPast() ? 'text-rose-600' : 'text-slate-600' }}">
{{ $m->expired_date->format('d/m/y') }}
</span>
@if($m->expired_date->isPast())
<span class="text-[7px] font-black text-rose-400 uppercase">Expired!</span>
@endif
</div>
@else
<span class="text-slate-300 text-[9px] font-bold italic">-</span>
@endif
</td>
{{-- AKSI: Proteksi Penuh Berdasarkan Matriks Role Management --}}
<td class="px-6 py-4">
<div class="flex justify-center gap-2">
{{-- Edit --}}
@can('check-access', ['medicines', 'update'])
<a href="{{ route('inventory.medicines.edit', $m->id) }}"
class="w-8 h-8 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm shadow-amber-100"
title="Edit Obat">
<i class="fas fa-edit text-[10px]"></i>
</a>
@endcan
{{-- Hapus: Pengecekan 'admin' dihapus agar permission matriks bekerja --}}
@can('check-access', ['medicines', 'delete'])
<button type="button"
onclick="confirmDeleteMedicine({{ $m->id }}, '{{ addslashes($m->nama_obat) }}')"
class="w-8 h-8 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-600 hover:text-white rounded-xl transition-all shadow-sm shadow-rose-100"
title="Hapus Obat">
<i class="fas fa-trash-alt text-[10px]"></i>
</button>
<form id="delete-medicine-{{ $m->id }}" action="{{ route('inventory.medicines.destroy', $m->id) }}" method="POST" class="hidden">
@csrf @method('DELETE')
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-6 py-16 text-center text-slate-400 text-xs italic font-bold">Belum ada data obat.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
{{-- SECTION 4: Scripts --}}
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function confirmDeleteMedicine(id, name) {
Swal.fire({
title: 'Hapus Obat?',
text: "Apakah Anda yakin ingin menghapus \"" + name + "\"? Data yang dihapus tidak bisa dikembalikan.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#f43f5e',
cancelButtonColor: '#64748b',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
customClass: {
popup: 'rounded-[1.5rem]'
}
}).then((result) => {
if (result.isConfirmed) {
document.getElementById('delete-medicine-' + id).submit();
}
});
}
{{-- Toast Notifikasi --}}
@if(session('success'))
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: "{{ session('success') }}",
showConfirmButton: false,
timer: 2000,
customClass: { popup: 'rounded-[1.5rem]' }
});
@endif
@if(session('error'))
Swal.fire({
icon: 'error',
title: 'Gagal!',
text: "{{ session('error') }}",
confirmButtonColor: '#4f46e5',
customClass: { popup: 'rounded-[1.5rem]' }
});
@endif
</script>
@endpush
</x-app-layout>
@@ -0,0 +1,52 @@
<x-app-layout>
<div class="py-12 bg-slate-50">
<div class="max-w-6xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm rounded-[2rem] p-8 md:p-12">
<form action="{{ route('inventory.supplies.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="mb-10">
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-4">FOTO PERLENGKAPAN</label>
<div class="flex flex-col md:flex-row items-center gap-6">
<div class="w-32 h-32 flex-shrink-0 bg-slate-50 border-2 border-dashed border-slate-200 rounded-[1.5rem] flex items-center justify-center">
<svg class="w-10 h-10 text-slate-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
</div>
<div class="flex-grow w-full">
<input type="file" name="foto_produk" class="block w-full text-sm text-slate-500 file:mr-4 file:py-2 file:px-6 file:rounded-full file:border-0 file:text-xs file:font-bold file:bg-slate-100 file:text-slate-700 hover:file:bg-slate-200 border border-slate-100 rounded-full bg-slate-50 p-1 focus:outline-none">
</div>
</div>
</div>
<div class="mb-8">
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">NAMA PERLENGKAPAN</label>
<input type="text" name="nama_perlengkapan" placeholder="Contoh: Pasir Kucing 10kg" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-10">
<div>
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">JUMLAH STOK AWAL</label>
<input type="number" name="qty" placeholder="0" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-2">SATUAN (UNIT)</label>
<input type="text" name="unit" placeholder="Pcs" class="w-full bg-slate-50 border-none rounded-full px-8 py-4 text-slate-700 placeholder-slate-300 focus:ring-2 focus:ring-indigo-100 shadow-sm">
</div>
</div>
<div class="flex justify-end items-center gap-4 pt-6 mt-8 border-t border-slate-100">
<button type="reset" class="text-[11px] font-bold text-slate-400 hover:text-slate-600 uppercase tracking-widest transition-colors">
Reset Form
</button>
<button type="submit" class="inline-flex items-center bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2.5 px-8 rounded-full text-[11px] uppercase tracking-widest shadow-md shadow-indigo-100 transition-all transform active:scale-95">
<svg class="w-3.5 h-3.5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"></path>
</svg>
Simpan Data
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,62 @@
<x-app-layout>
<div class="max-w-3xl mx-auto space-y-6 pb-12">
<div class="flex items-center gap-4 px-2">
<a href="{{ route('inventory.supplies.index') }}" class="p-3 bg-white border border-slate-200 rounded-2xl text-slate-400 hover:text-indigo-600 transition-all shadow-sm active:scale-90">
<i class="fas fa-arrow-left"></i>
</a>
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">Edit Perlengkapan</h2>
<p class="text-sm text-slate-500 font-medium italic">Pembaruan data inventori untuk {{ $supply->nama_perlengkapan }}.</p>
</div>
</div>
<form action="{{ route('inventory.supplies.update', $supply->id) }}" method="POST" enctype="multipart/form-data" class="space-y-6 mx-2">
@csrf
@method('PATCH')
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="md:col-span-2 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Nama Perlengkapan</label>
<input type="text" name="nama_perlengkapan" value="{{ old('nama_perlengkapan', $supply->nama_perlengkapan) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Jumlah Stok</label>
<input type="number" step="any" name="qty" value="{{ old('qty', (float)$supply->qty) }}" required
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Satuan (Unit)</label>
<input type="text" name="unit" value="{{ old('unit', $supply->unit) }}" required placeholder="Contoh: sak, set, pcs"
class="w-full px-5 py-4 bg-slate-50 border border-slate-200 rounded-2xl text-sm font-bold text-slate-800 focus:ring-2 focus:ring-indigo-500 transition-all outline-none">
</div>
<div class="md:col-span-2 space-y-1">
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Ganti Foto Item (Opsional)</label>
<input type="file" name="foto_produk"
class="w-full px-5 py-3 bg-slate-50 border border-slate-200 rounded-2xl text-xs font-bold text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-[10px] file:font-black file:bg-indigo-50 file:text-indigo-600 hover:file:bg-indigo-100">
</div>
</div>
@if($supply->foto_produk)
<div class="pt-4 border-t border-slate-100 flex items-center gap-4">
<div>
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-3">Pratinjau Foto</p>
<div class="w-24 h-24 rounded-2xl border-4 border-white shadow-md overflow-hidden bg-slate-50">
<img src="{{ asset('storage/' . $supply->foto_produk) }}" class="w-full h-full object-cover">
</div>
</div>
<div class="text-[10px] text-slate-400 italic">Foto lama akan dihapus otomatis jika Anda mengunggah foto baru.</div>
</div>
@endif
</div>
<button type="submit" class="w-full py-5 bg-indigo-600 text-white text-sm font-black rounded-[2rem] shadow-xl shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-[0.98] flex items-center justify-center gap-3">
<i class="fas fa-save text-lg"></i> SIMPAN PERUBAHAN ITEM
</button>
</form>
</div>
</x-app-layout>
@@ -0,0 +1,176 @@
<x-app-layout>
<div class="max-w-7xl mx-auto space-y-6 pb-12">
{{-- HEADER SECTION --}}
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 px-2">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1">Stok Perlengkapan</h2>
<p class="text-sm text-slate-500 font-medium italic">Manajemen inventori operasional Ily Cattery.</p>
</div>
{{-- PROTEKSI CREATE: Mengikuti matriks izin modul supplies --}}
@can('check-access', ['supplies', 'create'])
<div class="flex items-center gap-3">
<a href="{{ route('inventory.supplies.create') }}" class="inline-flex items-center px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-xl transition-all shadow-lg active:scale-95 uppercase tracking-widest">
<i class="fas fa-plus-circle mr-2"></i> TAMBAH ITEM
</a>
</div>
@endcan
</div>
{{-- BATCH IMPORT SECTION: KHUSUS ROLE ADMIN --}}
@if(auth()->user()->role === 'admin')
<div class="bg-indigo-50/50 border border-indigo-100 rounded-[2rem] p-6 shadow-sm mx-2">
<div class="flex flex-col lg:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-white rounded-xl flex items-center justify-center text-indigo-600 shadow-sm">
<i class="fas fa-boxes-stacked text-lg"></i>
</div>
<div>
<h4 class="text-xs font-black text-indigo-900 uppercase tracking-widest">Batch Import Supplies</h4>
<p class="text-[9px] text-indigo-400 font-bold italic">Update stok massal via file .xlsx.</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<a href="{{ route('inventory.supplies.template') }}" class="px-3 py-2 bg-white border border-indigo-200 text-indigo-600 text-[9px] font-black rounded-lg hover:bg-indigo-100 transition-all shadow-sm">
<i class="fas fa-download mr-1"></i> TEMPLATE EXCEL
</a>
<form action="{{ route('inventory.supplies.batch') }}" method="POST" enctype="multipart/form-data" class="flex items-center gap-2">
@csrf
<div class="relative">
<input type="file" name="file_excel" required class="text-[9px] w-48 file:mr-2 file:py-1 file:px-2 file:rounded-md file:border-0 file:text-[9px] file:font-black file:bg-indigo-600 file:text-white hover:file:bg-indigo-700 cursor-pointer">
</div>
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white text-[9px] font-black rounded-lg uppercase shadow-md hover:bg-indigo-700 active:scale-95 transition-all">
UPLOAD
</button>
</form>
</div>
</div>
</div>
@endif
{{-- DATA TABLE SECTION --}}
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm mx-2">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse table-fixed">
<thead class="bg-slate-50/80 border-b border-slate-100">
<tr>
<th class="w-auto px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest">Informasi Perlengkapan</th>
<th class="w-32 px-4 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Stok</th>
<th class="w-32 px-6 py-4 text-[10px] font-black text-slate-400 uppercase tracking-widest text-center">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($supplies as $s)
<tr class="hover:bg-slate-50/40 transition-all group">
<td class="px-6 py-4">
<div class="flex items-center gap-4">
<div class="w-12 h-12 rounded-2xl bg-slate-50 border border-slate-100 overflow-hidden shrink-0 flex items-center justify-center shadow-inner">
@if($s->foto_produk)
<img src="{{ \Storage::url($s->foto_produk) }}" class="w-full h-full object-cover">
@else
<i class="fas fa-box-open text-slate-200 text-lg"></i>
@endif
</div>
<div class="min-w-0">
<div class="text-sm font-black text-slate-800 truncate">{{ $s->nama_perlengkapan }}</div>
<span class="text-[8px] font-black text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100 uppercase italic">
{{ $s->category->name ?? $s->kategori }}
</span>
</div>
</div>
</td>
<td class="px-4 py-4 text-center">
<span class="inline-flex px-3 py-1.5 rounded-xl text-[10px] font-black border {{ $s->qty < 5 ? 'bg-rose-50 text-rose-600 border-rose-100' : 'bg-emerald-50 text-emerald-600 border-emerald-100' }}">
{{ (float)$s->qty }} {{ $s->unit }}
</span>
</td>
<td class="px-6 py-4">
<div class="flex justify-center gap-2">
{{-- PROTEKSI EDIT: Berdasarkan Matriks Izin --}}
@can('check-access', ['supplies', 'update'])
<a href="{{ route('inventory.supplies.edit', $s->id) }}" class="w-8 h-8 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm shadow-amber-100">
<i class="fas fa-edit text-[10px]"></i>
</a>
@endcan
{{-- PROTEKSI DELETE: Pengecekan manual 'admin' dihapus agar mengikuti matriks izin --}}
@can('check-access', ['supplies', 'delete'])
<button onclick="confirmDeleteSupply({{ $s->id }}, '{{ addslashes($s->nama_perlengkapan) }}')" class="w-8 h-8 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-600 hover:text-white rounded-xl transition-all shadow-sm shadow-rose-100">
<i class="fas fa-trash-alt text-[10px]"></i>
</button>
<form id="delete-supply-{{ $s->id }}" action="{{ route('inventory.supplies.destroy', $s->id) }}" method="POST" class="hidden">
@csrf @method('DELETE')
</form>
@endcan
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="px-6 py-20 text-center">
<div class="flex flex-col items-center justify-center">
<i class="fas fa-folder-open text-slate-200 text-4xl mb-3"></i>
<p class="text-slate-400 text-xs italic font-bold">Data perlengkapan belum tersedia.</p>
</div>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if(method_exists($supplies, 'links'))
<div class="px-6 py-4 bg-slate-50/50 border-t border-slate-100">
{{ $supplies->links() }}
</div>
@endif
</div>
</div>
{{-- SCRIPTS SECTION --}}
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
// Dialog Konfirmasi Hapus (TETAP UTUH)
function confirmDeleteSupply(id, name) {
Swal.fire({
title: 'Hapus Item?',
text: `Yakin ingin menghapus "${name}"? Tindakan ini tidak dapat dibatalkan.`,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#f43f5e',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
borderRadius: '1.5rem',
customClass: { title: 'font-black text-slate-800' }
}).then((result) => {
if (result.isConfirmed) document.getElementById(`delete-supply-${id}`).submit();
});
}
// Notifikasi Sukses & Error (TETAP UTUH)
@if(session('success'))
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: "{{ session('success') }}",
timer: 2500,
showConfirmButton: false,
borderRadius: '1.5rem',
iconColor: '#4f46e5'
});
@endif
@if(session('error'))
Swal.fire({
icon: 'error',
title: 'Gagal!',
text: "{{ session('error') }}",
borderRadius: '1.5rem'
});
@endif
</script>
@endpush
</x-app-layout>