make dashboard json
This commit is contained in:
parent
909ca1dbc2
commit
ffeb285293
@ -52,8 +52,8 @@ end STATS
|
||||
order by sr.COLLECTIONDATE desc";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
|
||||
$data['data'] = $results;
|
||||
$data['count'] = array_count_values(array_column($results, 'STATS'));
|
||||
return $this->respond($data,200);
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,10 @@ class Tubes extends BaseController {
|
||||
public function collect($access, $sample) {
|
||||
$userid = session()->userid;
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "if (not exists (select * from cmod.dbo.CM_TUBES where ACCESSNUMBER='$access' )) BEGIN
|
||||
INSERT INTO cmod.dbo.CM_TUBES(ACCESSNUMBER, SAMPLETYPE, CREATEDATE) select SP_ACCESSNUMBER, SAMPLETYPE, GETDATE() from SP_TUBES where SP_ACCESSNUMBER='$access'
|
||||
END";
|
||||
$query = $db->query($sql);
|
||||
$sql = "if (not exists (select * from cmod.dbo.CM_TUBES where ACCESSNUMBER='$access' AND SAMPLETYPE='$sample')) BEGIN
|
||||
INSERT INTO cmod.dbo.CM_TUBES(ACCESSNUMBER, SAMPLETYPE, COLLECTIONDATE, COLL_USERID, COLLSTATUS, CREATEDATE) VALUES ('$access','$sample', GETDATE(), '$userid', 1, GETDATE())
|
||||
END ELSE BEGIN
|
||||
|
||||
@ -90,15 +90,13 @@
|
||||
<div class="table-responsive">
|
||||
<table id="myTable" class="table">
|
||||
<thead>
|
||||
<tr >
|
||||
<th>Order</th>
|
||||
<th>MR</th>
|
||||
<th>Patient</th>
|
||||
<th>Request</th>
|
||||
<th>Hosp</th>
|
||||
<th>Test</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
<th>Order</th>
|
||||
<th>MR</th>
|
||||
<th>Patient</th>
|
||||
<th>Request</th>
|
||||
<th>Hosp</th>
|
||||
<th>Test</th>
|
||||
<th>Status</th>
|
||||
</thead>
|
||||
<tbody id="table-body">
|
||||
</tbody>
|
||||
@ -118,7 +116,6 @@
|
||||
|
||||
<?= $this->section('script') ?>
|
||||
<script>
|
||||
var tb = $('#myTable').DataTable();
|
||||
index();
|
||||
function index() {
|
||||
let url = '<?=base_url('');?>api/dashboard/index';
|
||||
@ -126,6 +123,8 @@ function index() {
|
||||
url: url,
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
// counter jaka yang ngerjakan
|
||||
// table
|
||||
$("#table-body").html("");
|
||||
var data = response['data'];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
@ -136,20 +135,37 @@ function index() {
|
||||
hon = data[i].HOSTORDERNUMBER;
|
||||
tests = data[i].TESTS;
|
||||
stats = data[i].STATS;
|
||||
if(stats == 'Pend') { statsTD = "<td role='button' class='bg-orange text-center align-middle' onclick='viewAccess("+accessnumber+")'>Pending</td>"; }
|
||||
else if(stats == 'PartColl') { statsTD = "<td role='button' class='bg-peach text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Collected</td>"; }
|
||||
else if(stats == 'PartRecv') { statsTD = "<td role='button' class='bg-soft-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Received</td>"; }
|
||||
else if(stats == 'PartVal') { statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Validated</td>"; }
|
||||
else if(stats == 'Coll') { statsTD = "<td role='button' class='bg-pink text-center align-middle' onclick='viewAccess("+accessnumber+")'>Collected</td>"; }
|
||||
else if(stats == 'Recv') { statsTD = "<td role='button' class='bg-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Received</td>"; }
|
||||
else if(stats == 'Inc') { statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Incomplete</td>"; }
|
||||
else if(stats == 'Comp') { statsTD = "<td role='button' class='bg-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Validated</td>"; }
|
||||
let datarow = '<tr class="align-middle">' +
|
||||
if(stats == 'Pend') {
|
||||
statsTD = "<td role='button' class='bg-orange text-center align-middle' onclick='viewAccess("+accessnumber+")'>Pending</td>";
|
||||
datafilter = "data-filterrow='1'";
|
||||
} else if(stats == 'PartColl') {
|
||||
statsTD = "<td role='button' class='bg-peach text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Collected</td>";
|
||||
datafilter = "data-filterrow='2'";
|
||||
} else if(stats == 'Coll') {
|
||||
statsTD = "<td role='button' class='bg-pink text-center align-middle' onclick='viewAccess("+accessnumber+")'>Collected</td>";
|
||||
datafilter = "data-filterrow='3'";
|
||||
} else if(stats == 'PartRecv') {
|
||||
statsTD = "<td role='button' class='bg-soft-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Received</td>";
|
||||
datafilter = "data-filterrow='4'";
|
||||
} else if(stats == 'Recv') {
|
||||
statsTD = "<td role='button' class='bg-blue text-center align-middle' onclick='viewAccess("+accessnumber+")'>Received</td>";
|
||||
datafilter = "data-filterrow='5'";
|
||||
} else if(stats == 'Inc') {
|
||||
statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Incomplete</td>";
|
||||
datafilter = "data-filterrow='6'";
|
||||
} else if(stats == 'PartVal') {
|
||||
statsTD = "<td role='button' class='bg-soft-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Partial Validated</td>";
|
||||
datafilter = "data-filterrow='7'";
|
||||
} else if(stats == 'Comp') {
|
||||
statsTD = "<td role='button' class='bg-green text-center align-middle' onclick='viewAccess("+accessnumber+")'>Validated</td>";
|
||||
datafilter = "data-filterrow='8'";
|
||||
}
|
||||
let datarow = '<tr class="align-middle" ' + datafilter + ' >' +
|
||||
'<td>' + colldate + '</td> <td>' + patnumber + '</td> <td>' + accessnumber + '</td> <td>' + patname + '</td> <td>' + hon + '</td> <td>' + tests + '</td>' +
|
||||
statsTD + '</tr>';
|
||||
$("#table-body").append(datarow);
|
||||
}
|
||||
tb.ajax.reload();
|
||||
$('#myTable').DataTable();
|
||||
},
|
||||
error: function(response) { console.log(response.responseJSON); }
|
||||
});
|
||||
|
||||
@ -79,8 +79,6 @@
|
||||
|
||||
<?= $this->section('script') ?>
|
||||
<script>
|
||||
var tb = $('#mytable').DataTable();
|
||||
|
||||
index();
|
||||
function index() {
|
||||
let url = '<?=base_url('');?>api/users/index';
|
||||
@ -103,7 +101,7 @@ function index() {
|
||||
'</tr>';
|
||||
$("#table-body").append(datarow);
|
||||
}
|
||||
tb.ajax.reload();
|
||||
$('#myTable').DataTable();
|
||||
},
|
||||
error: function(response) { console.log(response.responseJSON); }
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user