This commit expands report generation capabilities to Customer Service (CS) role
and refactors the report system for better maintainability and PDF support.
Changes Summary:
Access Control:
- Extended report access from Lab, Admin, Superuser to include CS role (filter: 0,1,2,4)
- Removed separate CS-only print routes, consolidated into unified report routes
- Routes now support /report/:num, /report/:num/eng, /report/:num/print, /report/:num/print/eng
Controller Refactoring (ReportController):
- Refactored generate() and print() methods to share common renderReport() logic
- Removed separate preview() method - preview now handled via preview parameter
- Added ispdf parameter support for PDF generation mode
- Print functionality now logs audit events to AUDIT_REQUESTS table
Database Queries (ReportHelper):
- Improved SQL queries with explicit aliases for better readability and maintainability
- Fixed date formatting issue: changed date_format() to date() with strtotime()
- Added getValData() method to retrieve validation user information (VAL1USER, VAL2USER)
- Added null coalescing operators (?? '') for safer array access
View Updates (report/template.php):
- Conditional CSS loading: uses pdf.css when ispdf=1, otherwise style.css
- Removed "PREVIEW ONLY - DO NOT PRINT" watermark
- Conditional header/footer images - only display when generating PDF
- Added validation user display: "Val1 By : {user} | Val2 By : {user}"
- Replaced signature placeholder with "This result is valid without signature" statement
- Improved footer layout spacing
Styling Adjustments (public/assets/report/style.css):
- Adjusted margins for better print layout: dinfo (2cm), dresult (17.5cm), footer (2cm)
- Increased footer width from 17cm to 18cm
- Added responsive image classes: .img and .img-footer with max-width: 100%
- Set footer image max-height to 2.5cm
Security:
- Maintained role-based access control with proper authentication checks
- All database queries use parameterized statements (no interpolation)
- Print actions still logged to AUDIT_REQUESTS for audit trail
150 lines
5.3 KiB
PHP
150 lines
5.3 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') ?>'>
|
|
<?php if (isset($ispdf) && $ispdf == 1): ?>
|
|
<link rel='stylesheet' href='<?= base_url('assets/report/pdf.css') ?>'>
|
|
<?php else: ?>
|
|
<link rel='stylesheet' href='<?= base_url('assets/report/style.css') ?>'>
|
|
<?php endif; ?>
|
|
</head>
|
|
<body style='-webkit-print-color-adjust:exact;'>
|
|
|
|
<?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>
|
|
|
|
<?php if (isset($ispdf) && $ispdf == 1): ?>
|
|
<img src='<?= base_url('assets/report/gleneagleshdr.png') ?>' class='img'/>
|
|
<?php endif; ?>
|
|
|
|
<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) ?>
|
|
Val1 By : <?= esc($val1User) ?> | Val2 By <?= esc($val2User) ?>
|
|
Page <?= $i ?>/<?= $npage ?> Printed By : <?= esc($valBy) ?> <?= esc($date) ?></pre>
|
|
</td>
|
|
<td class='right'>
|
|
<pre><b>”This result is valid without signature.”</b></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<?php if (isset($ispdf) && $ispdf == 1): ?>
|
|
<img src='<?= base_url('assets/report/gleneaglesftr.png') ?>' class='img img-footer'/>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php
|
|
$i++;
|
|
endforeach;
|
|
?>
|
|
|
|
<?php if ($others != ''): ?>
|
|
<div id='page'>
|
|
<div id='pagetop' style='height:0.01cm'></div>
|
|
|
|
<?php if (isset($ispdf) && $ispdf == 1): ?>
|
|
<img src='<?= base_url('assets/report/gleneagleshdr.png') ?>' class='img'/>
|
|
<?php endif; ?>
|
|
|
|
<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) ?>
|
|
Val1 By : <?= esc($val1User) ?> | Val2 By <?= esc($val2User) ?>
|
|
Page <?= $i ?>/<?= $npage ?> Printed By : <?= esc($valBy) ?> <?= esc($date) ?></pre>
|
|
</td>
|
|
<td class='right'>
|
|
<pre><b>”This result is valid without signature.”</b></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<?php if (isset($ispdf) && $ispdf == 1): ?>
|
|
<img src='<?= base_url('assets/report/gleneaglesftr.png') ?>' class='img img-footer'/>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</body>
|
|
</html>
|