<script src="assets/js/king-table.js"></script>
<!-- MAIN CONTENT WRAPPER -->
<div class="entrysettings">
<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> Add / View Farm Item Records</h3>
			</div>
			<div class="widget-content">
						<form id="frmmain" name="frmmain" data-parsley-validate novalidate>
						<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
							<?php echo csrf_field(); ?>

					<div class="col-sm-6 nopadding">
						<div class="form-group">							
							<select name="itemname" id="itemname" class="form-control">
								<option value="0">-- Select --</option>
								<?php 
									foreach($data['itemrecords'] as $item)
									{
								      	echo "<option value='".$item->itm_id."' >".$item->itm_name."</option>";
									}
								?>
							</select>
						</div>
					</div>
					<div class="col-sm-3 nopadding">
						<div class="form-group">
							<div class="input-group">								
								<div class="input-group-btn">
					<center><button  class="btn btn-primary btnfarm">Click Here to Add Farm Item</button></center>
								</div>
							</div>
						</div>
					</div>
						</form>
			</div>
		</div>
		<!-- END DATA EXPORT -->
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-table"></i> View Farm Item Records</h3>
			</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>	
										<th>Entry <br> settings</th>	
										<th>Sandard <br> Performance <br> Settings</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>	
								<td><button class="btn btn-default btn-xs print" onclick="viewentrysettings(<?php echo $Item->itm_id; ?>)">View</button></td>	
								<td><button class="btn btn-default btn-xs print" onclick="broilerperformancesettings(<?php echo $Item->itm_id; ?>)">View</button></td>				
							</tr>
							<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>	
						</tbody>
							</table>
						</div>
		</div>
		<!-- END DATA EXPORT -->
		
	</div>
</div>
</div>
<!-- /main -->
<script>
	$('.createMod').click(function(e)
	{   
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	$('.edit').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href')); 
	});
	//### Billing submission entry code starts here
	flag=0;
	$('.btnfarm').click(function(e)
	{
		e.preventDefault();
		var _token = $("input[name='_token']").val();
		var itemname = $('#itemname').val();
		
		$.ajax({
			url: "AddFarmItem",
			type:'POST',
			dataType: 'json',
    //cache : false,
	//processData: false,
			data: {_token:_token,itemname:itemname},
			success: function(data)
			{
			alert(data.status);
				if(data.status == "1")
				{
					alert("Record inserted successfully...");
					//$('#sideMenu').load('ViewFarmItems');
				}
				else
				{
					alert("Failed to insert record...");
					//printErrorMsg(data.message)
				}
			}
		});
	});
	//### Billing submission entry code ends here
	//###Entry settings starts here
	function viewentrysettings(item_id)
	{
		$.ajax({
			url: 'entrysettings',
				type: 'get',
				data:'&item_id='+item_id,
				success: function(data)
				{
					$('.entrysettings').html(data)
				}
		});		
	}
	//###Entry settings ends here
	//###Entry settings starts here
	function broilerperformancesettings(item_id)
	{
		$.ajax({
			url: 'broilerperformancesettings',
				type: 'get',
				data:'&item_id='+item_id,
				success: function(data)
				{
					$('.entrysettings').html(data)
				}
		});		
	}
	//###Entry settings ends here
</script>