79 lines
3.7 KiB
PHP
79 lines
3.7 KiB
PHP
<x-app-layout>
|
|
<div class="py-12">
|
|
<div class="max-w-3xl mx-auto sm:px-6 lg:px-8" id="strukArea">
|
|
<div class="bg-white p-6 rounded shadow">
|
|
|
|
<h2 class="text-2xl font-bold mb-4">Struk Pembayaran</h2>
|
|
|
|
|
|
@if(count($transaksi) > 0)
|
|
<div class="mb-6">
|
|
<p><strong>Nama Pasien:</strong> {{ $transaksi[0]->registrasi->pasien->nama_pasien ?? '-' }}</p>
|
|
<p><strong>MR Pasien:</strong>{{ $transaksi[0]->registrasi->mr_pasien ?? '-' }}</p>
|
|
<hr class="my-2 opacity-20"></hr>
|
|
<p><strong>Tanggal Registrasi:</strong> {{ $transaksi[0]->registrasi->tanggal_registrasi ?? '-' }}</p>
|
|
<p><strong>Nomor Registrasi:</strong> {{ $transaksi[0]->id_registrasi }}</p>
|
|
</div>
|
|
|
|
{{-- Tabel Tindakan --}}
|
|
<table class="min-w-full divide-y divide-gray-200 mb-6">
|
|
<thead>
|
|
<tr>
|
|
<th class="px-4 py-2 text-left">Tindakan</th>
|
|
<th class="px-4 py-2 text-left">Jumlah</th>
|
|
<th class="px-4 py-2 text-left">Tarif</th>
|
|
<th class="px-4 py-2 text-left">Subtotal</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200">
|
|
@php $total = 0; @endphp
|
|
@foreach ($transaksi as $t)
|
|
@foreach ($t->tindakan as $tindakan)
|
|
@php
|
|
$subtotal = $t->jumlah_tindakan * $tindakan->tarif;
|
|
$total += $subtotal;
|
|
@endphp
|
|
<tr>
|
|
<td class="px-4 py-2">{{ $tindakan->nama_tindakan }}</td>
|
|
<td class="px-4 py-2">{{ $t->jumlah_tindakan }}</td>
|
|
<td class="px-4 py-2">Rp{{ number_format($tindakan->tarif, 0, ',', '.') }}</td>
|
|
<td class="px-4 py-2">Rp{{ number_format($subtotal, 0, ',', '.') }}</td>
|
|
</tr>
|
|
@endforeach
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
{{-- Total --}}
|
|
<div class="text-right text-lg font-bold">
|
|
Total: Rp{{ number_format($total, 0, ',', '.') }}
|
|
</div>
|
|
@else
|
|
<p>Tidak ada transaksi ditemukan.</p>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-center mt-4">
|
|
<button onclick="printStruk()" class="bg-blue-500 text-white px-4 py-2 rounded-md">Cetak Struk</button>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.2/html2pdf.bundle.min.js"></script>
|
|
<script>
|
|
function printStruk() {
|
|
var element = document.getElementById('strukArea');
|
|
var opt = {
|
|
margin: 0.5,
|
|
filename: 'struk-pembayaran.pdf',
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: { scale: 2 },
|
|
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' }
|
|
};
|
|
|
|
html2pdf().set(opt).from(element).save();
|
|
}
|
|
</script>
|
|
</x-app-layout>
|