<div class="container">
	<h4>Detail Pesanan</h4>
	<div class="badge badge-pill badge-sm badge-dark my-3 ">No. Invoice: <?php echo $invoice->id ?></div>
	
	<table class="table table-bordered table-hover table-striped">
		
		<tr>
			<th><center>ID BARANG</center></th>
			<th><center>NAMA PRODUK</center></th>
			<th><center>JUMLAH PESANAN</center></th>
			<th><center>HARGA SATUAN</center></th>
			<th><center>SUB-TOTAL</center></th>
		</tr>
		
		<?php 
		$total = 0;
		foreach ($pesanan as $psn) :
			$subtotal = $psn->harga * $psn->jumlah + $psn->keuntungan;
			$total = $subtotal;
			?>

<tr>
	<td class="text-center"> <?php echo $psn->id_brg ?></td>
	<td class="text-center"> <?php echo $psn->nama_brg  ?></td>
	<td class="text-center"> <?php echo $psn->jumlah  ?></td>
	<td class="text-right">Rp. <?php echo number_format($psn->harga + ($psn->keuntungan / $psn->jumlah),0,',','.') ?></td>
	<td class="text-right">Rp. <?php echo number_format($subtotal,0,',','.') ?></td>
</tr>

<?php endforeach; ?>

<tr>
	<?php if($invoice->ket == 1):?>
		<td colspan="3" class="text-right text-light bg-success"><Strong>LUNAS</Strong></td>
		<?php else:?>
			<td colspan="3" class="text-right text-light bg-secondary"><Strong>BELUM LUNAS</Strong></td>
			<?php endif;?>
			<td align="right">Grand Total</td>
			<td align="right">Rp. <?php echo number_format($total,0,',','.') ?></td>
		</tr>
	</table>
	<?php if($invoice->ket!=0):?>
	<a href="<?= base_url('/uploads/kwitansi/'.$invoice->img) ?>"><img src="<?= base_url('/uploads/kwitansi/'.$invoice->img) ?>" class="w-25 img-thumbnail"></a>
	<?php if($invoice->ket!=1):?>
	<div class="my-5">
	<a onclick="return confirm('Apakah transaksi telah lunas?')" href="<?= base_url('admin/invoice/ket/'.$invoice->id.'/1') ?>"><div class="btn btn-sm btn-success mx-3">Lunas</div></a>
	<a onclick="return confirm('Apakah kwitansi tidak sesuai?')" href=" <?php echo base_url('admin/invoice/hapusinv/'.$invoice->id) ?>"><div class="btn btn-sm mx-3 btn-danger">Tolak Kwitansi</div></a>
	</div>
	<?php endif;?>
	<?php endif; ?>
	<div>
	<a href=" <?php echo base_url('admin/invoice/index') ?>"><div class="btn btn-sm btn-secondary">Kembali</div></a>
	<a href=" <?php echo base_url('admin/invoice/cetak/'.$invoice->id) ?>"><div class="btn btn-sm btn-primary">Cetak</div></a>
	</div>
	
</div>