<?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 { margin-top: 2%;
            /*border-collapse: collapse;*/
        }    
        th, td {
            padding: 4px;
            font-size: 13px;
        }
       /* 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
// Load file koneksi.php
include "./../koneksi.php";
error_reporting(1); //hide php errors

  if(isset($_GET['rekening'])) {   
}
$rekening = $_GET['rekening']; 
    
                       
         $print = mysqli_query($koneksi,"SELECT a.no_bukti AS no_bukti,a.tgl AS tgl,c.tgl AS tglp,a.pokok AS pokok,a.margin AS margin,a.keterangan AS keterangan,b.nama AS nama,c.barang AS barang,c.noseri AS noseri,c.jtempo AS jatuhtempo,count(a.no_bukti) AS angske FROM angsuran a LEFT JOIN registrasi b ON b.id=substr(a.rekening,1,10) LEFT JOIN pinjaman c ON a.rekening=c.rekening  WHERE a.rekening ='".$rekening."' AND a.no_bukti LIKE '%AG%'  ORDER BY a.no DESC LIMIT 1");
          $data = mysqli_fetch_array($print);
          extract($data);
          
          function jtempo($ke,$tgl){          
            if($ke<=1){
            $hasil= date('d-m-Y', strtotime('+15 days', strtotime($tgl)));
            }else if($ke<=2){
              $hasil= date('d-m-Y', strtotime('+30 days', strtotime($tgl)));
            }else{
              $hasil= date('d-m-Y', strtotime('+45 days', strtotime($tgl)));
            }

            return $hasil;
            
          }
          /*echo jtempo($angske,$tglp)."<br>";*/
         function jtempo2($ke,$tgl){          
            if($ke<=1){
            $hasi2= date('d-m-Y', strtotime('+30 days', strtotime($tgl)));
            }else if($ke<=2){
              $hasi2= date('d-m-Y', strtotime('+45 days', strtotime($tgl)));
            }else{
              $hasi2= date('d-m-Y', strtotime('+60 days', strtotime($tgl)));
           /* }else{
              $hasi2= date('d-m-Y', strtotime('+15 days', strtotime('Y-m-d')));*/
            }

            return $hasi2;
            
          }

      ?>
      
      
       
<style type="text/css">
.s2{  
  text-align:left;  
  font-size: 11px;
  
  font-feature-settings: "smcp", "zero";
  text-wrap: wrap;
  margin-bottom: 0px;
  margin-top: 0px;   
} 
td{  
  text-align:left;  
  font-size: 11px;
  /*line-height:14px;*/
  font-feature-settings: "smcp", "zero";
  text-wrap: wrap; 
   margin-bottom: 0px;
  margin-top: 0px; 
  
} 

.s1{  
  text-align:center;  
  font-size: 12px;
 font-feature-settings: "smcp", "zero";
  margin-bottom: 0px;
  margin-top: 0px;

}
</style>
<table border="0" style="margin-top: 0px;">
<tr>
<td><img src="./../img/angs.png" style="width:140px;height:72px;" />
</td>
</tr>
</table>
<p class="s1"><?php echo "Tgl ".date('d-m-Y'); ?></p>
<b><p class="s2" style="margin-top:0px;"><?php echo "---------------------------------------------\n";?></p></b>
<p class="s1"><?php echo "rekening ".$rekening; ?></p>
<b><p class="s2"><?php echo "---------------------------------------------\n";?></p></b>
<table border="0" style="margin-top:0px;">
<tr>
<td>Nama </td>
<td>:</td>    
<td class="s2" style="width: 80px;"><?php echo $nama; ?></td>
</tr>
<tr>
<td>Barang </td>
<td>:</td>    
<td class="s2;"style="width: 80px;"><?php echo $barang; ?></td>
</tr>
<tr>
<td class="s3">No Seri </td>
<td>:</td>    
<td class="s2"style="width: 80px;"><?php echo $noseri; ?></td>
</tr>
         
</table>

<b><p class="s2"><?php echo "---------------------------------------------\n";?></p></b>
<!-- <p class="s2">
<A?php echo "Nama"."&nbsp;&nbsp;&nbsp;".":".$nama."yssssssssssss10"; ?>
</p>
<p class="s2">
<A?php echo "Barang : ".$barang."<br>"; ?>
</p>
<p class="s2">
<A?php echo "No Seri : ".$barang."<br>"; ?>
</p> -->
<p class="s2">
<?php echo "Pembayaran ke  :" .$angske."<br>"."\n\n"; ?>
</p>
<p class="s2">
<?php echo "Jatuh Tempo  :" .jtempo($angske,$tglp)."<br>"."\n\n" ?>
</p>
<!-- tanggal jatuh temponya pembayaran sesuai urutnya -->
<p class="s2">
<?php echo "Cicil Pinjaman  :" .number_format($pokok,0)."<br>"."\n\n" ?>
</p>
<p class="s2">
<?php echo "Total Biaya Titip  :" .number_format($margin,0)."<br>"."\n\n" ?>
</p>
<b><p class="s2"><?php echo "---------------------------------------------\n";?></p></b>
<!-- <p class="s2">
<A?php  if($angske<=3){echo "Jatuh Tempo Selanjutnya  :".jtempo2($angske,$tglp);}else{echo "Jatuh Tempo Selanjutnya  :".date('d-m-Y', strtotime('+15 days', strtotime($tglskrg)))."<br>"."\n\n"; }?>
</p> -->
<p class="s2">
<?php echo "Mohon dicek kembali pembayarannya"."<br>"."\n\n" ?>
</p>
<p class="s1">
<?php echo "-------Terima Kasih-------"."<br>"."\n\n" ?>
</p>


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


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