Menambahkan Fitur Print and Preview PDF

This commit is contained in:
mikael-zakaria 2024-12-06 10:47:51 +08:00
parent 8ee919d733
commit 344633f0ea
7 changed files with 1413 additions and 2 deletions

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
<th>Hosp</th>
<th>Test</th>
<th>Status</th>
<th></th>
</thead>
<tbody id="table-body">
</tbody>
@ -117,7 +118,8 @@ function index() {
}
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>' +
"<td role='button' class='"+bgcolor+" text-center align-middle' onclick='viewAccess("+accessnumber+")'>"+stattext+"</td>" + '</tr>';
"<td role='button' class='"+bgcolor+" text-center align-middle' onclick='viewAccess("+accessnumber+")'>"+stattext+"</td>" +
"<td role='button' class='text-center align-middle' onclick='resultPdfAccess("+accessnumber+")'> <i class='bi bi-filetype-pdf'></i> </td>" +'</tr>';
$("#table-body").append(datarow);
}
$('#myTable').DataTable();
@ -169,5 +171,9 @@ function viewAccess(access) {
$('#modal').modal('show');
});
}
function resultPdfAccess(access) {
let url = '<?=base_url();?>prints/result_test/'+access;
window.open(url, '_blank');
}
</script>
<?= $this->endSection() ?>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='<?=base_url();?>assets/css/pdf.css' />
</head>
<body style='-webkit-print-color-adjust:exact;'>
<?php echo $data; ?>
</body>
</html>

125
public/assets/css/pdf.css Normal file
View File

@ -0,0 +1,125 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.7pt; margin:0;}
body {
background-color: rgb(17, 16, 16);
}
#page {
background: rgb(255, 255, 255);
display: block;
margin: 0 auto;
margin-bottom: 1px;
/* border: solid 1px black; */
/* margin-bottom: 5px; */
page-break-after:always;
width: 210mm;
height: 297mm;
}
.table-justify {
text-align: justify;
}
#dinfo {
background-size: 100% auto;
background-repeat: no-repeat;
}
#dresult {
margin: 0;
padding: 0;
height: 20.4cm;
}
.result {
table-layout:fixed;
border:solid 1px black;
width:95%;
}
table {
align-items: center;
margin:0;
padding: 0;
width: 95%;
border-collapse:collapse;
/* border: 1px solid black; */
}
.t_center {
margin-left: auto;
margin-right: auto;
}
th,td {
padding: 2;
line-height:1.5;
}
.result th,td {
line-height: 1.1 ;
}
.t_background {
background-color: #f2f2f2;
}
.padmaColor {
/* background-color: rgba(190, 160, 160, 0.192); */
background-color: #f2f2f2;
/* line-height: 1.5; */
font-size: 1.2em;
}
.info { border:solid 1px black; margin:-1cm 0 0 8.5cm; width:11cm;}
.flag { float:right; top:0; font-weight:bold; }
.textC { font-size:7pt; }
table.information {
border:1px solid rgba(0, 0, 0, 0.192);
/* border-collapse:collapse; */
}
table.result tr{
border:solid 1px rgba(0, 0, 0, 0.055);
}
table.result tr:nth-child(odd) {
background-color: #f2f2f2;
/* border:solid 1px rgba(0, 0, 0, 0.055); */
}
.chapter {
/* font-size: 5em; */
}
tr.chapter td {
border: none;
}
#notes { margin: 5mm 0 0 10mm; }
.table_collection {
font-size: 2em;
}
#footer {
/* background-color: rgb(201, 230, 192); */
/* float:left; */
margin:0;
padding: 0;
height:2.85cm;
}
.table_footer {
width: 95%;
/* border:solid 1px black; */
border-collapse:collapse;
}
.img { width:200mm; margin-left:0.5cm }
@media print {
@page { margin:0; size:210mm 297mm; }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

BIN
public/assets/img/ttd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB