update label collection
This commit is contained in:
parent
871a5e1cde
commit
b67a68f8a9
@ -109,5 +109,6 @@ $routes->group('fo', ['filter' => 'role:fo'], static function ($routes) {
|
|||||||
|
|
||||||
// Printers
|
// Printers
|
||||||
$routes->get('printLabel/single/(:any)/(:any)', 'PrintLabel::printSingle/$1/$2');
|
$routes->get('printLabel/single/(:any)/(:any)', 'PrintLabel::printSingle/$1/$2');
|
||||||
|
$routes->get('printLabel/collection/(:any)', 'PrintLabel::labelPostekCollection/$1');
|
||||||
$routes->get('printLabel/all/(:any)', 'PrintLabel::printAll/$1');
|
$routes->get('printLabel/all/(:any)', 'PrintLabel::printAll/$1');
|
||||||
$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1');
|
$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1');
|
||||||
@ -31,6 +31,110 @@ class PrintLabel extends BaseController {
|
|||||||
return ['line1' => $line1, 'line2' => $line2];
|
return ['line1' => $line1, 'line2' => $line2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function labelPostekCollection($access) {
|
||||||
|
|
||||||
|
$time = microtime(true);
|
||||||
|
$logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000);
|
||||||
|
$filename = "sample_".$logTime;
|
||||||
|
|
||||||
|
$role = session()->get('userrole');
|
||||||
|
$networkPath = "";
|
||||||
|
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX,
|
||||||
|
DATEDIFF(YEAR, BirthDate, GETDATE()) -
|
||||||
|
CASE WHEN MONTH(BirthDate) > MONTH(GETDATE()) OR (MONTH(BirthDate) = MONTH(GETDATE()) AND DAY(BirthDate) > DAY(GETDATE())) THEN 1
|
||||||
|
ELSE 0 END AS AGE, sr.COLLECTIONDATE
|
||||||
|
from SP_REQUESTS sr
|
||||||
|
left join SP_REQUESTS st on sr.SP_ACCESSNUMBER=st.SP_ACCESSNUMBER
|
||||||
|
left join PATIENTS p on p.PATID=sr.PATID
|
||||||
|
where st.SP_ACCESSNUMBER='$access'";
|
||||||
|
$query = $db->query($sql);
|
||||||
|
$results = $query->getResultArray();
|
||||||
|
$item = $results[0];
|
||||||
|
|
||||||
|
$uhid = substr($item['UHID'], -10);
|
||||||
|
$bv = $item['BV'];
|
||||||
|
$sex = $item['SEX'] == 1 ? "M" : "F";
|
||||||
|
$title = $item['SEX'] == 1 ? "Mr" : "Mrs";
|
||||||
|
$name = $item['NAME'];
|
||||||
|
$age = $item['AGE'];
|
||||||
|
$collectiondate = $item['COLLECTIONDATE'];
|
||||||
|
$date = \DateTime::createFromFormat('Y-m-d H:i:s.v', $collectiondate);
|
||||||
|
if ($date) {
|
||||||
|
$collectiondate = $date->format('d/m/Y H:i');
|
||||||
|
} else {
|
||||||
|
$collectiondate = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$fixName = $this->splitName($name);
|
||||||
|
$name1 = $fixName['line1'];
|
||||||
|
$name2 = $fixName['line2'];
|
||||||
|
|
||||||
|
if ($sex == 'M') {
|
||||||
|
$jarak = '42';
|
||||||
|
} else {
|
||||||
|
$jarak = '53';
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = "N
|
||||||
|
OD
|
||||||
|
q400
|
||||||
|
Q200,10+0
|
||||||
|
I8,A,001
|
||||||
|
D10
|
||||||
|
A4,3,0,2,1,1,N,\"$title.$name1\"
|
||||||
|
A$jarak,20,0,2,1,1,N,\"$name2\"
|
||||||
|
A325,25,0,2,1,1,N,\"$sex {$age}Y\"
|
||||||
|
B15,50,0,1,4,8,70,N,\"$access\"
|
||||||
|
A130,125,0,1,1,1,N,\"REQ# $access\"
|
||||||
|
A4,167,0,2,1,1,N,\"RM:$uhid\"
|
||||||
|
A4,150,0,2,1,1,N,\"VN:$bv\"
|
||||||
|
A195,167,0,2,1,1,N,\"$collectiondate\"
|
||||||
|
|
||||||
|
P1
|
||||||
|
";
|
||||||
|
// Ruang Analis Printer POSTEK C168/200s
|
||||||
|
if ($role === 'admin' || $role === 'user') {
|
||||||
|
$printer = $this->printerLab();
|
||||||
|
} else if ($role === 'sampling') {
|
||||||
|
$printer = $this->printerSampling();
|
||||||
|
} else {
|
||||||
|
// Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'message' => "Akses Tidak Berwenang",
|
||||||
|
'error' => "Hak Akses Anda Tidak Dikenali",
|
||||||
|
'status' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $folder = "C:/data/";
|
||||||
|
$folder = $printer[0];
|
||||||
|
$fullPath = $folder . $filename;
|
||||||
|
|
||||||
|
// Tulis file ke folder tujuan
|
||||||
|
if (!file_put_contents($fullPath, $label)) {
|
||||||
|
|
||||||
|
//exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var);
|
||||||
|
// Eksekusi Kode Berikut Apabila Ada Error
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'error' => $output,
|
||||||
|
'message' => "Gagal Melakukan Print, Mohon Ulangi Atau Cek Koneksi Printer Anda",
|
||||||
|
'status' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Hapus Koneksi
|
||||||
|
//exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var);
|
||||||
|
return $this->response->setJSON( [
|
||||||
|
'message' => "Print Berhasil!" ,
|
||||||
|
'status' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date) {
|
public function labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date) {
|
||||||
$fixName = $this->splitName($name);
|
$fixName = $this->splitName($name);
|
||||||
$name1 = $fixName['line1'];
|
$name1 = $fixName['line1'];
|
||||||
@ -183,7 +287,6 @@ P1
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_dump($printer);die();
|
|
||||||
// $folder = "C:/data/";
|
// $folder = "C:/data/";
|
||||||
$folder = $printer[0];
|
$folder = $printer[0];
|
||||||
$fullPath = $folder . $filename;
|
$fullPath = $folder . $filename;
|
||||||
|
|||||||
@ -56,10 +56,10 @@ $name = $row['NAME'];
|
|||||||
<div class="card-title"><h3>Sample List</h3></div>
|
<div class="card-title"><h3>Sample List</h3></div>
|
||||||
<table class='table'>
|
<table class='table'>
|
||||||
<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> <th class='text-center'>Coll.</th> <th class='text-center'>Recv.</th> <th>Sample Name</th> <th>Action</th> <th>Comment</th> </tr>
|
||||||
<!-- <tr>
|
<tr>
|
||||||
<td></td> <td></td> <td>Collection</td>
|
<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>
|
<td><button type='button' class='btn btn-dark m-0 px-2 py-1' onclick="printCollectionLabel(<?=$accessnumber;?>)"><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
|
||||||
</tr> -->
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td> <td></td> <td>All</td>
|
<td></td> <td></td> <td>All</td>
|
||||||
<td>
|
<td>
|
||||||
@ -107,6 +107,26 @@ $name = $row['NAME'];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
function printCollectionLabel(access){
|
||||||
|
const url = '<?=base_url();?>printLabel/collection/'+access.toString();
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.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 printSingleLabel(access, sample) {
|
function printSingleLabel(access, sample) {
|
||||||
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,10 @@ $name = $row['NAME'];
|
|||||||
<div class="card-title"><h3>Sample List</h3></div>
|
<div class="card-title"><h3>Sample List</h3></div>
|
||||||
<table class='table'>
|
<table class='table'>
|
||||||
<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> <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>Collection</td>
|
||||||
|
<td><button type='button' class='btn btn-dark m-0 px-2 py-1' onclick="printCollectionLabel(<?=$accessnumber;?>)"><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td> <td></td> <td>All</td>
|
<td></td> <td></td> <td>All</td>
|
||||||
<td>
|
<td>
|
||||||
@ -65,12 +69,7 @@ $name = $row['NAME'];
|
|||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>
|
</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
|
<?php
|
||||||
foreach($data as $row) {
|
foreach($data as $row) {
|
||||||
$sampletype = $row['SAMPLETYPE'];
|
$sampletype = $row['SAMPLETYPE'];
|
||||||
@ -108,6 +107,26 @@ $name = $row['NAME'];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
function printCollectionLabel(access){
|
||||||
|
const url = '<?=base_url();?>printLabel/collection/'+access.toString();
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.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 printSingleLabel(access, sample) {
|
function printSingleLabel(access, sample) {
|
||||||
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,10 @@ $name = $row['NAME'];
|
|||||||
<div class="card-title"><h3>Sample List</h3></div>
|
<div class="card-title"><h3>Sample List</h3></div>
|
||||||
<table class='table'>
|
<table class='table'>
|
||||||
<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> <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>Collection</td>
|
||||||
|
<td><button type='button' class='btn btn-dark m-0 px-2 py-1' onclick="printCollectionLabel(<?=$accessnumber;?>)"><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td> <td></td> <td>All</td>
|
<td></td> <td></td> <td>All</td>
|
||||||
<td>
|
<td>
|
||||||
@ -65,12 +69,7 @@ $name = $row['NAME'];
|
|||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>
|
</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
|
<?php
|
||||||
foreach($data as $row) {
|
foreach($data as $row) {
|
||||||
$sampletype = $row['SAMPLETYPE'];
|
$sampletype = $row['SAMPLETYPE'];
|
||||||
@ -108,6 +107,26 @@ $name = $row['NAME'];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
function printCollectionLabel(access){
|
||||||
|
const url = '<?=base_url();?>printLabel/collection/'+access.toString();
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.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 printSingleLabel(access, sample) {
|
function printSingleLabel(access, sample) {
|
||||||
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,10 @@ $name = $row['NAME'];
|
|||||||
<div class="card-title"><h3>Sample List</h3></div>
|
<div class="card-title"><h3>Sample List</h3></div>
|
||||||
<table class='table'>
|
<table class='table'>
|
||||||
<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> <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>Collection</td>
|
||||||
|
<td><button type='button' class='btn btn-dark m-0 px-2 py-1' onclick="printCollectionLabel(<?=$accessnumber;?>)"><h6 class='p-0 m-0'> <i class='bi bi-printer'></i></h6></button></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td> <td></td> <td>All</td>
|
<td></td> <td></td> <td>All</td>
|
||||||
<td>
|
<td>
|
||||||
@ -65,12 +69,7 @@ $name = $row['NAME'];
|
|||||||
<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>
|
<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>
|
</td>
|
||||||
</tr>
|
</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
|
<?php
|
||||||
foreach($data as $row) {
|
foreach($data as $row) {
|
||||||
$sampletype = $row['SAMPLETYPE'];
|
$sampletype = $row['SAMPLETYPE'];
|
||||||
@ -108,6 +107,26 @@ $name = $row['NAME'];
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
function printCollectionLabel(access){
|
||||||
|
const url = '<?=base_url();?>printLabel/collection/'+access.toString();
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.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 printSingleLabel(access, sample) {
|
function printSingleLabel(access, sample) {
|
||||||
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
const url = '<?=base_url();?>printLabel/single/'+access.toString()+'/'+sample.toString();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user