initial commit

This commit is contained in:
2026-09-23 12:45:02 +07:00
parent d16f454083
commit 507fc6ccdf
235 changed files with 19587 additions and 2835 deletions
@@ -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>