<?php 
session_start();
ob_start();

 ?>
<html>
<head>
  <title>Cetak PDF</title>
    
   <style>
   table {border-collapse:collapse; table-layout:fixed;width: 630px; }
  /* table td {word-wrap:break-word;width: 20%;}*/
    table td {margin: 0 20px 20px 0;}
</style>
<style>
   /*https://www.dicoding.com/blog/cara-membuat-table-di-html/*/
        table {
            border-collapse: collapse;
        }    
        th, td {
            padding: 4px;
            font-size: 15px;
        }
        p{ margin-top: 0px;            
        }
        h5{ margin-top: 0px;
        }
        h4{ margin-bottom: 1px;
        }
    </style>
   
</head>

<body>
    <page_footer align="right">
    Page[[page_cu]]
  </page_footer> 
  <page_header>
  
  </page_header>

 <!-- <table border="0">
  <tr>
   
<th ><img src="./../gambar/logommu.png" style="width:745px;height:100px"align="center" /></th>

</tr>

   </table>  --> 
      
<?php     
$periode = $_SESSION['bayar_kewajiban']['periode'];
$sqlbyr = $_SESSION['bayar_kewajiban']['kode']['sqlbyr'];
$namaKewajiban = $_SESSION['bayar_kewajiban']['namaKewajiban'];
?>
<p align="center" style="margin:0px;font-family : Arial; ">MMU A39 REJOSARI</p>
<!-- <p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"> KANTOR <a?php echo $_SESSION['kantor'];?> </p>
 --><p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;">LAPORAN PEMBAYARAN <?php echo strtoupper($namaKewajiban); ?>  MURID </p>
<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"><?php echo $periode; ?> </p>      

<table border="1" width="100%" style="padding-top: 19px;padding-bottom: 16px">
<tr>
<td style="text-align: center; background: #ddd;width: 3%"><b>No.</b></td>
<td style="text-align: center; background: #ddd; width: 7%"><b>ID</b></td> 
<td style="text-align: center; background: #ddd;width: 8%"><b>NIM</b></td>
<td style="text-align: center; background: #ddd;width: 20%"><b>Nama</b></td>
<td style="text-align: center; background: #ddd;width: 7%"><b>Kewajiban</b></td>
<td style="text-align: center; background: #ddd;width: 7%"><b>Bayar</b></td>
<td style="text-align: center; background: #ddd;width: 7%"><b>Sisa</b></td>
<td style="text-align: center; background: #ddd;width: 7%"><b>Kls</b></td>
<td style="text-align: center; background: #ddd;width: 21%"><b>Keterangan</b></td>
<td style="text-align: center; background: #ddd;width: 10%"><b>UserName</b></td>

</tr>

<?php
// Load file koneksi.php
include "./../koneksi.php";
 /*include ('../koneksi.php');*/
 error_reporting(0); 
 //hide php errors
/*error_reporting(E_ALL^(E_NOTICE|E_WARNING));
ini_set('display_errors',1);
error_reporting(0);*/
 $no=0;
 
$sql = mysqli_query($koneksi, $sqlbyr); // Eksekusi/Jalankan query dari variabel 
$row = mysqli_num_rows($sql); // Ambil jumlah data dari hasil eksekusi $sql
if($row > 0){ // Jika jumlah data lebih dari 0 (Berarti jika data ada)
    while($barisD = mysqli_fetch_array($sql)){ // Ambil semua data dari hasil  
    $t_kwajiban += $barisD['kewajiban'];
    $t_bayar += $barisD['bayar'];
    $t_sisa += $barisD['sisa'];
      
     $no++;     
    ?>   

  <tr>                      
    <td class ="pertama" style="text-align: center;"> <?php echo $no ?> </td>
    <!-- <td class ="pertama" style="text-align: center;"> <A?php echo date('d-m-Y',strtotime($tgl))?> </td> -->
    <td class ="pertama" style="text-align: left;"> <?php echo $barisD['id'];?> </td>
     <td class ="pertama" style="text-align: left;"> <?php echo $barisD['nim'];?> </td>
     <td class ="pertama" style="text-align: left;"> <?php echo $barisD['nama'];?> </td>
    <td class ="pertama" style="text-align: right;"> <?php echo number_format($barisD['kewajiban'], 0);?> </td>
    <td class ="pertama" style="text-align: right;"> <?php echo number_format($barisD['bayar'], 0); ?></td>
    <td class ="pertama" style="text-align: right;"> <?php echo number_format($barisD['sisa'], 0); ?> </td>       
    <td class ="pertama" style="text-align: left;"> <?php echo $barisD['no_kls']; ?> </td>
    <td class ="pertama" style="text-align: left;"> <?php echo $barisD['keterangan']; ?> </td>
    <td class ="pertama" style="text-align: left;"> <?php echo $barisD['username']; ?> </td>
     
    
</tr>
      <?php    
    }
    }?>
     <tr>
     <th class="warna" colspan="4" style="text-align: center;">Jumlah</th>
      <th class="warna" align="right" width="7%"><?php echo number_format($t_kwajiban,2);?></th>
      <th class="warna" align="right" width="7%"><?php echo number_format($t_bayar,0);?></th>
      <th class="warna" align="right" width="7%"><?php  echo number_format($t_sisa,0);?></th> 
      <th class="warna" align="right" width="7%"></th>   
      <th class="warna" align="right" width="7%"></th>
      <th class="warna" align="right" width="7%"></th>    
    </tr>                          
 
</table>

               
               


</body>
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
        
require '../html2pdf/autoload.php';
$pdf = new Spipu\Html2Pdf\Html2Pdf('L','A4','en');
$pdf->WriteHTML($html);
$pdf->Output('Laporan Pembayaran Murid.pdf', 'D');
?>


<!-- https://www.mynotescode.com/cara-mudah-membuat-laporan-pdf-dengan-php-dan-mysql/ -->