<div id="detail">
<table class="table table-bordered" id="jt_table">
<thead>
<tr>
	<td colspan="6">
    <?php if($act=="add" || $act=="edit"){?>
    <a href="javascript:void(0)" onclick="add_detailrow()" class="btn btn-primary btn-sm">Tambah Baris Baru
    </a>
    <?php } ?>
    </td>
</tr>
<tr class="thead" style="background-color:#333;color:white">
	<td style="width:30px">No</td>
	<td class="tc" style="width:350px">Nama Item</td>
    <td class="tr" style="width:120px;">Harga</td>
    <td class="tr" style="width:120px;">Qty</td>

	<td class="tl" style="width:200px;">Catatan</td>
    <td class="tl" style="width:80px;">Stok</td>
</tr>
</thead>
<?php

$total = 0;

$i = 0;

$sqldetail = "SELECT * FROM invtransd  a, mst_product b where a.pm_autoid = b.pm_autoid AND a.invt_autoid = '$autoid' ORDER BY a.invtd_autoid";
$detail_con = $conn->query($sqldetail) or die($sqldetail);
while($rsd = $detail_con->fetch_assoc()){
	$pmdesc = $rsd['pm_name']." - ".$rsd['pm_code'];
	
	$qty 	= $rsd['invtd_qty'];
	$dnotes = $rsd['invtd_notes'];
	$price 	= $rsd['invtd_bprice'];
	$ums 	= $rsd['invtd_um'];

	$stok = get_stok_info($rsd['pm_autoid'],0,$conn);

?>
<tr>
	<td><?php echo $i+1?></td>

	<td>
    	<input type="text" id="pm<?php echo $i?>" class="input" value="<?php echo $pmdesc?>" autocomplete="off" style="width:100%" onfocus="pm_auto_complete('<?php echo $i?>')">
        <input type="hidden" id="pm_autoid<?php echo $i?>"  autocomplete="off" name="pm_autoid<?php echo $i?>" value="<?php echo $rsd['pm_autoid']?>">
    </td>
    <td>
    	<input type="text" class="input tr" onkeyup="calc_cb()" id="price<?php echo $i?>"  value="<?php echo $price?>"
         name="price<?php echo $i?>" onkeydown="chk_coa('<?php echo $i?>')" style="width:100%" autocomplete="off">
    </td>
    <td>
    	<input type="text" class="input tr" onkeyup="calc_cb()" id="qty<?php echo $i?>" value="<?php echo $qty?>"
         name="qty<?php echo $i?>" onkeydown="chk_coa('<?php echo $i?>')" style="width:100%" autocomplete="off">
    </td>


    <td>
    	<input type="text" class="input tl" id="dnotes<?php echo $i?>" value="<?php echo $dnotes?>" name="dnotes<?php echo $i?>" 
        onblur="chk_field('<?php echo $i?>')" style="width:100%"autocomplete="off">
    </td>
    <td><input readonly id="stok<?php echo $i?>" class="input bg bg-warning" value="<?php echo $stok?>"></td>
</tr>
<?php 
$i = $i + 1;
$total = $total + $qty;
}?>

<tfoot>
<tr class="bg-primary" style="color:#fff">
	<td colspan="3" class="tr">TOTAL</td>
    <td class="tr">
    	<span id="jmlcb"><?php echo number_format($total)?></span>
    </td>
    <td colspan="4">

    </td>
</tr>
</tfoot>
</table>
<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?>" />
</div>
<div id="chk" style="display:none"></div>