This commit is contained in:
Dwi Swandhana
2026-03-11 14:19:37 +07:00
parent 3eb845b503
commit e03381c6aa
2 changed files with 50 additions and 44 deletions
@@ -976,43 +976,48 @@ class ReportController extends Controller
->pluck('id')
->toArray();
if (count($printableIds) === 0) {
return response()->json([
'status' => 'error',
'message' => 'Semua data yang dipilih sudah pernah dicetak.'
], 422);
}
if (count($printableIds) === 0) {
return response()->json([
'status' => 'error',
'message' => 'Semua data yang dipilih sudah pernah dicetak.'
], 422);
}
$rowsToPrint = Periksa::whereIn('id', $printableIds)
->orderBy('id', 'ASC')
->get()
->map(function ($row) {
$petugas = trim(($row->nmppdsmiddle2 ?? '').' '.($row->nmppdsjunior2 ?? ''));
return [
'id' => $row->id,
'noregister' => $row->noregister ?? '',
'nmpasien' => $row->nmpasien ?? '',
'nofoto' => $row->nofoto ?? '',
'asalpasien' => $row->asalpasien ?? '',
'daftar' => $row->daftar ?? '',
'reques' => $row->reques ?? '',
'kd_spesimen' => $row->kd_spesimen ?? '',
'nm_spesimen' => $row->nm_spesimen ?? '',
'status' => $row->status ?? '',
'tgldraft' => $row->tgldraft ?? '',
'petugas' => $petugas,
];
})
->values()
->toArray();
if (count($printableIds) > 0) {
Periksa::whereIn('id', $printableIds)->update([
'ppdsjunior2' => $userId,
'nmppdsjunior2' => $userNama,
'updated_at' => date('Y-m-d H:i:s'),
]);
}
if (count($printableIds) > 0) {
Periksa::whereIn('id', $printableIds)->update([
'ppdsjunior2' => $userId,
'nmppdsjunior2' => $userNama,
'updated_at' => date('Y-m-d H:i:s'),
]);
}
// Ambil data setelah update supaya payload cetak (petugas) sesuai yang tampil di tabel
$rowsToPrint = Periksa::whereIn('id', $printableIds)
->orderBy('id', 'ASC')
->get()
->map(function ($row) {
$petugas = trim(($row->nmppdsmiddle2 ?? '').' '.($row->nmppdsjunior2 ?? ''));
$status = trim((string)($row->status ?? ''));
if ($status === '') {
$status = '-';
}
return [
'id' => $row->id,
'noregister' => $row->noregister ?? '',
'nmpasien' => $row->nmpasien ?? '',
'nofoto' => $row->nofoto ?? '',
'asalpasien' => $row->asalpasien ?? '',
'daftar' => $row->daftar ?? '',
'reques' => $row->reques ?? '',
'kd_spesimen' => $row->kd_spesimen ?? '',
'nm_spesimen' => $row->nm_spesimen ?? '',
'status' => $status,
'tgldraft' => $row->tgldraft ?? '',
'petugas' => $petugas,
];
})
->values()
->toArray();
$history = RekapPenerimaanSamplePrintHistory::create([
'tanggal' => $tanggal,
@@ -125,7 +125,10 @@
@foreach($detail as $r)
@php
$isPrinted = !empty($r['ppdsjunior2']) && $r['ppdsjunior2'] != '0';
$statusValue = trim((string)($r['status'] ?? '-'));
$statusValue = trim((string)($r['status'] ?? ''));
if ($statusValue === '') {
$statusValue = '-';
}
$petugas = '';
if ($r['nmppdsmiddle2'] != '') {
$petugas = $r['nmppdsmiddle2'];
@@ -359,15 +362,13 @@
if (!table || !filterStatus) {
return;
}
var statusSet = new Set();
table.querySelectorAll('tbody tr').forEach(function(row) {
var statusText = (row.children[10] ? row.children[10].innerText : '').trim();
if (statusText !== '') {
statusSet.add(statusText);
}
});
while (filterStatus.options.length > 1) {
filterStatus.remove(1);
}
Array.from(statusSet).sort().forEach(function(status) {
// Status yang valid untuk rekap penerimaan sample
var allowed = ['-', 'Pemeriksaan awal', 'Pemeriksaan Sampel', 'Penerimaan Sampel'];
allowed.forEach(function(status) {
var opt = document.createElement('option');
opt.value = status.toLowerCase();
opt.textContent = 'Status: ' + status;