<table>
	<thead>
		<tr>
			<td>&nbsp;</td>
			<td>CV. KETJUBUNG</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>{{ $judul }}</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>PERIODE : {{ $periode }}</td>
		</tr>
	</thead>
</table>
<table border="1">
	<thead>
		<tr>
			<th>No</th>
            <th>Jenis Sarung</th>
            <th>Total</th>
            <th>Qty</th>
            <th>Harga</th>
            <th>Jumlah</th>
            <th>Diskon</th>
            <th>Netto</th>
		</tr>
	</thead>
	<tbody>
	@php
		$no = 1;
		$total_totalqty = 0;
		$total_qty = 0;
		$total_jumlah = 0;
		$total_diskon = 0;
		$total_netto = 0;
	@endphp
	@foreach($data AS $key=>$value)
		<tr>
			<td rowspan="{{ sizeof($value->child)==0 ? 1 : sizeof($value->child) }}" valign="middle">{{ $no }}</td>
			<td rowspan="{{ sizeof($value->child)==0 ? 1 : sizeof($value->child) }}" valign="middle">{{ $value->nama_barang }}</td>
			<td rowspan="{{ sizeof($value->child)==0 ? 1 : sizeof($value->child) }}" valign="middle">{{ $value->total_qty }}</td>
			@foreach($value->child AS $keyZ=>$valueZ)
				@php
					$jumlah_harga = $valueZ->jumlah_harga+$valueZ->jumlah_pajak;
					$jumlah = $valueZ->nominal_jumlah+$valueZ->nominal_pajak;
			        $netto = $valueZ->nominal_jumlah-$valueZ->nominal_potongan+$valueZ->nominal_pajak;
				@endphp

				@if($keyZ!=0)
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				@endif

				<td align="right">{{ $valueZ->jumlah_qty }}</td>
				@if($valueZ->mata_uang != 1)
					<td align="right">{{ $valueZ->harga_satuan*$valueZ->kurs_jual }}</td>
					<td align="right">{{ $jumlah*$valueZ->kurs_jual }}</td>
					<td align="right">{{ $valueZ->nominal_potongan*$valueZ->kurs_jual }}</td>
					<td align="right">{{ $netto*$valueZ->kurs_jual }}</td>
				@else
					<td align="right">{{ $valueZ->harga_satuan }}</td>
					<td align="right">{{ $jumlah }}</td>
					<td align="right">{{ $valueZ->nominal_potongan }}</td>
					<td align="right">{{ $netto }}</td>
				@endif

				@php
					$total_qty .= (float) $valueZ->jumlah_qty;
					$total_jumlah .= (float) $jumlah;
					$total_diskon .= (float) $valueZ->nominal_potongan;
					$total_netto .= (float) $netto;
				@endphp

			@endforeach
		</tr>
	@php
		$total_totalqty .= (float) $value->total_qty;

		$no++;
	@endphp
	@endforeach
	</tbody>
	<!-- <tfoot>
		<tr>
			<th colspan="2">TOTAL</th>
			<th align="right">{{ $total_qty }}</th>
			<th align="right">&nbsp;</th>
			<th align="right">{{ rupiah2($total_jumlah, 2) }}</th>
			<th align="right">{{ rupiah2($total_diskon, 2) }}</th>
			<th align="right">{{ rupiah2($total_netto, 2) }}</th>
		</tr>
	</tfoot> -->
</table>