Major Updates:
1. Extended Audit Trail System
- Added tube received events tracking from SP_TUBES table (TUBESTATUS=4)
- New audit tab "Receive" in dialog_audit.php to display tube reception history
- ApiRequestsAuditController now fetches and returns tube received events with:
* Sample type, tube status, collection date, and user information
- Audit events sorted chronologically combining validation, sampling, and receiving events
2. Enhanced PDF Generation Workflow
- Created new PdfHelper library with methods for PDF generation and posting to spooler
- Reports can now be generated via GET /report/{accessnumber}/pdf endpoint
- Updated PDF spooler API endpoint from port 3030 to 3000
- Added retry PDF button with spinner animation for failed generations
- Fixed PDF status check to use correct spooler endpoint
3. Validation UI Improvements
- Added toast notification showing PDF queued after second validation (val2)
- Retry PDF button appears when val1 and val2 are complete
- Toast notifications success/error states with auto-dismiss after 2 seconds
- Loading state with spinning icon during PDF retry operation
4. Report Template Fixes
- Fixed typo in Val2 By display (added missing ":")
- Consistent formatting with Val1 By : and Val2 By :
5. Documentation Updates
- TODO.md updated with:
* Auto generate PDF (in progress)
* Print Eng Result (pending)
* Add Receive to Audit (completed)
6. Cleanup
- Removed legacy Node.js spooler implementation (node_spooler directory)
- Deleted P0_log.txt (SQL setup scripts no longer needed in repo)
- Cleaned up .gitignore to remove stale node_spooler entries
Files Changed:
- app/Controllers/ApiRequestsAuditController.php (tube received audit)
- app/Controllers/ReportController.php (port update: 3030 → 3000)
- app/Libraries/PdfHelper.php (new library)
- app/Views/report/template.php (typo fix)
- app/Views/shared/content_requests.php (retry PDF button)
- app/Views/shared/dialog_audit.php (receive tab)
- app/Views/shared/script_requests.php (retry handler, tube events)
- app/Views/shared/script_validation.php (enhanced toast)
- TODO.md (pending/completed tasks)
- .gitignore (cleanup)
- Deleted: node_spooler/* (legacy implementation)
- Deleted: P0_log.txt (no longer needed)
69 lines
2.6 KiB
PHP
69 lines
2.6 KiB
PHP
<?php
|
|
namespace App\Controllers;
|
|
use App\Controllers\BaseController;
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class ApiRequestsAuditController extends BaseController {
|
|
use ResponseTrait;
|
|
|
|
public function show($accessnumber) {
|
|
$db = \Config\Database::connect();
|
|
|
|
$result = [
|
|
'accessnumber' => $accessnumber,
|
|
'validation' => [],
|
|
'sample_collection' => [],
|
|
'tube_received' => []
|
|
];
|
|
|
|
$sqlAudit = "SELECT EVENT_TYPE, USERID, EVENT_AT, REASON
|
|
FROM GDC_CMOD.dbo.AUDIT_EVENTS
|
|
WHERE ACCESSNUMBER = ?
|
|
ORDER BY EVENT_AT ASC";
|
|
$auditRows = $db->query($sqlAudit, [$accessnumber])->getResultArray();
|
|
|
|
foreach ($auditRows as $row) {
|
|
$isUnval = $row['EVENT_TYPE'] === 'UNVAL';
|
|
$result['validation'][] = [
|
|
'type' => $row['EVENT_TYPE'],
|
|
'user' => trim($row['USERID']),
|
|
'datetime' => $row['EVENT_AT'] ? date('Y-m-d H:i:s', strtotime($row['EVENT_AT'])) : null,
|
|
'reason' => $isUnval ? trim($row['REASON']) : null
|
|
];
|
|
}
|
|
|
|
$sqlTube = "SELECT TUBENUMBER, USERID, STATUS, LOGDATE
|
|
FROM GDC_CMOD.dbo.AUDIT_TUBES
|
|
WHERE ACCESSNUMBER = ?
|
|
ORDER BY LOGDATE ASC";
|
|
$tubeRows = $db->query($sqlTube, [$accessnumber])->getResultArray();
|
|
|
|
foreach ($tubeRows as $row) {
|
|
$action = $row['STATUS'] == 1 ? 'COLLECTED' : 'UNRECEIVED';
|
|
$result['sample_collection'][] = [
|
|
'tubenumber' => trim($row['TUBENUMBER']),
|
|
'user' => trim($row['USERID']),
|
|
'datetime' => $row['LOGDATE'] ? date('Y-m-d H:i:s', strtotime($row['LOGDATE'])) : null,
|
|
'action' => $action
|
|
];
|
|
}
|
|
|
|
$sqlSpTubes = "SELECT SAMPLETYPE, TUBESTATUS, COLLECTIONDATE, LOGUSERID
|
|
FROM glendb.dbo.SP_TUBES
|
|
WHERE SP_ACCESSNUMBER = ? AND TUBESTATUS = 4
|
|
ORDER BY COLLECTIONDATE ASC";
|
|
$spTubeRows = $db->query($sqlSpTubes, [$accessnumber])->getResultArray();
|
|
|
|
foreach ($spTubeRows as $row) {
|
|
$result['tube_received'][] = [
|
|
'sampletype' => trim($row['SAMPLETYPE']),
|
|
'tubestatus' => (int)$row['TUBESTATUS'],
|
|
'datetime' => $row['COLLECTIONDATE'] ? date('Y-m-d H:i:s', strtotime($row['COLLECTIONDATE'])) : null,
|
|
'user' => trim($row['LOGUSERID'])
|
|
];
|
|
}
|
|
|
|
return $this->respond(['status' => 'success', 'data' => $result]);
|
|
}
|
|
}
|