<?php include 'header.php'; ?>

<div class="content-wrapper">

  <section class="content-header">
    <h1>
      Bank
      <small>Data bank</small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
      <li class="active">Dashboard</li>
    </ol>
  </section>

  <section class="content">
    <div class="row">
      <section class="col-lg-12">
        <div class="box box-info">

          <div class="box-header">
            <h3 class="box-title">Data Akun Bank</h3>
          </div>
          <div class="box-body">

            <div class="table-responsive">
              <table class="table table-bordered table-striped" id="table-datatable">
                <thead>
                  <tr>
                    <th width="1%">NO</th>
                    <th>NAMA BANK</th>
                    <th>PEMILIK REKENING</th>
                    <th>NOMOR REKENING</th>
                    <th>SALDO</th>
                  </tr>
                </thead>
                <tbody>
                  <?php 
                  include '../koneksi.php';
                  $no=1;
                  $data = mysqli_query($koneksi,"SELECT bank_id, bank_nama, bank_pemilik, bank_nomor, bank_saldo FROM bank ORDER BY bank_id ASC");
                  while($d = mysqli_fetch_assoc($data)){
                    ?>
                    <tr>
                      <td class="text-center"><?php echo $no++; ?></td>
                      <td><?php echo !empty($d['bank_nama']) ? htmlspecialchars($d['bank_nama']) : '-'; ?></td>
                      <td><?php echo !empty($d['bank_pemilik']) ? htmlspecialchars($d['bank_pemilik']) : '-'; ?></td>
                      <td><?php echo !empty($d['bank_nomor']) ? htmlspecialchars($d['bank_nomor']) : '-'; ?></td>
                      <td class="text-right"><?php echo "Rp. ".number_format($d['bank_saldo'] ?? 0, 0, ',', '.')." ,-"; ?></td>
                    </tr>
                    <?php 
                  }
                  ?>
                </tbody>
              </table>
            </div>
          </div>

        </div>
      </section>
    </div>
  </section>

</div>

<script>
$(document).ready(function() {
  // Konfigurasi DataTables khusus untuk bank (client-side karena data biasanya tidak banyak)
  if ($('#table-datatable').length && !$('#table-datatable').hasClass('server-side')) {
    $('#table-datatable').DataTable({
      'paging': true,
      'lengthChange': true,
      'searching': true,
      'ordering': true,
      'info': true,
      'autoWidth': false,
      'pageLength': 25,
      'lengthMenu': [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
      'language': {
        'processing': 'Memproses data...',
        'search': 'Cari:',
        'lengthMenu': 'Tampilkan _MENU_ data per halaman',
        'info': 'Menampilkan _START_ sampai _END_ dari _TOTAL_ data',
        'infoEmpty': 'Menampilkan 0 sampai 0 dari 0 data',
        'infoFiltered': '(difilter dari _MAX_ total data)',
        'zeroRecords': 'Tidak ada data yang ditemukan',
        'emptyTable': 'Tidak ada data tersedia',
        'paginate': {
          'first': 'Pertama',
          'last': 'Terakhir',
          'next': 'Selanjutnya',
          'previous': 'Sebelumnya'
        }
      },
      'columnDefs': [
        { 'orderable': false, 'targets': [0] }, // NO tidak bisa di-sort
        { 'className': 'text-center', 'targets': [0] },
        { 'className': 'text-right', 'targets': [4] }
      ]
    });
  }
});
</script>

<?php include 'footer.php'; ?>