Add Feature Printer Barcode - Single & All Sample Print

This commit is contained in:
mikael-zakaria 2024-12-05 18:58:52 +08:00
parent 3d36283095
commit 8ee919d733
5 changed files with 115 additions and 13 deletions

View File

@ -80,4 +80,5 @@ $routes->group('fo', ['filter' => 'role:fo'], static function ($routes) {
}); });
// Printers // Printers
$routes->get('/prints/single_sample/(:any)/(:any)', 'PrinterController::printSingleSampleBarcode/$1/$2'); $routes->get('/prints/single_sample/(:any)/(:any)', 'PrinterController::printSingleSampleBarcode/$1/$2');
$routes->get('/prints/all_sample', 'PrinterController::printAllSampleBarcode');

View File

@ -22,7 +22,7 @@ class PrinterController extends BaseController {
$logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000);
$filename = "sample_".$logTime; $filename = "sample_".$logTime;
// $role = session()->get('userrole'); $role = session()->get('userrole');
// $role = "admin"; // $role = "admin";
$networkPath = ""; $networkPath = "";
@ -113,17 +113,14 @@ P1
'status' => true, 'status' => true,
] ]
); );
} }
} }
public function printAllSampleBarcode() { public function printAllSampleBarcode() {
$data = 5; $data = 3;
$role = session()->get('userrole'); $role = session()->get('userrole');
// $role="sampling";
$networkPath = ""; $networkPath = "";
// Ruang Analis Printer POSTEK // Ruang Analis Printer POSTEK

View File

@ -45,7 +45,7 @@ $name = $row['NAME'];
} }
echo "<td>$sampletext</td>"; echo "<td>$sampletext</td>";
echo "<td> echo "<td>
<button class='badge text-bg-dark'><i class='bi bi-printer' onclick='printSingleLabel($sampletype, $accessnumber)'></i></button> <button class='badge text-bg-dark' onclick='printSingleLabel($sampletype, $accessnumber)'><i class='bi bi-printer'></i></button>
<button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button> <button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button>
<button class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</button> <button class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</button>
<button class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</button> <button class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</button>
@ -61,7 +61,7 @@ $name = $row['NAME'];
<tr> <tr>
<td></td> <td></td> <td>All</td> <td></td> <td></td> <td>All</td>
<td> <td>
<button class='badge text-bg-dark'><i class='bi bi-printer'></i></button> <button class='badge text-bg-dark' onclick='printAllLabel()'><i class='bi bi-printer'></i></button>
<button class='badge text-bg-success' onclick='collectAll(<?=$accessnumber;?>)'>Coll.</button> <button class='badge text-bg-success' onclick='collectAll(<?=$accessnumber;?>)'>Coll.</button>
<!-- <button class='badge bg-black text-white' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</button> --> <!-- <button class='badge bg-black text-white' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</button> -->
<button class='badge text-bg-primary' onclick='unreceiveAll(<?=$accessnumber;?>)'>Un-Rec.</button> <button class='badge text-bg-primary' onclick='unreceiveAll(<?=$accessnumber;?>)'>Un-Rec.</button>
@ -74,7 +74,6 @@ $name = $row['NAME'];
</div> </div>
</div> </div>
<script> <script>
function printSingleLabel(sample, access) { function printSingleLabel(sample, access) {
const url = '<?=base_url();?>prints/single_sample/'+access.toString()+'/'+sample.toString(); const url = '<?=base_url();?>prints/single_sample/'+access.toString()+'/'+sample.toString();
@ -96,6 +95,27 @@ function printSingleLabel(sample, access) {
console.error('Error:', 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);
});
}
function collect(sample, access) { function collect(sample, access) {
sample = sample.toString().padStart(3,'0'); sample = sample.toString().padStart(3,'0');

View File

@ -45,7 +45,7 @@ $name = $row['NAME'];
} }
echo "<td>$sampletext</td>"; echo "<td>$sampletext</td>";
echo "<td> echo "<td>
<button class='badge text-bg-dark'><i class='bi bi-printer'></i></button> <button class='badge text-bg-dark' onclick='printSingleLabel($sampletype, $accessnumber)'><i class='bi bi-printer'></i></button>
<button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button> <button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button>
</td> "; </td> ";
echo "<td id='comment$sampletype'>$comment <i class='bi bi-pencil-square' role='button' 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>";
@ -54,7 +54,7 @@ $name = $row['NAME'];
?> ?>
<tr> <tr>
<td></td> <td></td> <td>Collection</td> <td></td> <td></td> <td>Collection</td>
<td> <button class='badge badge-dark'><i class='bi bi-printer'></i></button> </td> <td> <button class='badge badge-dark' onclick='printAllLabel()'><i class='bi bi-printer'></i></button> </td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td> <td>All</td> <td></td> <td></td> <td>All</td>
@ -70,6 +70,48 @@ $name = $row['NAME'];
</div> </div>
</div> </div>
<script> <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);
});
}
function collect(sample, access) { function collect(sample, access) {
sample = sample.toString().padStart(3,'0'); sample = sample.toString().padStart(3,'0');
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample; const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;

View File

@ -45,7 +45,7 @@ $name = $row['NAME'];
} }
echo "<td>$sampletext</td>"; echo "<td>$sampletext</td>";
echo "<td> echo "<td>
<button class='badge text-bg-dark'><i class='bi bi-printer'></i></button> <button class='badge text-bg-dark' onclick='printSingleLabel($sampletype, $accessnumber)'><i class='bi bi-printer'></i></button>
<button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button> <button class='badge text-bg-success' onclick='collect($sampletype, $accessnumber)'>Coll.</button>
<button class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</button> <button class='badge text-bg-warning' onclick='uncollect($sampletype, $accessnumber)'>Un-Coll.</button>
<button class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</button> <button class='badge text-bg-primary' onclick='unreceive($sampletype, $accessnumber)'>Un-Rec.</button>
@ -61,7 +61,7 @@ $name = $row['NAME'];
<tr> <tr>
<td></td> <td></td> <td>All</td> <td></td> <td></td> <td>All</td>
<td> <td>
<button class='badge text-bg-dark'><i class='bi bi-printer'></i></button> <button class='badge text-bg-dark' onclick='printAllLabel()'><i class='bi bi-printer'></i></button>
<button class='badge text-bg-success' onclick='collectAll(<?=$accessnumber;?>)'>Coll.</button> <button class='badge text-bg-success' onclick='collectAll(<?=$accessnumber;?>)'>Coll.</button>
<!-- <button class='badge bg-black text-white' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</button> --> <!-- <button class='badge bg-black text-white' onclick='uncollectAll(<?=$accessnumber;?>)'>un-collect</button> -->
<button class='badge text-bg-primary' onclick='unreceiveAll(<?=$accessnumber;?>)'>Un-Rec.</button> <button class='badge text-bg-primary' onclick='unreceiveAll(<?=$accessnumber;?>)'>Un-Rec.</button>
@ -74,6 +74,48 @@ $name = $row['NAME'];
</div> </div>
</div> </div>
<script> <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);
});
}
function collect(sample, access) { function collect(sample, access) {
sample = sample.toString().padStart(3,'0'); sample = sample.toString().padStart(3,'0');
const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample; const url = '<?=base_url();?>tubes/collect/'+access+'/'+sample;