<?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     

$akuncw =$_SESSION['warkatp']['akun'];
$sqlcw=  $_SESSION['warkatp']['kode']['sql'];
?>
<p align="center" style="margin:0px;font-family : Arial; "></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;"></p>
<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"> </p>
  



<?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, $sqlcw); // 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($datacw = mysqli_fetch_array($sql)){ // Ambil semua data dari hasil eksekusi $sql
      extract($datacw);
      
      
     }}  
    ?>   
 <table border="0" style="width: 100%;margin-top: 68px;">
    <tr>
    <!-- <td colspan="8" style="font-weight: bold;height: 5px; padding-left: 390px;"><?php echo"CABANG ".$_SESSION['kantor']; ?></td>  -->   
    </tr>
    </table>

<table border="0" style="padding-top: 19px;padding-bottom: 16px;margin-left: 70px;margin-top: 2px;">


    
<tr> 
<td style="text-align: left; padding-left:6px; width:16%;">Telah Terima dari</td>
<td style="text-align: center; width:1%;">:</td>               
<td style="text-align: left; padding-left: 6px; width:23%;"><?php echo ucwords(strtolower($nama)); ?> </td> 

</tr>
<tr>
<td style="text-align: left; padding-left:6px; width:16%;">Pinjaman</td>
<td style="text-align: center; width:1%;">:</td>                
<td style="text-align: left; padding-left: 6px; width:23%;"><?php echo number_format($pokok,0); ?> </td> 
</tr>

<tr>
<td style="text-align: left; padding-left:6px; width:16%;">Ujroh</td>
<td style="text-align: center; width:1%;">:</td>                
<td style="text-align: left; padding-left: 6px; width:23%;"><?php echo number_format($margin,0); ?> </td> 
</tr>

<tr>
<td style="text-align: left; padding-left: 6px; width:16%;">Jumlah</td>
<td style="text-align: center; width:1%;">:</td>
<td style="text-align: left; padding-left: 6px; width:23%;"><?php echo number_format($pkok+$margin,0); ?></td>

</tr>

</table>

<table border="1" style="margin-left: 70px;margin-top: 1px;width: 90%;">
<tr>

<td style="text-align: center; padding-left: 6px; width:16%;">Tanggal</td>
<td style="text-align: center; padding-left: 6px; width:20%;">Barang Jaminan</td> 
<td style="text-align: center; padding-left: 6px; width:50%;">Keterangan</td>

</tr>


    <tr>
    <td style="text-align: center; padding-left: 6px;"><?php echo date('d-M-Y',strtotime($tgl)); ?></td>
    <td style="text-align: center; padding-left: 6px;"><?php echo $jaminan; ?></td>
    <td style="text-align: center; padding-left: 6px;"><?php echo ucwords(strtolower($keterangan)); ?></td>
    </tr>

</table>

<table border="0" style="padding-top: 19px;padding-bottom: 16px;margin-left: 70px;margin-top: 2px;">

<tr>
<td style="text-align: center; padding-left: 6px; width:40%;">Dibayar Oleh</td>
<td style="text-align: center; padding-left: 6px; width:40%;">Diterima Oleh</td>    
</tr>

<tr>
<td style="text-align: center; padding-left: 6px;padding-top: 60px; width:40%;"><?php echo ucwords(strtolower($nama)); ?></td>
<td style="text-align: center; padding-left: 6px;padding-top: 60px; width:40%;"><?php echo ucwords(strtolower($usersystem)); ?></td>

</tr>



<tr>
    
    
    <td></td>
    <td >Samarinda,<?php echo date('d-m-Y');?></td>
    
    
    </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 Tunggakan.pdf', 'D');
?>


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