gdc_cmod/app/Views/report/template.php
mahdahar 31acb6bf33 feat: Implement comprehensive report generation system with role-based access control
Add native CodeIgniter 4 report generation functionality replacing legacy spooler_db system.
Provides centralized report generation with audit logging and multi-language support.

New Features:
- Report generation with Indonesian and English language support
- Role-based access control (Lab, Admin, Superuser: generate; CS: print only)
- Preview mode for validation workflow
- Print audit logging to AUDIT_REQUESTS table
- Multi-page report support with proper pagination
- Dual unit system (Conventional and International units)

Controllers:
- ReportController: Main controller for report generation, preview, and print
  - generate(): Full report with audit logging
  - preview(): Preview mode without audit logging
  - print(): Print-only access for CS role
- Home::printReport(): Route handler redirecting based on user role

Libraries:
- ReportHelper: Comprehensive report data retrieval
  - Patient information (name, MR number, demographics, referral)
  - Test results with reference ranges and unit conversions
  - Collection and reception data with timestamps
  - Validation status and validator information
  - Special handling for pending samples and Chinese translations

Routes:
- /report/(:num) - Generate report (Lab, Admin, Superuser)
- /report/(:num)/preview - Preview without audit logging
- /report/(:num)/eng - English language report
- /report/print/(:num) - Print-only access (CS role)
- /print/(:num) - Redirect based on role (all roles)

Views:
- report/template.php: Professional lab report template with Gleneagles branding
  - Header and footer images
  - Patient information table
  - Test results with dual unit columns
  - Collection and reception timestamps
  - Authorization signature area
  - Preview watermark

Role Index Views:
- Removed dialog_preview.php inclusion from all role dashboards
- Consolidated print button directly linking to new report routes

Assets:
- Report-specific CSS files (normalize.min.css, style.css, pdf.css, style_qr.css)
- Gleneagles header and footer images
- Legacy spooler_db files preserved in public/spooler_db/ for reference

Tests:
- ReportTest.php: Unit tests for report generation functionality

Database:
- Uses existing tables: REQUESTS, TESTS, DICT_TESTS, SP_REQUESTS, PATIENTS
- Inserts print audit records into AUDIT_REQUESTS table

Security:
- Parameterized queries throughout (SQL injection prevention)
- Role-based access control enforced at route level
- Proper output escaping with esc() in views
2026-02-02 16:54:22 +07:00

153 lines
5.1 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab Report - <?= esc($accessnumber) ?></title>
<link rel='stylesheet' href='<?= base_url('assets/report/normalize.min.css') ?>'>
<link rel='stylesheet' href='<?= base_url('assets/report/style.css') ?>'>
</head>
<body style='-webkit-print-color-adjust:exact;'>
<?php if ($preview == 1): ?>
<div style='font-size:30px; text-align:center; color:red;'>PREVIEW ONLY - DO NOT PRINT</div>
<?php endif; ?>
<?php
$othertitle = $eng == 1 ? "Non Laboratory Test" : "Pemeriksaan Non Laboratorium";
$npage = count($result);
$i = 1;
?>
<?php foreach ($result as $page): ?>
<div id='page'>
<div id='pagetop' style='height:0.01cm'></div>
<img src='<?= base_url('assets/report/gleneagleshdr.png') ?>' class='img'/>
<div id='dinfo'>
<?= $info ?>
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr>
<th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th>
<th colspan='3'>INTERNATIONAL</th>
</tr>
<tr style='border-bottom:solid 1px black;'>
<th>RESULT</th>
<th>REF. RANGES</th>
<th style='border-right:solid 1px black;'>UNIT</th>
<th>RESULT</th>
<th>REF. RANGES</th>
<th>UNIT</th>
</tr>
<?= $page ?>
</table>
<?php if ($i == $npage): ?>
<?= $noSample ?>
<table>
<tr><td>Note :</td> <td><pre><?= esc($notes) ?></pre></td></tr>
</table>
<br/>
<?php if ($others != '' && substr_count($others, "\r") + substr_count($result[$npage], "\r") < 38): ?>
<table>
<tr><td><b><?= esc($othertitle) ?>:</b><br/>
<?= $others ?></td></tr>
</table>
<?php $others = ''; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<div id='footer'>
<table class='footer'>
<tr>
<td>
<?php if ($i == $npage): ?>
Status : <?= esc($status) ?>
<?php endif; ?>
<pre class='small'>Collected on <?= esc($collData) ?>
Received on <?= esc($recvData) ?>
Page <?= $i ?>/<?= $npage ?> Printed By : <?= esc($valBy) ?> <?= esc($date) ?></pre>
</td>
<td class='right'>
<pre>
(__________________)
Authorised Signature
</pre>
</td>
</tr>
</table>
</div>
<img src='<?= base_url('assets/report/gleneaglesftr.png') ?>' class='img img-footer'/>
</div>
<?php
$i++;
endforeach;
?>
<?php if ($others != ''): ?>
<div id='page'>
<div id='pagetop' style='height:0.01cm'></div>
<?php if ($preview == 1): ?>
<div style='font-size:30px; text-align:center; color:red;'>PREVIEW ONLY - DO NOT PRINT</div>
<?php endif; ?>
<img src='<?= base_url('assets/report/gleneagleshdr.png') ?>' class='img'/>
<div id='dinfo'>
<?= $info ?>
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b><?= esc($othertitle) ?> : </b><br/>
<?= $others ?></td></tr>
</table>
</div>
<div id='footer'>
<table class='footer'>
<tr>
<td>
Status : <?= esc($status) ?>
<pre class='small'>Collected on <?= esc($collData) ?>
Received on <?= esc($recvData) ?>
Page <?= $i ?>/<?= $npage ?> Printed By : <?= esc($valBy) ?> <?= esc($date) ?></pre>
</td>
<td class='right'>
<pre>
(__________________)
Authorised Signature
</pre>
</td>
</tr>
</table>
</div>
<br/>
<img src='<?= base_url('assets/report/gleneaglesftr.png') ?>' class='img img-footer'/>
</div>
<?php endif; ?>
</body>
</html>