This commit is contained in:
mahdahar 2025-11-24 11:13:25 +07:00
parent bb24ef6d49
commit e68c88b600
5 changed files with 57 additions and 34 deletions

View File

@ -20,6 +20,7 @@ $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');
$routes->post('result/validate', 'Result::res_validate');
// ------------------------------------------------------Page Based on Role------------------------------------------------------ //
$routes->group('admin', ['filter' => 'role:1'], function($routes) {
@ -29,7 +30,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->get('result/invalidate/(:any)', 'Result::invalidate/$1');
});
$routes->group('doctor', ['filter' => 'role:2'], function($routes) {

View File

@ -3,16 +3,15 @@ namespace App\Controllers;
use CodeIgniter\RESTful\ResourceController;
class ApiDashboard extends ResourceController
{
public function index()
{
class ApiDashboard extends ResourceController {
public function index() {
$date1 = $this->request->getVar('date1');
$date2 = $this->request->getVar('date2');
$db = \Config\Database::connect();
$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 * 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'";
$query = $db->query($sql);
$results = $query->getResultArray();

View File

@ -8,10 +8,14 @@ class Result extends BaseController {
public function show($accessnumber) {
$db = db_connect();
$data['accessnumber'] = $accessnumber;
$sql = "SELECT d.STATS, r.ISVAL2 FROM GDC_CMOD.dbo.V_DASHBOARD_DEV d
left join GDC_CMOD.dbo.CM_REQUESTS r ON r.ACCESSNUMBER=d.SP_ACCESSNUMBER
WHERE d.SP_ACCESSNUMBER='$accessnumber'";
$result = $db
->query("SELECT STATS FROM GDC_CMOD.dbo.V_DASHBOARD_DEV WHERE SP_ACCESSNUMBER='$accessnumber'")
->query($sql)
->getResultArray();
$data['status'] = $result[0]['STATS'];
$data['verif'] = $result[0]['ISVAL2'];
return view('result/result_show',$data);
}
@ -24,4 +28,16 @@ class Result extends BaseController {
return $this->response->setJSON($data);
}
public function res_validate() {
$input = $this->request->getJSON(true);
$accessnumber = $input['accessnumber'];
$userid = $input['userid'];
$db = db_connect();
$sql = "update GDC_CMOD.dbo.CM_REQUESTS set ISVAL2=1, VAL2USER='$userid', VAL2DATE=GETDATE() where ACCESSNUMBER='$accessnumber'";
$result = $db->query($sql);
$data = ['status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber" ];
return $this->response->setJSON($data);
}
}

View File

@ -65,7 +65,7 @@
<table id="datatables" class="table table-sm table-hover table-bordered align-middle table-striped">
<thead class="table-primary">
<tr>
<th>S</th>
<th style="width:1%;">S</th>
<th style='width:7%;'>Order Datetime</th>
<th>Patient Name</th>
<th style='width:7%;'>No Lab</th>
@ -74,9 +74,8 @@
<th style='width:8%;'>Doctor</th>
<th style='width:15%;'>Tests</th>
<th style='width:5%;'>Result To</th>
<th style='width:8%;'>Validation</th>
<th style='width:5%;'>Status</th>
<th style='width:8%;'></th>
<th style='width:10%;'>Validation</th>
<th style='width:4%;'>Status</th>
</tr>
</thead>
<tbody>
@ -111,23 +110,27 @@
-->
<td> <?= esc($row['statscode']) ?> </td> <td> <?= esc($row['reqdate']) ?> </td> <td> <?= esc($row['patname']) ?> </td>
<td> <?= esc($row['sp_accessnumber']) ?> </td> <td> <?= esc($row['hostordernumber']) ?> </td> <td> <?= esc($row['reff']) ?> </td>
<td> <?= esc($row['doc']) ?> </td> <td> <?= $tests; ?> </td> <td> <?= esc($row['odr_cresult_to']) ?> </td>
<td> <?= esc($row['doc']) ?> </td> <td> <?= $tests; ?> </td>
<td>
<?= esc($row['odr_cresult_to']) ?> <br/>
<input type="checkbox" name="printed"> Printed
</td>
<td data-acc="<?=$row['sp_accessnumber'];?>">
<h6> <span class="px-3 py-2 badge bg-success"> <?=$row['val'];?> </span> </h6>
<span class="border border-success rounded p-1 mb-2 me-2"> <?=$row['val'];?> </span>
<?php if($row['val'] == 1) { ?>
<a href="<?=base_url('result/'.$row['sp_accessnumber']);?>" target="_blank" class="btn btn-xs btn-outline-primary px-1 py-0 mb-1">Verify</a> <br/>
<?php } else { echo "<br />"; } ?>
<?php if($row['val'] == 2) { ?>
<a href="http://glenlis/spooler_db/main_dev.php?acc=<?=$row['sp_accessnumber'];?>" target="_blank" class="btn btn-xs btn-primary py-0 px-1">Ind</a> |
<a href="http://glenlis/spooler_db/main_dev.php?acc=<?=$row['sp_accessnumber'];?>&eng=1" target="_blank" class="btn btn-xs btn-primary py-0 px-1">Eng</a> |
<a href="#" class="btn btn-xs btn-secondary py-0 px-1">Pdf</a> <br />
<?php } ?>
<?php if ($row['val'] != 0) {?>
<a href="#" class="btn btn-xs btn-secondary py-0 px-2 invalidate-btn" onclick="invalidate('<?=$row['sp_accessnumber'];?>'); return false;">Invalidate</a><br>
<?php }?>
</td>
<td class="pointercol <?= esc($class) ?>" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['stats']) ?> </td>
<td>
<a href="<?=base_url('result/'.$row['sp_accessnumber']);?>" target="_blank" class="btn btn-xs btn-primary py-0 px-2">Preview</a> <br/>
<?php if($row['val'] != 0) { ?>
<a href="http://glenlis/spooler_db/main_dev.php?acc=<?=$row['sp_accessnumber'];?>" target="_blank" class="btn btn-xs btn-primary py-0 px-1">Print</a> |
<a href="http://glenlis/spooler_db/main_dev.php?acc=<?=$row['sp_accessnumber'];?>&eng=1" target="_blank" class="btn btn-xs btn-primary py-0 px-1">Eng</a> |
<a href="#" class="btn btn-xs btn-secondary py-0 px-1">Pdf</a> <br />
<input type="checkbox" name="printed"> Printed
<?php } ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
@ -168,11 +171,11 @@
scrollY: '70vh',
columnDefs: [{
className: 'text-center',
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}, // semua kolom di tengah
{
className: 'text-start',
targets: [11]
targets: [10]
}
],
responsive: true,

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Result Preview</title>
<title>Result <?=$accessnumber?></title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
@ -19,9 +19,6 @@
</head>
<?php
$userid = session('userid');
$verif = 0;
if(strpos(strtolower($status), "verif") !== false) { $verif = 1; }
?>
<body class="bg-gray-50 flex items-start justify-center">
@ -88,18 +85,25 @@ if(strpos(strtolower($status), "verif") !== false) { $verif = 1; }
function validate() {
const ok = confirm('Are you sure?');
if (!ok) return;
fetch('inc/result_validate.php?accessnumber=<?=$accessnumber;?>&userid=<?=$userid;?>', {
method: 'GET'
})
const postData = {
accessnumber: '<?=$accessnumber;?>',
userid: '<?=$userid?>'
};
fetch('<?=base_url("result/validate");?>', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(postData)
})
.then(function (response) {
if (!response.ok) throw new Error('Failed to send data');
//return response.json();
})
.then(function (data) {
location.reload();
//location.reload();
})
.catch(function (error) {
alert('Error: ' + error.message);
alert('Error: ' + error.message);
});
}
<?php }?>