Files
ilycats/resources/views/pages/dashboard/medical.blade.php
T

140 lines
7.3 KiB
PHP

<x-app-layout>
<div class="space-y-8 pb-12">
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h2 class="text-3xl font-black text-slate-800 tracking-tight leading-none mb-1">Ringkasan Kesehatans</h2>
<p class="text-sm text-slate-500 font-medium italic uppercase tracking-tighter">Analisis Kesehatan & Konsumsi Obat Ily Cattery</p>
</div>
<div class="flex gap-2">
<span class="px-4 py-2 bg-white border border-slate-200 rounded-xl text-[10px] font-black text-slate-400">
PERIODE: {{ now()->subMonths(6)->format('M Y') }} - {{ now()->format('M Y') }}
</span>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<div class="lg:col-span-2 bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm">
<div class="flex items-center justify-between mb-8">
<div>
<h4 class="font-black text-slate-800 uppercase tracking-tighter text-lg">Tren Kunjungan Medis</h4>
<p class="text-[10px] text-slate-400 font-black">Volume pemeriksaan per bulan</p>
</div>
<i class="fas fa-wave-square text-indigo-500 text-xl"></i>
</div>
<div class="h-[300px]">
<canvas id="medicalTrendChart"></canvas>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-[2.5rem] p-8 shadow-sm">
<h4 class="font-black text-slate-800 uppercase tracking-tighter text-lg mb-6 text-center">Kasus Terbanyak</h4>
<div class="space-y-4">
@foreach($topComplaints as $complaint)
<div class="flex items-center justify-between p-4 bg-slate-50 rounded-2xl border border-slate-100 group hover:border-rose-200 transition-all">
<div class="flex items-center gap-3">
<span class="w-8 h-8 rounded-lg bg-rose-500 text-white flex items-center justify-center text-[10px] font-black">
{{ $loop->iteration }}
</span>
<span class="text-xs font-black text-slate-700 uppercase tracking-tighter">{{ $complaint->keluhan }}</span>
</div>
<span class="text-xs font-black text-rose-500 bg-rose-50 px-2 py-1 rounded-lg">{{ $complaint->total }}x</span>
</div>
@endforeach
</div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div class="bg-slate-900 rounded-[2.5rem] p-8 text-white shadow-2xl">
<div class="flex items-center justify-between mb-8 border-b border-slate-800 pb-4">
<h4 class="font-black uppercase tracking-widest text-sm">Obat Paling Sering Digunakan</h4>
<i class="fas fa-pills text-emerald-400"></i>
</div>
<div class="space-y-6">
@foreach($topObats as $medicine)
<div class="relative">
<div class="flex justify-between text-[10px] font-black uppercase mb-2">
<span>{{ $medicine->nama_obat }}</span>
<span class="text-emerald-400">{{ $medicine->total_used }} Unit</span>
</div>
<div class="w-full bg-slate-800 rounded-full h-1.5">
@php
$maxUsed = $topObats->first()->total_used ?? 1;
$percentage = ($medicine->total_used / $maxUsed) * 100;
@endphp
<div class="bg-emerald-400 h-1.5 rounded-full" style="width: {{ $percentage }}%"></div>
</div>
</div>
@endforeach
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="bg-white border border-slate-200 rounded-[2rem] p-6 flex flex-col items-center justify-center text-center shadow-sm">
<div class="w-12 h-12 bg-indigo-50 text-indigo-500 rounded-2xl flex items-center justify-center mb-4">
<i class="fas fa-stethoscope text-xl"></i>
</div>
<p class="text-[10px] font-black text-slate-400 uppercase">Rata-rata Medis</p>
<p class="text-2xl font-black text-slate-800">
{{ number_format($monthlyTrends->avg('total'), 1) }}
</p>
<p class="text-[9px] text-slate-400 mt-1 italic">Kasus / Bulan</p>
</div>
<div class="bg-indigo-600 rounded-[2rem] p-6 flex flex-col items-center justify-center text-center shadow-xl shadow-indigo-100">
<div class="w-12 h-12 bg-white/20 text-white rounded-2xl flex items-center justify-center mb-4">
<i class="fas fa-calendar-check text-xl"></i>
</div>
<p class="text-[10px] font-black text-white/60 uppercase">Puncak Kasus</p>
<p class="text-xl font-black text-white">
{{ $monthlyTrends->sortByDesc('total')->first()->month ?? '-' }}
</p>
<p class="text-[9px] text-white/60 mt-1 italic">Bulan Terpadat</p>
</div>
</div>
</div>
</div>
@push('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const ctx = document.getElementById('medicalTrendChart');
new Chart(ctx, {
type: 'line',
data: {
labels: {!! json_encode($monthlyTrends->pluck('month')) !!},
datasets: [{
label: 'Jumlah Pemeriksaan',
data: {!! json_encode($monthlyTrends->pluck('total')) !!},
borderColor: '#6366f1',
backgroundColor: 'rgba(99, 102, 241, 0.1)',
borderWidth: 4,
tension: 0.4,
fill: true,
pointBackgroundColor: '#fff',
pointBorderColor: '#6366f1',
pointBorderWidth: 3,
pointRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { display: false } },
scales: {
y: {
beginAtZero: true,
grid: { color: '#f1f5f9' },
ticks: { font: { size: 10, weight: 'bold' }, color: '#94a3b8' }
},
x: {
grid: { display: false },
ticks: { font: { size: 10, weight: 'bold' }, color: '#94a3b8' }
}
}
}
});
});
</script>
@endpush
</x-app-layout>