<?php
//error_reporting(0);
session_start();

ob_start();
$html = ob_get_clean();
// include autoloader
require_once '../setting/crud.php';
require_once '../setting/koneksi.php';
require_once '../setting/tanggal.php';
require_once '../setting/fungsi.php';

require_once '../dompdf/autoload.inc.php';
require_once  '../dompdf/vendor/autoload.php' ;
/*require_once '../dompdf/style.php';*/

use Dompdf\Dompdf;

/*$style=f_bootsrap();
*/$judul=$_SESSION['jurnalumum']['judul'];
$periode=$_SESSION['jurnalumum']['periode'];
$unit=$_SESSION['jurnalumum']['kantor'];
$sqlj=$_SESSION['jurnalumum']['kode']['sqlj'];


$header='<p align="center" style="margin:0px;font-family : Arial; ">'."PT. MENARA SEMBILAN SEJAHTERA".'</p>';
$header=$header.'<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;"> KANTOR '.$_SESSION['kantor'].' </p>';
$header=$header.'<p style="font-size:13px;text-align:center;margin:0px; font-family : Arial;">'."LAPORAN JURNAL UMUM".' </p>';
$periode='<p style="font-size:13px;text-align:center;margin-top:0px; font-family : Arial;">'.$periode.'</p>';

$isi=$isi='<table border="1" class="table table-bordered table-hover" align="center"
<style>
   table {border-collapse:collapse; table-layout:fixed;width: 97%; }
    table td {margin: 1 20px 20px 0; font-family : Arial;}
        table {
            border-collapse: collapse;
        }
        
        
        th, td {
            padding-right: 15px;
            font-size: 13px;
            height: 20px;
            /*text-align: right;*/
            margin-bottom: 11px;
            
            /*font-weight: bold; fon tebal*/
            border-bottom: bold;
          }

          body { font-family: Arial; }
          p { font-family: Courier, monospace; }
          div { font-family: "Duru Sans", Verdana, sans-serif; }
          
                 
        
    </style>
>

	    <thead>
	      <tr>
	        <th style="text-align: center; background: #ddd;width: 4%">No</th>
	        <th style="text-align: center; background: #ddd;width: 7%">Tanggal</th>
            <th style="text-align: center; background: #ddd;width: 12%">Faktur</th>
            <th style="text-align: center; background: #ddd;width: 10%">Rekening</th>
            <th style="text-align: center; background: #ddd;width: 8%">Debet</th>
            <th style="text-align: center; background: #ddd;width: 8%">Kredit</th>
            <th style="text-align: center; background: #ddd;width: 35%">Keterangan </th>
            
	      </tr>
	    </thead>
    <tbody>';
			$no=0;
	  	
      $saldo=0;
	  $query      = $sqlj;
	  $result     = $mysqli->query($query);
	  $num_result = $result->num_rows;
	  if ($num_result > 0) {
	  	
	    while ($data = mysqli_fetch_assoc($result)) {
	      extract($data);
	      $saldo+=$debet;
	      $saldo-=$kredit;
	      $no++;
	     
	      	$isi=$isi.'<tr>';
	       	$isi=$isi.'<td style="text-align: center; padding-left: 6px;">'.$no.'</td>';
	        $isi=$isi.'<td style="text-align: center; padding-left: 6px;">'.date('d-m-Y',strtotime($tanggal)).'</td>';
	        $isi=$isi.'<td style="text-align: left; padding-left: 6px;">'.$no_bukti.'</td>';
	        $isi=$isi.'<td style="text-align: left; padding-left: 6px;">'.$kode_akun.'</td>';
	        
	        $isi=$isi.'<td style="text-align: right; padding-right: 6px;">'.number_format($debet,0).'</td>';
	        $isi=$isi.'<td style="text-align: right; padding-right: 6px;">'.number_format($kredit,0).'</td>';
	        $isi=$isi.'<td style="text-align: left; padding-left: 6px;">'.$keterangan.'</td>';
	        $isi=$isi.'</tr>';
	        
	    }
	}

$isi=$isi.'</tbody></table>';

//echo $style.$header.$periode.$isi;

// instantiate and use the dompdf class
//echo $style.$header.$periode.$isi;
$html = ob_get_contents();
ob_end_clean();
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml($header.$periode.$isi);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$filename = "Laporan_Jurnal_Umum_".date("Y-m-d_H-i-s");
$dompdf->stream($filename);


?>