From bb24ef6d49deab8c6deed74860778144cb272f90 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Wed, 19 Nov 2025 13:57:23 +0700 Subject: [PATCH] prework --- app/Config/Routes.php | 8 +- app/Controllers/Admin.php | 4 + app/Controllers/Result.php | 15 ++- app/Controllers/Specimen.php | 55 +++++++++++ app/Views/_layouts/main.php | 12 ++- app/Views/admin/index.php | 93 +++++++++++++++---- app/Views/admin/modal_specimen.php | 12 +-- .../result/{show.php => result_show.php} | 4 +- 8 files changed, 173 insertions(+), 30 deletions(-) rename app/Views/result/{show.php => result_show.php} (97%) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4dc1cc0..bfe0429 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -16,10 +16,11 @@ $routes->get('/', 'Home::index'); $routes->match(['get','post'],'/login', 'Auth::login', ['filter' => 'guest']); $routes->get('/logout', 'Auth::logout'); -$routes->get('result/(:any)', 'Result::show/$1'); $routes->get('label/coll/(:any)', 'Label::coll/$1'); $routes->get('label/dispatch/(:any)/(:any)', 'Label::dispatch/$1/$2'); $routes->get('label/all/(:any)', 'Label::print_all/$1'); +$routes->get('result/(:any)', 'Result::show/$1'); + // ------------------------------------------------------Page Based on Role------------------------------------------------------ // $routes->group('admin', ['filter' => 'role:1'], function($routes) { $routes->get('/', 'Admin::index'); @@ -28,6 +29,7 @@ $routes->group('admin', ['filter' => 'role:1'], function($routes) { $routes->post('user/create', 'User::create'); $routes->post('user/update', 'User::update'); $routes->post('user/delete', 'User::delete'); + $routes->get('result/invalidate/(:any)', 'Result::invalidate/$1'); }); $routes->group('doctor', ['filter' => 'role:2'], function($routes) { @@ -44,4 +46,6 @@ $routes->group('cs', ['filter' => 'role:4'], function($routes) { // ------------------------------------------------------For API------------------------------------------------------ // // $routes->get('/api/dashboard', 'ApiDashboard::index'); -$routes->get('api/specimen/(:any)', 'Specimen::show/$1'); \ No newline at end of file +$routes->get('api/specimen/(:any)', 'Specimen::show/$1'); +$routes->post('api/specimen/collect/(:any)', 'Specimen::collect/$1'); +$routes->post('api/specimen/unreceive/(:any)', 'Specimen::unreceive/$1'); \ No newline at end of file diff --git a/app/Controllers/Admin.php b/app/Controllers/Admin.php index 55d0b36..70e9878 100644 --- a/app/Controllers/Admin.php +++ b/app/Controllers/Admin.php @@ -110,4 +110,8 @@ class Admin extends BaseController public function modal_specimen() { return view('admin/modal_specimen'); } + + public function result_show() { + return view('result/result_show'); + } } diff --git a/app/Controllers/Result.php b/app/Controllers/Result.php index 2d6d2f3..39c93e6 100644 --- a/app/Controllers/Result.php +++ b/app/Controllers/Result.php @@ -1,8 +1,10 @@ query("SELECT STATS FROM GDC_CMOD.dbo.V_DASHBOARD_DEV WHERE SP_ACCESSNUMBER='$accessnumber'") ->getResultArray(); $data['status'] = $result[0]['STATS']; - return view('result/show',$data); + return view('result/result_show',$data); } + public function invalidate($accessnumber) { + $db = db_connect(); + $sql = "update GDC_CMOD.dbo.CM_REQUESTS set ISVAL=null, VALUSER=null, VALDATE=null, + ISVAL2=null, VAL2USER=null, VAL2DATE=null where ACCESSNUMBER='$accessnumber'"; + $result = $db->query($sql); + $data = ['status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber" ]; + + return $this->response->setJSON($data); + } } diff --git a/app/Controllers/Specimen.php b/app/Controllers/Specimen.php index 3722eac..7b66c4d 100644 --- a/app/Controllers/Specimen.php +++ b/app/Controllers/Specimen.php @@ -1,7 +1,10 @@ response->setJSON($data); } + + public function collect($accessnumber) { + $db = \Config\Database::connect(); + $input = $this->request->getJSON(true); + $samplenumber = $input['samplenumber']; + $status = $input['status']; + $userid = $input['userid']; + $sql = "if not exists (select * from GDC_CMOD.dbo.TUBES where ACCESSNUMBER='$accessnumber' and TUBENUMBER='$samplenumber' and STATUS='$status') + begin + update GDC_CMOD.dbo.TUBES set USERID='$userid',STATUS='$status', COLLECTIONDATE=getdate() where ACCESSNUMBER='$accessnumber' and TUBENUMBER='$samplenumber' + end"; + $db->query($sql); + $sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_TUBES(ACCESSNUMBER, TUBENUMBER, USERID, STATUS, LOGDATE) + VALUES ('$accessnumber', '$samplenumber', '$userid', '$status', getdate())"; + $db->query($sql); + return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber-$samplenumber" ], 201); + } + public function unreceive($accessnumber) { + $db = \Config\Database::connect(); + $input = $this->request->getJSON(true); + $samplenumber = $input['samplenumber']; + // update firebird + $sql = "select r.EXTERNALORDERNUMBER, dt.TESTCODE, do.HISCODE from glendb.dbo.TESTS t + left join glendb.dbo.DICT_TESTS dt on dt.TESTID=t.TESTID + left join glendb.dbo.REQUESTS r on r.REQUESTID=t.REQUESTID + left join glendb.dbo.DICT_TEST_SAMPLES dts on dts.TESTID=t.TESTID + left join glendb.dbo.DICT_SAMPLES_TYPES ds on ds.SAMPTYPEID=dts.SAMPTYPEID + left join GDC_CMOD.dbo.DICT_TESTS_ORDER do on do.TESTCODE=dt.TESTCODE + where t.DEPTH=0 + and r.ACCESSNUMBER='$req' and ds.SAMPCODE='$samplenumber'"; + $rows = $db->query($sql)->getResultArray(); + $his_test = ''; + foreach( $rows as $row ) { + $hon = $row['EXTERNALORDERNUMBER']; + $testcode = $row['TESTCODE']; + $hiscode = $row['HISCODE']; + $his_test .= "'$hiscode',"; + $lis_test .= "'$testcode',"; + } + $his_test = rtrim($his_test,','); + $lis_test = rtrim($lis_test,','); + $conn = odbc_connect('GLENEAGLES','',''); + $sql = "UPDATE TDL_ORDERDT SET ODD_NRECEIVED=NULL , ODD_DTRECEIVE=NULL WHERE ODR_CNOLAB='$hon' and ODD_CPRODUCTCODE IN ($his_test)"; + $rs = odbc_exec($conn,$sql); + if (!$rs) {exit("Error in Update FB");} + + $sql = "update SP_TUBES set TUBESTATUS=0 where SP_ACCESSNUMBER='$accessnumber' and SAMPLETYPE='$samplenumber' "; + $db->query($sql); + $sql = "update SP_TESTS set SP_TESTSTATUS=NULL where SP_ACCESSNUMBER='$req' and SP_TESTCODE in ($lis_test)"; + $db->query($sql); + return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber-$samplenumber" ], 201); + } } diff --git a/app/Views/_layouts/main.php b/app/Views/_layouts/main.php index 2b0865d..80c5735 100644 --- a/app/Views/_layouts/main.php +++ b/app/Views/_layouts/main.php @@ -127,14 +127,22 @@ .Suspend { background-color: purple; } + + .btn-xs { + font-size : 0.7rem; + } renderSection('css'); ?> - + renderSection('content'); ?> - + + + diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index 0f408a1..a1a29f8 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -68,16 +68,15 @@ S Order Datetime Patient Name - No Lab - No Register - Reff - Doctor - Tests + No Lab + No Register + Reff + Doctor + Tests Result To Validation Status - @@ -95,6 +94,8 @@ case 9: $class = 'PenVerification'; break; default: $class = ''; break; } + $tests = esc($row['tests']); + $tests = str_replace(",", ", ", $tests); ?> - -
- Result
Invalidation
+ + +
+ + Invalidate
+ - Preview
- Print | Eng
- Pdf + Preview
+ + Print | + Eng | + Pdf
+ Printed + - Printed
Hardcopy @@ -158,14 +165,14 @@ order: [[0, 'asc'], [3, 'asc']], paging: false, scrollCollapse: true, - scrollY: '75vh', + scrollY: '70vh', columnDefs: [{ className: 'text-center', - targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }, // semua kolom di tengah { className: 'text-start', - targets: [12] + targets: [11] } ], responsive: true, @@ -191,7 +198,61 @@ }); }); + + function invalidate(accessnumber) { + if(confirm("Are you sure?")) { + $.get(`/${accessnumber}`); + const cell = document.querySelector(`[data-acc="${accessnumber}"]`); + if(cell){ + cell.querySelector(".badge").textContent = "0"; + const btn = cell.querySelector(".invalidate-btn"); + if (btn) btn.remove(); + } + } + } + + function collect(accessnumber, samplenumber, status) { + // toggle checkbox + const row = document.getElementById(`row-${accessnumber}-${samplenumber}`); + const checkbox = row.querySelector('.coll-checkbox'); + checkbox.checked = status; + + $.ajax({ + url: `/${accessnumber}`, + type: "POST", + contentType: "application/json; charset=utf-8", + dataType: "json", + data: JSON.stringify({ samplenumber:samplenumber, status:status, userid:"" }), + success: function(response) { + console.log("Success:", response); + }, + error: function(xhr, status, error) { + console.error("Error:", status, error); + } + }); + } + + function unreceive(accessnumber, samplenumber) { + // toggle checkbox + const row = document.getElementById(`row-${accessnumber}-${samplenumber}`); + const checkbox = row.querySelector('.recv-checkbox'); + checkbox.checked = status; + + $.ajax({ + url: `/${accessnumber}`, + type: "POST", + contentType: "application/json; charset=utf-8", + dataType: "json", + data: JSON.stringify({ samplenumber:samplenumber }), + success: function(response) { + console.log("Success:", response); + }, + error: function(xhr, status, error) { + console.error("Error:", status, error); + } + }); + } // Untuk Koment Value function commentValue() { diff --git a/app/Views/admin/modal_specimen.php b/app/Views/admin/modal_specimen.php index 5e32e70..faeef90 100644 --- a/app/Views/admin/modal_specimen.php +++ b/app/Views/admin/modal_specimen.php @@ -65,26 +65,26 @@ {{#samples}} - + {{sampcode}} {{name}} - - - - - + + + diff --git a/app/Views/result/show.php b/app/Views/result/result_show.php similarity index 97% rename from app/Views/result/show.php rename to app/Views/result/result_show.php index f94b3aa..639138b 100644 --- a/app/Views/result/show.php +++ b/app/Views/result/result_show.php @@ -3,7 +3,7 @@ - Responsive HTML Iframe Demo + Result Preview