295 lines
13 KiB
PHP
295 lines
13 KiB
PHP
<?= $this->extend('_layouts/main.php') ?>
|
|
|
|
<?= $this->section('title') ?>
|
|
<title>Admin Glenlis</title>
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
|
|
<div class="container-fluid px-3">
|
|
<div class='row p-1'>
|
|
<div class='col fw-bold'>Dashboard</div>
|
|
<div class='col text-end'>
|
|
Hi, <?=session('userid');?>
|
|
<button class="btn btn-sm btn-secondary" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-list"></i></button>
|
|
<div class="dropdown">
|
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
|
|
<li><a class="dropdown-item" href="<?=base_url('admin/');?>">Dashboard</a></li>
|
|
<li><a class="dropdown-item" href="<?=base_url('');?>">Report</a></li>
|
|
<li><a class="dropdown-item" href="<?=base_url('admin/user');?>">User</a></li>
|
|
<li><a class="dropdown-item" href="<?=base_url('logout');?>">Log Out</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class='col'>
|
|
<form method="GET" action='<?= base_url('/admin') ?>'>
|
|
<div class="row align-items-center g-1">
|
|
<div class="col-auto fw-semibold text-muted">
|
|
Date :
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<input type="date" class="form-control form-control-sm" name="date1"
|
|
value="<?php echo $date1; ?>" />
|
|
</div>
|
|
|
|
<div class="col-auto">-</div>
|
|
|
|
<div class="col-auto">
|
|
<input type="date" class="form-control form-control-sm" name="date2"
|
|
value="<?php echo $date2; ?>" />
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<button type="submit" class="btn btn-sm btn-primary">Search</button>
|
|
</div>
|
|
|
|
<div class="col-auto"> <button type="button" class="btn btn-sm btn-outline-dark" onclick="window.location.href='<?=base_url();?>';"> RESET </button> </div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div id="filterGroup" class="col text-end">
|
|
<button class='btn btn-sm btn-outline-secondary' data-type='secondary'><?=$counter['pending'];?> <small>Pending</small></button>
|
|
<button class='btn btn-sm btn-outline-info' data-type='info'><?=$counter['collect'];?> <small>Collect</small></button>
|
|
<button class='btn btn-sm btn-outline-primary' data-type='primary'><?=$counter['recv'];?> <small>Receive</small></button>
|
|
<button class='btn btn-sm btn-outline-warning' data-type='warning'><?=$counter['incomplete'];?> <small>Incomplete</small></button>
|
|
<button class='btn btn-sm btn-outline-success' data-type='success'><?=$counter['complete'];?> <small>Complete</small></button>
|
|
<button class='btn btn-sm btn-dark' data-type='dark'><?=$counter['total'];?> <small>Total</small></button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table table-responsive-scroll">
|
|
<table id="datatables" class="table table-sm table-hover table-bordered align-middle table-striped">
|
|
<thead class="table-primary">
|
|
<tr>
|
|
<th style="width:1%;">S</th>
|
|
<th style='width:7%;'>Order Datetime</th>
|
|
<th>Patient Name</th>
|
|
<th style='width:7%;'>No Lab</th>
|
|
<th style='width:7%;'>No Register</th>
|
|
<th style='width:8%;'>Reff</th>
|
|
<th style='width:8%;'>Doctor</th>
|
|
<th style='width:15%;'>Tests</th>
|
|
<th style='width:5%;'>Result To</th>
|
|
<th style='width:10%;'>Validation</th>
|
|
<th style='width:4%;'>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach($dataList as $row) : ?>
|
|
<?php
|
|
switch ($row['statscode']) {
|
|
case 1: $class = 'BackPend'; break;
|
|
case 2: $class = 'PartColl'; break;
|
|
case 3: $class = 'Collected'; break;
|
|
case 4: $class = 'PartRecv'; break;
|
|
case 5: $class = 'Received'; break;
|
|
case 6: $class = 'Incomplete'; break;
|
|
case 7: $class = 'Final'; break;
|
|
case 8: $class = 'FinVerification'; break;
|
|
case 9: $class = 'PenVerification'; break;
|
|
default: $class = ''; break;
|
|
}
|
|
$tests = esc($row['tests']);
|
|
$tests = str_replace(",", ", ", $tests);
|
|
?>
|
|
<tr>
|
|
<!--
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['statscode']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['reqdate']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['patname']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['sp_accessnumber']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['hostordernumber']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['reff']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['doc']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['tests']) ?> </td>
|
|
<td class="pointercol" data-access="<?= $row['sp_accessnumber'] ?>" data-bs-toggle="modal" data-bs-target="#detailModal"> <?= esc($row['odr_cresult_to']) ?> </td>
|
|
-->
|
|
<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']) ?> <br/>
|
|
<input type="checkbox" name="printed"> Printed
|
|
</td>
|
|
<td data-acc="<?=$row['sp_accessnumber'];?>">
|
|
<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>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<!-- Modal Specimen Collection-->
|
|
<div class="modal fade" id="detailModal" aria-hidden="true" aria-labelledby="detailModal" tabindex="-1">
|
|
<div class="modal-dialog modal-xl modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title fw-bold fs-4" id="detailModal">Specimen Collection</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body" id="modalContent"> </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('script') ?>
|
|
<script>
|
|
$(document).ready(function () {
|
|
table = $('#datatables').DataTable({
|
|
layout: {
|
|
topEnd: 'search',
|
|
bottomStart: null, bottomEnd: null
|
|
},
|
|
order: [[0, 'asc'], [3, 'asc']],
|
|
paging: false,
|
|
scrollCollapse: true,
|
|
scrollY: '70vh',
|
|
columnDefs: [{
|
|
className: 'text-center',
|
|
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
}, // semua kolom di tengah
|
|
{
|
|
className: 'text-start',
|
|
targets: [10]
|
|
}
|
|
],
|
|
responsive: true,
|
|
});
|
|
|
|
$('#filterGroup .btn').on('click', function () {
|
|
$('#filterGroup .btn').each(function () {
|
|
const type = $(this).data('type');
|
|
$(this).removeClass(`btn-${type}`).addClass(`btn-outline-${type}`);
|
|
});
|
|
|
|
const type = $(this).data('type');
|
|
$(this).removeClass(`btn-outline-${type}`).addClass(`btn-${type}`);
|
|
let vals;
|
|
if(type=='secondary') { vals = [0]; }
|
|
if(type=='info') { vals = ['1','2']; }
|
|
if(type=='primary') { vals = ['3','4','5']; }
|
|
if(type=='warning') { vals = [6,7]; }
|
|
if(type=='success') { vals = [8]; }
|
|
if(type=='dark') {vals=[];}
|
|
regex = vals.join('|');
|
|
table.column(0).search(regex, true, false).draw();
|
|
});
|
|
|
|
});
|
|
|
|
function invalidate(accessnumber) {
|
|
if(confirm("Are you sure?")) {
|
|
$.get(`<?=base_url('admin/result/invalidate/');?>/${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: `<?=base_url('api/specimen/collect');?>/${accessnumber}`,
|
|
type: "POST",
|
|
contentType: "application/json; charset=utf-8",
|
|
dataType: "json",
|
|
data: JSON.stringify({ samplenumber:samplenumber, status:status, userid:"<?=session('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: `<?=base_url('api/specimen/unreceive');?>/${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() {
|
|
const input = prompt("Masukkan Komentar :");
|
|
}
|
|
|
|
// Untuk Detail
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const modal = document.getElementById('detailModal');
|
|
const modalContent = document.getElementById('modalContent');
|
|
document.querySelectorAll('.pointercol').forEach(td => {
|
|
td.addEventListener('click', async function () {
|
|
const access = this.dataset.access;
|
|
modalContent.innerHTML =
|
|
"<p class='text-center text-muted'>Loading data...</p>";
|
|
try {
|
|
$.getJSON(`<?=base_url();?>api/specimen/${access}`, function(data) {
|
|
$.get(`<?=base_url('admin/modal_specimen');?>`, function(tpl) {
|
|
data.samples = data.samples.map(s => ({
|
|
...s,
|
|
is_coll: s.colstatus == 1,
|
|
is_recv: s.tubestatus == 4
|
|
}));
|
|
console.log(data);
|
|
const html = Mustache.render(tpl, data);
|
|
modalContent.innerHTML=html;
|
|
});
|
|
});
|
|
} catch (err) {
|
|
modalContent.innerHTML = "<p class='text-danger text-center'>Gagal memuat data.</p>";
|
|
console.error(err);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<?= $this->endSection() ?>
|