fix dashboard to API
This commit is contained in:
parent
7a4491c037
commit
748e7a04bc
@ -5,8 +5,6 @@ use CodeIgniter\Router\RouteCollection;
|
|||||||
/**
|
/**
|
||||||
* @var RouteCollection $routes
|
* @var RouteCollection $routes
|
||||||
*/
|
*/
|
||||||
$routes->get('/', 'Dashboard::index');
|
|
||||||
$routes->get('/dashboard/viewAccess/(:any)', 'Dashboard::viewAccess/$1');
|
|
||||||
|
|
||||||
// Tubes
|
// Tubes
|
||||||
$routes->get('/tubes/collect/(:any)/(:any)', 'Tubes::collect/$1/$2');
|
$routes->get('/tubes/collect/(:any)/(:any)', 'Tubes::collect/$1/$2');
|
||||||
@ -18,10 +16,15 @@ $routes->get('/tubes/unreceiveAll/(:any)', 'Tubes::unreceiveAll/$1');
|
|||||||
$routes->post('/tubes/comment/(:any)/(:any)', 'Tubes::comment/$1/$2');
|
$routes->post('/tubes/comment/(:any)/(:any)', 'Tubes::comment/$1/$2');
|
||||||
|
|
||||||
// Pages
|
// Pages
|
||||||
|
$routes->get('/', 'Pages::dashboard_index');
|
||||||
$routes->get('/userroles/', 'Pages::userroles_index');
|
$routes->get('/userroles/', 'Pages::userroles_index');
|
||||||
$routes->get('/users/', 'Pages::users_index');
|
$routes->get('/users/', 'Pages::users_index');
|
||||||
$routes->get('/changePass/', 'Pages::changePass');
|
$routes->get('/changePass/', 'Pages::changePass');
|
||||||
|
|
||||||
|
$routes->get('/dashboard/viewAccess/(:any)', 'Dashboard::viewAccess/$1');
|
||||||
|
// Dashboard
|
||||||
|
$routes->get('/api/dashboard/index', 'Dashboard::index');
|
||||||
|
|
||||||
// DICT_TESTS
|
// DICT_TESTS
|
||||||
$routes->get('/dict_tests/', 'Dict_tests::index');
|
$routes->get('/dict_tests/', 'Dict_tests::index');
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
class Dashboard extends BaseController {
|
use CodeIgniter\RESTful\ResourceController;
|
||||||
|
|
||||||
|
class Dashboard extends ResourceController {
|
||||||
|
protected $format = 'json';
|
||||||
|
|
||||||
public function index(): string {
|
public function index() {
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$sql = "select top 50 sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, p.NAME,
|
$sql = "select top 50 sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, p.NAME,
|
||||||
TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from
|
TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from
|
||||||
@ -50,9 +52,9 @@ end STATS
|
|||||||
order by sr.COLLECTIONDATE desc";
|
order by sr.COLLECTIONDATE desc";
|
||||||
$query = $db->query($sql);
|
$query = $db->query($sql);
|
||||||
$results = $query->getResultArray();
|
$results = $query->getResultArray();
|
||||||
$data['data'] = $results;
|
|
||||||
|
|
||||||
return view('dashboard', $data);
|
$data['data'] = $results;
|
||||||
|
return $this->respond($data,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viewAccess($accessnumber): string {
|
public function viewAccess($accessnumber): string {
|
||||||
|
|||||||
@ -4,6 +4,10 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
class Pages extends BaseController {
|
class Pages extends BaseController {
|
||||||
|
|
||||||
|
public function dashboard_index() {
|
||||||
|
return view('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
public function userroles_index(): string {
|
public function userroles_index(): string {
|
||||||
return view('userroles_index');
|
return view('userroles_index');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
<?= $this->extend('layouts/main.php') ?>
|
<?= $this->extend('layouts/main.php') ?>
|
||||||
|
|
||||||
<?= $this->section('content') ?>
|
<?= $this->section('content') ?>
|
||||||
<style>
|
|
||||||
#table_dashboard tr { cursor: pointer; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<div class="d-flex justify-content-between p-0">
|
<div class="d-flex justify-content-between p-0">
|
||||||
@ -91,9 +88,9 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<div class="card border-0">
|
<div class="card border-0">
|
||||||
<div class="body-card">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="table_dashboard" class="table">
|
<table id="myTable" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr >
|
<tr >
|
||||||
<th>Order</th>
|
<th>Order</th>
|
||||||
@ -105,28 +102,7 @@
|
|||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody id="table-body">
|
||||||
<?php
|
|
||||||
$i = 1;
|
|
||||||
foreach ($data as $row) {
|
|
||||||
$colldate = $row['COLLECTIONDATE'];
|
|
||||||
$colldate = substr($colldate,0,10);
|
|
||||||
$patnumber = $row['PATNUMBER'];
|
|
||||||
$patnumber = substr($patnumber,-16);
|
|
||||||
$accessnumber = $row['SP_ACCESSNUMBER'];
|
|
||||||
?>
|
|
||||||
<tr class="table-row viewAccess" data-bs-toggle="modal" data-bs-target="#modal" data-access='<?=$accessnumber;?>'>
|
|
||||||
<td class="text-start text-nowrap"><?=$colldate;?></td>
|
|
||||||
<td class="text-start text-nowrap"><?=$patnumber;?></td>
|
|
||||||
<td class="text-start"><?=$row['NAME'];?></td>
|
|
||||||
<td class="text-start"><?=$accessnumber;?></td>
|
|
||||||
<td class="text-start"><?=$row['HOSTORDERNUMBER'];?></td>
|
|
||||||
<td class="text-start"><?=$row['TESTS'];?></td>
|
|
||||||
<td class="bg-orange text-center align-middle">Pending</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -144,18 +120,41 @@
|
|||||||
|
|
||||||
<?= $this->section('script') ?>
|
<?= $this->section('script') ?>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
var tb = $('#mytable').DataTable();
|
||||||
$('#table_dashboard').DataTable({
|
index();
|
||||||
order: [],
|
function index() {
|
||||||
pageLength: 25
|
let url = '<?=base_url('');?>api/dashboard/index';
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
method: 'GET',
|
||||||
|
success: function(response) {
|
||||||
|
$("#table-body").html("");
|
||||||
|
var data = response['data'];
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
colldate = data[i].COLLECTIONDATE.substr(0,10);
|
||||||
|
patnumber = data[i].PATNUMBER.substr(-16,16);
|
||||||
|
accessnumber = data[i].SP_ACCESSNUMBER;
|
||||||
|
patname = data[i].NAME;
|
||||||
|
hon = data[i].HOSTORDERNUMBER;
|
||||||
|
tests = data[i].TESTS;
|
||||||
|
let datarow = '<tr class="align-middle">' +
|
||||||
|
'<td>' + colldate + '</td> <td>' + patnumber + '</td> <td>' + accessnumber + '</td> <td>' + patname + '</td> <td>' + hon + '</td> <td>' + tests + '</td>' +
|
||||||
|
"<td role='button' class='bg-orange text-center align-middle' onclick='viewAccess("+accessnumber+")'>Pending</td>"
|
||||||
|
'</tr>';
|
||||||
|
$("#table-body").append(datarow);
|
||||||
|
}
|
||||||
|
tb.ajax.reload();
|
||||||
|
},
|
||||||
|
error: function(response) { console.log(response.responseJSON); }
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
$('.viewAccess').on('click',function(){
|
function viewAccess(access) {
|
||||||
const access = $(this).data('access');
|
let url = '<?=base_url();?>dashboard/viewAccess/'+access;
|
||||||
$('.modal-content').load('<?=base_url();?>dashboard/viewAccess/'+access, function(){
|
$('.modal-content').load(url, function(){
|
||||||
$('#modal').modal('show');
|
$('#modal').modal('show');
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -59,7 +59,7 @@ span.badge { cursor:pointer; }
|
|||||||
<span class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</span>
|
<span class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</span>
|
||||||
<span class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</span>
|
<span class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</span>
|
||||||
</td> ";
|
</td> ";
|
||||||
echo "<td id='comment$sampletype'>$comment <i class='bi bi-pencil-square' onclick='comment($sampletype, $accessnumber, \"$sampletext\", \"$comment\")'></i></td>";
|
echo "<td id='comment$sampletype'>$comment <i class='bi bi-pencil-square' role='button' onclick='comment($sampletype, $accessnumber, \"$sampletext\", \"$comment\")'></i></td>";
|
||||||
echo " </tr>";
|
echo " </tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -88,8 +88,9 @@ function collect(sample, access) {
|
|||||||
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;
|
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$("#coll"+sample).prop("checked", true);
|
//$("#coll"+sample).prop("checked", true);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
}
|
}
|
||||||
@ -98,8 +99,9 @@ function collectAll(access) {
|
|||||||
const url = '<?=base_url();?>tubes/collectAll/'+access;
|
const url = '<?=base_url();?>tubes/collectAll/'+access;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$('input[id^="coll"]').prop('checked', true);
|
//$('input[id^="coll"]').prop('checked', true);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
|
|
||||||
@ -110,8 +112,9 @@ function uncollect(sample, access) {
|
|||||||
const url = '<?=base_url();?>tubes/uncollect/'+access+'/'+sample;
|
const url = '<?=base_url();?>tubes/uncollect/'+access+'/'+sample;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$("#coll"+sample).prop("checked", false);
|
//$("#coll"+sample).prop("checked", false);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
|
|
||||||
@ -121,8 +124,9 @@ function uncollectAll(access) {
|
|||||||
const url = '<?=base_url();?>tubes/uncollectAll/'+access;
|
const url = '<?=base_url();?>tubes/uncollectAll/'+access;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$('input[id^="coll"]').prop('checked', false);
|
//$('input[id^="coll"]').prop('checked', false);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
}
|
}
|
||||||
@ -132,8 +136,9 @@ function unreceive(sample, access) {
|
|||||||
const url = '<?=base_url();?>tubes/unreceive/'+access+'/'+sample;
|
const url = '<?=base_url();?>tubes/unreceive/'+access+'/'+sample;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$("#recv"+sample).prop("checked", false);
|
//$("#recv"+sample).prop("checked", false);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
|
|
||||||
@ -143,25 +148,26 @@ function unreceiveAll(access) {
|
|||||||
const url = '<?=base_url();?>tubes/unreceiveAll/'+access;
|
const url = '<?=base_url();?>tubes/unreceiveAll/'+access;
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
$('input[id^="recv"]').prop('checked', false);
|
//$('input[id^="recv"]').prop('checked', false);
|
||||||
|
viewAccess(access);
|
||||||
})
|
})
|
||||||
.catch(error => { console.error('Error:',error); });
|
.catch(error => { console.error('Error:',error); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function comment(sample, access, sampletext, comments) {
|
function comment(sample, access, sampletext, comments) {
|
||||||
const url = '<?=base_url();?>tubes/comment/'+access+'/'+sample;
|
const url = '<?=base_url();?>tubes/comment/'+access+'/'+sample;
|
||||||
let comment = prompt('Comment for sample '+sampletext, comments);
|
let comment = prompt('Comment for sample '+sampletext, comments);
|
||||||
if(comment) {
|
//$('#comment'+sample).html(comment +"<i class='bi bi-pencil-square' onclick='comment("+ sample +", "+ access +', "'+sampletext+'", "'+comment+'")\'></i>');
|
||||||
$('#comment'+sample).html(comment +"<i class='bi bi-pencil-square' onclick='comment("+ sample +", "+ access +', "'+sampletext+'", "'+comment+'")\'></i>');
|
fetch(url, {
|
||||||
fetch(url, {
|
method: "POST",
|
||||||
method: "POST",
|
body: JSON.stringify({ comment : comment }),
|
||||||
body: JSON.stringify({ comment : comment }),
|
headers: { "Content-type": "application/json; charset=UTF-8" }
|
||||||
headers: { "Content-type": "application/json; charset=UTF-8" }
|
}).then(data => {
|
||||||
})
|
//console.log(data);
|
||||||
.then(data => console.log(data))
|
viewAccess(access);
|
||||||
.catch(error => { console.error('Error:',error); });
|
})
|
||||||
}
|
.catch(error => { console.error('Error:',error); });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user