pbmc-cmod/app/Views/fo/dashboard_viewAccess.php

226 lines
7.7 KiB
PHP
Raw Normal View History

<?php
if(isset($data[0])) {
$row = $data[0];
$patnumber = $row['PATNUMBER'];
$host = $row['HOSTORDERNUMBER'];
$name = $row['NAME'];
?>
2024-11-25 16:52:52 +07:00
<div class="modal-header bg-soft-green text-white">
<h1 class="modal-title fs-5" id="exampleModalToggleLabel">Detail Request </h1>
2024-11-25 16:52:52 +07:00
<button type="button" class="btn-close text-white" data-bs-dismiss="modal" ></button>
</div>
2024-11-13 10:54:24 +07:00
<div class="modal-body" style='background-color:#F4F6FF'>
<div class="row">
2024-11-25 13:20:36 +07:00
<div class="col">
2024-11-13 10:54:24 +07:00
<table class="table table-sm table-borderless">
<tr> <th>Access#</th> <th>:</th> <td><?=$accessnumber;?></td> </tr>
2024-11-25 13:20:36 +07:00
<tr> <th>Patient</th> <th>:</th> <td><?=$patnumber;?> - <?=$name;?></td> </tr>
</table>
</div>
2024-11-13 10:54:24 +07:00
</div>
<div class='row'>
<div class="col-12">
2024-11-13 10:54:24 +07:00
<div class="card bg-white">
<div class="card-body">
2024-11-12 16:45:01 +07:00
<div class="card-title"><h3>Sample List</h3></div>
<table class='table'>
2024-11-13 16:48:53 +07:00
<tr> <th class='text-center'>Coll.</th> <th class='text-center'>Recv.</th> <th>Sample Name</th> <th>Action</th> <th>Comment</th> </tr>
<tr>
<td></td> <td></td> <td>All</td>
<td>
<button type='button' class='btn btn-dark m-0 px-2 py-1' onclick='printAllLabel()'> <h6 class='p-0 m-0'><i class='bi bi-printer'></i></h6> </button>
<button type='button' class='btn btn-success m-0 px-2 py-1' onclick='collectAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Coll.</h6></button>
<!-- <button class='badge bg-black text-white m-0 px-2 py-1' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</button> -->
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceiveAll(<?=$accessnumber;?>)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
</td>
</tr>
<tr>
<td></td> <td></td> <td>Collection</td>
<td><button type='button' class='btn btn-dark m-0 px-2 py-1'><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
</tr>
<?php
foreach($data as $row) {
$sampletype = $row['SAMPLETYPE'];
$sampletext = $row['SHORTTEXT'];
$tubestatus = $row['TUBESTATUS'];
$collstatus = $row['COLLSTATUS'];
2024-11-13 16:48:53 +07:00
$comment = $row['TUBECOMMENT'];
2024-11-12 16:45:01 +07:00
echo "\r\n <tr>";
2024-11-13 10:54:24 +07:00
if($collstatus==1) {
echo " <td class='text-center'><input type='checkbox' class='form-check-input' id='coll$sampletype' checked disabled></td>";
} else {
echo " <td class='text-center'><input type='checkbox' class='form-check-input' id='coll$sampletype' disabled></td>";
}
if($tubestatus==4) {
echo "<td class='text-center'><input type='checkbox' class='form-check-input' id='recv$sampletype' checked disabled></td>";
} else {
echo "<td class='text-center'><input type='checkbox' class='form-check-input' id='recv$sampletype' disabled></td>";
}
2024-11-12 16:45:01 +07:00
echo "<td>$sampletext</td>";
2024-11-13 10:54:24 +07:00
echo "<td>
<button type='button' class='btn btn-dark m-0 px-2 py-1' onclick='printSingleLabel($sampletype, $accessnumber)'><h6 class='p-0 m-0'><i class='bi bi-printer'></i></h6></button>
<button type='button' class='btn btn-success m-0 px-2 py-1' onclick='collect($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Coll.</h6></button>
<button type='button' class='btn btn-warning m-0 px-2 py-1' onclick='uncollect($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Un-Coll.</h6></button>
<button type='button' class='btn btn-primary m-0 px-2 py-1' onclick='unreceive($sampletype, $accessnumber)'><h6 class='p-0 m-0'>Un-Rec.</h6></button>
2024-11-12 16:45:01 +07:00
</td> ";
echo "<td id='comment$sampletype'>$comment <h6 class='p-0 m-0'><i class='bi bi-pencil-square' role='button' onclick='comment($sampletype, $accessnumber, \"$sampletext\", \"$comment\")'></i></h6></td>";
2024-11-12 16:45:01 +07:00
echo " </tr>";
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
2024-11-13 10:54:24 +07:00
<script>
function printSingleLabel(sample, access) {
const url = '<?=base_url();?>prints/single_sample/'+access.toString()+'/'+sample.toString();
fetch(url)
.then(response => response.json()) // Mengonversi response menjadi JSON (atau gunakan .text() jika formatnya teks)
.then(data => {
if (data['status']) {
console.log(data['message']);
} else {
console.log(data['message']+"\n"+data['error']);
message = data['message']+"\n"+data['error'];
alert(message);
}
})
.catch(error => {
console.error('Error:', error);
});
}
function printAllLabel() {
const url = '<?=base_url();?>prints/all_sample';
fetch(url)
.then(response => response.json()) // Mengonversi response menjadi JSON (atau gunakan .text() jika formatnya teks)
.then(data => {
if (data['status']) {
console.log(data['message']);
} else {
console.log(data['message']+"\n"+data['error']);
message = data['message']+"\n"+data['error'];
alert(message);
}
})
.catch(error => {
console.error('Error:', error);
});
}
2024-11-13 10:54:24 +07:00
function collect(sample, access) {
2024-11-13 16:48:53 +07:00
sample = sample.toString().padStart(3,'0');
2024-11-13 10:54:24 +07:00
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;
2024-11-13 16:48:53 +07:00
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$("#coll"+sample).prop("checked", true);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
2024-11-13 10:54:24 +07:00
}
function collectAll(access) {
const url = '<?=base_url();?>tubes/collectAll/'+access;
2024-11-13 16:48:53 +07:00
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$('input[id^="coll"]').prop('checked', true);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
}
function uncollect(sample, access) {
sample = sample.toString().padStart(3,'0');
const url = '<?=base_url();?>tubes/uncollect/'+access+'/'+sample;
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$("#coll"+sample).prop("checked", false);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
}
function uncollectAll(access) {
const url = '<?=base_url();?>tubes/uncollectAll/'+access;
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$('input[id^="coll"]').prop('checked', false);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
}
function unreceive(sample, access) {
sample = sample.toString().padStart(3,'0');
const url = '<?=base_url();?>tubes/unreceive/'+access+'/'+sample;
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$("#recv"+sample).prop("checked", false);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
}
function unreceiveAll(access) {
const url = '<?=base_url();?>tubes/unreceiveAll/'+access;
fetch(url)
.then(data => {
2024-11-21 15:38:56 +07:00
//console.log(data);
//$('input[id^="recv"]').prop('checked', false);
viewAccess(access);
2024-11-25 13:20:36 +07:00
index();
2024-11-13 16:48:53 +07:00
})
.catch(error => { console.error('Error:',error); });
}
function comment(sample, access, sampletext, comments) {
const url = '<?=base_url();?>tubes/comment/'+access+'/'+sample;
2024-11-21 15:38:56 +07:00
let comment = prompt('Comment for sample '+sampletext, comments);
//$('#comment'+sample).html(comment +"<i class='bi bi-pencil-square' onclick='comment("+ sample +", "+ access +', "'+sampletext+'", "'+comment+'")\'></i>');
fetch(url, {
method: "POST",
body: JSON.stringify({ comment : comment }),
headers: { "Content-type": "application/json; charset=UTF-8" }
}).then(data => {
//console.log(data);
viewAccess(access);
})
.catch(error => { console.error('Error:',error); });
2024-11-13 10:54:24 +07:00
}
</script>
<?php
} else {
?>
<div class="modal-header bg-black text-white">
<h1 class="modal-title fs-5" id="exampleModalToggleLabel">Detail Request </h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" ></button>
</div>
<div class="modal-body">
<h3>Data not found</h3>
</div>
<?php
}
?>