<?php include("sass/icon_for_datepicker_and_datatable.php");?>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <?php include("sass/sidebar.php");
			
			
			
 if(isset($_POST['update']))
    {
	
$product_id =$_POST['product_id'];
	$branch_id = $_POST['branch_id'];
	$present_stock = $_POST['present_stock'];
	
	$N = count($branch_id);
	
		
		for($i=0; $i < $N; $i++)
		{
		
				
			mysqli_query($connection,"UPDATE present_stock SET present_stock ='$present_stock[$i]' WHERE product_id = '$product_id' and branch_id = '$branch_id[$i]'")
				or die(mysqli_error()); 
			}		
	
	$errMsg="Present Stock Successfully Updated";
	

	
	}

	else {
	
	$product_id =$_REQUEST['gtt'];
	
	
	}
	
?>		

			
			
			
            <!-- Right side column. Contains the navbar and content of the page -->
               <aside class="right-side">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                       <?php echo $company_name ; ?>
                        <small>Control panel</small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                        <li class="active">Dashboard</li>
                    </ol>
                </section>
                 <section class="content">
                 	 <div class="row">
                        <div class="col-md-6">
						  <?php
							if (!empty($errMsg))
							{echo "<div class='alert alert-success alert-dismissible' role='alert'>$errMsg";
							echo "<button type='button' class='close' data-dismiss='alert'><span aria-hidden='false'>&times;</span><span class='sr-only'>		Close</span></button>
                        </div>";}
                        ?>
                 <!---Main Content--->
                    <form role="form"  action="<?php echo "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" method="post" id="login_form">
                <?php 
				
				
				$result_for_unit_type = mysqli_query($connection,"SELECT product_name FROM product_setup WHERE product_id  = '$product_id'");
		$test_for_unit_type = mysqli_fetch_array($result_for_unit_type);
				
				$product_name=$test_for_unit_type['product_name'];
				echo "<h3>Present Stock Of: $product_name</h3><input type='hidden' class='form-control' name='product_id' value='$product_id'>";
				
				
				
				 $query2 = "SELECT present_stock, branch_id FROM present_stock where product_id='$product_id'";
                                        $result2 = mysqli_query($connection,$query2);
                                       
                                        while($row2=mysqli_fetch_array($result2))
                                        {		
										 $present_stock = $row2['present_stock'];	
										 $branch_id = $row2['branch_id'];	
										 
							$result_for_unit_type = mysqli_query($connection,"SELECT branch_name FROM branch WHERE branch_id  = '$branch_id'");
		$test_for_unit_type = mysqli_fetch_array($result_for_unit_type);
				
				$branch_name=$test_for_unit_type['branch_name'];			 
										 
									echo "<div class='form-group'>
                                            <label for='exampleInputEmail1'>Present Stock $branch_name</label>
											<input type='hidden' class='form-control' name='branch_id[]' value='$branch_id'>
											<input type='text' class='form-control' name='present_stock[]' value='$present_stock'>
											 </div>";	 
										 
										 }
				
				
				?>
				 <button type="submit" name="update" class="btn btn-primary">Update</button>
                 		  </form>	
                 
                 		</div>
                    </div>
                 
                 
                 </section>
                </aside>
                <!-- /.right-side -->
        </div><!-- ./wrapper -->

        <!-- add new calendar event modal -->


        <!-- jQuery 2.0.2 -->
          <?php include("sass/footer_for_datepicker_and_datatable.php");?>

    </body>
</html>