<nav class="navbar fixed-top">
    <div id="specificCard" class="card col-12" style="border-radius: 20px; background: none; border: none; margin-top: 10px;">
        <div class="row">
            <div class="col-6 icon-container">
                <a href="index.php" class="fa fa-arrow-left text-light"></a>
            </div>
            <div class="col-6 text-right">
                <h6 class="text-light mt-2 mb-2">Riwayat Transaksi</h6>
            </div>
        </div>
    </div>
</nav>
<div class="card" style="border-radius: 0px; background: none; border: none; margin-top: 50px;">
  <div class="card-body">    
  </div>
</div>
<div class="card" id="2" style="border-top-right-radius: 40px; border-top-left-radius: 40px; min-height: 850px; border: none; z-index: 1;">
  	<div class="card-body m-4">
  		<table class="table mt-2" style="zoom: 95%;">
		    <tbody>
		        <?php 
		        // Menetapkan batas dan offset untuk chunking
		        $limit = 10; // Jumlah data yang diambil setiap chunk
		        $offset = 0;

		        do {
		            // Mempersiapkan query menggunakan PDO dengan LIMIT dan OFFSET
		            $stmt = $pdo->prepare("SELECT * FROM transaksi_agen_voucher WHERE id_agen_voucher = :id_agen ORDER BY id DESC LIMIT :limit OFFSET :offset");
		            $stmt->bindParam(':id_agen', $_SESSION['agen'], PDO::PARAM_INT);
		            $stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
		            $stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
		            $stmt->execute();

		            // Mengambil hasil
		            $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

		            // Menampilkan hasil
		            foreach ($rows as $pecah) {
		        ?>
		            <tr>
		                <td class="p-2">
		                    <?php echo htmlspecialchars($pecah['input_time']); ?>
		                    <p class="m-0"><?php echo htmlspecialchars($pecah['keterangan']); ?></p>
		                </td>
		                <?php if (empty($pecah['debet'])) { ?>
		                    <td class="p-2 text-right text-danger" style="min-width: 150px;">Rp. <?php echo number_format($pecah['kredit']); ?></td>
		                <?php } else { ?>
		                    <td class="p-2 text-right text-success" style="min-width: 150px;">Rp. <?php echo number_format($pecah['debet']); ?></td>
		                <?php } ?>
		            </tr>
		        <?php 
		            }
		            $offset += $limit; // Mengupdate offset untuk chunk berikutnya
		        } while (count($rows) === $limit); // Terus ambil data sampai tidak ada lagi yang tersisa
		        ?>
		    </tbody>
		</table>
  	</div>
</div>