Files
ilycats/resources/views/pages/reports/index.blade.php
T
2026-02-08 15:16:35 +07:00

199 lines
14 KiB
PHP

<x-app-layout>
<div class="max-w-[1600px] mx-auto p-4 sm:px-6 lg:px-8 py-8 space-y-6">
{{-- 1. ACTION HEADER --}}
<div class="flex flex-col md:flex-row justify-between items-center gap-6 bg-white p-8 rounded-[3rem] border border-slate-100 shadow-sm">
<div>
<h1 class="text-3xl font-black text-slate-800 tracking-tighter uppercase leading-none">
Intelligence <span class="text-indigo-600">Center</span>
</h1>
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-[0.3em] mt-2">
Laporan: {{ strtoupper(str_replace('_', ' ', $module)) }}
</p>
</div>
{{-- PROTEKSI EXPORT: Hanya muncul jika memiliki izin 'create' pada modul reports --}}
@can('check-access', ['reports', 'create'])
<div class="flex items-center gap-3">
{{-- Export PDF --}}
<a href="{{ route('admin.reports.index', array_merge(request()->query(), ['export' => 'pdf'])) }}"
class="bg-rose-600 text-white px-6 py-3.5 rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-rose-700 shadow-lg shadow-rose-100 transition-all flex items-center gap-2">
<i class="fas fa-file-pdf text-sm"></i> Export PDF
</a>
{{-- Export Excel --}}
<a href="{{ route('admin.reports.index', array_merge(request()->query(), ['export' => 'xlsx'])) }}"
class="flex items-center gap-2 px-6 py-3.5 bg-emerald-50 text-emerald-700 border border-emerald-100 rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-emerald-600 hover:text-white hover:border-emerald-600 shadow-lg shadow-emerald-100/50 transition-all active:scale-95 group">
<i class="fas fa-file-excel text-sm text-emerald-600 group-hover:text-white transition-colors"></i>
<span>Export Excel</span>
</a>
</div>
@endcan
</div>
{{-- 2. ADVANCED FILTER PANEL (TETAP UTUH) --}}
<div class="bg-white rounded-[3rem] border border-slate-100 shadow-sm p-8">
<form action="{{ route('admin.reports.index') }}" method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-8">
{{-- Source & Search --}}
<div class="space-y-3">
<label class="block text-[10px] font-black text-slate-400 uppercase tracking-widest ml-2">Data Source</label>
<select name="module" onchange="this.form.submit()" class="w-full bg-slate-50 border-none rounded-2xl text-xs font-bold text-slate-700">
<option value="cats" {{ $module == 'cats' ? 'selected' : '' }}>Populasi Kucing</option>
<option value="vaccine" {{ $module == 'vaccine' ? 'selected' : '' }}>Jadwal Vaksin</option>
<option value="deworming" {{ $module == 'deworming' ? 'selected' : '' }}>Jadwal Obat Cacing</option>
<option value="flea" {{ $module == 'flea' ? 'selected' : '' }}>Jadwal Obat Kutu</option>
<option value="grooming" {{ $module == 'grooming' ? 'selected' : '' }}>Jadwal Grooming</option>
<option value="medicine" {{ $module == 'medicine' ? 'selected' : '' }}>Inventori Obat</option>
<option value="food" {{ $module == 'food' ? 'selected' : '' }}>Inventori Makanan</option>
<option value="supplies" {{ $module == 'supplies' ? 'selected' : '' }}>Perlengkapan</option>
</select>
<input type="text" name="q" value="{{ request('q') }}" placeholder="Search Keyword..." class="w-full bg-slate-50 border-none rounded-2xl text-xs font-bold">
</div>
{{-- PIC & Period --}}
<div class="space-y-3">
<label class="block text-[10px] font-black text-slate-400 uppercase tracking-widest ml-2">Staff & Periode</label>
<select name="pic_id" class="w-full bg-slate-50 border-none rounded-2xl text-xs font-bold">
<option value="">Semua PIC Staff</option>
@foreach($users as $user)
<option value="{{ $user->id }}" {{ request('pic_id') == $user->id ? 'selected' : '' }}>{{ $user->name }}</option>
@endforeach
</select>
<div class="grid grid-cols-2 gap-2">
<input type="date" name="start_date" value="{{ request('start_date') }}" class="w-full bg-slate-50 border-none rounded-2xl text-[10px] font-bold">
<input type="date" name="end_date" value="{{ request('end_date') }}" class="w-full bg-slate-50 border-none rounded-2xl text-[10px] font-bold">
</div>
</div>
{{-- Status Filter --}}
<div class="space-y-3">
<label class="block text-[10px] font-black text-slate-400 uppercase tracking-widest ml-2">Status Analitik</label>
<select name="status" class="w-full bg-slate-50 border-none rounded-2xl text-xs font-bold">
<option value="">Pilih Status</option>
@if($module == 'cats')
<option value="sehat" {{ request('status') == 'sehat' ? 'selected' : '' }}>Sehat</option>
<option value="sakit" {{ request('status') == 'sakit' ? 'selected' : '' }}>Dalam Perawatan</option>
@elseif(in_array($module, ['vaccine', 'deworming', 'flea', 'grooming']))
<option value="not_set" {{ request('status') == 'not_set' ? 'selected' : '' }}>Date Not Set</option>
<option value="overdue" {{ request('status') == 'overdue' ? 'selected' : '' }}>Overdue (Terlewat)</option>
<option value="soon" {{ request('status') == 'soon' ? 'selected' : '' }}>Akan Datang (7 Hari)</option>
@elseif(in_array($module, ['medicine', 'food', 'supplies']))
<option value="critical" {{ request('status') == 'critical' ? 'selected' : '' }}>Stok Kritis (< 5)</option>
<option value="expired" {{ request('status') == 'expired' ? 'selected' : '' }}>Sudah Expired</option>
<option value="safe" {{ request('status') == 'safe' ? 'selected' : '' }}>Stok Aman</option>
@endif
</select>
<button type="submit" class="w-full bg-indigo-600 text-white py-3 rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-slate-900 shadow-xl shadow-indigo-100 transition-all">
<i class="fas fa-filter mr-2"></i> Apply Filter
</button>
</div>
{{-- Summary & Reset --}}
<div class="flex flex-col justify-between">
<div class="bg-indigo-50 p-5 rounded-[2rem] border border-indigo-100 text-center">
<p class="text-[9px] font-black text-indigo-400 uppercase tracking-widest mb-1">Total Data</p>
<span class="text-3xl font-black text-indigo-700 leading-none">{{ $results->total() }}</span>
</div>
<a href="{{ route('admin.reports.index') }}" class="w-full bg-slate-100 text-slate-400 py-3 rounded-2xl text-[10px] font-black uppercase tracking-widest text-center hover:bg-rose-50 hover:text-rose-600 transition-all">
<i class="fas fa-sync-alt mr-2"></i> Reset Filter
</a>
</div>
</form>
</div>
{{-- 3. DATA TABLE (TETAP UTUH) --}}
<div class="bg-white rounded-[3rem] border border-slate-100 shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left">
<thead class="bg-slate-50/50 border-b border-slate-100">
<tr>
<th class="p-6 text-[10px] font-black text-slate-400 uppercase tracking-widest">Informasi Utama</th>
<th class="p-6 text-[10px] font-black text-slate-400 uppercase tracking-widest">Detail Data</th>
<th class="p-6 text-[10px] font-black text-slate-400 uppercase tracking-widest">Staff & Jadwal</th>
<th class="p-6 text-[10px] font-black text-slate-400 uppercase tracking-widest text-right">Status Aktif</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse($results as $item)
@php
$dateCol = match($module) {
'cats' => 'tanggal_lahir',
'vaccine' => 'jadwal_vaksin',
'deworming' => 'jadwal_obat_cacing',
'flea' => 'jadwal_obat_kutu',
'grooming' => 'jadwal_grooming',
'medicine', 'food', 'supplies' => 'expired_date',
default => 'created_at'
};
$dateValue = $item->{$dateCol};
@endphp
<tr class="group hover:bg-slate-50/30 transition-all">
<td class="p-6">
<p class="text-xs font-black text-slate-800 uppercase leading-none mb-1">
{{ $item->nama_kucing ?? $item->nama_obat ?? $item->nama_makanan ?? $item->nama_perlengkapan }}
</p>
<p class="text-[9px] text-slate-400 font-bold uppercase tracking-widest italic">ID: #{{ $item->id }}</p>
</td>
<td class="p-6">
@if(isset($item->qty))
<div class="flex items-center gap-2">
<span class="text-xs font-black {{ $item->qty < 5 ? 'text-rose-600' : 'text-slate-700' }}">{{ $item->qty }}</span>
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-widest">{{ $item->unit ?? 'Unit' }}</span>
</div>
@else
<span class="text-[10px] font-black text-slate-500 uppercase">{{ $item->ras ?? '-' }}</span>
@endif
</td>
<td class="p-6">
<div class="flex flex-col gap-1">
<span class="text-[10px] font-black text-slate-600 uppercase">{{ $item->pic->name ?? 'System' }}</span>
<span class="text-[9px] font-bold text-slate-400 italic">
<i class="far fa-calendar-alt mr-1"></i> {{ $dateValue ? \Carbon\Carbon::parse($dateValue)->format('d/m/Y') : 'DATE NOT SET' }}
</span>
</div>
</td>
<td class="p-6 text-right">
@if(in_array($module, ['vaccine', 'deworming', 'flea', 'grooming']))
@if(empty($dateValue))
<span class="px-3 py-1.5 bg-slate-100 text-slate-400 rounded-lg text-[8px] font-black uppercase">Date Not Set</span>
@elseif(\Carbon\Carbon::parse($dateValue)->isPast())
<span class="px-3 py-1.5 bg-rose-100 text-rose-600 rounded-lg text-[8px] font-black uppercase animate-pulse">Overdue</span>
@elseif(\Carbon\Carbon::parse($dateValue)->diffInDays(now()) <= 7)
<span class="px-3 py-1.5 bg-amber-100 text-amber-600 rounded-lg text-[8px] font-black uppercase">Soon</span>
@else
<span class="px-3 py-1.5 bg-emerald-100 text-emerald-600 rounded-lg text-[8px] font-black uppercase">Scheduled</span>
@endif
@elseif(in_array($module, ['medicine', 'food', 'supplies']))
@if(isset($item->expired_date) && \Carbon\Carbon::parse($item->expired_date)->isPast())
<span class="px-3 py-1.5 bg-rose-600 text-white rounded-lg text-[8px] font-black uppercase">Expired</span>
@elseif($item->qty < 5)
<span class="px-3 py-1.5 bg-rose-100 text-rose-600 rounded-lg text-[8px] font-black uppercase">Low Stock</span>
@else
<span class="px-3 py-1.5 bg-slate-100 text-slate-500 rounded-lg text-[8px] font-black uppercase">Safe</span>
@endif
@else
<span class="px-3 py-1.5 {{ $item->riwayat_sakit_terakhir ? 'bg-amber-100 text-amber-600' : 'bg-emerald-100 text-emerald-600' }} rounded-lg text-[8px] font-black uppercase">
{{ $item->riwayat_sakit_terakhir ? 'Treatment' : 'Healthy' }}
</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="4" class="p-20 text-center text-[10px] font-black text-slate-300 uppercase tracking-widest">Data Tidak Ditemukan</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
{{-- PAGINATION --}}
<div class="mt-8">
{{ $results->links() }}
</div>
</div>
</x-app-layout>