From 226f9569859ac38a8f2634440ffc865dbe4a1844 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 06:17:59 +0530 Subject: [PATCH] Add discharge preview and PDF quick-launch to template settings --- .../Setting/Template/discharge_templates.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/app/Views/Setting/Template/discharge_templates.php b/app/Views/Setting/Template/discharge_templates.php index 3ffdc3f..0460d5a 100644 --- a/app/Views/Setting/Template/discharge_templates.php +++ b/app/Views/Setting/Template/discharge_templates.php @@ -32,6 +32,24 @@ $status = (int) ($edit['status'] ?? 1); condition at discharge, discharge medication with dose/duration, follow-up plan, and warning signs/emergency contact. +
+
+
+
+ + +
+
+ + +
+
+
+ Uses the live discharge routes: /Ipd_discharge/preview_discharge_report/{ipdId} and /Ipd_discharge/show_discharge/{ipdId}/0. +
+
+
+
@@ -108,6 +126,32 @@ $status = (int) ($edit['status'] ?? 1); (function () { var form = document.getElementById('discharge_template_form'); var editorFieldId = 'template_html_editor'; + var previewIpdInput = document.getElementById('discharge_preview_ipd_id'); + var previewBtn = document.getElementById('btn_discharge_preview'); + var pdfBtn = document.getElementById('btn_discharge_pdf'); + + function getSelectedTemplateId() { + return 0 ? (int) $editId : 0 ?>; + } + + function openDischargeUrl(baseUrl, ipdId, printType) { + if (!ipdId || ipdId < 1) { + alert('Enter a valid IPD ID first.'); + return; + } + + var url = baseUrl + '/' + ipdId; + if (typeof printType !== 'undefined') { + url += '/' + printType; + } + + var tplId = getSelectedTemplateId(); + if (tplId > 0) { + url += '?tpl=' + encodeURIComponent(tplId); + } + + window.open(url, '_blank'); + } function initTemplateEditor() { if (!window.CKEDITOR) { @@ -156,5 +200,19 @@ $status = (int) ($edit['status'] ?? 1); syncTemplateEditor(); }); } + + if (previewBtn) { + previewBtn.addEventListener('click', function () { + var ipdId = parseInt((previewIpdInput && previewIpdInput.value) ? previewIpdInput.value : '0', 10); + openDischargeUrl('', ipdId); + }); + } + + if (pdfBtn) { + pdfBtn.addEventListener('click', function () { + var ipdId = parseInt((previewIpdInput && previewIpdInput.value) ? previewIpdInput.value : '0', 10); + openDischargeUrl('', ipdId, 0); + }); + } })();