273 lines
17 KiB
PHP
273 lines
17 KiB
PHP
<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
|
|
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
|
|
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
|
|
<?php $component->withName('app-layout'); ?>
|
|
<?php if ($component->shouldRender()): ?>
|
|
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
|
|
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
|
|
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
|
|
<?php endif; ?>
|
|
<?php $component->withAttributes([]); ?>
|
|
<?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';
|
|
};
|
|
?>
|
|
|
|
<div class="max-w-7xl mx-auto space-y-6 pb-12">
|
|
|
|
|
|
<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 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">
|
|
<?php if(auth()->user()->role === 'admin'): ?>
|
|
<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="<?php echo e(route('categories.recategorize')); ?>" method="POST" class="hidden">
|
|
<?php echo csrf_field(); ?>
|
|
</form>
|
|
<?php endif; ?>
|
|
|
|
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('check-access', ['categories', 'create'])): ?>
|
|
<button onclick="toggleCreateForm()" class="inline-flex items-center px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-[10px] font-black rounded-xl transition-all shadow-lg active:scale-95">
|
|
<i class="fas fa-plus-circle mr-2"></i> TAMBAH KATEGORI
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<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"><?php echo e($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"><?php echo e($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>
|
|
|
|
|
|
<div class="px-2">
|
|
<form action="<?php echo e(route('categories.index')); ?>" method="GET" class="relative max-w-md">
|
|
<input type="hidden" name="sort" value="<?php echo e(request('sort')); ?>">
|
|
<input type="hidden" name="direction" value="<?php echo e(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="<?php echo e(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>
|
|
|
|
|
|
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('check-access', ['categories', 'create'])): ?>
|
|
<div id="create-form" class="<?php echo e($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="<?php echo e(route('categories.store')); ?>" method="POST" class="grid grid-cols-1 md:grid-cols-7 gap-6">
|
|
<?php echo csrf_field(); ?>
|
|
<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" value="<?php echo e(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-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="<?php echo e(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 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>
|
|
</form>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
|
|
<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">
|
|
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest border-b border-slate-100">
|
|
<tr>
|
|
<th class="px-6 py-5">
|
|
<a href="<?php echo e(request()->fullUrlWithQuery(['sort' => 'name', 'direction' => $nextDir])); ?>" class="flex items-center gap-2 hover:text-indigo-600 transition-colors">
|
|
Informasi Kategori <i class="fas <?php echo e($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="<?php echo e(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 <?php echo e($getSortIcon('created_at')); ?>"></i>
|
|
</a>
|
|
</th>
|
|
<th class="px-6 py-5 text-right">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100">
|
|
<?php $__empty_1 = true; $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
|
<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 uppercase tracking-tight"><?php echo e($cat->name); ?></div>
|
|
<div class="text-[9px] text-slate-400 font-bold italic truncate">slug: <?php echo e($cat->slug); ?></div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-5">
|
|
<div class="flex flex-wrap gap-1.5 max-w-md">
|
|
<?php $__currentLoopData = explode(',', $cat->keywords); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $word): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
|
<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">
|
|
<?php echo e(trim($word)); ?>
|
|
|
|
</span>
|
|
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-5 text-center">
|
|
<span class="text-[10px] font-bold text-slate-400"><?php echo e($cat->created_at->format('d/m/Y')); ?></span>
|
|
</td>
|
|
<td class="px-6 py-5 text-right">
|
|
<div class="flex justify-end gap-2">
|
|
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('check-access', ['categories', 'update'])): ?>
|
|
<a href="<?php echo e(route('categories.edit', $cat->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 Kategori">
|
|
<i class="fas fa-edit text-xs"></i>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('check-access', ['categories', 'delete'])): ?>
|
|
<button type="button"
|
|
onclick="confirmDelete(<?php echo e($cat->id); ?>, '<?php echo e(addslashes($cat->name)); ?>')"
|
|
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-xs"></i>
|
|
</button>
|
|
<form id="delete-form-<?php echo e($cat->id); ?>" action="<?php echo e(route('categories.destroy', $cat->id)); ?>" method="POST" class="hidden">
|
|
<?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
|
<tr>
|
|
<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>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php if($categories->hasPages()): ?>
|
|
<div class="px-8 py-6 bg-slate-50/50 border-t border-slate-100">
|
|
<?php echo e($categories->links()); ?>
|
|
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php $__env->startPush('scripts'); ?>
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<script>
|
|
function toggleCreateForm() {
|
|
const form = document.getElementById('create-form');
|
|
if (form) form.classList.toggle('hidden');
|
|
}
|
|
|
|
function confirmRecategorize() {
|
|
Swal.fire({
|
|
title: '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-[2rem]' }
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
const form = document.getElementById('form-recategorize');
|
|
if (form) form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
function confirmDelete(id, name) {
|
|
Swal.fire({
|
|
title: 'Hapus Kategori?',
|
|
text: `Kategori "${name}" akan dihapus permanen. Data produk terkait akan kembali ke kategori "Umum".`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#f43f5e',
|
|
cancelButtonColor: '#64748b',
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
cancelButtonText: 'Batal',
|
|
customClass: { popup: 'rounded-[2rem]' }
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
const form = document.getElementById(`delete-form-${id}`);
|
|
if (form) form.submit();
|
|
}
|
|
});
|
|
}
|
|
|
|
<?php if(session('success')): ?>
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil!',
|
|
text: "<?php echo e(session('success')); ?>",
|
|
showConfirmButton: false,
|
|
timer: 2500,
|
|
customClass: { popup: 'rounded-[2rem]' },
|
|
iconColor: '#4f46e5'
|
|
});
|
|
<?php endif; ?>
|
|
</script>
|
|
<?php $__env->stopPush(); ?>
|
|
<?php echo $__env->renderComponent(); ?>
|
|
<?php endif; ?>
|
|
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
|
|
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
|
|
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
|
|
<?php endif; ?>
|
|
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
|
|
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
|
|
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
|
|
<?php endif; ?><?php /**PATH /home/u806112658/domains/earrinasia.com/ilycats/resources/views/pages/inventory/categories/index.blade.php ENDPATH**/ ?>
|