From 28109df663ca118ba534368ef2738d46680bb1da Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 18 Aug 2026 16:36:53 +0530 Subject: [PATCH] Build mPDF debug input on demand --- app/Controllers/Ipd_discharge.php | 10 +++++++++- app/Views/ipd_discharge/discharge_template_edit.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index 35c7a0f..45869b9 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -5562,8 +5562,16 @@ class Ipd_discharge extends BaseController } $file = WRITEPATH . 'debug' . DIRECTORY_SEPARATOR . 'discharge_mpdf_input_' . $ipdId . '_' . $templateId . '.html'; + if (! is_file($file) && (int) ($this->request->getGet('build') ?? 0) === 1) { + $previousGet = $_GET; + $_GET['tpl'] = $templateId; + $_GET['refresh'] = 1; + unset($_GET['build']); + $this->show_discharge($ipdId, 1); + $_GET = $previousGet; + } if (! is_file($file)) { - return $this->response->setStatusCode(404)->setBody('Generate the PDF first, then reopen this debug view.'); + return $this->response->setStatusCode(404)->setBody('Generate the PDF first, then reopen this debug view with ?build=1.'); } return view('ipd_discharge/mpdf_raw_html', [ diff --git a/app/Views/ipd_discharge/discharge_template_edit.php b/app/Views/ipd_discharge/discharge_template_edit.php index 230aa32..691d46f 100644 --- a/app/Views/ipd_discharge/discharge_template_edit.php +++ b/app/Views/ipd_discharge/discharge_template_edit.php @@ -271,7 +271,7 @@ $placeholders = [ document.getElementById('btn_mpdf_input').addEventListener('click', function () { var ipdId = parseInt(val('preview_ipd_id'), 10); if (!ipdId || !editId) { alert('Save the template and enter IPD ID first.'); return; } - window.open('/' + ipdId + '/' + editId, '_blank'); + window.open('/' + ipdId + '/' + editId + '?build=1', '_blank'); }); /* Placeholder click-to-copy */