<table>
	<thead>
		<tr>
			<td colspan="7" style="text-align: center; font-weight: bold;">{{ strtoupper($judul) }}</td>
		</tr>
		<tr>
			<td colspan="7" style="text-align: center; font-weight: bold;">{{ strtoupper(strtolower("Bulan : ".$periode)) }}</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</thead>
</table>
<table border="1">
	<thead>
		<tr>
			<th style="text-align: center; font-weight: bold;">No</th>
            <th style="text-align: center; font-weight: bold;">TANGGAL PENGAMBILAN</th>
            <th style="text-align: center; font-weight: bold;">NO. FAKTUR</th>
            <th style="text-align: center; font-weight: bold;">NAMA PELANGGAN</th>
            <th style="text-align: center; font-weight: bold;">JUMLAH</th>
            <th style="text-align: center; font-weight: bold;">TGL JATUH TEMPO</th>
            <th style="text-align: center; font-weight: bold;">KETERANGAN</th>
		</tr>
	</thead>
	<tbody>
	@php
		$total = 0;
	@endphp
	@if(count($data) > 0)
	@php
		$no = 1;
	@endphp
	@foreach($data AS $key=>$d)
		@php
			$selisih = (float)$d->piutang-(float)$d->total_bayar;
			if($selisih==0){
			    continue;
			}

			$set_selisih = 0;
			if ($d->mata_uang != 1) {
			    $set_selisih = $selisih*$d->kurs_jual;
			    $total += $set_selisih;
			} else {
			    $set_selisih = $selisih;
			    $total += $set_selisih;
			}
		@endphp
		<tr>
			<td>{{ $no }}</td>
			<td style="text-align: center;">{{ date_db($d->tanggal_faktur, true) }}</td>
			<td>{{ nomor_penjualan($d) }}</td>
			<td>{{ $d->nama_pelanggan }}</td>
			<td style="text-align: right;">{{ $set_selisih }}</td>
			<td style="text-align: center;">{{ date_db($d->tanggal_tempo, true) }}</td>
			<td>{{ $d->keterangan }}</td>
		</tr>
		@php($no++)
	@endforeach
	<tr>
		<td colspan="4" style="text-align: right; font-weight: bold;">Total</td>
		<td style="text-align: right; font-weight: bold;">{{ $total }}</td>
		<td colspan="2"></td>
	</tr>
	@endif
	</tbody>
</table>