update
This commit is contained in:
@@ -8,11 +8,19 @@
|
||||
<div class="ribbon ribbon-danger">Rekapitulasi Penerimaan Sample {{$tanggal}}</div>
|
||||
<p></p>
|
||||
<div class="table-responsive">
|
||||
<button type="button" class="btn btn-primary" id="btnexport"><i class="fa fa-print"></i> Export</button>
|
||||
<button type="button" class="btn btn-primary" id="btnexport"><i class="fa fa-file-excel-o"></i> Export</button>
|
||||
<select id="printOrientation" class="btn btn-default">
|
||||
<option value="landscape">Landscape</option>
|
||||
<option value="portrait">Portrait</option>
|
||||
</select>
|
||||
<button type="button" class="btn btn-success" id="btnprintselected"><i class="fa fa-print"></i> Cetak Terpilih</button>
|
||||
|
||||
<table class="table table-bordered table-striped" id="penerimaansamplereport">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px; text-align:center;">
|
||||
<input type="checkbox" id="checkAllRows">
|
||||
</th>
|
||||
<th>No.RM</th>
|
||||
<th>Nama</th>
|
||||
<th>No.Sample</th>
|
||||
@@ -30,6 +38,9 @@
|
||||
<tbody>
|
||||
@foreach($detail as $r)
|
||||
<tr>
|
||||
<td style="text-align:center;">
|
||||
<input type="checkbox" class="row-check">
|
||||
</td>
|
||||
<td>{{ $r['noregister'] }}</td>
|
||||
<td>{{ $r['nmpasien'] }}</td>
|
||||
<td>{{ $r['nofoto'] }}</td>
|
||||
@@ -71,7 +82,25 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
var table = document.getElementById('penerimaansamplereport');
|
||||
var checkAllRows = document.getElementById('checkAllRows');
|
||||
var printOrientation = document.getElementById('printOrientation');
|
||||
var appName = @json(config('global.namaapps'));
|
||||
var appDomain = @json(config('global.domainapps'));
|
||||
var appSubDomain = @json(config('global.subdomainapps'));
|
||||
var appSubSubDomain = @json(config('global.subsubdomainapps'));
|
||||
var appAddress = @json(config('global.addressapps'));
|
||||
var petugasCetak = @json(Session('nama'));
|
||||
|
||||
if (checkAllRows && table) {
|
||||
checkAllRows.addEventListener('change', function() {
|
||||
var rowChecks = table.querySelectorAll('tbody .row-check');
|
||||
rowChecks.forEach(function(cb) {
|
||||
cb.checked = checkAllRows.checked;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('btnexport').addEventListener('click', function() {
|
||||
var table = document.getElementById('penerimaansamplereport');
|
||||
if (table) {
|
||||
@@ -81,6 +110,115 @@
|
||||
console.error('Tabel dengan ID "penerimaansamplereport" tidak ditemukan.');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('btnprintselected').addEventListener('click', function() {
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedRows = table.querySelectorAll('tbody tr');
|
||||
var printedRows = [];
|
||||
|
||||
selectedRows.forEach(function(row) {
|
||||
var rowCheck = row.querySelector('.row-check');
|
||||
if (rowCheck && rowCheck.checked) {
|
||||
var cells = row.querySelectorAll('td');
|
||||
printedRows.push([
|
||||
cells[1] ? cells[1].innerText : '',
|
||||
cells[2] ? cells[2].innerText : '',
|
||||
cells[3] ? cells[3].innerText : '',
|
||||
cells[4] ? cells[4].innerText : '',
|
||||
cells[5] ? cells[5].innerText : '',
|
||||
cells[6] ? cells[6].innerText : '',
|
||||
cells[7] ? cells[7].innerText : '',
|
||||
cells[8] ? cells[8].innerText : '',
|
||||
cells[9] ? cells[9].innerText : '',
|
||||
cells[10] ? cells[10].innerText : '',
|
||||
cells[11] ? cells[11].innerText : ''
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
if (printedRows.length === 0) {
|
||||
alert('Pilih minimal satu baris untuk dicetak.');
|
||||
return;
|
||||
}
|
||||
|
||||
var now = new Date();
|
||||
var orientation = printOrientation ? printOrientation.value : 'landscape';
|
||||
var tanggalCetak = now.toLocaleString('id-ID', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
});
|
||||
|
||||
var printWindow = window.open('', '_blank');
|
||||
if (!printWindow) {
|
||||
alert('Pop-up diblokir browser. Izinkan pop-up untuk mencetak.');
|
||||
return;
|
||||
}
|
||||
|
||||
var rowsHtml = '';
|
||||
printedRows.forEach(function(rowData) {
|
||||
rowsHtml += '<tr>';
|
||||
rowData.forEach(function(value) {
|
||||
rowsHtml += '<td>' + value + '</td>';
|
||||
});
|
||||
rowsHtml += '</tr>';
|
||||
});
|
||||
|
||||
var html = ''
|
||||
+ '<!DOCTYPE html>'
|
||||
+ '<html><head><title>Cetak Rekap Penerimaan Sample</title>'
|
||||
+ '<style>'
|
||||
+ '@page { size: A4 ' + orientation + '; margin: 10mm; }'
|
||||
+ 'body { font-family: Arial, sans-serif; margin: 0; color: #111; }'
|
||||
+ '.header { text-align: center; margin-bottom: 8px; }'
|
||||
+ '.header h2 { margin: 0; font-size: 16px; }'
|
||||
+ '.header .line { margin: 2px 0; font-size: 12px; }'
|
||||
+ '.meta { display: flex; justify-content: space-between; margin: 8px 0 10px; font-size: 11px; }'
|
||||
+ '.title { text-align: center; font-weight: 700; margin-bottom: 8px; font-size: 12px; }'
|
||||
+ 'table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10px; }'
|
||||
+ 'th, td { border: 1px solid #000; padding: 3px; word-break: break-word; vertical-align: top; }'
|
||||
+ 'th { background: #f1f1f1; }'
|
||||
+ '</style></head><body>'
|
||||
+ '<div class="header">'
|
||||
+ '<h2>' + (appName || '') + '</h2>'
|
||||
+ '<div class="line">' + (appDomain || '') + '</div>'
|
||||
+ '<div class="line">' + (appSubDomain || '') + ', ' + (appSubSubDomain || '') + '</div>'
|
||||
+ '<div class="line">' + (appAddress || '') + '</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="title">Rekapitulasi Penerimaan Sample {{$tanggal}}</div>'
|
||||
+ '<div class="meta">'
|
||||
+ '<div>Tanggal Cetak: ' + tanggalCetak + '</div>'
|
||||
+ '<div>Petugas: ' + (petugasCetak || '-') + '</div>'
|
||||
+ '</div>'
|
||||
+ '<table>'
|
||||
+ '<thead><tr>'
|
||||
+ '<th>No.RM</th>'
|
||||
+ '<th>Nama</th>'
|
||||
+ '<th>No.Sample</th>'
|
||||
+ '<th>Asal Pasien</th>'
|
||||
+ '<th>Daftar</th>'
|
||||
+ '<th>Order</th>'
|
||||
+ '<th>Kode</th>'
|
||||
+ '<th>Spesimen</th>'
|
||||
+ '<th>Status</th>'
|
||||
+ '<th>Tanggal Terima</th>'
|
||||
+ '<th>Petugas</th>'
|
||||
+ '</tr></thead>'
|
||||
+ '<tbody>' + rowsHtml + '</tbody>'
|
||||
+ '</table>'
|
||||
+ '<script>window.onload = function(){ window.print(); window.close(); };<\/script>'
|
||||
+ '</body></html>';
|
||||
|
||||
printWindow.document.open();
|
||||
printWindow.document.write(html);
|
||||
printWindow.document.close();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user