<!-- main -->
<style>
	.filesss
	{
	color:red;
	}
	
	.uplod-file
	{
	position: relative;
	overflow: hidden;
	border: 0px solid #a02e09;
	border-radius: 0px;
	transition:all ease 0.3s;
	margin: 5px;
	}
	.uplod-file input[type=file] 
	{
	position: absolute;
	top: 0;right: 0;
	min-width: 100%;
	min-height: 100%;
	font-size: 100px;
	text-align: right;
	filter: alpha(opacity=0);
	opacity: 0;
	outline: none;
	background: white;
	cursor: inherit;display: block;
	}
	.uplod-file:hover, 
</style>
<div class="content">
	
	<div class="main-content">
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-user"></i> Entry</h3> <em> - Entry records</em>
			</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()); ?>">						
					
					<div class="alert  alert-info " >
						<ul><li class="fa fa-cog  fa-1x fa-fw"></li>Kindly enter Entry details..</ul>
					</div>						
					<div class="alert alert-success print-success-msg" style="display:none">
						<ul></ul>
					</div>	
					<div class="alert alert-danger print-error-msg" style="display:none">
						<ul></ul>
					</div>
					
					<div class="col-md-6">
						<!-- ADVANCED VALIDATION -->
						<div class="widget-content">  
							
							<div class="form-group">
								<label for="multiselect1">Shed Name<span class="filesss">*</span></label>
                                <select name="shedName" id="shedName" class="form-control" required>
									<option value="0">-- Select --</option>
									<?php foreach($data['Shed'] as $shd){
								      	echo "<option value='".$shd->shd_id."' >".$shd->shd_name."";
									    echo "</option>";
									}?>
								</select>
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Batch Number<span class="filesss">*</span></label>
                                <select name="BatchNumber" id="BatchNumber" class="form-control" required>
									<option value="0">-- Select --</option>
								</select>
								<small class="text-danger" id="errcompname"></small>
							</div>
							
							<div class="form-group">
								<label for="text-input1">Date.<span class="filesss">*</span></label>
								<input type="date" name="Date1" id="Date1" class="form-control" disabled>
								<input type="hidden" name="Date1" id="Date1" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Day.<span class="filesss">*</span></label>
								<input type="text" name="day" id="day" class="form-control" disabled>
								<input type="hidden" name="day" id="day" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Feed <span class="filesss">*</span></label>
								<input type="text" name="Feed" id="Feed" class="form-control" disabled>
								<input type="hidden" name="Feed" id="Feed" class="form-control" >
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Water<span class="filesss">*</span></label>
								<input type="text" name="Water" id="Water" class="form-control" disabled>
								<input type="hidden" name="Water" id="Water" class="form-control">
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">TEMP.<span class="filesss">*</span></label>
								<input type="text" name="TEMP" id="TEMP" class="form-control" disabled>
								<input type="hidden" name="TEMP" id="TEMP" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							
							<div class="form-group">
								<label for="text-input1">Mortality.<span class="filesss">*</span></label>
								<input type="date" name="Mortality" id="Mortality" class="form-control"disabled >
								<input type="hidden" name="Mortality" id="Mortality" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>                        
							<div class="form-group">
								<label for="multiselect1">Feed<span class="filesss">*</span></label>
								<input type="text" name="Feed1" id="Feed1" class="form-control" >
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Water<span class="filesss">*</span></label>
								<input type="text" name="Water1" id="Water1" class="form-control" >
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Med/VAC.<span class="filesss">*</span></label>
								<input type="text" name="Med/VAC" id="Med/VAC" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Humidity.<span class="filesss">*</span></label>
								<input type="text" name="Humidity" id="Humidity" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							
							
							
							<div class="form-group">
								<label for="multiselect1">Feed<span class="filesss">*</span></label>
								<input type="text" name="Feed1" id="Feed1" class="form-control" >
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="multiselect1">Water<span class="filesss">*</span></label>
								<input type="text" name="Water1" id="Water1" class="form-control" >
								<small class="text-danger" id="errcompname"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Med/VAC.<span class="filesss">*</span></label>
								<input type="text" name="Med/VAC" id="Med/VAC" class="form-control" >
								<small class="text-danger" id="errcustomername"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Observation</label>
								<textarea  class="form-control" id="Observation" name="Observation" ></textarea>
								<small class="text-danger" id="errcustomername"></small>
							</div>
							<div class="form-group">
								<label for="text-input1">Suggestion</label>
								<textarea  class="form-control" id="Suggestion" name="Suggestion" ></textarea>
								<small class="text-danger" id="errcustomername"></small>
							</div>
							
							
						</div>
						<!-- END ADVANCED VALIDATION -->
					</div>
					
					<div class="col-md-6">
						<!-- ADVANCED VALIDATION -->
						<div class="widget-content">
							
							
							
							
							<div class="form-group">
								<table id="tab_logic" class="table table-sorting table-striped table-hover datatable">
									<thead>
										<tr>
											<th>SL. No.</th>
											<th>No. of Birds</th>
											<th>Total Weight in GM</th>
											<th>Add</th>
											<th>Remove</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td> <input type="text" name="batchSlno1" id="batchSlno1" class="form-control" value='1' ></td>
											<td> <input type="text" name="noOfBird1" id="noOfBird1" class="form-control" onkeyup="TotalnoOfBirds(1)"></td>
											<td> <input type="text" name="ToatlWeight1" id="ToatlWeight1" class="form-control" onkeyup="ToatlWeights(1)" ></td>
											<td><button type="button"  value="Add" class="form-control" id="add_row" >+</button></td>
											<td><button type="button"  value="Add" class="form-control" id="delete_row" >-</button></td>
										</tr>
										<tr id='addr2'></tr>
									</tbody>
									
									
									<tfoot>
										<tr>
											<th>Total <input readonly style="border:0px; width:25px; font-size:30; color:red;" id="num" name="num" value="1"/></th>
											<th><input readonly style="border:0px; width:60px; font-size:30; color:red;" id="TnoOfBird" name="TnoOfBird" value="0"/></th>
											<th><input readonly style="border:0px; width:60px; font-size:30; color:red;" id="grams" name="grams" value="0"/></th>
										</tr>
										<tr>
											<th></th>
											<th>Total bird in Gm</th>
											<th><input readonly style="border:0px; width:100px; font-size:30; color:red;" id="totalGrams" name="totalGrams" value="0"/></th>
										</tr>
									</tfoot>
								</table>
							</div>
							<!-- END ADVANCED VALIDATION -->
						</div>
						
						
						
						<div class="form-group">
							<label for="text-input1">Capture.<span class="filesss">*</span></label>
							
							<span class="btn btn-default btn-sm uplod-file">
								Capture <input type="file" id="Capture" name="Capture" class="upload" accept="image/*"/>
							</span>
							
						</div>
						
					</div>
					<!-- END ADVANCED VALIDATION -->
				</div>
				<div class="col-md-12">
					<div class="form-group">
						<center><button type="submit" id="submit" name="submit" class="btn btn-primary Addrecord">Add record</button></center>
					</div>
				</div>                        
			</form>
			
		</div>
	</div>
	<!-- END DATA EXPORT -->
	
</div>
</div>
<!-- /main -->	
<script>
	$('#shedName').change(function(e)
	{
		id=$('#shedName').val();
		e.preventDefault();
		$.ajax({
			url: 'SubshedName',
			type: 'get',
			data:'&shedid='+id,
			success: function(data) {
				
				var sel = document.getElementById('BatchNumber');
				for (i = sel.length - 1; i >= 0; i--) {
					sel.remove(i);
				}
				
				var jsonData = JSON.parse(data);
				for (var i = 0; i < jsonData.length; i++) {
					var prop = jsonData[i];
					$("#BatchNumber").append("<option value=\"" + prop.bch_id +"\">"+ prop.bch_id +"</option>");
				}
				
			}
		});
	});
	$('#BatchNumber').change(function(e)
	{
		BatchNo=$('#BatchNumber').val();
		$.ajax({
			url: 'BatchEntryFarm',
			type: 'get',
			data:'&BatchNo='+BatchNo,
			success: function(data) 
			{
				$('#Mortality').val(data['DailyHumidity']);
				$('#Feed').val(data['DailyFeed']);
				$('#Water').val(data['DailyWater']);
				$('#TEMP').val(data['DailyTemp']);
				$('#Date1').val(data['day']);
				$('#day').val(data['day_number']);
			}
			
		});
	});
	$('.Addrecord').click(function(e)
	{
		e.preventDefault();
		$.ajax({
			url: 'AddFarmRecord',
			type: 'POST',
			data:$('#frmmain').serialize(),
			success: function(data) 
			{
				
			}
			
		});
	});
</script>		

<script>
	
	$(document).ready(function(){
		var i=2;
		$("#add_row").click(function(){
			$('#addr'+i).html("<td><input name='batchSlno"+i+"' id='batchSlno"+i+"' type='text'  class='form-control input-md' value='"+i+"' /> </td><td><input  name='noOfBird"+i+"'id='noOfBird"+i+"' type='text'   class='form-control input-md' onkeyup='TotalnoOfBirds("+i+")'></td><td><input  name='ToatlWeight"+i+"' id='ToatlWeight"+i+"' type='text'  class='form-control input-md'onkeyup='ToatlWeights("+i+")'></td>");
			
			$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
			
			$('#num').val(i);
			i++; 
			
			
		});
		$("#delete_row").click(function(){
			if(i>1){
				$("#addr"+(i-1)).html('');
				i--;
				$('#num').val(i);
			}
		});
		
	});	
	noOfBirds=0;
	ToatlWeight=0;
	function TotalnoOfBirds(totalLoop)
	{
		totalLoop=$('#num').val();
		
		$("#noOfBird"+totalLoop).each(function () {
			if (!isNaN(noOfBird.value) && noOfBird.value.length != 0)
			{
				noOfBirds += parseFloat(("#noOfBird"+totalLoop).val());
			}
			//$("#grams").val(noOfBirds.toFixed(2));
			$("#TnoOfBird").val(noOfBirds);
		});
		
	}
	function ToatlWeights(totalLoop)
	{
		totalLoop=$('#num').val();
		
		$("#ToatlWeight"+totalLoop).each(function () {
			if (!isNaN(ToatlWeight.value) && ToatlWeight.value.length != 0)
			{
				ToatlWeight += parseFloat(ToatlWeight.value);
			}
			//$("#grams").val(noOfBirds.toFixed(2));
			$("#grams").val(ToatlWeight.toFixed(2));
			$("#totalGrams").val(ToatlWeight.toFixed(2));
		});
		
	}
	
	
	
	
	/*function calcAll() {
		
		var product = 1;
		$(".amount").each(function () {
		if (!isNaN(this.value) && this.value.length != 0) {
		product += parseFloat(this.value);
		}
		$("#total1").val(product.toFixed(2));
		});
		
		
		var sum = 0;
		$(".total").each(function () {
		if (!isNaN(this.value) && this.value.length != 0) {
		sum += parseFloat(this.value);
		}
		});
		
		$("#netto").val(sum.toFixed(2));
		
	}*/
	</script>						