<?php include("conn.php");
$page='Bar Auditing';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>
<body>

    <?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Main body Start-->
           
            <!--Nav menu end-->
            <!--Main body Start-->
            <div style="overflow:scroll; height:100vh;" id="accordions" class="col-sm-12 mt-1">
            <?php
              $sql1="select * from menu where itemlocation='Bar' ";
              $result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
               $total_menu = mysqli_num_rows($result1) ;
              ?>
      <hr class="bg-success">
                <!--search section end-->
                <!--Orders start-->

                <!--order-items-->
                <!--order-items-one-->
               <div  id="collapseOne" class="  col-sm-12  " data-parent="#accordions">         
                    <h5 class="text-center">Bar Auditing</h5>
                    <!-- Button trigger modal -->

  








  <table id="example_table" class="table-customer table-striped table-hover  w-100 table-bordered">
                        <thead>
                            
                        <tr>
                            <th>Id</th>
                            <th>Image</th>
                            <th>Name</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php

      

$sql="select * from menu where itemlocation='Bar' order by id desc";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {




 $data=$row['id'];
   $image=$row['image'];
   $category=$row['category'];
   $name=$row['name'];
   $discription=$row['discription'];
   $status=$row['status'];
   $price=$row['price'];
   
 


 $link="edit/add_audit.php?id=".urlencode(base64_encode($data));
 $dat=$data;


 $text='';





  include('item_data.php');

?>
                        <tr>
                            <td><?php echo $data ?></td>
                            <td><img style="width: 40px;" src="image/<?php echo $image ?>" alt=""></td>
                            <td><?php echo $name ?></td>
                            <td>
                            <input  type="button" name="view" value="Add" id="<?php echo $row["id"]; ?>" class="btn  btn-success btn-sm view_datas" />
                          
                          </td>
                        </tr>
                        <?php } ?>
                        <thead>
                        <th>id</th>
                            <th>Image</th>
                            <th>Name</th>
                            <th>Action</th>
                            </thead>
                    </tbody>
                    </table>
    

                </div>

        


       

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

            <!--Customer massaging section-->
    
              

                

          



       <!--modal delete-->
<!-- Large modal -->
<div id="dataModal1" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div  id="employee_detail1" class="modal-content text-dark">
      
     
    
    </div>
  </div>
</div>

      
<?php
	
	if(isset($_POST['submit'])){

		
		$name=$_POST['name'];
		 $qty=$_POST['qty'];
		$id=($_POST['id'])/15;
		$location=$_POST['location'];
		$date=$_POST['date'];
    $time=$_POST['time'];
		$by=($_POST['by'])/15;
    $qtyInStock=($_POST['qtyInStock'])/15;
	$totalLose=$qtyInStock-$qty;
  $amountLose=$totalLose*$price;
   
	
		
			// Image db insert sql
			$sql = "INSERT INTO `bar_auditing`(`item_id`, `name`,`qty` ,`qtyInStock` ,`totalLose` ,`amountLose` , `uploadby`,`date`,`time`) VALUES ('$id','$name','$qty','$qtyInStock','$totalLose','$amountLose','$by','$date','$time')";
			if(mysqli_query($conn,$sql)){
        echo"<script>alert('Item added succesfully');</script>";
			}
			else{
			  echo 'Error: '.mysqli_error($conn);
			}
		}

	?>

   
    
 <!--  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', {
            order:[[2,"asc"]],
            autoFill: true,
            pageLength : 200,
    lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
    layout: {
        topStart: {
            buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
        }
    }
});
       } );
</script>
    
    <script>
    

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

</html>