gdc_cmod/app/Views/admin/index.php
2025-11-18 16:20:31 +07:00

231 lines
10 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>S</th>
<th style='width:7%;'>Order Datetime</th>
<th>Patient Name</th>
<th>No Lab</th>
<th>No Register</th>
<th style='width:10%;'>Reff</th>
<th>Doctor</th>
<th style='width:10%;'>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:6%;'></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;
}
?>
<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> <?= esc($row['tests']) ?> </td> <td> <?= esc($row['odr_cresult_to']) ?> </td>
<td> <h6> <span class="px-3 py-2 badge text-success border border-success bg-success-subtle"> <?=$row['val'];?> </span> </h6>
<a href="#" class="text-primary">Result</a><br> <a href="#" class="text-primary" disabled>Invalidation</a><br>
</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="text-primary">Preview</a> <br/>
<a href="#" class="text-danger">Print</a> | <a href="#" class="text-danger">Eng</a> <br/>
<a href="#" class="text-primary">Pdf</a>
</td>
<td> <input type="checkbox" name="printed"> Printed<br> <input type="checkbox" name="hardcopy"> Hardcopy </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: '75vh',
columnDefs: [{
className: 'text-center',
targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
}, // semua kolom di tengah
{
className: 'text-start',
targets: [12]
}
],
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();
});
});
// 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() ?>