<?php include("conn.php");
$page='Online Order Management';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php");

if ($order=='none') {
  echo"<script>alert('You are not allow to access this page, contact your admintrator'); window.location.href='login'</script>";
}
?>



<style>
     * { box-sizing: border-box; }


/* ---- button ---- */


.button:active,
.button.is-checked {
  background-color: #28F;
}

.button.is-checked {
  color: white;
  text-shadow: 0 -1px hsla(0, 0%, 0%, 0.8);
}

.button:active {
  box-shadow: inset 0 1px 10px hsla(0, 0%, 0%, 0.8);
}

/* ---- button-group ---- */


.button-group .button:first-child { border-radius: 0.5em 0 0 0.5em; }
.button-group .button:last-child { border-radius: 0 0.5em 0.5em 0; }

/* ---- grid ---- */





.element-item > * {
  margin: 0;
  padding: 0;
}



.element-item .number {
  position: absolute;
  right: 8px;
  top: 5px;
}

.element-item .weight {
  position: absolute;
  left: 10px;
  top: 76px;
  font-size: 12px;
}
</style>
<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
       
            <!--Nav menu end-->

            <!--Main body Start-->
            <div id="accordions" class="  mt-2">
              
      <center>

      
      </center> 
      <hr class="bg-success">


                <!--search section end-->
                <!--Orders start-->

                <!--order-items-->
                <!--order-items-one-->
               <div  id="collapseOne" class="orders order_auto  " data-parent="#accordions">
                    <h5 class="text-center">Online Active Orders</h5>
                    <a style="font-size:12px;" href="online_orders" class="btn m-2 btn-outline-success"> <i class="fa fa-refresh" aria-hidden="true"></i></a>
                    <div class=" grid row no-gutters " >
                   






                    <?php
             $sql1="select * from orders_details where status=0 and order_type=1 order by date desc";
             $result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
             while ($row1=mysqli_fetch_array($result1)) {
              $data=$row1['orderid'];
                $customer_name=$row1['costomer_name'];
                $total=$row1['amount'];
                $status=$row1['status'];
                $order_type=$row1['order_type'];
                $date=$row1['date'];
                $time=$row1['time'];
                $payment_status=$row1['payment_status'];
             if ($order_type==1) {
              $order_type='Online Order';
             }
             else{
               $order_type='In Store Order';
             }
             
                $real_id=substr($data,-2);
             $ord = sprintf('%03d',$real_id);   
             
            ?>
               
                
              <!--menu items 1-->
                        <div style="display:<?php echo  $prepare_order_r ." ". $prepare_order_b ?>;" id="pizza" class=" col-sm-2 m-3 col-5 menu-items-order-managment   element-item transition  <?php echo $location ?> ">
                            <h4 style="font-size:15px;"class="text-center">#<?php echo $ord?> <small><?php echo $order_type?></small></h4>
                            <hr class="bg-success">
                            <?php 

$sql2="SELECT * FROM currency ";
$result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
$row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];

                $sql="select * from orders where  orderid ='$data' and confirm='0' and status='0'order by date desc  ";
                $result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
                while ($row=mysqli_fetch_array($result)) {
                $order_id=$row['orderid'];
                $item_id=$row['item_id'];
                    $location=$row['location']; 
                    $sql3="SELECT * FROM menu  WHERE id=$item_id";
                    $result3 = mysqli_query($conn,$sql3)or die( mysqli_error($conn));
                    $row2=mysqli_fetch_array($result3) ;
                    $link="edit/confirm_order.php?l=online_orders&id=".urlencode(base64_encode($order_id));
                    $cancel="cancel_order_reason.php?l=online_orders&id=".urlencode(base64_encode($order_id));
                ?>
                            <div class="d-flex border ">
                                <img style="width: 50px; height: 50px; margin: 10px;" src="image/<?php echo $row2['image']?>" alt="">
                                <div class="menu-text">
                                    <p style="font-size:12px;"class="menu-tittle m-2"><?php echo $row['item_name']?> x <?php echo $row['quantity']?></p>
                                <P style="font-size:12px;" class="menu-dis m-1"><?php echo $row2['discription']?>trrr</P>
                                <p style="font-size:12px;" class="menu-price-order-managment "><b><?php echo $currency?><?php echo number_format($row['price'],2)?></b></p>
                                </div>
                            </div>

                            <?php }?>
                            <div class="action bg-dark text-center">
                                <a style="font-size:12px;" href="<?=$link ?>" class="btn m-2 btn-outline-success">Ready</a>
                                 <a style="font-size:12px;" href="<?=$cancel ?>" class="btn m-2 btn-outline-warning">Cancel</a>
                            </div>
                           
                        </div>
    
                   <?php } ?>
 
    
    
<!-- 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>

                        
                        
                    </div>
    

                </div>


 

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script>
 
// quick search regex
var qsRegex;
var buttonFilter;

// init Isotope
var $grid = $('.grid').isotope({
  itemSelector: '.element-item',
  layoutMode: 'fitRows',
  filter: function() {
    var $this = $(this);
    var searchResult = qsRegex ? $this.text().match( qsRegex ) : true;
    var buttonResult = buttonFilter ? $this.is( buttonFilter ) : true;
    return searchResult && buttonResult;
  }
});

$('#filters').on( 'click', 'button', function() {
  buttonFilter = $( this ).attr('data-filter');
  $grid.isotope();
});

// use value of search field to filter
var $quicksearch = $('#quicksearch').keyup( debounce( function() {
  qsRegex = new RegExp( $quicksearch.val(), 'gi' );
  $grid.isotope();
}) );


  // change is-checked class on buttons
$('.button-group').each( function( i, buttonGroup ) {
  var $buttonGroup = $( buttonGroup );
  $buttonGroup.on( 'click', 'button', function() {
    $buttonGroup.find('.is-checked').removeClass('is-checked');
    $( this ).addClass('is-checked');
  });
});
  

// debounce so filtering doesn't happen every millisecond
function debounce( fn, threshold ) {
  var timeout;
  threshold = threshold || 100;
  return function debounced() {
    clearTimeout( timeout );
    var args = arguments;
    var _this = this;
    function delayed() {
      fn.apply( _this, args );
    }
    timeout = setTimeout( delayed, threshold );
  };
}




</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(){
setInterval(function(){
      $(".order_auto").load(window.location.href + " .order_auto" );
}, 3000);
});

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

</html>