Add ISPDF flag endpoint and dashboard indicator
- Add POST /api/requests/{accessnumber}/pdf endpoint (no auth required)
- Add setPdfFlag() method to update CM_REQUESTS.ISPDF to 1
- Log PDF_FLAG events to AUDIT_EVENTS table
- Include ISPDF field in dashboard API response
- Add PDF icon indicator in dashboard table (after Val column)
- Icon shows green when ISPDF=1, gray when null/0
- Pass accessnumber to PDF spooler for tracking
Files modified:
- app/Config/Routes.php: Add external PDF endpoint route
- app/Controllers/RequestsController.php: Add setPdfFlag method, include ISPDF in query
- app/Controllers/ReportController.php: Pass accessnumber to spooler
- app/Libraries/PdfHelper.php: Pass accessnumber to spooler
- app/Views/shared/content_requests.php: Add PDF column with icon
This commit is contained in:
parent
c2c70505e5
commit
b102ba657c
@ -108,5 +108,8 @@ $routes->group('report', ['filter' => 'role:0,1,2,4'], function ($routes) {
|
||||
|
||||
$routes->get('report/status/(:any)', 'ReportController::checkPdfStatus/$1');
|
||||
|
||||
// External PDF generator endpoint - no auth required
|
||||
$routes->post('api/requests/(:any)/pdf', 'RequestsController::setPdfFlag/$1');
|
||||
|
||||
// Keep backward compatibility - updated filter
|
||||
$routes->get('print/(:num)', 'ReportController::generate/$1', ['filter' => 'role:0,1,2,3,4']);
|
||||
|
||||
@ -118,8 +118,8 @@ class ReportController extends BaseController
|
||||
$filename = $accessnumber . ($eng == 1 ? '_eng' : '') . '.pdf';
|
||||
$collectionDate = $data['collectionDate'] ?? '';
|
||||
|
||||
try {
|
||||
$jobId = $this->postToSpooler($html, $filename, $collectionDate);
|
||||
try {
|
||||
$jobId = $this->postToSpooler($html, $filename, $collectionDate, $accessnumber);
|
||||
|
||||
$sqlCheck = "SELECT COUNT(*) as cnt FROM GDC_CMOD.dbo.AUDIT_REQUESTS
|
||||
WHERE ACCESSNUMBER = ? AND STEPTYPE IN ('GEN_PDF', 'REGEN_PDF')";
|
||||
@ -171,7 +171,7 @@ class ReportController extends BaseController
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
private function postToSpooler($html, $filename, $collectionDate = '')
|
||||
private function postToSpooler($html, $filename, $collectionDate = '', $accessnumber = '')
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://glenlis:3000/api/pdf/generate');
|
||||
@ -186,6 +186,10 @@ class ReportController extends BaseController
|
||||
$payload['collectionDate'] = $collectionDate;
|
||||
}
|
||||
|
||||
if ($accessnumber) {
|
||||
$payload['accessnumber'] = $accessnumber;
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
|
||||
@ -16,13 +16,13 @@ class RequestsController extends BaseController
|
||||
|
||||
// Only allow Lab role (role 2)
|
||||
if ($userroleid == 2) {
|
||||
$sql = "SELECT d.*, r.REPORT_LANG from GDC_CMOD.dbo.V_DASHBOARD_DEV d
|
||||
$sql = "SELECT d.*, r.REPORT_LANG, r.ISPDF from GDC_CMOD.dbo.V_DASHBOARD_DEV d
|
||||
LEFT JOIN GDC_CMOD.dbo.CM_REQUESTS r ON r.ACCESSNUMBER=d.SP_ACCESSNUMBER
|
||||
where d.COLLECTIONDATE between '$date1 00:00' and '$date2 23:59'
|
||||
and d.ODR_DDATE between '$date1 00:00' and '$date2 23:59'
|
||||
and (d.TESTS IS NOT NULL AND d.TESTS like '%[A-Za-z]%')";
|
||||
} else {
|
||||
$sql = "SELECT d.*, r.REPORT_LANG from GDC_CMOD.dbo.V_DASHBOARD_DEV d
|
||||
$sql = "SELECT d.*, r.REPORT_LANG, r.ISPDF from GDC_CMOD.dbo.V_DASHBOARD_DEV d
|
||||
LEFT JOIN GDC_CMOD.dbo.CM_REQUESTS r ON r.ACCESSNUMBER=d.SP_ACCESSNUMBER
|
||||
where d.COLLECTIONDATE between '$date1 00:00' and '$date2 23:59'
|
||||
and d.ODR_DDATE between '$date1 00:00' and '$date2 23:59'";
|
||||
@ -176,9 +176,10 @@ class RequestsController extends BaseController
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://glenlis:3000/api/pdf/generate');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
|
||||
$payload = [
|
||||
$payload = [
|
||||
'html' => $html,
|
||||
'filename' => $filename
|
||||
'filename' => $filename,
|
||||
'accessnumber' => $accessnumber
|
||||
];
|
||||
|
||||
if (!empty($data['collectionDate'])) {
|
||||
@ -216,4 +217,20 @@ class RequestsController extends BaseController
|
||||
'message' => 'English PDF queued for generation'
|
||||
];
|
||||
}
|
||||
|
||||
public function setPdfFlag(string $accessnumber): \CodeIgniter\HTTP\ResponseInterface
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$sql = "UPDATE GDC_CMOD.dbo.CM_REQUESTS SET ISPDF = 1 WHERE ACCESSNUMBER = ?";
|
||||
$db->query($sql, [$accessnumber]);
|
||||
|
||||
$logAudit = "INSERT INTO GDC_CMOD.dbo.AUDIT_EVENTS (ACCESSNUMBER, EVENT_TYPE, USERID, EVENT_AT) VALUES (?, 'PDF_FLAG', 'SYSTEM', GETDATE())";
|
||||
$db->query($logAudit, [$accessnumber]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => 'success',
|
||||
'accessnumber' => $accessnumber
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,18 +21,25 @@ class PdfHelper
|
||||
$html = view('report/template', $data);
|
||||
$filename = $accessnumber . ($eng == 1 ? '_eng' : '') . '.pdf';
|
||||
|
||||
return $this->postHtmlToSpooler($html, $filename);
|
||||
return $this->postHtmlToSpooler($html, $filename, $accessnumber);
|
||||
}
|
||||
|
||||
public function postHtmlToSpooler(string $html, string $filename): string
|
||||
public function postHtmlToSpooler(string $html, string $filename, string $accessnumber = ''): string
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://glenlis:3000/api/pdf/generate');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
|
||||
|
||||
$payload = [
|
||||
'html' => $html,
|
||||
'filename' => $filename
|
||||
]));
|
||||
];
|
||||
|
||||
if ($accessnumber) {
|
||||
$payload['accessnumber'] = $accessnumber;
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json'
|
||||
|
||||
@ -185,6 +185,7 @@
|
||||
<th style='width:20%;'>Tests</th>
|
||||
<th style='width:4%;'>ResTo</th>
|
||||
<th style='width:5%;'>Val</th>
|
||||
<th style='width:3%;'>PDF</th>
|
||||
<th style='width:5%;'>Result</th>
|
||||
<th style='width:5%;'></th>
|
||||
</tr>
|
||||
@ -206,6 +207,9 @@
|
||||
<p>2: <span x-text="req.VAL2USER"></span></p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<i class="fa fa-file-pdf" :class="req.ISPDF ? 'text-success' : 'text-base-300'"></i>
|
||||
</td>
|
||||
<?php
|
||||
$configFile = include __DIR__ . '/config.php';
|
||||
$roleMap = ['superuser' => 'superuser', 'admin' => 'admin', 'lab analyst' => 'lab', 'phlebotomist' => 'phlebo', 'customer service' => 'cs'];
|
||||
@ -311,15 +315,13 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (session('userroleid') == 3): ?>
|
||||
<span class="text-xs text-base-content/40">-</span>
|
||||
<?php else: ?>
|
||||
<div class="dropdown dropdown-top dropdown-end dropdown-hover">
|
||||
<div tabindex="0" role="button" class="btn btn-xs btn-primary w-full">
|
||||
<i class="fa fa-cog mr-1"></i> Actions
|
||||
</div>
|
||||
<ul tabindex="0"
|
||||
class="dropdown-content menu bg-base-100 rounded-box z-50 w-48 p-2 shadow-lg border border-base-300 text-xs">
|
||||
<ul tabindex="0"
|
||||
class="dropdown-content menu bg-base-100 rounded-box z-50 w-48 p-2 shadow-lg border border-base-300 text-xs">
|
||||
<?php if (!in_array(session('userroleid'), [3, 4])): ?>
|
||||
<li x-show="req.ISVAL == 1 && req.ISPENDING != 1 && (req.VAL1USER == '<?= session('userid'); ?>' || req.VAL2USER == '<?= session('userid'); ?>')">
|
||||
<?php if (session()->get('userlevel') <= 1): ?>
|
||||
<a @click="openUnvalDialog(req.SP_ACCESSNUMBER)" class="text-error hover:bg-error/10">
|
||||
@ -327,6 +329,7 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li>
|
||||
<a @click="openSampleDialog(req.SP_ACCESSNUMBER)">
|
||||
<i class="fa fa-vial mr-2 text-success"></i> View Samples
|
||||
@ -338,8 +341,7 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user