fix dashboard stats color

This commit is contained in:
mikael-zakaria 2024-11-21 17:41:34 +08:00
parent 748e7a04bc
commit 909ca1dbc2
4 changed files with 95 additions and 20 deletions

View File

@ -8,7 +8,7 @@ class Dashboard extends ResourceController {
public function index() { public function index() {
$db = \Config\Database::connect(); $db = \Config\Database::connect();
$sql = "select top 50 sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, p.NAME, $sql = "select sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, p.NAME,
TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from
( select T.SP_TESTCODE from SP_TESTS T ( select T.SP_TESTCODE from SP_TESTS T
where T.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER where T.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER
@ -19,12 +19,12 @@ case
when exists (select 1 from AUDIT_TRAIL at where at.ATR_ACCESSNUMBER=sr.SP_ACCESSNUMBER and at.STEPTYPE=2 and at.LIS_SESSION='RFC' ) then when exists (select 1 from AUDIT_TRAIL at where at.ATR_ACCESSNUMBER=sr.SP_ACCESSNUMBER and at.STEPTYPE=2 and at.LIS_SESSION='RFC' ) then
case case
when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv'
when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and (T.RESTYPE IN (null,'0') OR T.TESTID='1805') ) then 'Inc' when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') ) then 'Inc'
--when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') and T.TESTID='1805' ) then 'Inc' --when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') and T.TESTID='1805' ) then 'Inc'
else 'Comp' else 'Comp'
end end
-- inc -- inc
when exists (select 1 from TESTS T where T.RESTYPE not in (0,4) and T.REQUESTID=r.REQUESTID AND T.TESTID<>'1805') then when exists (select 1 from TESTS T where T.RESTYPE not in (0,4) and T.REQUESTID=r.REQUESTID ) then
case case
when exists ( select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl' when exists ( select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl'
when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv'
@ -37,18 +37,18 @@ when not exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESS
else 'Recv' else 'Recv'
end end
--coll --coll
when not exists (select 1 FROM cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then when exists (select 1 FROM cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER ) then
case case
when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=4 ) then 'PartRecv' when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=4 ) then 'PartRecv'
when exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl'
else 'Coll' else 'Coll'
end end
when exists ( select 1 from CMOD.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=1 ) then 'PartColl'
else 'Pend' else 'Pend'
end STATS end STATS
from SP_REQUESTS sr from SP_REQUESTS sr
left join PATIENTS p on p.PATID=sr.PATID left join PATIENTS p on p.PATID=sr.PATID
left join REQUESTS r on r.ACCESSNUMBER=sr.SP_ACCESSNUMBER left join REQUESTS r on r.ACCESSNUMBER=sr.SP_ACCESSNUMBER
where sr.COLLECTIONDATE between '2023-09-16 00:00' and '2023-09-17 23:59' where sr.COLLECTIONDATE between '2024-11-13 00:00' and '2024-11-21 23:59'
order by sr.COLLECTIONDATE desc"; order by sr.COLLECTIONDATE desc";
$query = $db->query($sql); $query = $db->query($sql);
$results = $query->getResultArray(); $results = $query->getResultArray();

View File

@ -2,9 +2,8 @@
<?= $this->section('content') ?> <?= $this->section('content') ?>
<!--
<div class="d-flex justify-content-between p-0"> <div class="d-flex justify-content-between p-0">
<div class="custom-card"> <div class="custom-card" data-filtertype="1">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-orange"> <h5 class="m-0"><i class="bi bi-clock-history"></i></h5> </div> <div class="col-3 text-start text-orange"> <h5 class="m-0"><i class="bi bi-clock-history"></i></h5> </div>
@ -14,7 +13,7 @@
<h3 class="custom-card-text m-0 p-0 text-orange">Pending</h3> <h3 class="custom-card-text m-0 p-0 text-orange">Pending</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="2">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-peach"> <h5 class="m-0"><i class="bi bi-tv"></i></h5> </div> <div class="col-3 text-start text-peach"> <h5 class="m-0"><i class="bi bi-tv"></i></h5> </div>
@ -24,7 +23,7 @@
<h3 class="custom-card-text m-0 p-0 text-peach">Part. Collect</h3> <h3 class="custom-card-text m-0 p-0 text-peach">Part. Collect</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="3">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-pink"> <h5 class="m-0"><i class="bi bi-collection"></i></h5> </div> <div class="col-3 text-start text-pink"> <h5 class="m-0"><i class="bi bi-collection"></i></h5> </div>
@ -34,7 +33,7 @@
<h3 class="custom-card-text m-0 p-0 text-pink">Collected</h3> <h3 class="custom-card-text m-0 p-0 text-pink">Collected</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="4">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-soft-blue"> <h5 class="m-0"><i class="bi bi-file-medical"></i></h5> </div> <div class="col-3 text-start text-soft-blue"> <h5 class="m-0"><i class="bi bi-file-medical"></i></h5> </div>
@ -44,7 +43,7 @@
<h3 class="custom-card-text m-0 p-0 text-soft-blue">Part. Rcv.</h3> <h3 class="custom-card-text m-0 p-0 text-soft-blue">Part. Rcv.</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="5">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-blue"> <h5 class="m-0"><i class="bi bi-journal-medical"></i></h5> </div> <div class="col-3 text-start text-blue"> <h5 class="m-0"><i class="bi bi-journal-medical"></i></h5> </div>
@ -54,7 +53,7 @@
<h3 class="custom-card-text m-0 p-0 text-blue">Received</h3> <h3 class="custom-card-text m-0 p-0 text-blue">Received</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="6">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-grey"> <h5 class="m-0"><i class="bi bi-calendar3-week"></i></h5> </div> <div class="col-3 text-start text-grey"> <h5 class="m-0"><i class="bi bi-calendar3-week"></i></h5> </div>
@ -64,7 +63,7 @@
<h3 class="custom-card-text m-0 p-0 text-grey">Inprocess</h3> <h3 class="custom-card-text m-0 p-0 text-grey">Inprocess</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="7">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-soft-green"> <h5 class="m-0"><i class="bi bi-check2"></i></h5> </div> <div class="col-3 text-start text-soft-green"> <h5 class="m-0"><i class="bi bi-check2"></i></h5> </div>
@ -74,7 +73,7 @@
<h3 class="custom-card-text m-0 p-0 text-soft-green">Part. Val.</h3> <h3 class="custom-card-text m-0 p-0 text-soft-green">Part. Val.</h3>
</div> </div>
</div> </div>
<div class="custom-card"> <div class="custom-card" data-filtertype="8">
<div class="custom-card-content"> <div class="custom-card-content">
<div class="row p-0 d-flex justify-content-between"> <div class="row p-0 d-flex justify-content-between">
<div class="col-3 text-start text-green"> <h5 class="m-0"><i class="bi bi-clipboard-check"></i></h5> </div> <div class="col-3 text-start text-green"> <h5 class="m-0"><i class="bi bi-clipboard-check"></i></h5> </div>
@ -85,7 +84,6 @@
</div> </div>
</div> </div>
</div> </div>
-->
<div class="card border-0"> <div class="card border-0">
<div class="card-body"> <div class="card-body">
@ -120,7 +118,7 @@
<?= $this->section('script') ?> <?= $this->section('script') ?>
<script> <script>
var tb = $('#mytable').DataTable(); var tb = $('#myTable').DataTable();
index(); index();
function index() { function index() {
let url = '<?=base_url('');?>api/dashboard/index'; let url = '<?=base_url('');?>api/dashboard/index';
@ -137,10 +135,18 @@ function index() {
patname = data[i].NAME; patname = data[i].NAME;
hon = data[i].HOSTORDERNUMBER; hon = data[i].HOSTORDERNUMBER;
tests = data[i].TESTS; tests = data[i].TESTS;
stats = data[i].STATS;
if(stats == 'Pend') { statsTD = "<td role='button' class='bg-orange text-center align-middle' onclick='viewAccess("+accessnumber+")'>Pending</td>"; }
else if(stats == 'PartColl') { statsTD = "<td role='button' class='bg-peach text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Collected</td>"; }
else if(stats == 'PartRecv') { statsTD = "<td role='button' class='bg-soft-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Received</td>"; }
else if(stats == 'PartVal') { statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Validated</td>"; }
else if(stats == 'Coll') { statsTD = "<td role='button' class='bg-pink text-center align-middle' onclick='viewAccess("+accessnumber+")'>Collected</td>"; }
else if(stats == 'Recv') { statsTD = "<td role='button' class='bg-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Received</td>"; }
else if(stats == 'Inc') { statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Incomplete</td>"; }
else if(stats == 'Comp') { statsTD = "<td role='button' class='bg-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Validated</td>"; }
let datarow = '<tr class="align-middle">' + let datarow = '<tr class="align-middle">' +
'<td>' + colldate + '</td> <td>' + patnumber + '</td> <td>' + accessnumber + '</td> <td>' + patname + '</td> <td>' + hon + '</td> <td>' + tests + '</td>' + '<td>' + colldate + '</td> <td>' + patnumber + '</td> <td>' + accessnumber + '</td> <td>' + patname + '</td> <td>' + hon + '</td> <td>' + tests + '</td>' +
"<td role='button' class='bg-orange text-center align-middle' onclick='viewAccess("+accessnumber+")'>Pending</td>" statsTD + '</tr>';
'</tr>';
$("#table-body").append(datarow); $("#table-body").append(datarow);
} }
tb.ajax.reload(); tb.ajax.reload();
@ -156,5 +162,40 @@ function viewAccess(access) {
}); });
} }
const filterButton = document.querySelectorAll("[data-filtertype]");
const table = document.querySelector("#myTable");
const tr = table.getElementsByTagName("tr");
let activeButton = null;
filterButton.forEach((button) => {
button.addEventListener("click", () => {
const selectedButton = button.getAttribute("data-filtertype");
console.log(selectedButton);
if (activeButton === button) {
button.classList.remove("active", "border", "border-primary", "border-5");
activeButton = null;
for (let i = 1; i < tr.length; i++) {
tr[i].style.display = "";
}
} else {
filterButton.forEach((btn) => btn.classList.remove("active", "border", "border-info", "border-3"));
button.classList.add("active", "border", "border-info", "border-3");
activeButton = button;
for (let i = 1; i < tr.length; i++) {
const filterValue = tr[i].getAttribute("data-filterrow");
if (filterValue === selectedButton) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
});
});
</script> </script>
<?= $this->endSection() ?> <?= $this->endSection() ?>

View File

@ -13,7 +13,8 @@
<link href="<?=base_url();?>assets/css/styles.css" rel="stylesheet" /> <link href="<?=base_url();?>assets/css/styles.css" rel="stylesheet" />
</head> </head>
<body class="sb-nav-fixed sb-sidenav-toggled"> <!-- <body class="sb-nav-fixed sb-sidenav-toggled"> -->
<body class="sb-nav-fixed">
<?= $this->include('layouts/topbar'); ?> <?= $this->include('layouts/topbar'); ?>
<div id="layoutSidenav"> <div id="layoutSidenav">

33
public/web.config Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="(.+)/$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="{C:1}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^on$" ignoreCase="false" negate="true" />
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
</conditions>
<action type="Redirect" url="http://{C:1}{URL}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^([\s\S]*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>