<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: 900px; border: none; z-index: 1;">
  	<div class="card-body m-4">
  		<center>
  			<h6 class="mb-4">Riwayat Penjualan Per Bulan</h6>
  		</center>
  		<table class="table mt-2" style="zoom: 95%">
		    <tbody>
		        <?php 

		     
		            // Mempersiapkan query menggunakan PDO dengan LIMIT dan OFFSET
		            $stmt = $pdo->prepare("SELECT * FROM v_detail_agen_pascabayar WHERE id_agen_voucher = :id_agen ORDER BY generate_time DESC");
		            $stmt->bindParam(':id_agen', $_SESSION['agen'], 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 substr(formatIndo($pecah['generate_time']),3); ?>
		                    <h4>Rp. <b><?php echo number_format($pecah['kredit']); ?></b></h4>
		                </td>
		                <td class="p-2 text-right">
		                	<?php if($pecah['kredit'] > $pecah['debet']) { ?>
		                	<h5 class="text-danger">Belum Lunas</h5>
		                	<?php } else { ?>
		                	<h5 class="text-success">Lunas</h5>
		                	<?php } ?>
		                	<a href="?<?php echo base64_encode('riwayat_transaksi_pascabayar_list|'.substr($pecah['generate_time'],0,7)); ?>" class="btn btn-info btn-sm m-1">Detail</a>
		                </td>
		            </tr>
		        <?php } ?>
		    </tbody>
		</table>
  	</div>
</div>