initial commit
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user