<?php
	$now = @$this->uri->segment(3);
	$cat = substr($now,-1);
?>

<h3 class="page-header">
	<?php echo $judul;?>
</h3>
<div class="panel panel-default">
<div class="panel-heading">
	<div class="row">
		<div class='col-sm-6'><?php echo $judul;?> List</div>
		<div class='col-sm-6' align='right'>
			<a href="<?=$url?>barang-new" class="btn btn-success btn-sm"><i class=" fa fa-plus"></i> Add</a>
		</div>
	</div>
</div>
<div class="panel-body">
	<div class="table-responsive">
		<table class="table table-striped table-bordered table-hover dataTables" >
			<thead>
				<tr>
					<th width='35'>No</th>
					<th width=''>Nama</th> 
					<th width='50'>Isi</th> 
					<th width='80'>Satuan</th> 
					<th width='120'>H. Beli</th> 
					<th width='120'>H. Resep</th> 
					<th width='120'>H. Satuan</th> 
					<th width='120'>H. Box</th> 
					<th width='50'>Stok</th> 
					<th width='50'>Status</th>
					<th width='160'></th>
				</tr>
			</thead>
			<tbody>
				<?php
					$no=1;
					if(isset($data) && count($data) > 0): foreach($data as $row):  
					$now = @$this->uri->segment(3);
				?>
				<tr>
					<td align='center'><?=$no;?></td>
					<td align='left'><?=$row['nama'];?></td>
					<td align='left'><?=$row['isi'];?></td>
					<td align='left'><?=$row['satuan'];?></td>
					<td align='left'>Rp. <?=number_format($row['harga_beli']);?></td>
					<td align='left'>Rp. <?=number_format($row['harga_resep']);?></td>
					<td align='left'>Rp. <?=number_format($row['harga_satuan']);?></td>
					<td align='left'>Rp. <?=number_format($row['harga_box']);?></td>
					<td align='left'><?=$row['stok'];?></td>
					<td align='center'>
						<a href='javascript:void(0);' class="label label-success" id='st-<?php echo $row['id_barang'];?>' onclick="change_status('st-<?php echo $row['id_barang'];?>','<?=isset($row['status']) ?  $status[$row['status']] : '-'?>','<?=$row['id_barang']?>','<?=base_url()?>cms/logic/delete_ajax/barang/<?=$row['id_barang']?>')">
							<?php echo isset($row['status']) ?  $status[$row['status']] : '-'?>
						</a>
					</td>
					<td align='center'>
						<a title="Edit" href="<?=$url?>barang-new?_id=<?=$row['id_barang']?>" class='btn btn-xs btn-success '><i class="fa fa-edit "></i></a>
						<a title="Delete" class='btn btn-xs btn-danger' onclick="return confirm('Are you sure you want to delete this item?');" href="<?=base_url()?>cms/logic/delete/barang/<?=$row['id_barang']?>?part=<?=$now;?>" class="text-danger"><i class="fa fa-trash-o"></i></a>					
					</td>
				</tr>
				<?php $no++; endforeach; endif; ?>
			</tbody>
		</table>
	</div>
</div>
</div>