From 5f6cf476894037060a61d0366678222a080496fd Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Wed, 25 Feb 2026 16:38:07 +0700 Subject: [PATCH] Add engineering result dialog and functionality across all roles --- app/Config/Routes.php | 7 +-- app/Controllers/RequestsController.php | 32 +++++++++--- app/Views/admin/index.php | 1 + app/Views/cs/index.php | 1 + app/Views/lab/index.php | 1 + app/Views/phlebo/index.php | 1 + app/Views/shared/content_requests.php | 58 +++++++++++++-------- app/Views/shared/dialog_eng_result.php | 72 ++++++++++++++++++++++++++ app/Views/shared/dialog_sample.php | 14 ++--- app/Views/shared/layout.php | 6 ++- app/Views/shared/script_requests.php | 59 +++++++++++++++++++++ app/Views/superuser/index.php | 1 + 12 files changed, 214 insertions(+), 39 deletions(-) create mode 100644 app/Views/shared/dialog_eng_result.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ad47c1f..c45a065 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -36,9 +36,10 @@ $routes->group('api', function ($routes) { // Requests - All Roles (0,1,2,3,4) $routes->group('requests', ['filter' => 'role:0,1,2,3,4'], function ($routes) { $routes->get('', 'RequestsController::index'); - $routes->get('(:any)/audit', 'ApiRequestsAuditController::show/$1'); - $routes->post('validate/(:any)', 'RequestsController::val/$1'); - $routes->delete('validate/(:any)', 'RequestsController::unval/$1'); +$routes->get('(:any)/audit', 'ApiRequestsAuditController::show/$1'); + $routes->post('validate/(:any)', 'RequestsController::val/$1'); + $routes->delete('validate/(:any)', 'RequestsController::unval/$1'); + $routes->post('(:any)/eng', 'RequestsController::setEngLanguage/$1'); }); // Validate API - Lab (2), Admin (1), Superuser (0) diff --git a/app/Controllers/RequestsController.php b/app/Controllers/RequestsController.php index 02482d0..fce09ee 100644 --- a/app/Controllers/RequestsController.php +++ b/app/Controllers/RequestsController.php @@ -16,14 +16,16 @@ class RequestsController extends BaseController // Only allow Lab role (role 2) if ($userroleid == 2) { - $sql = "SELECT * from GDC_CMOD.dbo.V_DASHBOARD_DEV where - COLLECTIONDATE between '$date1 00:00' and '$date2 23:59' - and ODR_DDATE between '$date1 00:00' and '$date2 23:59' - and (TESTS IS NOT NULL AND TESTS like '%[A-Za-z]%')"; + $sql = "SELECT d.*, r.REPORT_LANG 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 * from GDC_CMOD.dbo.V_DASHBOARD_DEV where - COLLECTIONDATE between '$date1 00:00' and '$date2 23:59' - and ODR_DDATE between '$date1 00:00' and '$date2 23:59'"; + $sql = "SELECT d.*, r.REPORT_LANG 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'"; } $rows = $db->query($sql)->getResultArray(); @@ -132,4 +134,20 @@ class RequestsController extends BaseController return $this->response->setJSON($data); } + + public function setEngLanguage($accessnumber) + { + $userid = session('userid'); + $db = \Config\Database::connect(); + + // Set REPORT_LANG to 1 (English) + $sql = "UPDATE GDC_CMOD.dbo.CM_REQUESTS SET REPORT_LANG=1 WHERE ACCESSNUMBER='$accessnumber'"; + $db->query($sql); + + // Log the action + $logAudit = "INSERT INTO GDC_CMOD.dbo.AUDIT_EVENTS (ACCESSNUMBER, EVENT_TYPE, USERID, EVENT_AT) VALUES (?, 'SET_ENG', ?, GETDATE())"; + $db->query($logAudit, [$accessnumber, $userid]); + + return $this->response->setJSON(['status' => 'success', 'message' => 'English result created']); + } } diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index fa080f9..e014146 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -11,6 +11,7 @@ $roleConfig = $config['admin']; = $this->include('shared/dialog_unval'); ?> = $this->include('shared/dialog_audit'); ?> = $this->include('shared/dialog_results_generate'); ?> + = $this->include('shared/dialog_eng_result'); ?> = $this->include('shared/dialog_preview'); ?> = $this->endSection(); ?> diff --git a/app/Views/cs/index.php b/app/Views/cs/index.php index 3cf0cc8..9043ee6 100644 --- a/app/Views/cs/index.php +++ b/app/Views/cs/index.php @@ -11,6 +11,7 @@ $roleConfig = $config['cs']; = $this->include('shared/dialog_unval'); ?> = $this->include('shared/dialog_audit'); ?> = $this->include('shared/dialog_results_generate'); ?> + = $this->include('shared/dialog_eng_result'); ?> = $this->endSection(); ?> diff --git a/app/Views/lab/index.php b/app/Views/lab/index.php index 63d9a00..8f55dd1 100644 --- a/app/Views/lab/index.php +++ b/app/Views/lab/index.php @@ -11,6 +11,7 @@ $roleConfig = $config['lab']; = $this->include('shared/dialog_unval'); ?> = $this->include('shared/dialog_audit'); ?> = $this->include('shared/dialog_results_generate'); ?> + = $this->include('shared/dialog_eng_result'); ?> = $this->include('shared/dialog_preview'); ?> = $this->endSection(); ?> diff --git a/app/Views/phlebo/index.php b/app/Views/phlebo/index.php index 1f622e8..91f51e7 100644 --- a/app/Views/phlebo/index.php +++ b/app/Views/phlebo/index.php @@ -11,6 +11,7 @@ $roleConfig = $config['phlebo']; = $this->include('shared/dialog_unval'); ?> = $this->include('shared/dialog_audit'); ?> = $this->include('shared/dialog_results_generate'); ?> + = $this->include('shared/dialog_eng_result'); ?> = $this->endSection(); ?> diff --git a/app/Views/shared/content_requests.php b/app/Views/shared/content_requests.php index aeb80e7..0d0368c 100644 --- a/app/Views/shared/content_requests.php +++ b/app/Views/shared/content_requests.php @@ -1,5 +1,5 @@ -