86 lines
2.3 KiB
PHP
86 lines
2.3 KiB
PHP
<?= $this->extend('admin/layout') ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
<div class='container-fluid'>
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h5 class="card-title">LIS Requests</h5>
|
|
<form class="row g-2 align-items-center" id="myForm">
|
|
<div class="col-auto">
|
|
<label for="startDate" class="col-form-label">Date</label>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<input type="date" class="form-control form-control-sm" id="date1" name='date1'>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<span>-</span>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<input type="date" class="form-control form-control-sm" id="date2" name='date2'>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<button type="button" class="btn btn-sm btn-primary" onclick='searchRequests()'>Search</button>
|
|
</div>
|
|
</form>
|
|
|
|
<div class='table-responsive'>
|
|
<table class='table' id='dataTable'>
|
|
<thead>
|
|
<tr>
|
|
<th>Access#</th> <th>Pat#</th> <th>PatName</th> <th>Loc</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= $this->endSection() ?>
|
|
<?= $this->section('script') ?>
|
|
<script>
|
|
let curDate = new Date().toJSON().slice(0, 10);
|
|
$('#date1').val(curDate);
|
|
$('#date2').val(curDate);
|
|
|
|
function searchRequests() {
|
|
const form = document.getElementById('myForm');
|
|
const formData = new FormData(form);
|
|
|
|
const tableBody = document.getElementById('dataTable').getElementsByTagName('tbody')[0];
|
|
tableBody.innerHTML = '';
|
|
|
|
let url = '<?=base_url('');?>admin/api/LISRequests';
|
|
|
|
fetch(url, {
|
|
method: 'POST',
|
|
body: formData
|
|
}).then(response => {
|
|
if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); }
|
|
return response.json();
|
|
}).then(data => {
|
|
data.data.forEach(item => {
|
|
const row = `<tr> <td>${item.SP_ACCESSNUMBER}<br/>HON : ${item.HOSTORDERNUMBER}</td> <td>${item.name}</td> <td>${item.price}</td> </tr>`;
|
|
tableBody.insertAdjacentHTML('beforeend', row);
|
|
})
|
|
});
|
|
/*
|
|
data.forEach(rowData => {
|
|
const row = tableBody.insertRow();
|
|
for (const key in rowData) {
|
|
if (rowData.hasOwnProperty(key)) {
|
|
const cell = row.insertCell();
|
|
cell.textContent = rowData[key];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
*/
|
|
}
|
|
</script>
|
|
<?= $this->endSection() ?>
|