<?php if($act=="add" || $act=="edit"){?>
<div class="py-3 pl-1">
	<a href="javascript:void(0)" onclick="add_detailrow()" class="btn btn-primary btn-sm">Tambah Baris Baru
	</a>
</div>
<?php } ?>

<div id="detail" style="overflow-y:scroll;height:350px;">
<table class="table table-bordered" id="jt_table">
<thead>
<tr class="thead" style="background-color:#333;color:white"> 	
	<td class="tc" style="width:300px">Nama Item</td>
    <td class="tr" style="width:120px;">Harga Beli</td>
    <td class="tr" style="width:120px;">Qty</td>
    <td class="tc" style="width:50px;">Satuan</td>
    <td class="tr" style="width:150px;">Subtotal</td>
</tr>
</thead>
<?php

$subtotal = 0;

$i = 0;

$sqldetail = "SELECT * FROM prdetail a, mst_product b 
				WHERE a.pm_autoid = b.pm_autoid AND a.pr_autoid = '$autoid' ORDER BY a.prd_autoid";
$detail_con = $conn->query($sqldetail) or die($sqldetail);
while($rsd = $detail_con->fetch_assoc()){
	$pmdesc = $rsd['pm_name'];
	
	$qty = $rsd['prd_qty'];
	$pm_bprice = $rsd['prd_price'];
	$detail_subtotal = $qty * $pm_bprice;
	$pm_autoid = $rsd['pm_autoid'];
?>
<tr>
	<td><?php echo $pmdesc?></td>
    <td class="tr"><?php echo number_format($pm_bprice)?></td>
    <td class="tr"><?php echo $qty?></td>
    <td class="tc">Kg</td>
    <td class="tr"><?php echo number_format($detail_subtotal)?></td>
</tr>
<?php 
$i = $i + 1;
$subtotal = $subtotal + $detail_subtotal;
}?>

</table>
</div>
<script>
</script>
<div style="border-top:1px solid black;">
<table class="table table-bordered">
<tr class="bold">
	<td style="width:80%" class="tr">TOTAL PEMBELIAN</td>
    <td class="tr"><?php echo number_format($subtotal)?>
    </td>
</tr>
</table>
</div>
<div id="chk" style="display:none"></div>

							<input type="hidden" id="totalcb" name="totalcb" value="<?php echo $total?>" autocomplete="off">
							<input type="hidden" id="row" autocomplete="off" name="row" value="<?php echo $i?>" />