<section class="content" style="zoom : 85%;">
  <div class="container-fluid">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-header">
            <div class="row">
              <div class="col-sm-6">
                <h4>Tunggakan Tagihan</h4>
              </div>
              <div class="col-sm-6">
              </div>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <table id="example1" class="table table-bordered table-striped">
              <thead>
              <tr class="bg-danger">
                <th style="max-width: 20px">No</th>
                <th>Nama</th>
                <th>Id Pelanggan</th>
                <th>Alamat</th>
                <th>Keterangan</th>
                <th>Paket Berlanggan</th>
                <th>Jumlah Tagihan</th>
                <th>Nama Server</th>
                <th>Action</th>
              </tr>
              </thead>
              <tbody>
            <?php
            
            // Teknik CHUNGKING
            $no = 1;
            $chunkSize = 200;
            $stmt = $pdo->query("SELECT COUNT(id) FROM v_tagihan WHERE $SqlSvData $tagihanJalan status = 'lewat'");
            $totalRows = $stmt->fetchColumn();
            for ($offset = 0; $offset < $totalRows; $offset += $chunkSize) {
                $stmt = $pdo->prepare("SELECT * FROM v_tagihan WHERE $SqlSvData $tagihanJalan status = 'lewat' LIMIT :limit OFFSET :offset");
                $stmt->bindValue(':limit', $chunkSize, PDO::PARAM_INT);
                $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
                $stmt->execute();

                $data = $stmt->fetchAll();
                foreach ($data as $row) {
                
            ?>
              <tr>
                <td style="max-width: 20px"><?php echo $no; ?></td>
                <td style="max-width: 150px"><?php echo $row['nama']; ?></td>
                <td style="max-width: 150px"><?php echo $row['akun']; ?></td>
                <td style="max-width: 200px"><?php echo $row['alamat']; ?></td>
                <td style="max-width: 200px"><?php echo $row['keterangan']; ?></td>
                <td><?php echo $row['nama_paket']; ?></td>
                <td>Rp. <?php echo number_format($row['verifikasi_tagihan']); ?></td>
                <td style="max-width: 200px"><?php echo $row['nama_server']; ?></td>
                <td>
                  <?php if(in_array("Bayar", $json_array[4]['sub_menu'])){ ?>
                  <a href="?<?php echo encrypt_url('tagihan_bayar|'.$row['id'].'|'.$page[0]); ?>" class="btn btn-sm btn-primary btn-sm m-1">Bayar</a>
                  <?php } ?>
                  <a href="?<?php echo encrypt_url('tagihan_detail|'.$row['id'].'|'.$page[0]); ?>" class="btn btn-sm btn-info btn-sm m-1">Detail</a>
                </td>
              </tr>
              
            <?php 
            $no++; 
          }} ?>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</section> 