
<?php include("conn.php");
$page='Items in stock';
$location_page='item_instock';
?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>
<style>
    #panel {
  display: none;
}
#panel1 {
  display: none;
}
</style>
<body>

<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Nav menu end-->

          

            <!--Main body Start-->
            <div class="col-sm-12 mt-2">
            
               <!--search section start-->


               <center>
               <?php include('inventory_button.php')?>
                
              </center>            
      <hr class="bg-success">
                <!--search section end-->
                <!--Orders start-->
                
            <?php 
            $today= date("F j, Y ,h:ia");
            $order_id='T'.date('ymdhi').mt_rand(10,100);
            
    

      
            ?>
                <div style="font-family: 'Convergence'!important;" id="myList" class="menu-analytics row no-gutters">
                    <div class="daily-report ">
                      <!--  <div class="daily-report-item">
                                    <b><i class="fa fa-money" aria-hidden="true"></i></b>
                                    <p class="text-center order-text-order-managment"><b>Revenue</b></p>
                                    <p class="text-center order-text-order-managment"><b></b></p>
                        </div>--->

                  
                    </div>


                    <div  id="collapseOne" class="  col-sm-12  " data-parent="#accordions">
                    <h5 class="text-center">Items In Stock</h5>
                    <table id="example_table" class="table-customer table-striped   w-100 table-bordered">
                        <thead>
                        <tr>
                        <th>Id</th>
                            <th>Item Name</th>
                            <th>Quantity Added</th>
                            <th>Quantity Out</th>
                            <th>Quantity Remaining</th>
                          
                        </tr>
                        </thead>
                        <tbody>
                        <?php


$sql7="select item_id from inventory_cat ";
$result7 = mysqli_query($conn,$sql7)or die( mysqli_error($conn));
while ($row7=mysqli_fetch_array($result7)) {

 $data=$row7['item_id'];
  

   $sql11="select * from inventory where item_id='$data' ";
   $result11 = mysqli_query($conn,$sql11)or die( mysqli_error($conn));
   $row11=mysqli_fetch_array($result11);
   $total_can = mysqli_num_rows($result11) ;
   $item_name=$row11['item_name'];
   $unit=$row11['unit'];
   $unit_value=$row11['unit_value'];
   $quantity=$row11['quantity'];
   $datein=$row11['datein'];

   $id=$row11['id'];
   
   $sql8="select  SUM(quantity) from inventory where item_id='$data' ";
   $result8 = mysqli_query($conn,$sql8)or die( mysqli_error($conn));
   $row8=mysqli_fetch_array($result8);
   $rtotal=$row8['SUM(quantity)'];


   $sql13="select  SUM(quantity) from inventory_out where item_id='$data' ";
   $result13 = mysqli_query($conn,$sql13)or die( mysqli_error($conn));
   $row13=mysqli_fetch_array($result13);
  
  
    $out=$row13['SUM(quantity)'];
  
$out=$out+0;

$item_left=$rtotal-$out;

   $sql12="select datein from inventory where item_id='$data'   ";
   $result12 = mysqli_query($conn,$sql12)or die( mysqli_error($conn));
   $row12=mysqli_fetch_array($result12);
   $datein=$row12['datein'];


   $status=0;

 $text='';

 if ($item_left<10) {
   $text='In stock';
   $read='text-white';
   $bg='bg-danger';

 }
                            else {
   $text='Out of stock';
   $read='';
  $de='activate';
  $sta=1;
  $bg='';
 }

?>
                        <tr>
                            <td><?php echo $data ?></td>
                            <td><?php echo $item_name ?></td>
                            <td><?php echo $rtotal." ".$unit ?></td>
                            <td><?php echo $out." ".$unit ?></td>  
                            <td><?php echo $item_left." ".$unit ?></td>                          
                          
                        
                        </tr>
                        <?php } ?>
                        </tbody>
                        <thead>
                        <th>Id</th>
                            <th>Item Name</th>
                            <th>Quantity Added</th>
                            <th>Quantity Out</th>
                            <th>Quantity Remaining</th>
  
                        </thead>
                    </table>
    

                </div>

                    <!-- <div id="chart_div" style="width: 100%; height: 500px;"></div>--->
        
                </div>

         
              
            </div>
            <!--Main body end-->

           


            <!--Invoice Section end-->



    
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
     <!-- jQuery js-->
     <!-- jQuery Datatable js -->
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" ></script>
     <script src="https://cdn.datatables.net/2.0.5/js/dataTables.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/dataTables.buttons.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.html5.min.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.print.min.js"></script>
     <script>
         $(document).ready( function () {
        new DataTable('#example_table', {
            autoFill: true,
            pageLength : 20,
    lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
    layout: {
        topStart: {
            buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
        }
    }
});
       } );
       </script>
 

    <script>
function myFunction() {
  document.getElementById("panel").style.display = "block";
  document.getElementById("select_item").style.display = "none";
}

function myFunctions() {
  document.getElementById("panel1").style.display = "block";
  document.getElementById("select_item1").style.display = "none";
}
</script>

<script>
    

    $(document).ready(function(){  
   $('.view_datas').click(function(){  
        var employee_ids = $(this).attr("id");  
        $.ajax({  
             url:"inventory_item_details.php",  
             method:"post",  
             data:{employee_ids:employee_ids},  
             success:function(data){  
                  $('#employee_detail1').html(data);  
                  $('#dataModal1').modal("show");  
             }  
        });  
   });  
});  
</script>
</body>

</html>