<?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");?>

            <!-- 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">


        
                 
                 
                 </section>
                 
                 
                 
                 <section class="content">
					<div class="box-body table-responsive" id="tbldiv">

                                    <table id="example1" class="table table-bordered table-striped">
                                        <thead>
                                           <tr>
												<th>Product Name</th>
                                                <?php	
												 $query3 = "SELECT branch_name FROM branch";
                                        $result3 = mysqli_query($connection,$query3);
                                       
                                        while($row3=mysqli_fetch_array($result3))
                                        {		
										 $branch_name = $row3['branch_name'];	
                                                echo "<th>$branch_name Present Stock</th>";
												
												}
												?>
                                                <th>Apply</th>
                                            </tr>

                                        </thead>
                                        <tbody>
										<?php
                                        
                                        $query = "SELECT * FROM product_setup";
                                        $result = mysqli_query($connection,$query);
                                        
										 $i=0;
                                        while($row=mysqli_fetch_array($result))
                                        {
                                        
                                         $i++;
										 $product_id = $row['product_id'];
											$product_name = $row['product_name'];
											$buy_price = $row['buy_price'];
											$selling_price = $row['selling_price'];
											$unit_type_id = $row['unit_type_id'];
											$stock_limit = $row['stock_limit'];
												$buy_price_sum[] = $row['buy_price'];
												$selling_price_sum[] = $row['selling_price'];
												
									$result_for_unit_type = mysqli_query($connection,"SELECT * FROM unit_type WHERE unit_type_id  = '$unit_type_id'");
		$test_for_unit_type = mysqli_fetch_array($result_for_unit_type);
				
				$unit_type_name=$test_for_unit_type['unit_type_name'];
				
				
				$search_present_stock = mysqli_query($connection,"select present_stock from present_stock where product_id='$product_id'");
		$test_search_present_stock = mysqli_fetch_array($search_present_stock);
				
		$present_stock=$test_search_present_stock['present_stock'];
		
		$present_stock_rr_sum[] = $test_search_present_stock['present_stock'];
                                        
                                        
                                        echo "<tr>
                                        <td>$product_name
										<input type='hidden' id='product_name$i' value='$product_name'/>
										<input type='hidden' id='buy_price$i' value='$buy_price'/>
										<input type='hidden' id='selling_price$i' value='$selling_price'/>
										</td>";
                                         	 $query2 = "SELECT branch_id FROM branch";
                                        $result2 = mysqli_query($connection,$query2);
                                       
                                        while($row2=mysqli_fetch_array($result2))
                                        {		
										 $branch_id = $row2['branch_id'];		
								
				$search_present_stock = mysqli_query($connection,"select present_stock from present_stock where product_id='$product_id' and branch_id = '$branch_id'");
		$test_search_present_stock = mysqli_fetch_array($search_present_stock);
				
		$present_stock=$test_search_present_stock['present_stock'];		
                                         echo "<td>$present_stock $unit_type_name"; echo "<input type='hidden' id='present_stock$i' value='$present_stock'/></td>";
										 
										 }
                                        echo "
                                        <td>
                                        <a href='update_present_stock.php?gtt=$product_id'><button type='button' class='btn btn-info'><i class='fa fa-edit'></i> &nbsp;Edit Present Stock</button></a>
                                        </td> 
                                        </tr>";
										
										
										


										
										}	
                                        ?>

                                        </tbody>
                                     
                                    </table>
                                    
                                    
                                  

                                  
                                </div>
                </section>
                 
                </aside>
                <!-- /.right-side -->
        </div><!-- ./wrapper -->

        <!-- add new calendar event modal -->
<script type="text/javascript">
	 $('#login_form').submit(function() {
	$('#formdiv').hide();
	$('#tbldiv').hide();
    $('#loading_image').show(); // show animation
    return true; // allow regular form submission
});
 </script>

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

    </body>
</html>