update
This commit is contained in:
@@ -89,13 +89,10 @@ class FrontpageController extends Controller
|
||||
'poli.subpoli',
|
||||
'poli.modaliti2'
|
||||
)
|
||||
->where(function($q) {
|
||||
$q->whereNull('periksa.status')
|
||||
->orWhere(function($sub) {
|
||||
$sub->where('periksa.status', '<>', 'Selesai')
|
||||
->where('periksa.status', 'not like', 'Dibatalkan%');
|
||||
});
|
||||
})
|
||||
->whereNotNull('periksa.status')
|
||||
->where('periksa.status', '<>', '')
|
||||
->whereRaw('LOWER(periksa.status) <> ?', ['selesai'])
|
||||
->whereRaw('LOWER(periksa.status) not like ?', ['%dibatalkan%'])
|
||||
->whereNotNull('periksa.daftar')
|
||||
->orderBy('periksa.daftar', 'ASC')
|
||||
->get();
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Jadwalperiksa;
|
||||
use App\Riwayat;
|
||||
use App\RekapAntibiotik;
|
||||
use App\Organisms;
|
||||
use App\RekapPenerimaanSamplePrintHistory;
|
||||
use DateTime;
|
||||
use Carbon\Carbon;
|
||||
use Session;
|
||||
@@ -880,9 +881,30 @@ class ReportController extends Controller
|
||||
if ($periksa->count() == 0) {
|
||||
return response()->json([]);
|
||||
}
|
||||
$histories = RekapPenerimaanSamplePrintHistory::whereDate('tanggal', $tanggal)
|
||||
->orderBy('printed_at', 'DESC')
|
||||
->orderBy('id', 'DESC')
|
||||
->get()
|
||||
->map(function ($h) {
|
||||
$rowIds = json_decode($h->row_ids, true);
|
||||
$rowsPayload = json_decode($h->rows_payload, true);
|
||||
return [
|
||||
'id' => $h->id,
|
||||
'printed_by_id' => $h->printed_by_id,
|
||||
'printed_by_name' => $h->printed_by_name,
|
||||
'printed_at' => $h->printed_at,
|
||||
'printed_at_label' => $h->printed_at ? Carbon::parse($h->printed_at)->format('Y-m-d H:i:s') : '-',
|
||||
'row_ids' => is_array($rowIds) ? $rowIds : [],
|
||||
'rows_payload' => is_array($rowsPayload) ? $rowsPayload : [],
|
||||
'total_rows' => is_array($rowIds) ? count($rowIds) : 0,
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
return view('cetak.rekappenerimaansample', [
|
||||
'tanggal' => $tanggal,
|
||||
'detail' => $periksa
|
||||
'detail' => $periksa,
|
||||
'printHistories' => $histories
|
||||
]);
|
||||
}
|
||||
public function markRekapPenerimaanSamplePrinted(Request $request) {
|
||||
@@ -920,6 +942,8 @@ class ReportController extends Controller
|
||||
'message' => 'Data yang dipilih tidak valid.'
|
||||
], 422);
|
||||
}
|
||||
$tanggal = $request->input('tanggal');
|
||||
$tanggal = !empty($tanggal) ? $tanggal : null;
|
||||
|
||||
$printableIds = Periksa::whereIn('id', $ids)
|
||||
->where(function ($query) {
|
||||
@@ -929,18 +953,72 @@ 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);
|
||||
}
|
||||
|
||||
$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'),
|
||||
]);
|
||||
}
|
||||
|
||||
$history = RekapPenerimaanSamplePrintHistory::create([
|
||||
'tanggal' => $tanggal,
|
||||
'printed_by_id' => $userId,
|
||||
'printed_by_name' => $userNama,
|
||||
'printed_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'row_ids' => json_encode(array_values($printableIds)),
|
||||
'rows_payload' => json_encode($rowsToPrint),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$historyResponse = [
|
||||
'id' => $history->id,
|
||||
'printed_by_id' => $history->printed_by_id,
|
||||
'printed_by_name' => $history->printed_by_name,
|
||||
'printed_at' => $history->printed_at,
|
||||
'printed_at_label' => Carbon::parse($history->printed_at)->format('Y-m-d H:i:s'),
|
||||
'row_ids' => $printableIds,
|
||||
'rows_payload' => $rowsToPrint,
|
||||
'total_rows' => count($printableIds),
|
||||
];
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Status cetak berhasil diperbarui.',
|
||||
'affected_ids'=> $printableIds,
|
||||
'printed_by' => $userNama
|
||||
'printed_by' => $userNama,
|
||||
'history' => $historyResponse
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user