Files

161 lines
10 KiB
PHP
Raw Permalink Normal View History

2026-09-23 12:45:02 +07:00
{{-- resources/views/pages/reports/medical_history.blade.php --}}
<div style="font-family: Helvetica, Arial, sans-serif; color: #334155;">
{{-- Header Utama --}}
<div style="text-align: center; border-bottom: 2px solid #4f46e5; padding-bottom: 15px; margin-bottom: 20px;">
<h1 style="margin:0; font-size: 24px; color: #0f172a; letter-spacing: 1px;">LAPORAN KESEHATAN: {{ strtoupper($cat->nama_kucing) }}</h1>
<p style="margin:5px 0; font-size: 10px; color: #64748b; letter-spacing: 2px;">SISTEM MANAJEMEN ILY AREGAU CATTERY</p>
</div>
{{-- Document Metadata (Informasi Unduh & Total Record) --}}
<div style="background-color: #f8fafc; border: 1px solid #e2e8f0; padding: 15px; margin-bottom: 30px; border-radius: 8px; font-size: 11px;">
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td style="width: 50%; vertical-align: top;">
<p style="margin: 4px 0;"><strong style="color: #4f46e5;">Cat Name:</strong> {{ $cat->nama_kucing }}</p>
<p style="margin: 4px 0;"><strong style="color: #4f46e5;">Breed / Gender:</strong> {{ $cat->ras }} / {{ $cat->jenis_kelamin }}</p>
<p style="margin: 4px 0;"><strong style="color: #4f46e5;">Microchip:</strong> {{ $cat->microchip ?? 'Unchipped' }}</p>
</td>
<td style="width: 50%; vertical-align: top; text-align: right;">
<p style="margin: 4px 0;"><strong style="color: #4f46e5;">Dicetak oleh:</strong> {{ auth()->user()->name ?? 'Sistem Administrator' }}</p>
<p style="margin: 4px 0;"><strong style="color: #4f46e5;">Timestamp:</strong> {{ \Carbon\Carbon::now()->translatedFormat('d F Y, H:i') }} WIB</p>
{{-- FIX: Menambahkan Klinis Log ke dalam Judul Metadata --}}
<p style="margin: 4px 0;">
<strong style="color: #4f46e5;">Summary Records:</strong> <br>
{{ $cat->medicalRecords->count() }} Catatan rutin •
<span style="color: #e11d48; font-weight: bold;">{{ $cat->treatments->count() }} Klinis Log</span> •
{{ $cat->weightHistories->count() }} Berat Log
</p>
</td>
</tr>
</table>
</div>
{{-- SECTION 1: ROUTINE MEDICAL LEDGER (Vaksin, Obat Cacing, dll) --}}
@foreach(['Vaccine', 'Deworming', 'Flea Perawatan', 'Grooming'] as $type)
@php $records = $cat->medicalRecords->where('type', $type)->sortByDesc('date_given'); @endphp
<div style="margin-top: 25px;">
<div style="background: #e0e7ff; padding: 8px 12px; border-left: 4px solid #4f46e5; font-weight: bold; font-size: 11px; margin-bottom: 8px; color: #3730a3;">
{{ strtoupper($type) }} HISTORY ({{ $records->count() }} Data)
</div>
<table style="width: 100%; border-collapse: collapse; font-size: 10px;">
<thead>
<tr style="background: #4f46e5; color: white;">
<th style="padding: 8px; text-align: left; border: 1px solid #4f46e5; width: 15%;">DATE GIVEN</th>
<th style="padding: 8px; text-align: left; border: 1px solid #4f46e5; width: 30%;">PRODUCT / TREATMENT</th>
<th style="padding: 8px; text-align: left; border: 1px solid #4f46e5; width: 40%;">NOTES</th>
<th style="padding: 8px; text-align: center; border: 1px solid #4f46e5; width: 15%;">NEXT SCHEDULE</th>
</tr>
</thead>
<tbody>
@forelse($records as $r)
<tr style="background: {{ $loop->even ? '#f8fafc' : '#ffffff' }};">
<td style="padding: 8px; border: 1px solid #e2e8f0;">{{ $r->date_given->format('d/m/Y') }}</td>
<td style="padding: 8px; border: 1px solid #e2e8f0; font-weight: bold;">
{{ $r->treatment_name }}
@if($r->dosage) <br><span style="font-size: 8px; color: #059669; font-weight: normal;">Dose: {{ $r->dosage }} {{ $r->unit }}</span> @endif
</td>
<td style="padding: 8px; border: 1px solid #e2e8f0; font-style: italic;">{{ $r->notes ?? '-' }}</td>
<td style="padding: 8px; border: 1px solid #e2e8f0; text-align: center;">{{ $r->next_schedule?->format('d/m/Y') ?? '-' }}</td>
</tr>
@empty
<tr><td colspan="4" style="padding: 10px; text-align: center; color: #94a3b8; border: 1px solid #e2e8f0;">No routine records.</td></tr>
@endforelse
</tbody>
</table>
</div>
@endforeach
{{-- SECTION 2: CLINICAL CASE HISTORY (Data Perawatan) --}}
<div style="margin-top: 35px;">
<div style="background: #fff1f2; padding: 8px 12px; border-left: 4px solid #e11d48; font-weight: bold; font-size: 11px; margin-bottom: 8px; color: #9f1239;">
CLINICAL CASE & TREATMENT HISTORY ({{ $cat->treatments->count() }} Data)
</div>
<table style="width: 100%; border-collapse: collapse; font-size: 10px;">
<thead>
<tr style="background: #e11d48; color: white;">
<th style="padding: 8px; text-align: left; border: 1px solid #e11d48; width: 15%;">DATE</th>
<th style="padding: 8px; text-align: left; border: 1px solid #e11d48; width: 25%;">DIAGNOSIS / KELUHAN</th>
<th style="padding: 8px; text-align: left; border: 1px solid #e11d48; width: 25%;">THERAPY (MEDICINE)</th>
<th style="padding: 8px; text-align: left; border: 1px solid #e11d48; width: 35%;">STATUS & RESOLUTION</th>
</tr>
</thead>
<tbody>
@forelse($cat->treatments->sortByDesc('tanggal') as $t)
<tr style="background: {{ $loop->even ? '#fff1f2' : '#ffffff' }}; vertical-align: top;">
<td style="padding: 8px; border: 1px solid #fecdd3;">{{ $t->tanggal->format('d/m/Y') }}</td>
<td style="padding: 8px; border: 1px solid #fecdd3;">
<strong style="color: #be123c;">{{ $t->keluhan }}</strong><br>
<span style="font-size: 9px; color: #64748b;">{{ $t->diagnosa }}</span>
</td>
<td style="padding: 8px; border: 1px solid #fecdd3;">
{{-- Menggunakan relasi medicine atau nama kolom asli sesuai database --}}
<strong>{{ $t->nama_obat ?? ($t->medicine ? $t->medicine->nama_obat : '-') }}</strong><br>
<span style="font-size: 9px;">Dosis/Qty: {{ $t->dosis ?? $t->qty_used }}</span>
</td>
<td style="padding: 8px; border: 1px solid #fecdd3;">
{{-- BLOK BARU: STATUS DAN REMARK PASCA SAKIT --}}
@if($t->status_perawatan == 2)
<div style="color: #059669; font-weight: bold; margin-bottom: 4px;">✓ RESOLVED (SEMBUH)</div>
@if($t->remark_pasca_sakit)
<div style="font-style: italic; font-size: 9px; color: #475569;">
"{{ $t->remark_pasca_sakit }}"
</div>
@endif
@else
<div style="color: #e11d48; font-weight: bold; margin-bottom: 4px;">⚠ ONGOING TREATMENT</div>
@endif
@if($t->keterangan)
<div style="margin-top: 6px; font-size: 9px; border-top: 1px dashed #fecdd3; padding-top: 4px;">
<strong style="color: #94a3b8;">Initial Notes:</strong> {{ $t->keterangan }}
</div>
@endif
</td>
</tr>
@empty
<tr><td colspan="4" style="padding: 10px; text-align: center; color: #94a3b8; border: 1px solid #fecdd3;">No clinical cases found.</td></tr>
@endforelse
</tbody>
</table>
</div>
{{-- SECTION 3: WEIGHT HISTORY --}}
@if($cat->weightHistories->count() > 0)
<div style="page-break-before: auto; margin-top: 35px;">
<div style="background: #ecfdf5; padding: 8px 12px; border-left: 4px solid #10b981; font-weight: bold; font-size: 11px; margin-bottom: 8px; color: #065f46;">
GROWTH & WEIGHT DALAM PROSES ({{ $cat->weightHistories->count() }} Data)
</div>
<table style="width: 100%; border-collapse: collapse; font-size: 10px;">
<thead>
<tr style="background: #10b981; color: white;">
<th style="padding: 8px; text-align: left; border: 1px solid #10b981;">DATE RECORDED</th>
<th style="padding: 8px; text-align: center; border: 1px solid #10b981;">WEIGHT (KG)</th>
<th style="padding: 8px; text-align: center; border: 1px solid #10b981;">PROGRESSION</th>
</tr>
</thead>
<tbody>
@php $wLogs = $cat->weightHistories->sortByDesc('created_at')->values(); @endphp
@foreach($wLogs as $index => $weight)
@php
$trend = '-';
$trendColor = '#64748b';
if (isset($wLogs[$index + 1])) {
$prev = (float)$wLogs[$index + 1]->berat;
$curr = (float)$weight->berat;
if ($curr > $prev) { $trend = 'Naik'; $trendColor = '#059669'; }
elseif ($curr < $prev) { $trend = 'Turun'; $trendColor = '#e11d48'; }
else { $trend = 'Stable'; }
}
@endphp
<tr style="background: {{ $loop->even ? '#ecfdf5' : '#ffffff' }};">
<td style="padding: 8px; border: 1px solid #d1fae5;">{{ $weight->created_at->format('d M Y, H:i') }}</td>
<td style="padding: 8px; border: 1px solid #d1fae5; text-align: center; font-weight: bold;">{{ $weight->berat }} Kg</td>
<td style="padding: 8px; border: 1px solid #d1fae5; text-align: center; font-weight: bold; color: {{ $trendColor }};">{{ $trend }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>