initial commit
This commit is contained in:
@@ -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