<div class="editItem">
	<script src="assets/js/king-table.js"></script>
	<?php
	/*
	<div class="col-lg-12">
		<ul class="breadcrumb">
			<li><i class="fa fa-home"></i><a href="/home">Home</a></li>
			<li class="active">View Item Purchase records</li>
		</ul>
	</div>
	*/
	?>
	<!-- MAIN CONTENT WRAPPER -->		
	<div class="content">            
		<div class="main-content">
			<!-- DATA EXPORT -->
			<div class="widget widget-table">
				<div class="widget-header">
					
					<h3><i class="fa fa-table"></i> View Item Purchase records</h3>
					<div class="btn-group widget-header-toolbar">
						<?php if($data['create']=='1'): ?>
						<a class="btn-borderless btn-focus clickme" href="purchaseitem" title="Focus" ><i class="fa fa-plus"></i></a>
						<?php endif; ?>
						<!--<a href="#" title="Expand/Collapse" class="btn-borderless btn-toggle-expand"><i class="fa fa-chevron-up"></i></a>
						<a href="#" title="Remove" class="btn-borderless btn-remove"><i class="fa fa-times"></i></a>-->
					</div>
				</div>
				<div class="widget-content">
					<table id="datatable-data-export" class="table table-sorting table-striped table-hover table-bordered datatable">
						<thead>
							<tr>
								<th>Category</th>
								<th>Item Type</th>
								<th>Item code</th>
								<th>Item name</th>
								<th>Unit</th>
								<th>Purchase cost</th>
								<th>Sales cost</th>
								<th>Note</th>	
								<th>Status</th>			
								<?php if($data['edit']=='1' || $data['delete']=='1'){ echo'<th>Action</th>';}?>							
							</tr>
						</thead>
						<tbody>
							<?php $__currentLoopData = $data['Item']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $Item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
							<tr>
								<td><?php echo e($Item->cat_name); ?>-<?php echo e($Item->cat_description); ?></td>
								<td><?php echo e($Item->itm_type); ?></td>
								<td><?php echo e($Item->itm_code); ?></td>
								<td><?php echo e($Item->itm_name); ?></td>
								<td><?php echo e($Item->unt_type); ?></td>
								<td><?php echo e($Item->itm_purchasecost); ?></td>
								<td><?php echo e($Item->itm_salescost); ?></td>
								<td><?php echo e($Item->itm_note); ?></td>
								<td><?php echo e($Item->itm_status); ?></td>	
								<?php if($data['edit']=='1' || $data['delete']=='1'){ echo'<td>';}?>	
								
								<?php if($data['edit']=='1'){echo'<button class="btn btn-default btn-xs print" onclick="editItem('.$Item->itm_id.')">Edit</button>'; } if($data['delete']=='1'){echo' <button class="btn btn-default btn-xs print" onclick="deleteId('.$Item->itm_id.')">Delete</button>';} echo '</td>';?>							
							</tr>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>	
						</tbody>
					</table>
				</div>
			</div>
			<!-- END DATA EXPORT -->
			
		</div>
	</div>
</div>
<!-- /main -->
<script>
	$('.clickme').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	function editItem(edit_id)
	{
		$.ajax({
			url: 'PurchaseEditItem',
			type: 'get',
			data:'&editId='+edit_id,
			success: function(data)
			{
				$('.editItem').html(data)
			}
		});
	}
	function deleteId(dele_id)
	{
		if (confirm("Are you sure delete!") == true)
		{
			$.ajax({
				url: 'DeleteItem',
				type: 'get',
				data:'&deleteId='+dele_id,
				success: function(data)
				{
					$('#sideMenu').load('purchaseviewitem');
				}
			});
		}
	}
</script>