568 lines
16 KiB
PHP
568 lines
16 KiB
PHP
{{-- resources/views/pdf/hasil-diagnosa.blade.php
|
|
KEGUNAAN: Template PDF untuk hasil diagnosa.
|
|
Di-render oleh DomPDF menjadi file PDF yang bisa didownload.
|
|
Desain bersih dan profesional agar mudah dibaca. --}}
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Hasil Diagnosa — {{ $konsultasi->kode_konsultasi }}</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
font-family: sans-serif;
|
|
font-size: 12px;
|
|
color: #1a1a1a;
|
|
background: #fff;
|
|
padding: 0;
|
|
}
|
|
|
|
/* ── HEADER ── */
|
|
.header {
|
|
background: #C0392B;
|
|
color: #fff;
|
|
padding: 20px 30px;
|
|
margin-bottom: 0;
|
|
}
|
|
.header-top {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
margin-bottom: 12px;
|
|
}
|
|
.brand {
|
|
font-size: 22px;
|
|
font-weight: 800;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
.brand-sub {
|
|
font-size: 10px;
|
|
opacity: 0.75;
|
|
margin-top: 2px;
|
|
letter-spacing: 0.05em;
|
|
text-transform: uppercase;
|
|
}
|
|
.kode-box {
|
|
text-align: right;
|
|
}
|
|
.kode-label {
|
|
font-size: 9px;
|
|
opacity: 0.7;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.08em;
|
|
}
|
|
.kode-value {
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
font-family: monospace;
|
|
margin-top: 2px;
|
|
}
|
|
.header-meta {
|
|
border-top: 1px solid rgba(255,255,255,0.2);
|
|
padding-top: 10px;
|
|
display: flex;
|
|
gap: 24px;
|
|
}
|
|
.meta-item {
|
|
font-size: 10px;
|
|
opacity: 0.85;
|
|
}
|
|
.meta-label {
|
|
opacity: 0.65;
|
|
display: block;
|
|
margin-bottom: 2px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.06em;
|
|
font-size: 9px;
|
|
}
|
|
|
|
/* ── BODY ── */
|
|
.body { padding: 24px 30px; }
|
|
|
|
/* ── HASIL UTAMA ── */
|
|
.hasil-utama {
|
|
border: 2px solid #C0392B;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
margin-bottom: 20px;
|
|
}
|
|
.hasil-utama-header {
|
|
background: #FDEDEC;
|
|
padding: 12px 16px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
border-bottom: 1px solid #FADBD8;
|
|
}
|
|
.hasil-utama-title {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
color: #A93226;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.06em;
|
|
}
|
|
.hasil-utama-badge {
|
|
background: #C0392B;
|
|
color: #fff;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
padding: 3px 10px;
|
|
border-radius: 100px;
|
|
}
|
|
.hasil-utama-body {
|
|
padding: 16px;
|
|
}
|
|
.penyakit-nama {
|
|
font-size: 20px;
|
|
font-weight: 800;
|
|
color: #1a1a1a;
|
|
margin-bottom: 4px;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
.penyakit-jenis {
|
|
display: inline-block;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
padding: 2px 8px;
|
|
border-radius: 100px;
|
|
margin-bottom: 10px;
|
|
}
|
|
.jenis-hama {
|
|
background: #FEF9E7;
|
|
color: #B7770D;
|
|
border: 1px solid #F9E79F;
|
|
}
|
|
.jenis-penyakit {
|
|
background: #FDEDEC;
|
|
color: #A93226;
|
|
border: 1px solid #FADBD8;
|
|
}
|
|
.cf-row {
|
|
display: flex;
|
|
gap: 16px;
|
|
margin-top: 8px;
|
|
}
|
|
.cf-box {
|
|
flex: 1;
|
|
background: #F8F9FA;
|
|
border: 1px solid #E9ECEF;
|
|
border-radius: 6px;
|
|
padding: 10px 12px;
|
|
text-align: center;
|
|
}
|
|
.cf-box-label {
|
|
font-size: 9px;
|
|
color: #6B7280;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.06em;
|
|
display: block;
|
|
margin-bottom: 4px;
|
|
}
|
|
.cf-box-value {
|
|
font-size: 18px;
|
|
font-weight: 800;
|
|
color: #C0392B;
|
|
}
|
|
.cf-box-sub {
|
|
font-size: 10px;
|
|
color: #9CA3AF;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
/* PROGRESS BAR */
|
|
.progress-wrap {
|
|
margin-top: 10px;
|
|
}
|
|
.progress-label {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-size: 10px;
|
|
color: #6B7280;
|
|
margin-bottom: 4px;
|
|
}
|
|
.progress-bar-bg {
|
|
background: #F3F4F6;
|
|
border-radius: 4px;
|
|
height: 8px;
|
|
overflow: hidden;
|
|
}
|
|
.progress-bar-fill {
|
|
background: #C0392B;
|
|
height: 100%;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
/* ── SOLUSI ── */
|
|
.section-title {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
color: #1a1a1a;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.06em;
|
|
margin-bottom: 10px;
|
|
padding-bottom: 6px;
|
|
border-bottom: 1px solid #E9ECEF;
|
|
}
|
|
.solusi-grid {
|
|
display: flex;
|
|
gap: 12px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.solusi-box {
|
|
flex: 1;
|
|
border: 1px solid #E9ECEF;
|
|
border-radius: 6px;
|
|
overflow: hidden;
|
|
}
|
|
.solusi-box-header {
|
|
padding: 8px 12px;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
.solusi-box-header.penanganan {
|
|
background: #EBF5FB;
|
|
color: #1A5276;
|
|
}
|
|
.solusi-box-header.pencegahan {
|
|
background: #EAFAF1;
|
|
color: #1E8449;
|
|
}
|
|
.solusi-box-body {
|
|
padding: 10px 12px;
|
|
font-size: 11px;
|
|
color: #374151;
|
|
line-height: 1.65;
|
|
}
|
|
|
|
/* ── GEJALA ── */
|
|
.gejala-grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 6px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.gejala-chip {
|
|
background: #F3F4F6;
|
|
border: 1px solid #E5E7EB;
|
|
border-radius: 4px;
|
|
padding: 4px 8px;
|
|
font-size: 10px;
|
|
color: #374151;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
}
|
|
.gejala-kode {
|
|
font-family: monospace;
|
|
font-weight: 700;
|
|
color: #C0392B;
|
|
font-size: 9px;
|
|
}
|
|
|
|
/* ── KEMUNGKINAN LAIN ── */
|
|
.other-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-bottom: 20px;
|
|
font-size: 11px;
|
|
}
|
|
.other-table th {
|
|
background: #F3F4F6;
|
|
padding: 8px 10px;
|
|
text-align: left;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
color: #6B7280;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
border-bottom: 1px solid #E9ECEF;
|
|
}
|
|
.other-table td {
|
|
padding: 8px 10px;
|
|
border-bottom: 1px solid #F3F4F6;
|
|
color: #374151;
|
|
}
|
|
.other-table tr:last-child td { border-bottom: none; }
|
|
|
|
/* ── LOG CF ── */
|
|
.log-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 10px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.log-table th {
|
|
background: #1a1a1a;
|
|
color: #fff;
|
|
padding: 7px 8px;
|
|
text-align: left;
|
|
font-size: 9px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
.log-table td {
|
|
padding: 7px 8px;
|
|
border-bottom: 1px solid #F3F4F6;
|
|
color: #374151;
|
|
vertical-align: middle;
|
|
}
|
|
.log-table tr:nth-child(even) td { background: #FAFAFA; }
|
|
.mono { font-family: monospace; font-weight: 700; color: #C0392B; }
|
|
|
|
/* ── FOOTER PDF ── */
|
|
.pdf-footer {
|
|
margin-top: 24px;
|
|
padding-top: 12px;
|
|
border-top: 1px solid #E9ECEF;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-size: 9px;
|
|
color: #9CA3AF;
|
|
}
|
|
|
|
/* ── STATUS TIDAK TERDETEKSI ── */
|
|
.tidak-terdeteksi {
|
|
background: #FFFBF5;
|
|
border: 1px solid #FDE68A;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
.tidak-terdeteksi h3 {
|
|
font-size: 16px;
|
|
color: #92400E;
|
|
margin-bottom: 6px;
|
|
}
|
|
.tidak-terdeteksi p {
|
|
font-size: 11px;
|
|
color: #B45309;
|
|
line-height: 1.6;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
{{-- ── HEADER ── --}}
|
|
<div class="header">
|
|
<div class="header-top">
|
|
<div>
|
|
<div class="brand">RedGuard</div>
|
|
<div class="brand-sub">Sistem Pakar Penyakit Cabai Rawit · Certainty Factor</div>
|
|
</div>
|
|
<div class="kode-box">
|
|
<div class="kode-label">Kode Konsultasi</div>
|
|
<div class="kode-value">{{ $konsultasi->kode_konsultasi }}</div>
|
|
</div>
|
|
</div>
|
|
<div class="header-meta">
|
|
<div class="meta-item">
|
|
<span class="meta-label">Nama Pengguna</span>
|
|
{{ $konsultasi->user->name ?? 'User' }}
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Tanggal Konsultasi</span>
|
|
{{ \Carbon\Carbon::parse($konsultasi->tanggal)->format('d F Y, H:i') }} WIB
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Jumlah Gejala</span>
|
|
{{ $konsultasi->gejalaList->count() }} gejala dipilih
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Status</span>
|
|
{{ $konsultasi->status === 'selesai' ? 'Terdeteksi' : 'Tidak Terdeteksi' }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="body">
|
|
|
|
{{-- ── HASIL TIDAK TERDETEKSI ── --}}
|
|
@if($konsultasi->status === 'tidak_terdeteksi')
|
|
<div class="tidak-terdeteksi">
|
|
<h3>⚠️ Tidak Ada Penyakit Terdeteksi</h3>
|
|
<p>Gejala yang dipilih tidak cukup untuk mendiagnosis penyakit secara pasti.<br>
|
|
Silakan konsultasikan ke penyuluh pertanian atau dokter tanaman terdekat.</p>
|
|
</div>
|
|
|
|
{{-- ── HASIL TERDETEKSI ── --}}
|
|
@else
|
|
@php $utama = $konsultasi->hasilDiagnosa->first(); @endphp
|
|
@if($utama)
|
|
|
|
{{-- Hasil Utama --}}
|
|
<div class="hasil-utama">
|
|
<div class="hasil-utama-header">
|
|
<span class="hasil-utama-title">🏆 Diagnosa Utama</span>
|
|
<span class="hasil-utama-badge">Ranking #1</span>
|
|
</div>
|
|
<div class="hasil-utama-body">
|
|
<div class="penyakit-nama">{{ $utama->penyakit->nama ?? '-' }}</div>
|
|
@if($utama->penyakit)
|
|
<span class="penyakit-jenis {{ $utama->penyakit->jenis === 'Hama' ? 'jenis-hama' : 'jenis-penyakit' }}">
|
|
{{ $utama->penyakit->jenis }}
|
|
</span>
|
|
@if($utama->penyakit->penyebab && $utama->penyakit->penyebab !== '-')
|
|
<div style="font-size:11px;color:#6B7280;font-style:italic;margin-bottom:8px;">
|
|
{{ $utama->penyakit->penyebab }}
|
|
</div>
|
|
@endif
|
|
@endif
|
|
|
|
<div class="cf-row">
|
|
<div class="cf-box">
|
|
<span class="cf-box-label">Nilai CF</span>
|
|
<div class="cf-box-value">{{ number_format($utama->nilai_cf_akhir, 4) }}</div>
|
|
</div>
|
|
<div class="cf-box">
|
|
<span class="cf-box-label">Persentase</span>
|
|
<div class="cf-box-value">{{ number_format($utama->persentase, 2) }}%</div>
|
|
</div>
|
|
<div class="cf-box">
|
|
<span class="cf-box-label">Interpretasi</span>
|
|
<div class="cf-box-value" style="font-size:13px;">
|
|
@php
|
|
$cf = $utama->nilai_cf_akhir;
|
|
echo $cf >= 0.81 ? 'Sangat Yakin' : ($cf >= 0.61 ? 'Yakin' : ($cf >= 0.41 ? 'Cukup Yakin' : ($cf >= 0.21 ? 'Mungkin' : 'Tidak Yakin')));
|
|
@endphp
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="progress-wrap">
|
|
<div class="progress-label">
|
|
<span>Tingkat Keyakinan</span>
|
|
<span>{{ number_format($utama->persentase, 1) }}%</span>
|
|
</div>
|
|
<div class="progress-bar-bg">
|
|
<div class="progress-bar-fill" style="width:{{ $utama->persentase }}%"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Solusi & Pencegahan --}}
|
|
@if($utama->penyakit && $utama->penyakit->solusi)
|
|
<div class="section-title">Solusi & Pencegahan</div>
|
|
<div class="solusi-grid">
|
|
<div class="solusi-box">
|
|
<div class="solusi-box-header penanganan">💊 Solusi Penanganan</div>
|
|
<div class="solusi-box-body">{{ $utama->penyakit->solusi->solusi }}</div>
|
|
</div>
|
|
<div class="solusi-box">
|
|
<div class="solusi-box-header pencegahan">🛡️ Pencegahan</div>
|
|
<div class="solusi-box-body">{{ $utama->penyakit->solusi->pencegahan ?? '-' }}</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Kemungkinan Lain --}}
|
|
@if($konsultasi->hasilDiagnosa->count() > 1)
|
|
<div class="section-title">Kemungkinan Penyakit Lain</div>
|
|
<table class="other-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Ranking</th>
|
|
<th>Penyakit</th>
|
|
<th>Jenis</th>
|
|
<th>Nilai CF</th>
|
|
<th>Persentase</th>
|
|
<th>Interpretasi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($konsultasi->hasilDiagnosa->skip(1) as $hasil)
|
|
<tr>
|
|
<td>#{{ $hasil->ranking }}</td>
|
|
<td>{{ $hasil->penyakit->nama ?? '-' }}</td>
|
|
<td>{{ $hasil->penyakit->jenis ?? '-' }}</td>
|
|
<td><span class="mono">{{ number_format($hasil->nilai_cf_akhir, 4) }}</span></td>
|
|
<td>{{ number_format($hasil->persentase, 2) }}%</td>
|
|
<td>
|
|
@php
|
|
$c = $hasil->nilai_cf_akhir;
|
|
echo $c >= 0.81 ? 'Sangat Yakin' : ($c >= 0.61 ? 'Yakin' : ($c >= 0.41 ? 'Cukup Yakin' : ($c >= 0.21 ? 'Mungkin' : 'Tidak Yakin')));
|
|
@endphp
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
@endif
|
|
|
|
@endif
|
|
@endif
|
|
|
|
{{-- ── GEJALA DIPILIH ── --}}
|
|
<div class="section-title">Gejala yang Dipilih ({{ $konsultasi->gejalaList->count() }} gejala)</div>
|
|
<div class="gejala-grid">
|
|
@foreach($konsultasi->gejalaList as $kg)
|
|
<div class="gejala-chip">
|
|
<span class="gejala-kode">{{ $kg->gejala->kode ?? '-' }}</span>
|
|
{{ $kg->gejala->nama ?? '-' }}
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
|
|
{{-- ── LOG PERHITUNGAN CF ── --}}
|
|
@if($konsultasi->status === 'selesai')
|
|
<div class="section-title">Detail Perhitungan Certainty Factor</div>
|
|
@foreach($hasilInfer['detail_log'] ?? [] as $idP => $logs)
|
|
@php
|
|
$p = \App\Models\Penyakit::find($idP);
|
|
$cfAkhir = $hasilInfer['semua_cf'][$idP] ?? 0;
|
|
$isDeteksi = $cfAkhir >= 0.2;
|
|
@endphp
|
|
@if($isDeteksi)
|
|
<div style="margin-bottom:14px;">
|
|
<div style="font-size:11px;font-weight:700;color:#1a1a1a;margin-bottom:6px;padding:6px 8px;background:#F3F4F6;border-radius:4px;">
|
|
{{ $p->nama ?? '-' }} —
|
|
CF Akhir: <span class="mono">{{ number_format($cfAkhir, 4) }}</span>
|
|
({{ number_format($cfAkhir * 100, 2) }}%)
|
|
</div>
|
|
<table class="log-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Step</th>
|
|
<th>Rule</th>
|
|
<th>Gejala</th>
|
|
<th>CF Pakar</th>
|
|
<th>CF Individu</th>
|
|
<th>CF Sesudah</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($logs as $log)
|
|
<tr>
|
|
<td>{{ $log['step'] }}</td>
|
|
<td><span class="mono">{{ $log['rule'] }}</span></td>
|
|
<td>
|
|
<span class="mono" style="font-size:9px;">{{ $log['kode_gejala'] }}</span>
|
|
{{ \Illuminate\Support\Str::limit($log['nama_gejala'], 35) }}
|
|
</td>
|
|
<td style="text-align:center;">{{ $log['cf_pakar'] }}</td>
|
|
<td style="text-align:center;"><span class="mono">{{ $log['cf_individu'] }}</span></td>
|
|
<td style="text-align:center;"><span class="mono">{{ $log['cf_sesudah'] }}</span></td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
@endif
|
|
|
|
{{-- ── FOOTER PDF ── --}}
|
|
<div class="pdf-footer">
|
|
<span>RedGuard — Sistem Pakar Penyakit Cabai Rawit</span>
|
|
<span>Metode: Certainty Factor · Dicetak: {{ \Carbon\Carbon::now()->format('d F Y, H:i') }} WIB</span>
|
|
</div>
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|