<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Laporan Detail</title>
	<style>
		@page {
			size: landscape;
		}

		body {
			text-align: center;
		}

		table {
			width: 100%;
			border-collapse: collapse;
			margin-bottom: 20px;
		}

		table th,
		table td {
			padding: 8px;
			text-align: left;
			border-bottom: 1px solid #ddd;
		}

		table th {
			background-color: #f2f2f2;
		}

		tbody tr:nth-child(even) {
			background-color: #f2f2f2;
		}

		tfoot {
			font-weight: bold;
		}

		tfoot:last-child {
			display: table-footer-group;
		}

		.additional-info {
			text-align: right;
			margin-top: 50px;
		}

	</style>
</head>

<body onload="window.print()">
	<h1>LAPORAN DETAIL</h1>
	<h2>KOPERASI DHARMA AL MUHTADIN DEPOK</h2>
	<p><b>Dari tanggal : <?php echo date("d-n-Y", strtotime($start)); ?> s/d tanggal : <?php echo date("d-n-Y", strtotime($end)); ?></b></p>
	<table>
		<thead>
			<tr>
				<th>No.</th>
				<th>Tgl. Transaksi</th>
				<th>No. Transaksi</th>
				<th>NIS</th>
				<th>Nama Siswa</th>
				<th>Kelas</th>
				<th>Status</th>
				<th>Nama Barang</th>
				<th>Qty</th>
				<th>Harga Beli</th>
				<th>Harga Jual</th>
				<th>Diskon</th>
				<th>Total</th>
				<th>Petugas</th>
			</tr>
		</thead>
		<tbody>
			<?php
            $no = 0;
            $total = 0; // Inisialisasi total
            foreach ($laporan as $row) {
                $diskon= ($row->diskon / 100) * $row->sub_total;
                            $totalnya = $row->sub_total - $diskon;
                            $total += $totalnya;
            ?>
			<tr>
				<td><?php echo ++$no; ?>.</td>
				<td><?php echo $row->tgl_trf; ?></td>
				<td><?php echo $row->no_trf; ?></td>
				<td><?php echo $row->nis_siswa; ?></td>
				<td><?php echo $row->nama_siswa; ?></td>
				<td><?php echo $row->kelas; ?></td>
				<td><?php echo $row->status; ?></td>
				<td><?php echo $row->nama_barang; ?></td>
				<td><?php echo $row->jumlah_stok; ?></td>
				<td>Rp. <?php echo number_format($row->harga_beli); ?></td>
				<td>Rp. <?php echo number_format($row->harga); ?></td>
				<td><?php echo $row->diskon; ?>%</td>
				<td align="right">Rp. <?php echo number_format($totalnya); ?></td>
				<td><?php echo $row->operator; ?></td>
			</tr>
			<?php } ?>
		</tbody>
        <tr>
					<td colspan="12" style="text-align: right;"><b>Grand Total :</b></td>
					<td colspan="2" style="text-align: left;"><b>Rp. <?php echo number_format($total); ?></b></td>
					<!-- <td></td> Kolom operator tidak ada total -->
		</tr>
		

	</table>
    <table>
			<tfoot>
				
			</tfoot>
	</table>
		<div class="additional-info">
			<p>Depok, <?php echo date("d-n-Y"); ?></p>
			<p>Petugas Print : <?= $this->session->userdata['nama'] ?></p>
		</div>
</body>

</html>
