
<?php include("conn.php");
$page='Bar Inventory Managment';

$location='bar_inventory';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php");
if ($inventory=='none') {
  echo"<script>alert('You are not allow to access this page, contact your admintrator'); window.location.href='login'</script>";
}
?>
<style>
    #panel {
  display: none;
}
#panel1 {
  display: none;
}
</style>
<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Main body Start-->
            <div class="col-sm-12 mt-1">
            
               <!--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 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 added to stock</h5>
                    <button class="btn btn-primary btn-sm m-4"  data-toggle="modal" data-target="#exampleModal">Add Item</button>

                    <table id="example_table" class="table-customer table-striped  table-hover w-100 table-bordered">
                        <thead>
                        <tr>
                            <th>Id</th>
                            <th>Item Name</th>
                            <th>Quantity</th>
                            <th>Date Uploaded</th>

                        </tr>
                        </thead>
                        <tbody>
                        <?php


$sql7="select * from bar_inventory ";
$result7 = mysqli_query($conn,$sql7)or die( mysqli_error($conn));
while ($row7=mysqli_fetch_array($result7)) {
 $data=$row7['item_id'];
   $item_name=$row7['name'];
   $quantity=$row7['quantity'];
   $datein=$row7['date'];
   $time=$row7['time'];


?>
                        <tr>
                            <td><?php echo $data ?></td>
                            <td><?php echo $item_name ?></td>
                            <td><?php echo $quantity ?></td>                            
                            <td><?php echo  $datein." ".$time ?></td>

                        </tr>
                        <?php } ?>
                        </tbody>
                        <thead>
                        <th>id</th>
                            <th>Item Name</th>
                            <th>Quantity</th>
                            <th>Date Uploaded</th>
                        </thead>
                    </table>
    

                </div>

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

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

           
            <!-- Small modal -->
<div id="dataModal"  class="modal fade bd-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div id="employee_detail" class="modal-content text-dark">
     
    
    
    </div>
  </div>
</div>
             <!-- Modal Add items -->
             <div  class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content ">
        <div class="modal-header">
          <h5 class="modal-title text-center text-dark" id="exampleModalLabel">Add Item</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">


<form method="post" action="edit/add_item.php" class="row">
<div id="panel" class="form-group col-sm-6 mb-3">
                 <input type="text" class="form-control" name="item_names" id="exampleFormControlInput1" placeholder="Item name" >
               </div>

               <div id="panel1" class="form-group col-sm-6 mb-3">
                 <input type="text" class="form-control" name="units" id="exampleFormControlInput1" placeholder="unit"  >
               </div>

            <div  id="select_item" class="input-group col-sm-6 mb-3 ">
        <div class="input-group-prepend">
          <a onclick="myFunction()" class=" btn  btn-primary" >+</a>
        </div>
        <?php 
    $query ="SELECT name,id FROM menu ";
    $result = $conn->query($query);
    if($result->num_rows> 0){
      $options= mysqli_fetch_all($result, MYSQLI_ASSOC);
    }
?>
                  <select class="form-control" name="item_name">
                  <option value="nan">Select Item</option>
                  <?php 
  foreach ($options as $option) {
  ?>
    <option value="<?php echo $option['id']; ?>"><?php echo $option['name']; ?> </option>
    <?php 
    }
   ?>
                  </select>
      </div>

                 
      
                <div class="form-group col-sm-4 mb-3">
                 
                  <input type="number" class="form-control" name="quantity" id="exampleFormControlInput1" placeholder="Quantity" required>
                </div>

                 
 
                <input type="hidden" name="datein" value="<?php echo $today ?>">
                <input type="hidden" name="by" value="<?php echo $id_user ?>">
                <input type="hidden" name="item_id_new" value="<?php echo $order_id ?>">
                
                  <button class="btn btn-success btn-sm btn-block"  name="submit">Submit</button>
</form>



        </div>
        <div class="modal-footer">
        </div>
      </div>
    </div>
  </div>

          


          
            <!--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-->
 
     <!-- Bootstrap js -->
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
     <!-- jQuery Datatable js -->
     <script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
     <!-- Bootstrap Datatable js -->    
     <script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
     <script>
       $(document).ready( function () {
           $('#example_table').DataTable();
       } );

       $(document).ready(function(){  
      $('.view_data').click(function(){  
           var employee_id = $(this).attr("id");  
           $.ajax({  
                url:"inventory_details.php",  
                method:"post",  
                data:{employee_id:employee_id},  
                success:function(data){  
                     $('#employee_detail').html(data);  
                     $('#dataModal').modal("show");  
                }  
           });  
      });  
 });  
       </script>
    <!--google graph-->
   
 

    <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>
</body>

</html>