<?php
include("../connection.php");
include("../user.php");

$ho_access=$_SESSION['ha'];
if($ho_access=="yes"){
	$branch=$_REQUEST['branch'];
}else{
	$branch=$_SESSION['branch_id']; }

$po_number=$_REQUEST['po_number'];

?>
<table id="upload" class="table table-striped" style="text-transform:upper;" >
		<thead>
		<tr>
		<th></th>
		<th>Category</th>
		<th>Order Quantity</th>
		<th>Available Quantity</th>
		<th>Already Received Quantity</th>
		<th>Inward Quantity</th>
		
		</tr>
		</thead>
		<tbody>
		<?php 
		$cat_table=mysqli_query($con,"select ic.*,cm.category list_cat from inward_create_table ic left join category_master cm on cm.id=ic.category left join inward_master im on im.id=ic.po_id where ic.po_no='$po_number' and ic.quantity<>ic.received_qty and im.branch='$branch'");
		
		
	$cat_no=1;
	$cat_id=1;
	$qty_no=1;
	$avbl_no=1;
	$rec_no=1;
	$in_no=1;
	$s_no=1;
	
		while($cat_list=mysqli_fetch_array($cat_table))
		{
				$sum=$cat_list['quantity']-$cat_list['received_qty'];
				
		?>
					<tr id="rw_1" class="row_1">
				<?php
				$cat=mysqli_query($con,"select * from category_master where status=0");
				?>
				<td>	<input class="checkbox"  type="checkbox" name="checkbox<?php echo $s_no;?>" id="checkbox<?php echo $s_no;?>" onclick="enablebox(this.id)"></td>
				<td>
				<input type="text" name="cat[]" id="cat_<?php echo $cat_no++; ?>" class="form-control" value="<?php echo $cat_list['list_cat']; ?>"  readonly >
				<input type="hidden" name="inward_table_id[]" value="<?php echo $cat_list['id']; ?>"   >
				</td>
				<input type="hidden" class="form-control" id="counter" value="1" name="counter_tab[]">
				<td><input  class="form-control" type="text" id="quantity_<?php echo $qty_no++; ?>" value="<?php echo $cat_list['quantity']; ?>"  name="qty[]" autocomplete="off" readonly></td>
				<td><input  class="form-control" type="text" id="available_qty_<?php echo $avbl_no++; ?>" value="<?php echo $sum; ?>"  name="available_qty[]" autocomplete="off" readonly></td>
				<td><input  class="form-control" type="text" id="received_qty_<?php echo $rec_no++; ?>" value="<?php echo $cat_list['received_qty']; ?>"  name="received_qty[]" autocomplete="off" readonly></td>
				<input type="hidden" id="cat_id_<?php echo $cat_id++; ?>" value="<?php echo $cat_list['id'];   ?>">
				<td><input class="form-control" type="text" id="inward_qty_<?php echo $in_no++; ?>" placeholder="Enter Inward"  name="inward_qty[]" autocomplete="off" onchange="inward_valid(this.value,this.id)" disabled="disabled"></td>	
				</tr>
				<tr>
				<td colspan=6>
				
				<div id="s_<?php  echo $s_no; ?>">
				</div></td>
				</tr>
				
	<?php $s_no++;   }?>
		</tbody>
		</table>
		
	
		<script>
		
	$('#checkbox1').click(function() {
    $('#inward_qty_1').attr('disabled',! this.checked)
});

$('#checkbox2').click(function() {
    $('#inward_qty_2').attr('disabled',! this.checked)
});
$('#checkbox3').click(function() {
    $('#inward_qty_3').attr('disabled',! this.checked)
});
$('#checkbox4').click(function() {
    $('#inward_qty_4').attr('disabled',! this.checked)
});
$('#checkbox5').click(function() {
    $('#inward_qty_5').attr('disabled',! this.checked)
});
$('#checkbox6').click(function() {
    $('#inward_qty_6').attr('disabled',! this.checked)
});
$('#checkbox7').click(function() {
    $('#inward_qty_7').attr('disabled',! this.checked)
});
$('#checkbox8').click(function() {
    $('#inward_qty_8').attr('disabled',! this.checked)
});
$('#checkbox9').click(function() {
    $('#inward_qty_9').attr('disabled',! this.checked)
});
$('#checkbox10').click(function() {
    $('#inward_qty_10').attr('disabled',! this.checked)
});

</script>
