<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;margin:0;outline:0;padding:0;vertical-align:baseline}
ol,ul{list-style:none}
table{border-collapse:collapse;border-spacing:0;width:100%}
body{font-size:12px !important;padding:15px 15px 15px 25px}
th,td{border:1px solid #000;padding:2px}
th{align:center;vertical-align:middle}
.header{border-bottom:1px solid #000;margin-bottom:10px;padding-bottom:3px}
.header .title{font-size:14px}
</style>
</head>
<body>
<div class="header">
<p class="title">Laporan Pembiayaan Kendaraan Bermotor</p>
<?php if ($unit): ?>
<p class="period">Unit : <?php echo $unit ?></p>
<?php endif ?>
<p class="period">Periode Laporan : <?php echo $start ?> s/d <?php echo $end ?></p>
</div>
<table>
<thead>
<tr>
<th>No</th>
<th width="6%">Tanggal</th>
<th width="7%">Nama</th>
<th>No. SP</th>
<th>Merek</th>
<th width="6%">Tipe</th>
<th width="8%">No. Polisi</th>
<th width="9%">No. BPKB</th>
<th>DP</th>
<th>Saldo Piutang</th>
<th>JW</th>
<th>Ang/Bln</th>
<th>S.P. Pokok</th>
<th>S. Bunga</th>
<th>Harga Netto</th>
<th>Harga Total</th>
<th>Harga Beli</th>
<th>Pembiayaan</th>
</tr>
</thead>
<tbody>
<?php $total_advance = 0; $total_receivable = 0; $total_installment = 0; $total_principal = 0; $total_interest = 0; $total_net_price = 0; $total_purchase_price = 0; $total_financing = 0; $grand_total = 0; ?>
<?php foreach ($transactions as $index => $transaction): ?>
<tr>
<td align="center"><?php echo $index + 1 ?></td>
<td align="center"><?php echo date('d/m/y', $transaction['date']) ?></td>
<td><?php echo $transaction['customer_name'] ?></td>
<td align="center"><?php echo $transaction['transaction_number'] ?></td>
<td><?php echo $transaction['brand'] ?></td>
<td><?php echo $transaction['type'] ?></td>
<td align="center"><?php echo $transaction['vehicle_number'] ?></td>
<td align="center"><?php echo $transaction['vehicle_owner_number'] ?></td>
<td align="right"><?php echo number_format($transaction['advance']) ?></td>
<td align="right"><?php echo number_format($transaction['receivable']) ?></td>
<td align="center"><?php echo $transaction['term'] ?></td>
<td align="right"><?php echo number_format($transaction['installment']) ?></td>
<td align="right"><?php echo number_format($transaction['principal']) ?></td>
<?php $interest = $transaction['receivable'] - $transaction['principal'] ?>
<td align="right"><?php echo number_format($interest) ?></td>
<td align="right"><?php echo number_format($transaction['net_price']) ?></td>
<td align="right"><?php echo number_format($transaction['total_price']) ?></td>
<?php $financing = ($transaction['purchase_price'] - $transaction['advance']) < 0 ? 0 : ($transaction['purchase_price'] - $transaction['advance']) ?>
<td align="right"><?php echo number_format($transaction['purchase_price']) ?></td>
<td align="right"><?php echo number_format($financing) ?></td>
<?php $total_advance += $transaction['advance'] ?>
<?php $total_receivable += $transaction['receivable'] ?>
<?php $total_installment += $transaction['installment'] ?>
<?php $total_principal += $transaction['principal'] ?>
<?php $total_interest += $interest ?>
<?php $total_net_price += $transaction['net_price'] ?>
<?php $total_purchase_price += $transaction['purchase_price'] ?>
<?php $total_financing += $financing ?>
<?php $grand_total += $transaction['total_price'] ?>
</tr>
<?php endforeach ?>
<tr>
<td colspan="8"></td>
<td align="right"><?php echo number_format($total_advance) ?></td>
<td align="right"><?php echo number_format($total_receivable) ?></td>
<td></td>
<td align="right"><?php echo number_format($total_installment) ?></td>
<td align="right"><?php echo number_format($total_principal) ?></td>
<td align="right"><?php echo number_format($total_net_price) ?></td>
<td align="right"><?php echo number_format($grand_total) ?></td>
<!-- -->
<td align="right"><?php echo number_format($total_purchase_price) ?></td>
<td align="right"><?php echo number_format($total_financing) ?></td>
</tr>
</tbody>
</table>
</body>
</html>