<?php 
include_once "../library/inc.sesadmin.php";
include_once "../library/inc.library.php";
include_once "../library/inc.connection.php";

$page=$_GET['page'];
// $tahun_ajaran=$_GET['tahun_ajaran'];
$kelas=$_GET['kelas'];
$dari=$_GET['dari'];
$sampai=$_GET['sampai'];
?>

<!-- data table start -->
<div class="col-12 mt-4">
  <div class="card">
    <div class="card-body">
      <h1 class="header-title">Rekap Transaksi Pembayaran SPMP Per Kelas</h1>
      <table>
        <tr>
          <td width="50%">Periode tanggal</td>
          <td>:</td>
          <td><?php echo $dari." sampai ".$sampai; ?></td>
        </tr>
        <tr>
          <td>Kelas</td>
          <td>:</td>
          <td><?php echo $kelas; ?></td>
        </tr>
      </table>
      <br>
      <div class="data-tables">
        <table id="dataTable2" class="text-center">
          <thead class="bg-light text-capitalize">
            <tr>
              <th>No</th>
              <th>Tanggal Transaksi</th>
              <th>NIS</th>
              <th>Nama Siswa</th>
              <th>Jumlah</th>
              <th>Keterangan</th>
            </tr>
          </thead>
          <tbody>
            <?php
            $query = "SELECT transaksi.tgl_transaksi, transaksi_item.nis, siswa.nama_siswa, transaksi_item.banyak, bulan.keterangan FROM transaksi INNER JOIN transaksi_item ON transaksi.no_transaksi=transaksi_item.no_transaksi INNER JOIN kelas_siswa ON transaksi_item.nis=kelas_siswa.nis INNER JOIN kelas ON kelas_siswa.kdkelas=kelas.kdkelas INNER JOIN siswa ON kelas_siswa.nis=siswa.nis INNER JOIN bulan ON transaksi_item.kode_bayar=bulan.kode WHERE kelas.namakelas='$kelas' AND bulan.keterangan LIKE '%SPMP%' AND transaksi.tgl_transaksi BETWEEN '$dari' AND '$sampai'";
            $hasil = mysql_query($query);
  // echo mysql_num_rows($hasil);
            $nomor = 0;
            $total = 0;
            while ($qtabel = mysql_fetch_array($hasil))
            { 
              $nomor++;
              $total = $total + intval($qtabel['banyak']);
              ?>
              <tr>
                <td align="center"><b><?php echo $nomor; ?></b></td>
                <td align="center"><?php echo IndonesiaTgl($qtabel['tgl_transaksi']); ?></td>
                <td align="center"><?php echo $qtabel['nis']; ?></td>
                <td><?php echo $qtabel['nama_siswa']; ?></td>
                <td align="center"><?php echo format_angka($qtabel['banyak']); ?></td>
                <td><?php echo $qtabel['keterangan']; ?></td>
              </tr>
              <?php } ?>
            </tbody>
          </table>
          <!-- table info start -->
          <h4 class="header-title">Rekap Pemasukan</h4>
          <div class="single-table">
            <div class="table-responsive">
              <table class="table text-center">
                <thead class="text-uppercase bg-info">
                  <tr class="text-white">
                    <th scope="col">Total</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <th scope="row"><h2><?php echo "Rp. ".format_angka($total); ?></h2></th>
                  </tr>
                  <tr>
                    <th scope="row"><a href="../file/laporan/excel_laporan_spmp_kelas.php?kelas=<?php echo $kelas; ?>&dari=<?php echo $dari; ?>&sampai=<?php echo $sampai; ?>" target="_blank"><button type="button" class="btn btn-primary mb-3 col-12">Export ke Excel</button></a></th>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
          <!-- table info end -->
        </div>
      </div>
    </div>
  </div>
  <!-- data table end -->