<?php 
session_start();
ob_start();

 ?>
<html>
<head>
  <title>Cetak PDF</title>
    
   <style>
   table {border-collapse:collapse; table-layout:fixed;width:106%; }
  /* 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: 12px;
        }
        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['jurnalumumadmin']['periode'];
$sqlj = $_SESSION['jurnalumumadmin']['kode']['sqlj'];
?>
<p align="center" style="margin:0px;font-family : Arial; ">PT. MENARA SEMBILAN SEJAHTERA</p>
<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"> KANTOR <?php echo $_SESSION['kantor'];?> </p>
<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;">LAPORAN JURNAL UMUM KHUSUS </p>
<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"><?php echo $periode; ?> </p>      

<table border="1" style="padding-top: 19px;padding-bottom: 16px">
<tr>
<td style="text-align: center; background: #ddd;"><b>No.</b></td>
<td style="text-align: center; background: #ddd;"><b>Tgl</b></td>
<td style="text-align: center; background: #ddd;"><b>No.Bukti</b></td>
<td style="text-align: center; background: #ddd;"><b>Rekening</b></td>
<td style="text-align: center; background: #ddd;"><b>Debet</b></td>
<td style="text-align: center; background: #ddd;"><b>Kredit</b></td>
<td style="text-align: center; background: #ddd;"><b>Keterangan</b></td>
<td style="text-align: center; background: #ddd;"><b>UserName</b></td>

</tr>

<?php
// Load file koneksi.php
include "./../koneksi.php";
 /*include ('../koneksi.php');*/
 error_reporting(0); //hide php errors
 $no=0;
 
$sql = mysqli_query($koneksi, $sqlj); // 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($databb = mysqli_fetch_array($sql)){ // Ambil semua data dari hasil eksekusi $sql
      extract($databb);
      $tdebet +=$debet;
      $tkredit+=$kredit;
     $no++;     
    ?>   

  <tr>                      
    <td class ="pertama" width="5%" style="text-align: center;"> <?php echo $no ?></td>
    <td class ="pertama" width="6%" style="text-align: center;"> <?php echo date('d-m-Y',strtotime($tglsystem))?> </td>
     <td class ="pertama" style="text-align: left; width: 18%;"> <?php echo $no_bukti?> </td>
     <td class ="pertama" style="text-align: left; width: 8%;"> <?php echo $kode_akun?> </td>
        
    <td class ="pertama"  style="text-align: right; width: 7%;"> <?php echo number_format($debet);?> </td>
    <td class ="pertama" style="text-align: right; width: 7%;"> <?php echo number_format($kredit);?> </td>
    <td class ="pertama" style="text-align: left; width: 28%;"> <?php echo substr($keterangan,0,30)  ;?> </td>
    <td class ="pertama" style="text-align: left; width: 10%;"> <?php echo substr($usersys,0,20)  ;?> </td>      
</tr>
      <?php    
    }
    }?>
     <tr>
    <b><td class="warna" colspan="4" style="text-align: center;">Jumlah</td></b>
    <b><td class="warna" style="text-align: right;"><?php echo number_format($tdebet,0)?></td></b>             
    <b><td class="warna" align="right" ><?php echo number_format($tkredit,0);?></td></b>
    <b><td> </td></b>
    
    </tr>                          
 
</table>

               
               


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


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