<?php
include '../koneksi.php';

header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=Data_Hutang.xls");
?>

<table border="1" width="100%">
<tr>
  <th colspan="5">DATA HUTANG</th>
</tr>
<tr>
  <th>No</th>
  <th>Kode</th>
  <th>Tanggal</th>
  <th>Keterangan</th>
  <th>Nominal</th>
</tr>

<?php
$no=1;
$total=0;
$data = mysqli_query($koneksi,"SELECT * FROM hutang ORDER BY hutang_id DESC");
while($d=mysqli_fetch_array($data)){
?>
<tr>
  <td><?= $no++ ?></td>
  <td>HTG-000<?= $d['hutang_id'] ?></td>
  <td><?= date('d/m/Y', strtotime($d['hutang_tanggal'])) ?></td>
  <td><?= $d['hutang_keterangan'] ?></td>
  <td><?= $d['hutang_nominal'] ?></td>
</tr>
<?php $total += $d['hutang_nominal']; } ?>

<tr>
  <th colspan="4">TOTAL</th>
  <th><?= $total ?></th>
</tr>
</table>
