From 7ca1e3a96e2fd6bf907af68e8d4ba7172b090fc0 Mon Sep 17 00:00:00 2001 From: Dwi Swandhana Date: Mon, 20 Apr 2026 15:37:11 +0700 Subject: [PATCH] update --- .../app/Http/Controllers/ReportController.php | 67 +++++++++++-------- .../views/admin/glassreport.blade.php | 14 ++-- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/htdocs/app/Http/Controllers/ReportController.php b/htdocs/app/Http/Controllers/ReportController.php index 9a37d605..0ae4a9bf 100644 --- a/htdocs/app/Http/Controllers/ReportController.php +++ b/htdocs/app/Http/Controllers/ReportController.php @@ -618,8 +618,7 @@ class ReportController extends Controller ]; return [ - 'A' => array_merge($tableC, ['Nama Spesies Bakteri', 'ESBL', 'MRSA'], $tableAAntibiotics), - 'B' => array_merge($tableC, ['Nama Spesies Jamur'], $tableBAntibiotics), + 'A' => array_merge($tableC, ['Nama Spesies Bakteri', 'Pertumbuhan Bakteri', 'SIR Bakteri', 'ESBL', 'MRSA'], $tableAAntibiotics, $tableBAntibiotics), 'C' => $tableC, 'A_antibiotics' => $tableAAntibiotics, 'B_antibiotics' => $tableBAntibiotics, @@ -738,7 +737,7 @@ class ReportController extends Controller $komponen = DB::table('db_komponenjawaban') ->select('accnumber', 'komponen', 'isidata') ->whereIn('accnumber', $accnumbers) - ->whereIn('komponen', ['bakteri', 'id_bakteri01', 'id_bakteri02', 'id_mikroorganisme']) + ->whereIn('komponen', ['bakteri', 'id_bakteri01', 'id_bakteri02', 'id_mikroorganisme', 'id_biakankultur', 'bakterisir', 'id_bakterisir01', 'id_bakterisir02']) ->whereNotNull('isidata') ->where('isidata', '!=', '') ->get() @@ -757,7 +756,7 @@ class ReportController extends Controller private function splitGlassReportRows($rows, $lookups) { $headers = $this->getGlassReportHeaders(); $aliases = $this->getGlassReportAntibioticAliases(); - $tables = ['A' => [], 'B' => [], 'C' => []]; + $tables = ['A' => [], 'C' => []]; foreach ($rows as $row) { $baseRow = $this->buildGlassReportBaseRow($row); @@ -765,6 +764,12 @@ class ReportController extends Controller $antibioticRows = $lookups['antibiotik'][$row->id] ?? collect([]); $speciesNames = []; + $growthValue = ''; + $sirValues = [ + 'bakteri' => '', + 'id_bakteri01' => '', + 'id_bakteri02' => '', + ]; foreach ($komponenRows as $komponenRow) { $value = trim(strip_tags((string) $komponenRow->isidata)); @@ -773,12 +778,31 @@ class ReportController extends Controller } if (in_array($komponenRow->komponen, ['bakteri', 'id_bakteri01', 'id_bakteri02'], true) && stripos($value, 'Ditemukan morfologi') === false) { - $speciesNames[] = $value; + $speciesNames[] = [ + 'name' => $value, + 'component' => $komponenRow->komponen, + ]; + } + + if ($komponenRow->komponen === 'id_biakankultur' && $growthValue === '') { + $growthValue = $value; + } + + if ($komponenRow->komponen === 'bakterisir' && $sirValues['bakteri'] === '') { + $sirValues['bakteri'] = $value; + } + + if ($komponenRow->komponen === 'id_bakterisir01' && $sirValues['id_bakteri01'] === '') { + $sirValues['id_bakteri01'] = $value; + } + + if ($komponenRow->komponen === 'id_bakterisir02' && $sirValues['id_bakteri02'] === '') { + $sirValues['id_bakteri02'] = $value; } } $speciesNames = array_values(array_filter($speciesNames, function ($value) { - return trim((string) $value) !== ''; + return trim((string) ($value['name'] ?? '')) !== ''; })); $antibioticValues = []; @@ -802,14 +826,15 @@ class ReportController extends Controller } $hasJenisSpesimen = trim((string) ($baseRow[10] ?? '')) !== ''; - $hasFungalAntibiotic = collect($headers['B_antibiotics'])->contains(function ($antibioticHeader) use ($antibioticValues) { - return array_key_exists($antibioticHeader, $antibioticValues); - }); - if (!empty($speciesNames) && $hasJenisSpesimen && !$hasFungalAntibiotic) { - foreach ($speciesNames as $speciesName) { + if (!empty($speciesNames) && $hasJenisSpesimen) { + foreach ($speciesNames as $speciesData) { + $sirKey = $speciesData['component'] ?? 'bakteri'; + $sirValue = $sirValues[$sirKey] ?? ''; $tableRow = array_merge($baseRow, [ - $speciesName, + $speciesData['name'] ?? '', + $growthValue, + $sirValue, $row->id_esbl ?? '', $row->id_mrsa ?? '', ]); @@ -818,22 +843,11 @@ class ReportController extends Controller $tableRow[] = $antibioticValues[$antibioticHeader] ?? ''; } - $tables['A'][] = $tableRow; - } - continue; - } - - if (!empty($speciesNames) && $hasJenisSpesimen && $hasFungalAntibiotic) { - foreach ($speciesNames as $speciesName) { - $tableRow = array_merge($baseRow, [ - $speciesName, - ]); - foreach ($headers['B_antibiotics'] as $antibioticHeader) { $tableRow[] = $antibioticValues[$antibioticHeader] ?? ''; } - $tables['B'][] = $tableRow; + $tables['A'][] = $tableRow; } continue; } @@ -902,7 +916,6 @@ class ReportController extends Controller $headers = $this->getGlassReportHeaders(); $tables = [ 'A' => [], - 'B' => [], 'C' => [], ]; @@ -917,14 +930,14 @@ class ReportController extends Controller $lookups = $this->getGlassReportLookups($rows); $chunkTables = $this->splitGlassReportRows($rows, $lookups); - foreach (['A', 'B', 'C'] as $tableKey) { + foreach (['A', 'C'] as $tableKey) { foreach ($chunkTables[$tableKey] as $tableRow) { $tables[$tableKey][] = $tableRow; } } }); - foreach (['A', 'B', 'C'] as $tableKey) { + foreach (['A', 'C'] as $tableKey) { fputcsv($handle, ['TABEL '.$tableKey]); fputcsv($handle, $headers[$tableKey]); diff --git a/htdocs/resources/views/admin/glassreport.blade.php b/htdocs/resources/views/admin/glassreport.blade.php index dd8100e6..ec0c4cf5 100644 --- a/htdocs/resources/views/admin/glassreport.blade.php +++ b/htdocs/resources/views/admin/glassreport.blade.php @@ -69,9 +69,12 @@
Preview Glass Report ditampilkan per halaman 50 pemeriksaan agar aman di memori. Untuk data lengkap gunakan tombol download CSV.
- @foreach (['A', 'B', 'C'] as $tableKey) + @foreach (['A', 'C'] as $tableKey)

TABEL {{ $tableKey }}

+ @@ -171,15 +174,6 @@ console.error('Tabel dengan ID "tabelA" tidak ditemukan.'); } }); - document.getElementById('btnexporttabelB').addEventListener('click', function() { - var table = document.getElementById('tabelB'); - if (table) { - var wb = XLSX.utils.table_to_book(table, { sheet: "Jamur" }); - XLSX.writeFile(wb, "TABEL_B_{{$bulan}}_Tahun{{$tahun}}.xlsx"); - } else { - console.error('Tabel dengan ID "tabelB" tidak ditemukan.'); - } - }); document.getElementById('btnexporttabelC').addEventListener('click', function() { var table = document.getElementById('tabelC'); if (table) {