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

$page=$_GET['page'];
$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 Pengeluaran</h1>
      <table>
        <tr>
          <td width="50%">Periode tanggal</td>
          <td>:</td>
          <td><?php echo $dari." sampai ".$sampai; ?></td>
        </tr>
      </table>
      <br>
      <div class="data-tables">
        <table id="dataTable2" class="text-center">
          <thead class="bg-light text-capitalize">
            <tr>
              <th width="5%">No</th>
              <th width="15%">No. Kwitansi</th>
              <th width="15%">No. Akun</th>
              <th width="10%">Tanggal</th>
              <th width="20%">Penerima</th>
              <th width="25%">Keterangan</th>
              <th width="10%">Banyak</th>
            </tr>
          </thead>
          <tbody>
            <?php
            $query = "SELECT * FROM pengeluaran WHERE tanggal 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 $qtabel['no_kwitansi']; ?></td>
                <td align="center"><?php echo $qtabel['no_akun']; ?></td>
                <td align="center"><?php echo IndonesiaTgl($qtabel['tanggal']); ?></td>
                <td align="left"><?php echo $qtabel['penerima']; ?></td>
                <td align="left"><?php echo $qtabel['keterangan']; ?></td>
                <td align="right"><?php echo $qtabel['banyak']; ?></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_pengeluaran.php?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 -->
