<script type="text/javascript">
$(function() {
	$("#dataTable.detail tr:even").addClass("stripe1");
	$("#dataTable.detail tr:odd").addClass("stripe2");
	$("#dataTable.detail tr").hover(
		function() {
			$(this).toggleClass("highlight");
		},
		function() {
			$(this).toggleClass("highlight");
		}
	);
});
function pilih(id,nama_barang,satuan,harga_beli,harga,stok){
	$("#dlg").dialog('close');
	$("#kode_brg").val(id);
	$("#nama_brg").val(nama_barang);
	$("#satuan").val(satuan);
	$("#harga_beli").val(harga_beli);
	$("#harga").val(harga);
	$("#jml_sblm").val(stok);
	$("#kode_brg").focus();
	$("#jml").focus();
}
</script>
<table id="dataTable" class="detail" width="100%">
<tr>
	<th>No</th>
    <th>Kode Barang</th>
    <th>Nama Barang</th>
    <th>Satuan</th>
    <th>Harga Jual</th>
    <th>Harga Beli</th>
    <th>Stok</th>
    <th>Barcode</th>
    <th>Ambil</th>
</tr>
<?php
	if($data->num_rows()>0){
		$no =1;
		foreach($data->result_array() as $db){  
		$stok = $this->app_model->CariStokAkhirSesuaiStok($db['kode_barang']);
		?>    
    	<tr>
			<td align="center" width="20"><?php echo $no; ?></td>
            <td align="center" width="90" ><?php echo $db['kode_barang']; ?></td>
            <td ><?php echo $db['nama_barang']; ?></td>
            <td align="center" width="80" ><?php echo $db['satuan']; ?></td>
            <td align="right" width="90" ><?php echo number_format($db['harga_jual']); ?></td>
            <td align="right" width="90" ><?php echo number_format($db['harga_beli']); ?></td>
          <td align="center" width="60" ><?php echo $stok; ?></td>
          <td ><?php echo $db['barcode']; ?></td>
            <td align="center" width="80">
            <a href="javascript:pilih('<?php echo $db['kode_barang'];?>','<?php echo $db['nama_barang']; ?>','<?php echo $db['satuan']; ?>','<?php echo $db['harga_beli']; ?>','<?php echo $db['harga_jual']; ?>','<?php echo $stok; ?>')" >
        	<img src="<?php echo base_url();?>asset/images/add.png" title='Ambil'>
        	</a>
            </td>
    </tr>
    <?php
		$no++;
		}
	}else{
	?>
    	<tr>
        	<td colspan="7" align="center" >Tidak Ada Data</td>
        </tr>
    <?php	
	}
?>
</table>