<?php
	require_once "core/koneksi.php";
	require_once 'core/paramx.php';
?>
<!DOCTYPE html>
<html>
<head>
	<script src="report_new/jspdf/jspdf.js"></script>
	<script src="report_new/jspdf/jquery-2.1.3.js"></script>
	<title></title>
	<style>
	/* Style Css Tidak Bisa Dipisah */
	.company{ font-size: 15px; margin-left: 17px; margin-top: 25px; margin-bottom: 25px; font-weight: bold; }
	.tablehead{ font-size: 12px; height:20px; width: 120px; border: 1px solid #3c3c3c; padding: 1px 8px;}
	a{ background: blue; color: #fff; padding: 8px 10px; text-decoration: none; border-radius: 2px; }
	.no{ font-size: 12px; height:20px; width: 40px; border: 1px solid #3c3c3c; padding: 1px 8px; }
	table td{ font-size: 13px; height:25px; border: 0px solid #3c3c3c; padding: 2px 8px; }
	.caption{ font-size: 15px; font-weight: bold; text-align: left; margin-bottom: 0px; }
	.name{ text-align: center; margin-bottom:25px; font-size: 18px; font-weight: bold; }
	.table-all{ margin: 20px auto; border-collapse: collapse; margin-top: 20px; }
	.total{ font-size: 14px; font-weight: bold; border: 0px; }
	*{ font-family: sans-serif; background-color: white; }
	.period{ margin-bottom: 25px; margin-left: 17px;}
	</style>
</head>
<body>
	<div id="HTMLtoPDF"> <!-- Div untuk mengambil data untuk pdf -->
		<div class="company">
		      	CV ABRINDO SEJAHTERA
		</div>
		<div class="name">
				LAPORAN BUKU BESAR
		</div>
		<div class="period">
					Periode : <?=$date_from?> s/d <?=$date_end?>
	</div>
<?php
$no=1;
$temp = '';
$credittot = 0;
$tempOld = '1';
$saldoCount = 0;
unset($_SESSION['temp']);
$debittot  = $lihat['fcdebit'];
?>
 <?php while($lihat = mysqli_fetch_assoc($result)){ ?>
 <?php
		//Mengubah Stok Awal Menjadi 0
	 if ($lihat['ftDescription']  == 'Saldo Awal') {
	      // $lihat['fcsaldo'] = 0;
	  }

	 $saldoCount = $saldoCount + $lihat['fcdebit'] - $lihat['fccredit'];
	 $debittot   = $debittot + $lihat['fcdebit'];
	 $temp = $lihat['ftcoa_code'];

 ?>
	<?php
	    if ($tempOld != $temp) {
	    if ($_SESSION['temp'] == 'true') {
	?>
		<tr>
		<td></td>
		<td></td>
		<td></td>
		<td></td>
		<td class="total">TOTAL :</td>
		<td class="total"><?=rupiah($debittot)?></td>
		<td class="total"><?=rupiah($credittot)?></td>
		<td></td>
  	</tr>
	<?php
		 }
	}
	?>
	<?php if($temp != $tempOld) {
		$no=1;
		$saldoCount = $lihat['fcsaldo'];
		$debittot   = $lihat['fcdebit'];
		$credittot =  $lihat['fccredit'];
		$credittot  = $credittot - $credittot;
	?>
	<table class="table-all">
		<div class="caption">
			<?=$lihat['ftcoa_code']."-".$lihat['ftcoa_name']?>
		</div>
		<tr>
			<th class="no">No</th>
			<th class="tablehead">Tanggal</th>
			<th class="tablehead">No.Transaksi</th>
			<th class="tablehead">Keterangan</th>
			<th class="tablehead">Jumlah (Non IDR)</th>
			<th class="tablehead">Debit (IDR) </th>
			<th class="tablehead">Kredit (IDR)</th>
			<th class="tablehead">Saldo (IDR)</th>
		</tr>
	<?php
   }
 $tempOld = $temp;
 $_SESSION['temp'] = 'true';
	?>
			<tr>
			<td><?=$no?></td>
			<td><?=$lihat['fdtrans_date']?></td>
			<td><?=$lihat['ftdocument_no']?></td>
			<td><?=$lihat['ftDescription']?></td>
      <td></td>
      <td><?=rupiah($lihat['fcdebit'])?></td>
      <td><?=rupiah($lihat['fccredit'])?></td>
      <td><?=rupiah($saldoCount)?></td>
	  	</tr>
 <?
  $credittot  = $credittot + $lihat['fccredit'];
$no++;
?>
<?php } ?>
	</table>
</div><!-- div penutup jquery -->
</body>

</html>
