2024-12-07 19:46:42 +08:00
|
|
|
<?= $this->extend('sampling/layout/main.php') ?>
|
|
|
|
|
|
|
|
|
|
<?= $this->section('content') ?>
|
|
|
|
|
|
|
|
|
|
<style>
|
2025-01-28 14:57:55 +07:00
|
|
|
.pointercol {
|
2024-12-07 19:46:42 +08:00
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<div id='stats' class="d-flex justify-content-between p-0">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card border-0">
|
|
|
|
|
|
|
|
|
|
<!-- div.card-head -->
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
|
|
|
|
|
<div class="row d-flex align-items-center">
|
|
|
|
|
<div class="col col-auto">
|
|
|
|
|
<b>Date</b> : <input class='date1' type='date' value=''> - <input class='date2' type='date'>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col col-auto">
|
|
|
|
|
<button class='btn btn-sm btn-primary py-1 px-2 d-flex align-items-center' onclick='index()'><i class="bi bi-calendar2-event"></i> Search</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="table-responsive mt-3">
|
|
|
|
|
<table id="myTable" class="table table-hover">
|
2024-12-12 12:48:51 +08:00
|
|
|
<thead class='text-start'>
|
|
|
|
|
<th class='text-start' width="10%">Order Date</th>
|
|
|
|
|
<th width="12%">Patient#</th>
|
|
|
|
|
<th width="17%">Patient Name</th>
|
|
|
|
|
<th class='text-start' width="10%">Access#</th>
|
2025-03-12 23:09:53 +08:00
|
|
|
<th width="9%">Visit#</th>
|
2024-12-07 19:46:42 +08:00
|
|
|
<th>Test</th>
|
|
|
|
|
<th>Status</th>
|
|
|
|
|
<th></th>
|
|
|
|
|
</thead>
|
2024-12-12 12:48:51 +08:00
|
|
|
<tbody id="table-body" class='text-start'>
|
2024-12-07 19:46:42 +08:00
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="modal fade" id="modal" aria-hidden="true" tabindex="-1">
|
|
|
|
|
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?= $this->endSection() ?>
|
|
|
|
|
|
|
|
|
|
<?= $this->section('script') ?>
|
|
|
|
|
<script>
|
|
|
|
|
let curDate = new Date().toJSON().slice(0, 10);
|
|
|
|
|
$('.date1').val(curDate);
|
|
|
|
|
$('.date2').val(curDate);
|
2024-12-12 12:48:51 +08:00
|
|
|
index();
|
2024-12-07 19:46:42 +08:00
|
|
|
|
2024-12-08 16:53:13 +07:00
|
|
|
document.addEventListener('keydown', function(event) {
|
|
|
|
|
if (event.key === 'F5') { event.preventDefault(); index(); }
|
|
|
|
|
});
|
|
|
|
|
|
2024-12-07 19:46:42 +08:00
|
|
|
function index() {
|
|
|
|
|
let url = '<?=base_url('');?>api/dashboard/index';
|
|
|
|
|
date1 = $('.date1').val();
|
|
|
|
|
date2 = $('.date2').val();
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data : {date1:date1, date2:date2},
|
|
|
|
|
success: function(response) {
|
|
|
|
|
/*
|
|
|
|
|
// counter
|
|
|
|
|
*/
|
|
|
|
|
$("#stats").html("");
|
|
|
|
|
var stats = ['Pend', 'PartColl', 'Coll', 'PartRecv', 'Recv', 'Inc', 'PartVal', 'Comp'];
|
|
|
|
|
var statcolor = ['text-orange', 'text-peach', 'text-pink', 'text-soft-blue', 'text-blue', 'text-grey', 'text-soft-green', 'text-green'];
|
|
|
|
|
var staticon = ['bi-clock-history','bi-tv', 'bi-collection', 'bi-file-medical', 'bi-journal-medical', 'bi-calendar3-week', 'bi-check2', 'bi-clipboard-check'];
|
|
|
|
|
var stattext = ['Pending', 'Part Collected', 'Collected', 'Part Received', 'Received', 'Incomplete', 'Part Validated', 'Validated'];
|
|
|
|
|
var count = response['count'];
|
|
|
|
|
var statcontent = '';
|
|
|
|
|
stats.forEach ( (item, index) => {
|
|
|
|
|
//console.log(item + ' ' + index);
|
|
|
|
|
if(!count[item]) { count[item] = 0; }
|
2024-12-14 12:03:43 +08:00
|
|
|
statcontent += '<div class="custom-card shadow" data-filtertype="'+index+'">' +
|
2024-12-07 19:46:42 +08:00
|
|
|
'<div class="custom-card-content">' +
|
|
|
|
|
'<div class="row p-0 d-flex justify-content-between">' +
|
|
|
|
|
'<div class="col-3 text-start '+statcolor[index]+'"> <h5 class="m-0"><i class="bi '+staticon[index]+'"></i></h5> </div>' +
|
|
|
|
|
'<div class="col-9 text-end pe-3"> <h2 class="m-0 custom-card-title">'+count[item]+'</h2> </div>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
"<hr class='"+statcolor[index]+"'>" +
|
|
|
|
|
'<h3 class="custom-card-text m-0 p-0 '+statcolor[index]+'">'+ stattext[index] +'</h3>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
'</div>';
|
|
|
|
|
});
|
|
|
|
|
$("#stats").html(statcontent);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// table
|
|
|
|
|
*/
|
|
|
|
|
$("#myTable").DataTable().destroy();
|
|
|
|
|
$("#table-body").html("");
|
|
|
|
|
var data = response['data'];
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2025-01-28 14:57:55 +07:00
|
|
|
colldate = data[i].COLLECTIONDATE.slice(0,10);
|
|
|
|
|
colltime = data[i].COLLECTIONDATE.slice(10,16);
|
2024-12-26 10:44:41 +07:00
|
|
|
|
|
|
|
|
if (data[i].PATNUMBER != null) {
|
2025-03-12 23:10:34 +08:00
|
|
|
patnumber = data[i].PATNUMBER.replace(/^0+/, '');
|
|
|
|
|
// patnumber = data[i].PATNUMBER.substr(-16,16);
|
|
|
|
|
// patnumber = patnumber.substring(patnumber.length - 10);
|
2024-12-26 10:44:41 +07:00
|
|
|
} else {
|
|
|
|
|
patnumber = ' NULL ';
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 19:46:42 +08:00
|
|
|
accessnumber = data[i].SP_ACCESSNUMBER;
|
|
|
|
|
patname = data[i].NAME;
|
|
|
|
|
hon = data[i].HOSTORDERNUMBER;
|
2025-03-06 13:36:50 +07:00
|
|
|
let testing_test = "";
|
|
|
|
|
if (hon[0] === 'X' || hon[0] === 'Z') {
|
|
|
|
|
testing_test = "<div class='badge text-bg-warning'>testing tm</div><br>";
|
|
|
|
|
} else {
|
|
|
|
|
testing_test = "";
|
|
|
|
|
}
|
2024-12-07 19:46:42 +08:00
|
|
|
tests = data[i].TESTS;
|
|
|
|
|
stat = data[i].STATS;
|
|
|
|
|
if(stat == 'Pend') {
|
|
|
|
|
bgcolor = 'bg-orange';
|
|
|
|
|
datafilter = "data-filterrow='0'";
|
|
|
|
|
stattext = 'Pending';
|
|
|
|
|
} else if(stat == 'PartColl') {
|
|
|
|
|
bgcolor = 'bg-peach';
|
|
|
|
|
datafilter = "data-filterrow='1'";
|
|
|
|
|
stattext = 'Part Collected';
|
|
|
|
|
} else if(stat == 'Coll') {
|
|
|
|
|
bgcolor = 'bg-pink';
|
|
|
|
|
datafilter = "data-filterrow='2'";
|
|
|
|
|
stattext = 'Collected';
|
|
|
|
|
} else if(stat == 'PartRecv') {
|
|
|
|
|
bgcolor = 'bg-soft-blue';
|
2024-12-12 12:48:51 +08:00
|
|
|
datafilter = "data-filterrow='3'";
|
2024-12-07 19:46:42 +08:00
|
|
|
stattext = 'Part Received';
|
|
|
|
|
} else if(stat == 'Recv') {
|
|
|
|
|
bgcolor = 'bg-blue';
|
|
|
|
|
datafilter = "data-filterrow='4'";
|
|
|
|
|
stattext = 'Received';
|
|
|
|
|
} else if(stat == 'Inc') {
|
|
|
|
|
bgcolor = 'bg-grey';
|
|
|
|
|
datafilter = "data-filterrow='5'";
|
|
|
|
|
stattext = 'Incomplete';
|
|
|
|
|
} else if(stat == 'PartVal') {
|
|
|
|
|
bgcolor = 'bg-soft-green';
|
|
|
|
|
datafilter = "data-filterrow='6'";
|
|
|
|
|
stattext = 'Part Validated';
|
|
|
|
|
} else if(stat == 'Comp') {
|
|
|
|
|
bgcolor = 'bg-green';
|
|
|
|
|
datafilter = "data-filterrow='7'";
|
|
|
|
|
stattext = 'Validated';
|
|
|
|
|
}
|
2025-01-28 14:57:55 +07:00
|
|
|
let datarow = "<tr class='align-middle'" + datafilter +" >" +
|
2025-03-06 13:36:50 +07:00
|
|
|
"<td class='text-start'>" + colldate + '<br>'+ colltime +'</td> <td>' + patnumber + '</td> <td>' + patname.trim() + "</td> <td class='text-start' style='cursor: pointer;' ondblclick='copyToClipboard(this)'>" + accessnumber + "<br><span class='copy-message badge text-bg-success' style='display: none;'>Disalin</span>" +"</td> <td style='cursor: pointer;' ondblclick='copyToClipboard(this)'>" + testing_test + hon + "<br><span class='copy-message badge text-bg-success' style='display: none;'>Disalin</span></td> <td>" + tests + '</td>' +
|
2025-01-28 14:57:55 +07:00
|
|
|
"<td role='button' class='"+bgcolor+" text-center align-middle pointercol' onclick='viewAccess("+accessnumber+")'>"+stattext+"</td>" +
|
2024-12-08 15:14:05 +08:00
|
|
|
"<td role='button' class='text-center align-middle' onclick='resultPdfAccess("+accessnumber+ ",event" +")'> <h4 class='p-0 m-0'><i class='bi bi-filetype-pdf'></i></h4> </td>" +'</tr>';
|
2024-12-07 19:46:42 +08:00
|
|
|
$("#table-body").append(datarow);
|
|
|
|
|
}
|
2025-02-05 17:08:23 +07:00
|
|
|
$('#myTable').DataTable({
|
|
|
|
|
"pageLength": 25, // Ganti sesuai kebutuhan
|
|
|
|
|
"lengthMenu": [25, 50, 100] // Pilihan dropdown entries per halaman
|
|
|
|
|
});
|
2024-12-07 19:46:42 +08:00
|
|
|
|
|
|
|
|
// datatable filter
|
|
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
error: function(response) { console.log(response.responseJSON); }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function viewAccess(access) {
|
|
|
|
|
let url = '<?=base_url();?>sampling/dashboard/viewAccess/'+access;
|
|
|
|
|
$('.modal-content').load(url, function(){
|
|
|
|
|
$('#modal').modal('show');
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-12-08 15:14:05 +08:00
|
|
|
function resultPdfAccess(access, event) {
|
|
|
|
|
event.stopPropagation(); // Mencegah klik pada <tr> dieksekusi
|
2024-12-09 13:10:16 +07:00
|
|
|
let url = '<?=base_url();?>printResult/'+access;
|
2024-12-07 19:46:42 +08:00
|
|
|
window.open(url, '_blank');
|
|
|
|
|
}
|
2025-02-11 14:48:20 +07:00
|
|
|
function copyToClipboard(element) {
|
|
|
|
|
let text = element.innerText.trim(); // Ambil teks dari elemen
|
|
|
|
|
text = text.replace("Teks sudah disalin", "").trim(); // Hilangkan teks notifikasi sebelumnya
|
|
|
|
|
|
|
|
|
|
if (navigator.clipboard) {
|
|
|
|
|
navigator.clipboard.writeText(text).then(() => {
|
|
|
|
|
showCopyMessage(element);
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.error("Gagal menyalin teks: ", err);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Alternatif jika Clipboard API tidak didukung
|
|
|
|
|
let tempInput = document.createElement("textarea");
|
|
|
|
|
tempInput.value = text;
|
|
|
|
|
document.body.appendChild(tempInput);
|
|
|
|
|
tempInput.select();
|
|
|
|
|
document.execCommand("copy");
|
|
|
|
|
document.body.removeChild(tempInput);
|
|
|
|
|
|
|
|
|
|
showCopyMessage(element);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function showCopyMessage(element) {
|
|
|
|
|
let message = element.querySelector(".copy-message");
|
|
|
|
|
if (message) {
|
|
|
|
|
message.style.display = "inline"; // Tampilkan teks notifikasi
|
|
|
|
|
|
|
|
|
|
// Sembunyikan kembali setelah 2 detik
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
message.style.display = "none";
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-07 19:46:42 +08:00
|
|
|
</script>
|
|
|
|
|
<?= $this->endSection() ?>
|