todo : fix tube comment fecth
This commit is contained in:
parent
2c96d7c2dd
commit
c354bd7130
@ -7,10 +7,21 @@ use CodeIgniter\Router\RouteCollection;
|
||||
*/
|
||||
$routes->get('/', 'Dashboard::index');
|
||||
$routes->get('/dashboard/viewAccess/(:any)', 'Dashboard::viewAccess/$1');
|
||||
|
||||
// Tubes
|
||||
$routes->get('/tubes/collect/(:any)/(:any)', 'Tubes::collect/$1/$2');
|
||||
$routes->get('/tubes/collectAll/(:any)', 'Tubes::collectAll/$1');
|
||||
$routes->get('/tubes/uncollect/(:any)/(:any)', 'Tubes::uncollect/$1/$2');
|
||||
$routes->get('/tubes/uncollectAll/(:any)', 'Tubes::uncollectAll/$1');
|
||||
$routes->get('/tubes/unreceive/(:any)/(:any)', 'Tubes::unreceive/$1/$2');
|
||||
$routes->get('/tubes/unreceiveAll/(:any)', 'Tubes::unreceiveAll/$1');
|
||||
|
||||
// Users
|
||||
$routes->get('/users/', 'Users::index');
|
||||
|
||||
// DICT_TESTS
|
||||
$routes->get('/dict_tests/', 'Dict_tests::index');
|
||||
|
||||
// Auth
|
||||
$routes->get('/auth/logout', 'Auth::logout');
|
||||
$routes->get('/auth/loginTD', 'Auth::loginTD');
|
||||
|
||||
@ -25,11 +25,11 @@ class Dashboard extends BaseController {
|
||||
|
||||
public function viewAccess($accessnumber): string {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "select p.PATNUMBER, p.NAME, sr.HOSTORDERNUMBER, tu.SAMPLETYPE, ds.SHORTTEXT, tu.TUBESTATUS, ct.COLLSTATUS from SP_TUBES tu
|
||||
$sql = "select p.PATNUMBER, p.NAME, sr.HOSTORDERNUMBER, tu.SAMPLETYPE, ds.SHORTTEXT, tu.TUBESTATUS, ct.COLLSTATUS, ct.TUBECOMMENT from SP_TUBES tu
|
||||
left join SP_REQUESTS sr on tu.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER
|
||||
left join PATIENTS p on p.PATID=sr.PATID
|
||||
left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE= tu.SAMPLETYPE
|
||||
left join cmod.dbo.CM_TUBES ct on ct.SAMPLETYPE=tu.SAMPLETYPE
|
||||
left join cmod.dbo.CM_TUBES ct on ct.SAMPLETYPE=tu.SAMPLETYPE and ct.ACCESSNUMBER=tu.SP_ACCESSNUMBER
|
||||
where tu.SP_ACCESSNUMBER='$accessnumber'";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
|
||||
@ -5,7 +5,63 @@ namespace App\Controllers;
|
||||
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' 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
|
||||
UPDATE cmod.dbo.CM_TUBES set COLLECTIONDATE=GETDATE(), COLL_USERID='$userid', COLLSTATUS='1' where ACCESSNUMBER='$access' and SAMPLETYPE='$sample'
|
||||
END";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
|
||||
public function uncollect($access, $sample) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "UPDATE cmod.dbo.CM_TUBES set COLLSTATUS=null where ACCESSNUMBER='$access' and SAMPLETYPE='$sample'";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
|
||||
public function unreceive($access, $sample) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "UPDATE SP_TUBES set TUBESTATUS=null where SP_ACCESSNUMBER='$access' and SAMPLETYPE='$sample'";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
|
||||
public function collectAll($access) {
|
||||
$userid = session()->userid;
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "select SAMPLETYPE from SP_TUBES where SP_ACCESSNUMBER='$access'";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
foreach($results as $data) {
|
||||
$sample = $data['SAMPLETYPE'];
|
||||
$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
|
||||
UPDATE cmod.dbo.CM_TUBES set COLLECTIONDATE=GETDATE(), COLL_USERID='$userid', COLLSTATUS='1' where ACCESSNUMBER='$access'
|
||||
END";
|
||||
//echo "<pre>$sql</pre>";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function uncollectAll($access) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "UPDATE cmod.dbo.CM_TUBES set COLLSTATUS=null where ACCESSNUMBER='$access'";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
|
||||
public function unreceiveAll($access) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "UPDATE SP_TUBES set TUBESTATUS=null where SP_ACCESSNUMBER='$access'";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
public function commentUpdate($access, $sample) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "UPDATE cmod.dbo.CM_TUBES set TUBECOMMENT='$comment' where ACCESSNUMBER='$access' and SAMPLETYPE='$sample'";
|
||||
$query = $db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,13 +33,14 @@ span.badge { cursor:pointer; }
|
||||
<div class="card-body">
|
||||
<div class="card-title"><h3>Sample List</h3></div>
|
||||
<table class='table'>
|
||||
<tr> <th class='text-center'>Coll.</th> <th class='text-center'>Recv.</th> <th>Sample Name</th> <th></th> </tr>
|
||||
<tr> <th class='text-center'>Coll.</th> <th class='text-center'>Recv.</th> <th>Sample Name</th> <th>Action</th> <th>Comment</th> </tr>
|
||||
<?php
|
||||
foreach($data as $row) {
|
||||
$sampletype = $row['SAMPLETYPE'];
|
||||
$sampletext = $row['SHORTTEXT'];
|
||||
$tubestatus = $row['TUBESTATUS'];
|
||||
$collstatus = $row['COLLSTATUS'];
|
||||
$comment = $row['TUBECOMMENT'];
|
||||
echo "\r\n <tr>";
|
||||
if($collstatus==1) {
|
||||
echo " <td class='text-center'><input type='checkbox' class='form-check-input' id='coll$sampletype' checked disabled></td>";
|
||||
@ -53,25 +54,26 @@ span.badge { cursor:pointer; }
|
||||
}
|
||||
echo "<td>$sampletext</td>";
|
||||
echo "<td>
|
||||
<span class='badge bg-black text-white'>reprint</span>
|
||||
<span class='badge bg-black text-white' onclick='collect($sampletype, $accessnumber)'>collect</span>
|
||||
<span class='badge bg-black text-white'>un-collect</span>
|
||||
<span class='badge bg-black text-white'>un-receive</span>
|
||||
<span class='badge text-bg-dark'><i class='bi bi-printer'></i></span>
|
||||
<span class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>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>
|
||||
</td> ";
|
||||
echo "<td id='comment$sampletype'>$comment <i class='bi bi-pencil-square' onclick='comment($sampletype, $accessnumber, \"$sampletext\", \"$comment\")'></i></td>";
|
||||
echo " </tr>";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td></td> <td></td> <td>Collection</td>
|
||||
<td> <span class='badge bg-black text-white'>reprint</span> </td>
|
||||
<td> <span class='badge badge-dark'><i class='bi bi-printer'></i></span> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td> <td></td> <td>All</td>
|
||||
<td>
|
||||
<span class='badge bg-black text-white'>reprint</span>
|
||||
<span class='badge bg-black text-white' onclick='collectAll(<?=$accessnumber;?>)'>collect</span>
|
||||
<span class='badge bg-black text-white'>un-collect</span>
|
||||
<span class='badge bg-black text-white'>un-receive</span>
|
||||
<span class='badge text-bg-dark'><i class='bi bi-printer'></i></span>
|
||||
<span class='badge text-bg-success' onclick='collectAll(<?=$accessnumber;?>)'>Coll.</span>
|
||||
<!-- <span class='badge bg-black text-white' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</span> -->
|
||||
<span class='badge text-bg-primary' onclick='unreceiveAll(<?=$accessnumber;?>)'>Un-Rec.</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -82,13 +84,86 @@ span.badge { cursor:pointer; }
|
||||
</div>
|
||||
<script>
|
||||
function collect(sample, access) {
|
||||
sample = sample.toString().padStart(3,'0');
|
||||
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;
|
||||
$("#coll"+sample).prop("checked", true);
|
||||
fetch(url)
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
$("#coll"+sample).prop("checked", true);
|
||||
})
|
||||
.catch(error => { console.error('Error:',error); });
|
||||
}
|
||||
|
||||
function collectAll(access) {
|
||||
const url = '<?=base_url();?>tubes/collectAll/'+access;
|
||||
$('input[id^="coll"]').prop('checked', true);
|
||||
fetch(url)
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
$('input[id^="coll"]').prop('checked', true);
|
||||
})
|
||||
.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 => {
|
||||
console.log(data);
|
||||
$("#coll"+sample).prop("checked", false);
|
||||
})
|
||||
.catch(error => { console.error('Error:',error); });
|
||||
|
||||
}
|
||||
|
||||
function uncollectAll(access) {
|
||||
const url = '<?=base_url();?>tubes/uncollectAll/'+access;
|
||||
fetch(url)
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
$('input[id^="coll"]').prop('checked', false);
|
||||
})
|
||||
.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 => {
|
||||
console.log(data);
|
||||
$("#recv"+sample).prop("checked", false);
|
||||
})
|
||||
.catch(error => { console.error('Error:',error); });
|
||||
|
||||
}
|
||||
|
||||
function unreceiveAll(access) {
|
||||
const url = '<?=base_url();?>tubes/unreceiveAll/'+access;
|
||||
fetch(url)
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
$('input[id^="recv"]').prop('checked', false);
|
||||
})
|
||||
.catch(error => { console.error('Error:',error); });
|
||||
}
|
||||
|
||||
function comment(sample, access, sampletext, comments) {
|
||||
const url = '<?=base_url();?>tubes/comment/'+access+'/'+sample;
|
||||
let comment = prompt('Comment for sample '+sampletext, comments);
|
||||
if(comment != null) {
|
||||
$('#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( response => response.json() )
|
||||
.then( json => console.log(json) );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user