initial commit
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
</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>
|
||||
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Penyesuaian kata kunci kategori</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
<x-app-layout>
|
||||
<div class="max-w-6xl mx-auto space-y-6 pb-12">
|
||||
@php
|
||||
// Helper untuk logika sorting dinamis
|
||||
$currentSort = request('sort', 'name');
|
||||
$currentDir = request('direction', 'asc');
|
||||
$nextDir = $currentDir === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
$getSortIcon = function($field) use ($currentSort, $currentDir) {
|
||||
if ($currentSort !== $field) return 'fa-sort opacity-20';
|
||||
return $currentDir === 'asc' ? 'fa-sort-up text-indigo-600' : 'fa-sort-down text-indigo-600';
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="max-w-7xl mx-auto space-y-6 pb-12">
|
||||
|
||||
{{-- HEADER SECTION --}}
|
||||
{{-- 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">Kategori Manager</h2>
|
||||
<p class="text-sm text-slate-500 font-medium italic">Master data Smart Categorization Ily Cattery.</p>
|
||||
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 uppercase">Kategori Manager</h2>
|
||||
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-[0.2em]">Master data kategori ILY Cattery</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
|
||||
@@ -31,21 +38,59 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- FORM TAMBAH KATEGORI (Proteksi Ganda dengan @can) --}}
|
||||
{{-- SECTION 2: Quick Stats (3 Cards) --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 px-2">
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm">
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Total Master Kategori</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ $totalCategories }} <span class="text-xs text-slate-400 font-bold">LABEL</span></h3>
|
||||
</div>
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm border-l-4 border-l-indigo-500">
|
||||
<p class="text-[9px] font-black text-indigo-600 uppercase tracking-widest">Kategori Terbaru</p>
|
||||
<h3 class="text-sm font-black text-slate-800 mt-2 uppercase truncate">{{ $latestCategory }}</h3>
|
||||
</div>
|
||||
<div class="bg-indigo-50 border border-indigo-100 p-6 rounded-[2rem] shadow-sm flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[9px] font-black text-indigo-600 uppercase tracking-widest">Status Sinkronisasi</p>
|
||||
<h3 class="text-xs font-black text-indigo-900 mt-1 uppercase tracking-tighter">Deteksi Kategori Aktif</h3>
|
||||
</div>
|
||||
<i class="fas fa-microchip text-indigo-200 text-2xl"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- SECTION 3: Search Bar --}}
|
||||
<div class="px-2">
|
||||
<form action="{{ route('categories.index') }}" method="GET" class="relative max-w-md">
|
||||
<input type="hidden" name="sort" value="{{ request('sort') }}">
|
||||
<input type="hidden" name="direction" value="{{ request('direction') }}">
|
||||
|
||||
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text" name="search" value="{{ request('search') }}"
|
||||
placeholder="Cari nama kategori atau kata kunci..."
|
||||
class="w-full pl-12 pr-4 py-3.5 bg-white border border-slate-200 rounded-2xl text-xs font-bold focus:ring-4 focus:ring-indigo-500/10 focus:border-indigo-500 transition-all shadow-sm">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- SECTION 4: Create Form (Toggleable) --}}
|
||||
@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">
|
||||
<div id="create-form" class="{{ $errors->any() ? '' : 'hidden' }} bg-white border border-indigo-100 rounded-[2.5rem] p-8 shadow-xl shadow-indigo-100/50 animate-fade-in-down mx-2">
|
||||
<div class="flex items-center gap-3 mb-6 border-b border-slate-50 pb-4">
|
||||
<i class="fas fa-plus-circle text-indigo-600"></i>
|
||||
<h4 class="text-xs font-black text-slate-800 uppercase tracking-widest">Entry Master Data Baru</h4>
|
||||
</div>
|
||||
<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">
|
||||
<div class="md:col-span-2 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" 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">
|
||||
<input type="text" name="name" value="{{ old('name') }}" required placeholder="Contoh: Antibiotik"
|
||||
class="w-full px-4 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-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 class="md:col-span-3 space-y-2">
|
||||
<label class="text-[10px] font-black text-slate-400 uppercase tracking-widest ml-1">Kata Kunci Deteksi (Pisah Koma)</label>
|
||||
<input type="text" name="keywords" value="{{ old('keywords') }}" required placeholder="amoxicillin, doxy, antibiotic"
|
||||
class="w-full px-4 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 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">
|
||||
<div class="md:col-span-2 flex items-end pb-1">
|
||||
<button type="submit" class="w-full py-4 bg-indigo-600 text-white font-black rounded-2xl text-[10px] uppercase tracking-[0.2em] shadow-lg shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-95">
|
||||
SIMPAN MASTER DATA
|
||||
</button>
|
||||
</div>
|
||||
@@ -53,57 +98,68 @@
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
{{-- DATA TABLE SECTION --}}
|
||||
{{-- SECTION 5: Data Table --}}
|
||||
<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">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest 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>
|
||||
<th class="px-6 py-5">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'name', 'direction' => $nextDir]) }}" class="flex items-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Informasi Kategori <i class="fas {{ $getSortIcon('name') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5">Kata Kunci Deteksi</th>
|
||||
<th class="px-6 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'created_at', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Dibuat Pada <i class="fas {{ $getSortIcon('created_at') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5 text-right">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@forelse($categories as $cat)
|
||||
<tr class="hover:bg-slate-50/30 transition-all">
|
||||
<td class="px-6 py-5 overflow-hidden">
|
||||
<tr class="hover:bg-slate-50/50 transition-all group">
|
||||
<td class="px-6 py-5">
|
||||
<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 class="text-sm font-black text-slate-800 uppercase tracking-tight">{{ $cat->name }}</div>
|
||||
<div class="text-[9px] text-slate-400 font-bold italic truncate">slug: {{ $cat->slug }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-5">
|
||||
<div class="flex flex-wrap gap-1.5 max-w-full">
|
||||
<div class="flex flex-wrap gap-1.5 max-w-md">
|
||||
@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">
|
||||
<span class="px-2.5 py-1 bg-slate-100 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 --}}
|
||||
<td class="px-6 py-5 text-center">
|
||||
<span class="text-[10px] font-bold text-slate-400">{{ $cat->created_at->format('d/m/Y') }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-5 text-right">
|
||||
<div class="flex justify-end gap-2">
|
||||
@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"
|
||||
class="w-9 h-9 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Edit Kategori">
|
||||
<i class="fas fa-edit text-[10px]"></i>
|
||||
<i class="fas fa-edit text-xs"></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"
|
||||
class="w-9 h-9 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-500 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Hapus Kategori">
|
||||
<i class="fas fa-trash-alt text-[10px]"></i>
|
||||
<i class="fas fa-trash-alt text-xs"></i>
|
||||
</button>
|
||||
<form id="delete-form-{{ $cat->id }}" action="{{ route('categories.destroy', $cat->id) }}" method="POST" class="hidden">
|
||||
@csrf @method('DELETE')
|
||||
@@ -114,14 +170,24 @@
|
||||
</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 colspan="4" class="px-8 py-24 text-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<i class="fas fa-tags text-5xl text-slate-100 mb-4"></i>
|
||||
<h3 class="text-slate-400 font-black uppercase text-xs tracking-[0.4em]">Kategori Kosong</h3>
|
||||
<p class="text-slate-300 text-[10px] font-bold mt-2 uppercase italic tracking-tighter font-mono">Gunakan pencarian lain atau tambahkan data baru</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if($categories->hasPages())
|
||||
<div class="px-8 py-6 bg-slate-50/50 border-t border-slate-100">
|
||||
{{ $categories->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -136,14 +202,14 @@
|
||||
|
||||
function confirmRecategorize() {
|
||||
Swal.fire({
|
||||
title: 'Recategorize All?',
|
||||
text: "Sistem akan memindai seluruh obat berdasarkan kata kunci terbaru.",
|
||||
title: 'Sinkronisasi Ulang?',
|
||||
text: "Sistem akan memindai seluruh data persediaan berdasarkan kata kunci terbaru. Ini mungkin memakan waktu.",
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#10b981',
|
||||
confirmButtonText: 'Ya, Sinkronkan!',
|
||||
cancelButtonText: 'Batal',
|
||||
customClass: { popup: 'rounded-[1.5rem]' }
|
||||
customClass: { popup: 'rounded-[2rem]' }
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const form = document.getElementById('form-recategorize');
|
||||
@@ -155,13 +221,14 @@
|
||||
function confirmDelete(id, name) {
|
||||
Swal.fire({
|
||||
title: 'Hapus Kategori?',
|
||||
text: `Kategori "${name}" akan dihapus permanen. Data obat terkait akan kembali ke status "Umum".`,
|
||||
text: `Kategori "${name}" akan dihapus permanen. Data produk terkait akan kembali ke kategori "Umum".`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#f43f5e',
|
||||
cancelButtonColor: '#64748b',
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
cancelButtonText: 'Batal',
|
||||
customClass: { popup: 'rounded-[1.5rem]' }
|
||||
customClass: { popup: 'rounded-[2rem]' }
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const form = document.getElementById(`delete-form-${id}`);
|
||||
@@ -170,7 +237,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
{{-- Toast Notifikasi Sukses --}}
|
||||
@if(session('success'))
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
@@ -178,7 +244,7 @@
|
||||
text: "{{ session('success') }}",
|
||||
showConfirmButton: false,
|
||||
timer: 2500,
|
||||
customClass: { popup: 'rounded-[1.5rem]' },
|
||||
customClass: { popup: 'rounded-[2rem]' },
|
||||
iconColor: '#4f46e5'
|
||||
});
|
||||
@endif
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<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">
|
||||
<input type="date" name="expired_at" 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">
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<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') : '') }}"
|
||||
<input type="date" name="expired_at" min="{{ date('Y-m-d') }}" value="{{ old('expired_at', $food->expired_at ? $food->expired_at->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>
|
||||
|
||||
|
||||
@@ -1,69 +1,78 @@
|
||||
<x-app-layout>
|
||||
@php
|
||||
$currentSort = request('sort', 'nama_makanan');
|
||||
$currentDir = request('direction', 'asc');
|
||||
$nextDir = $currentDir === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
$getSortIcon = function($field) use ($currentSort, $currentDir) {
|
||||
if ($currentSort !== $field) return 'fa-sort opacity-20';
|
||||
return $currentDir === 'asc' ? 'fa-sort-up text-indigo-600' : 'fa-sort-down text-indigo-600';
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="max-w-7xl mx-auto space-y-6 pb-12">
|
||||
{{-- SECTION 1: Header --}}
|
||||
{{-- 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>
|
||||
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 uppercase">Stok Makanan & Nutrisi</h2>
|
||||
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-[0.2em]">Persediaan Makanan • 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>
|
||||
<a href="{{ route('inventory.foods.create') }}" class="inline-flex items-center px-6 py-3 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-2xl shadow-lg active:scale-95 transition-all">
|
||||
<i class="fas fa-plus-circle mr-2"></i> TAMBAH PAKAN
|
||||
</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 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>
|
||||
{{-- Quick Stats (3 Cards) --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 px-2">
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm">
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Total Volume Stok</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ number_format($totalStock, 1) }} <span class="text-xs text-slate-400">UNIT</span></h3>
|
||||
</div>
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm border-l-4 border-l-rose-500">
|
||||
<p class="text-[9px] font-black text-rose-600 uppercase tracking-widest">Stok Menipis (<= 5)</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ $lowStockCount }} <span class="text-xs text-slate-400">PRODUK</span></h3>
|
||||
</div>
|
||||
<div class="bg-indigo-50 border border-indigo-100 p-6 rounded-[2rem] shadow-sm">
|
||||
<p class="text-[9px] font-black text-indigo-600 uppercase tracking-widest">Varian Produk</p>
|
||||
<h3 class="text-2xl font-black text-indigo-900 mt-1">{{ $totalItems }} <span class="text-xs text-indigo-400">JENIS</span></h3>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- SECTION 3: Tabel Utama --}}
|
||||
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm mx-2">
|
||||
{{-- Search & Sorting --}}
|
||||
<div class="px-2">
|
||||
<form action="{{ route('inventory.foods.index') }}" method="GET" class="relative max-w-md">
|
||||
<input type="hidden" name="sort" value="{{ request('sort') }}">
|
||||
<input type="hidden" name="direction" value="{{ request('direction') }}">
|
||||
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text" name="search" value="{{ request('search') }}" placeholder="Cari merk pakan atau kategori..." class="w-full pl-12 pr-4 py-3.5 bg-white border border-slate-200 rounded-2xl text-xs font-bold focus:ring-4 focus:ring-indigo-500/10 transition-all shadow-sm">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- Table --}}
|
||||
<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">
|
||||
<table class="w-full text-left">
|
||||
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest 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>
|
||||
<th class="px-6 py-5">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'nama_makanan', 'direction' => $nextDir]) }}" class="hover:text-indigo-600 transition-colors flex items-center gap-2">
|
||||
Informasi Pakan <i class="fas {{ $getSortIcon('nama_makanan') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'qty', 'direction' => $nextDir]) }}" class="hover:text-indigo-600 transition-colors flex items-center justify-center gap-2">
|
||||
Stok Tersedia <i class="fas {{ $getSortIcon('qty') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5 text-center">Ditambahkan Pada</th>
|
||||
<th class="px-6 py-5 text-right">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@forelse($foods as $f)
|
||||
<tr class="hover:bg-slate-50/40 transition-all group">
|
||||
<tr class="hover:bg-slate-50/50 transition-all">
|
||||
<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">
|
||||
@@ -73,94 +82,48 @@
|
||||
<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 }}
|
||||
<div>
|
||||
<div class="text-sm font-black text-slate-800 uppercase tracking-tight">{{ $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 mt-1 inline-block">
|
||||
{{ $f->kategori ?? ($f->category->name ?? 'Umum') }}
|
||||
</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 class="px-6 py-4 text-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="flex items-baseline gap-1 {{ $f->qty <= 5 ? 'text-rose-600' : 'text-emerald-600' }}">
|
||||
<span class="text-sm font-black">{{ (float)$f->qty }}</span>
|
||||
<span class="text-[9px] font-bold uppercase">{{ $f->unit ?? 'UNIT' }}</span>
|
||||
</div>
|
||||
@if($f->qty <= 5)
|
||||
<span class="text-[7px] font-black text-rose-400 uppercase tracking-widest animate-pulse mt-1">Low!</span>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-center gap-2">
|
||||
{{-- PROTEKSI EDIT: Mengikuti matriks permission --}}
|
||||
<td class="px-6 py-4 text-center text-[10px] font-bold text-slate-400">
|
||||
{{ $f->created_at->format('d/m/Y') }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="flex justify-end gap-2">
|
||||
@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>
|
||||
<a href="{{ route('inventory.foods.edit', $f->id) }}" class="w-9 h-9 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all"><i class="fas fa-edit text-xs"></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>
|
||||
<button onclick="confirmDelete({{ $f->id }}, '{{ addslashes($f->nama_makanan) }}')" class="w-9 h-9 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-600 hover:text-white rounded-xl transition-all"><i class="fas fa-trash-alt text-xs"></i></button>
|
||||
@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>
|
||||
<tr><td colspan="4" class="px-6 py-20 text-center text-slate-300 text-xs italic font-bold uppercase tracking-widest">Pakan tidak ditemukan.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if($foods->hasPages())
|
||||
<div class="p-6 bg-slate-50/50 border-t border-slate-100">{{ $foods->links() }}</div>
|
||||
@endif
|
||||
</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>
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
<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') }}"
|
||||
<input type="date" name="expired_at" value="{{ old('expired_at') }}"
|
||||
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>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<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') : '') }}"
|
||||
<input type="date" name="expired_at" value="{{ old('expired_at', $medicine->expired_at ? $medicine->expired_at->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>
|
||||
|
||||
|
||||
@@ -1,66 +1,103 @@
|
||||
<x-app-layout>
|
||||
@php
|
||||
// Helper untuk logika sorting
|
||||
$currentSort = request('sort', 'nama_obat');
|
||||
$currentDir = request('direction', 'asc');
|
||||
$nextDir = $currentDir === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
$getSortIcon = function($field) use ($currentSort, $currentDir) {
|
||||
if ($currentSort !== $field) return 'fa-sort opacity-20';
|
||||
return $currentDir === 'asc' ? 'fa-sort-up text-indigo-600' : 'fa-sort-down text-indigo-600';
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="space-y-6 pb-12">
|
||||
{{-- SECTION 1: Header --}}
|
||||
{{-- SECTION 1: Header & Quick Stats --}}
|
||||
<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>
|
||||
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 uppercase">Inventori Obat & Vitamin</h2>
|
||||
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-[0.2em]">Persediaan Obat & Vitamin • 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 href="{{ route('inventory.medicines.create') }}" class="inline-flex items-center px-6 py-3 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-2xl shadow-lg shadow-indigo-100 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>
|
||||
{{-- SECTION 2: Global Search & Sorting Header --}}
|
||||
<div class="grid grid-cols-1 lg:grid-cols-12 gap-4 items-center">
|
||||
<div class="lg:col-span-4">
|
||||
<form action="{{ route('inventory.medicines.index') }}" method="GET" class="relative">
|
||||
{{-- Hidden input agar saat search, sorting tidak hilang --}}
|
||||
<input type="hidden" name="sort" value="{{ request('sort') }}">
|
||||
<input type="hidden" name="direction" value="{{ request('direction') }}">
|
||||
|
||||
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text" name="search" value="{{ request('search') }}"
|
||||
placeholder="Cari nama obat, kategori, atau deskripsi..."
|
||||
class="w-full pl-12 pr-4 py-3 bg-white border border-slate-200 rounded-2xl text-xs font-bold focus:ring-4 focus:ring-indigo-500/10 focus:border-indigo-500 transition-all shadow-sm">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-8">
|
||||
@if(auth()->user()->role === 'admin')
|
||||
<div class="bg-indigo-50/50 border border-indigo-100 rounded-2xl p-2 px-4 shadow-sm">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-file-excel text-indigo-600"></i>
|
||||
<span class="text-[10px] font-black text-indigo-900 uppercase">Batch Import</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('inventory.medicines.template') }}" class="px-3 py-1.5 bg-white border border-indigo-200 text-indigo-600 text-[9px] font-black rounded-lg hover:bg-indigo-100">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-32 border-none bg-transparent">
|
||||
<button type="submit" class="px-3 py-1.5 bg-indigo-600 text-white text-[9px] font-black rounded-lg uppercase">Unggah</button>
|
||||
</form>
|
||||
</div>
|
||||
</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>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- SECTION 3: Tabel Utama --}}
|
||||
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm">
|
||||
<div class="bg-white border border-slate-200 rounded-[2.5rem] 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">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest 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>
|
||||
<th class="px-6 py-5">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'nama_obat', 'direction' => $nextDir]) }}" class="flex items-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Informasi Produk <i class="fas {{ $getSortIcon('nama_obat') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-4 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'kategori', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Kategori <i class="fas {{ $getSortIcon('kategori') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-4 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'stok', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Stok Tersisa <i class="fas {{ $getSortIcon('stok') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-4 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'expired_at', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Kadaluarsa <i class="fas {{ $getSortIcon('expired_at') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5 text-right">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
<tbody class="divide-y divide-slate-100 font-medium text-slate-700">
|
||||
@forelse($medicines as $m)
|
||||
<tr class="hover:bg-slate-50/40 transition-all group">
|
||||
{{-- Informasi Produk --}}
|
||||
<td class="px-6 py-4 overflow-hidden">
|
||||
<tr class="hover:bg-slate-50/80 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">
|
||||
<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-sm">
|
||||
@if($m->foto_produk)
|
||||
<img src="{{ asset('storage/' . $m->foto_produk) }}" class="w-full h-full object-cover">
|
||||
@else
|
||||
@@ -68,33 +105,42 @@
|
||||
@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 class="text-sm font-black text-slate-800 truncate uppercase tracking-tight">{{ $m->nama_obat }}</div>
|
||||
<div class="text-[9px] font-bold text-slate-400 mt-0.5 italic">{{ Str::limit($m->keterangan, 40) }}</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 class="px-2.5 py-1 bg-indigo-50 text-indigo-600 rounded-lg text-[9px] font-black uppercase border border-indigo-100 shadow-sm">
|
||||
{{ $m->kategori ?? 'Umum' }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
{{-- Kadaluarsa --}}
|
||||
<td class="px-4 py-4 text-center">
|
||||
@if($m->expired_date)
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="flex items-baseline gap-1 {{ $m->qty <= 5 ? 'text-rose-600' : 'text-emerald-600' }}">
|
||||
<span class="text-sm font-black">{{ (float)$m->qty }}</span>
|
||||
<span class="text-[9px] font-bold uppercase">{{ $m->unit ?? 'Unit' }}</span>
|
||||
</div>
|
||||
@if($m->qty <= 5)
|
||||
<div class="flex items-center gap-1 mt-1 text-rose-400 animate-pulse">
|
||||
<i class="fas fa-exclamation-triangle text-[7px]"></i>
|
||||
<span class="text-[7px] font-black uppercase tracking-widest">Restock!</span>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-4 text-center">
|
||||
@if($m->expired_at)
|
||||
@php $isExpired = $m->expired_at->isPast(); @endphp
|
||||
<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 class="text-[10px] font-black {{ $isExpired ? 'text-rose-600' : 'text-slate-600' }}">
|
||||
{{ $m->expired_at->format('d M Y') }}
|
||||
</span>
|
||||
@if($m->expired_date->isPast())
|
||||
<span class="text-[7px] font-black text-rose-400 uppercase">Expired!</span>
|
||||
@if($isExpired)
|
||||
<span class="text-[7px] font-black text-rose-400 uppercase tracking-tighter">Kadaluarsa!</span>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
@@ -102,25 +148,22 @@
|
||||
@endif
|
||||
</td>
|
||||
|
||||
{{-- AKSI: Proteksi Penuh Berdasarkan Matriks Role Management --}}
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-center gap-2">
|
||||
{{-- Edit --}}
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="flex justify-end gap-2">
|
||||
@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"
|
||||
class="w-9 h-9 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Edit Obat">
|
||||
<i class="fas fa-edit text-[10px]"></i>
|
||||
<i class="fas fa-edit text-xs"></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"
|
||||
onclick="confirmDeleteObat({{ $m->id }}, '{{ addslashes($m->nama_obat) }}')"
|
||||
class="w-9 h-9 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-500 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Hapus Obat">
|
||||
<i class="fas fa-trash-alt text-[10px]"></i>
|
||||
<i class="fas fa-trash-alt text-xs"></i>
|
||||
</button>
|
||||
<form id="delete-medicine-{{ $m->id }}" action="{{ route('inventory.medicines.destroy', $m->id) }}" method="POST" class="hidden">
|
||||
@csrf @method('DELETE')
|
||||
@@ -131,60 +174,47 @@
|
||||
</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>
|
||||
<td colspan="5" class="px-6 py-24 text-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<i class="fas fa-pills text-5xl text-slate-100 mb-4"></i>
|
||||
<h3 class="text-slate-400 font-black uppercase text-xs tracking-[0.4em]">Obat Tidak Ditemukan</h3>
|
||||
<p class="text-slate-300 text-[10px] font-bold mt-2 uppercase italic">Coba gunakan kata kunci pencarian lain</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if($medicines->hasPages())
|
||||
<div class="p-8 border-t border-slate-100 bg-slate-50/30">
|
||||
{{ $medicines->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- SECTION 4: Scripts --}}
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
function confirmDeleteMedicine(id, name) {
|
||||
function confirmDeleteObat(id, name) {
|
||||
Swal.fire({
|
||||
title: 'Hapus Obat?',
|
||||
text: "Apakah Anda yakin ingin menghapus \"" + name + "\"? Data yang dihapus tidak bisa dikembalikan.",
|
||||
text: `Apakah Anda yakin ingin menghapus "${name}"? Tindakan ini permanen.`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#f43f5e',
|
||||
cancelButtonColor: '#64748b',
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
cancelButtonText: 'Batal',
|
||||
customClass: {
|
||||
popup: 'rounded-[1.5rem]'
|
||||
}
|
||||
customClass: { popup: 'rounded-[2rem]' }
|
||||
}).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>
|
||||
@@ -6,7 +6,7 @@
|
||||
</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>
|
||||
<p class="text-sm text-slate-500 font-medium italic">Pembaruan data persediaan untuk {{ $supply->nama_perlengkapan }}.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,104 +1,199 @@
|
||||
<x-app-layout>
|
||||
@php
|
||||
// Helper untuk logika sorting dinamis
|
||||
$currentSort = request('sort', 'nama_perlengkapan');
|
||||
$currentDir = request('direction', 'asc');
|
||||
$nextDir = $currentDir === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
$getSortIcon = function($field) use ($currentSort, $currentDir) {
|
||||
if ($currentSort !== $field) return 'fa-sort opacity-20';
|
||||
return $currentDir === 'asc' ? 'fa-sort-up text-indigo-600' : 'fa-sort-down text-indigo-600';
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="max-w-7xl mx-auto space-y-6 pb-12">
|
||||
{{-- HEADER SECTION --}}
|
||||
{{-- 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 Perlengkapan</h2>
|
||||
<p class="text-sm text-slate-500 font-medium italic">Manajemen inventori operasional Ily Cattery.</p>
|
||||
<h2 class="text-2xl font-black text-slate-800 tracking-tight leading-none mb-1 uppercase">Inventori Perlengkapan</h2>
|
||||
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-[0.2em]">Persediaan Perlengkapan • 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>
|
||||
<a href="{{ route('inventory.supplies.create') }}" class="inline-flex items-center px-6 py-3 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-2xl shadow-lg shadow-indigo-100 transition-all active:scale-95 uppercase tracking-widest">
|
||||
<i class="fas fa-plus-circle mr-2"></i> TAMBAH ITEM BARU
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{{-- BATCH IMPORT SECTION: KHUSUS ROLE ADMIN --}}
|
||||
{{-- SECTION 2: Quick Stats (3 Cards) --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 px-2">
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm hover:shadow-md transition-shadow">
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Volume Stok Fisik</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ number_format($totalStock, 0) }} <span class="text-xs text-slate-400">UNIT</span></h3>
|
||||
</div>
|
||||
<div class="bg-white border border-slate-200 p-6 rounded-[2rem] shadow-sm border-l-4 border-l-rose-500">
|
||||
<p class="text-[9px] font-black text-rose-600 uppercase tracking-widest">Perlu Restock (<= 5)</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ $lowStockCount }} <span class="text-xs text-slate-400">ITEM</span></h3>
|
||||
</div>
|
||||
<div class="bg-indigo-50 border border-indigo-100 p-6 rounded-[2rem] shadow-sm">
|
||||
<p class="text-[9px] font-black text-indigo-600 uppercase tracking-widest">Varian Perlengkapan</p>
|
||||
<h3 class="text-2xl font-black text-indigo-900 mt-1">{{ $totalItems }} <span class="text-xs text-indigo-400">JENIS</span></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- SECTION 3: Search & Batch Import (Optimized Alignment) --}}
|
||||
<div class="grid grid-cols-1 lg:grid-cols-12 gap-3 items-center px-2">
|
||||
|
||||
{{-- 1. Kotak Cari (Samping Kiri) --}}
|
||||
<div class="lg:col-span-4">
|
||||
<form action="{{ route('inventory.supplies.index') }}" method="GET" class="relative">
|
||||
<input type="hidden" name="sort" value="{{ request('sort') }}">
|
||||
<input type="hidden" name="direction" value="{{ request('direction') }}">
|
||||
|
||||
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 text-[10px]"></i>
|
||||
|
||||
<input type="text" name="search" value="{{ request('search') }}"
|
||||
placeholder="Cari item..."
|
||||
class="w-full pl-12 pr-4 h-11 bg-white border border-slate-200 rounded-2xl text-[10px] font-black focus:ring-4 focus:ring-indigo-500/10 focus:border-indigo-500 transition-all shadow-sm uppercase tracking-wider">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- 2. Kotak Batch Update (Samping Kanan) --}}
|
||||
<div class="lg:col-span-8">
|
||||
@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="bg-white border border-slate-200 rounded-2xl p-1 h-11 flex items-center shadow-sm">
|
||||
<div class="flex items-center justify-between w-full gap-2">
|
||||
|
||||
<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>
|
||||
{{-- Info & Template Icon --}}
|
||||
<div class="flex items-center gap-2 pl-2 shrink-0">
|
||||
<div class="w-7 h-7 rounded-lg bg-slate-900 flex items-center justify-center shrink-0">
|
||||
<i class="fas fa-boxes-stacked text-white text-[9px]"></i>
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="text-[9px] font-black text-slate-700 uppercase tracking-tighter leading-none hidden xl:block">Batch Update</span>
|
||||
|
||||
<a href="{{ route('inventory.supplies.template') }}"
|
||||
class="w-7 h-7 flex items-center justify-center bg-indigo-50 text-indigo-600 rounded-lg hover:bg-indigo-600 hover:text-white transition-all"
|
||||
title="Unduh Template">
|
||||
<i class="fas fa-download text-[9px]"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Form Unggah (Integrasi ke dalam bar) --}}
|
||||
<form action="{{ route('inventory.supplies.batch') }}" method="POST" enctype="multipart/form-data"
|
||||
class="flex items-center gap-1 flex-1 justify-end min-w-0">
|
||||
@csrf
|
||||
|
||||
<label class="relative flex-1 group cursor-pointer min-w-0 max-w-[200px]">
|
||||
<div class="flex items-center gap-2 px-3 h-8 bg-slate-50 border border-dashed border-slate-200 rounded-xl transition-all hover:bg-slate-100">
|
||||
<i class="fas fa-paperclip text-slate-400 text-[9px] shrink-0"></i>
|
||||
<span id="file-label" class="text-[9px] font-black text-slate-500 uppercase truncate">Pilih File...</span>
|
||||
</div>
|
||||
<input type="file" name="file_excel" class="hidden" required onchange="updateFileName(this)">
|
||||
</label>
|
||||
|
||||
<button type="submit" class="h-8 px-4 bg-indigo-600 hover:bg-indigo-700 text-white text-[9px] font-black rounded-xl uppercase shadow-sm active:scale-95 transition-all flex items-center gap-2 shrink-0">
|
||||
<i class="fas fa-upload text-[8px]"></i>
|
||||
<span>UNGGAH</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- DATA TABLE SECTION --}}
|
||||
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm mx-2">
|
||||
{{-- SECTION 4: Data Table --}}
|
||||
<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">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest 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>
|
||||
<th class="px-6 py-5">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'nama_perlengkapan', 'direction' => $nextDir]) }}" class="flex items-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Informasi Perlengkapan <i class="fas {{ $getSortIcon('nama_perlengkapan') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-4 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'qty', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Stok Fisik <i class="fas {{ $getSortIcon('qty') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-4 py-5 text-center">
|
||||
<a href="{{ request()->fullUrlWithQuery(['sort' => 'created_at', 'direction' => $nextDir]) }}" class="flex items-center justify-center gap-2 hover:text-indigo-600 transition-colors">
|
||||
Ditambahkan <i class="fas {{ $getSortIcon('created_at') }}"></i>
|
||||
</a>
|
||||
</th>
|
||||
<th class="px-6 py-5 text-right">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@forelse($supplies as $s)
|
||||
<tr class="hover:bg-slate-50/40 transition-all group">
|
||||
<tr class="hover:bg-slate-50/80 transition-all group">
|
||||
{{-- Informasi Produk --}}
|
||||
<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>
|
||||
<i class="fas fa-box 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 class="text-sm font-black text-slate-800 truncate uppercase tracking-tight">{{ $s->nama_perlengkapan }}</div>
|
||||
<div class="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">
|
||||
{{ $s->kategori ?? ($s->category->name ?? 'Persediaan') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
{{-- Stok dengan indikator Low Stock --}}
|
||||
<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 }}
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="flex items-baseline gap-1 {{ $s->qty <= 5 ? 'text-rose-600' : 'text-emerald-600' }}">
|
||||
<span class="text-sm font-black">{{ (float)$s->qty }}</span>
|
||||
<span class="text-[9px] font-bold uppercase">{{ $s->unit ?? 'PCS' }}</span>
|
||||
</div>
|
||||
@if($s->qty <= 5)
|
||||
<div class="flex items-center gap-1 mt-1 text-rose-400 animate-pulse">
|
||||
<i class="fas fa-exclamation-triangle text-[7px]"></i>
|
||||
<span class="text-[7px] font-black uppercase tracking-widest">Restock!</span>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
|
||||
{{-- Tanggal dibuat --}}
|
||||
<td class="px-4 py-4 text-center">
|
||||
<span class="text-[10px] font-bold text-slate-400 uppercase tracking-tighter">
|
||||
{{ $s->created_at->format('d/m/Y') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-center gap-2">
|
||||
{{-- PROTEKSI EDIT: Berdasarkan Matriks Izin --}}
|
||||
|
||||
{{-- Tombol Aksi --}}
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="flex justify-end gap-2">
|
||||
@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 href="{{ route('inventory.supplies.edit', $s->id) }}"
|
||||
class="w-9 h-9 flex items-center justify-center bg-amber-50 text-amber-600 hover:bg-amber-600 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Edit Item">
|
||||
<i class="fas fa-edit text-xs"></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 type="button"
|
||||
onclick="confirmDeleteSupply({{ $s->id }}, '{{ addslashes($s->nama_perlengkapan) }}')"
|
||||
class="w-9 h-9 flex items-center justify-center bg-rose-50 text-rose-600 hover:bg-rose-500 hover:text-white rounded-xl transition-all shadow-sm"
|
||||
title="Hapus Item">
|
||||
<i class="fas fa-trash-alt text-xs"></i>
|
||||
</button>
|
||||
<form id="delete-supply-{{ $s->id }}" action="{{ route('inventory.supplies.destroy', $s->id) }}" method="POST" class="hidden">
|
||||
@csrf @method('DELETE')
|
||||
@@ -109,10 +204,11 @@
|
||||
</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>
|
||||
<td colspan="4" class="px-6 py-24 text-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<i class="fas fa-box-open text-5xl text-slate-100 mb-4"></i>
|
||||
<h3 class="text-slate-400 font-black uppercase text-xs tracking-[0.4em]">Item Tidak Ditemukan</h3>
|
||||
<p class="text-slate-300 text-[10px] font-bold mt-2 uppercase italic tracking-tighter">Coba gunakan kata kunci pencarian lain</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -120,9 +216,10 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if(method_exists($supplies, 'links'))
|
||||
<div class="px-6 py-4 bg-slate-50/50 border-t border-slate-100">
|
||||
|
||||
{{-- Pagination --}}
|
||||
@if($supplies->hasPages())
|
||||
<div class="px-8 py-6 bg-slate-50/50 border-t border-slate-100">
|
||||
{{ $supplies->links() }}
|
||||
</div>
|
||||
@endif
|
||||
@@ -132,45 +229,37 @@
|
||||
{{-- SCRIPTS SECTION --}}
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<!-- <script>
|
||||
function updateFileName(input) {
|
||||
const label = document.getElementById('file-label');
|
||||
if (input.files && input.files.length > 0) {
|
||||
label.innerText = input.files[0].name;
|
||||
label.classList.remove('text-slate-500');
|
||||
label.classList.add('text-indigo-600');
|
||||
} else {
|
||||
label.innerText = 'Pilih File';
|
||||
}
|
||||
}
|
||||
</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.`,
|
||||
title: 'Hapus Perlengkapan?',
|
||||
text: `Apakah Anda yakin ingin menghapus "${name}"? Tindakan ini bersifat permanen.`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#f43f5e',
|
||||
cancelButtonColor: '#64748b',
|
||||
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();
|
||||
customClass: { popup: 'rounded-[2rem]' }
|
||||
}).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>
|
||||
Reference in New Issue
Block a user