<!DOCTYPE html>
<html lang = "en">
<head>
<?php   include('conn.php');
$page='Customer profile';
include 'common/head_online.php'; ?>
 
</head>


<?php 
include('conn.php');
if (isset($_GET['r'])) {
$id=mysqli_real_escape_string($conn, $_GET['r']);
$id2=base64_decode($id);

}

      ?>


<?php
 if (isset($_POST['Add_to_cart'])) {
     if (isset($_SESSION['cart'])) {
         $session_array_id=array_column($_SESSION['cart'],"id");
         if (!in_array($_GET['id'],$session_array_id)) {
          $session_array=array(
               'id'=>$_GET["id"],
               "image"=>$_POST['image'],
               "orderid"=>$_POST['orderid'],
               "location"=>$_POST['location'],
               "name"=>$_POST['name'],
               "note"=>$_POST['note'],
               "date"=>$_POST['dates'],
               "new_price"=>$_POST['new_price'],
               "discount"=>$_POST['discount'],
               "discription"=>$_POST['discription'],
               "quantity"=>$_POST['quantity'],
                "price"=>$_POST['price']);
          $_SESSION['cart'][]=$session_array;
         }
     }
     else {
          $session_array=array(
               'id'=>$_GET["id"],
              "image"=>$_POST['image'],
              "location"=>$_POST['location'],
              "orderid"=>$_POST['orderid'],
              "name"=>$_POST['name'],
              "note"=>$_POST['note'],
              "date"=>$_POST['dates'],
              "new_price"=>$_POST['new_price'],
               "discount"=>$_POST['discount'],
               "discription"=>$_POST['discription'],
               "quantity"=>$_POST['quantity'],
          "price"=>$_POST['price']);
          $_SESSION['cart'][]=$session_array;
     }
 }
 


 if (isset($_GET['action'])) {
  if ($_GET['action']=='remove') {
       foreach($_SESSION['cart'] as  $key =>$value){
            if ($value['id']==$_GET['id']) {
                 unset($_SESSION['cart'][$key]);
                
            }

       }
  }

  if (isset($_GET['action'])) {
    if ($_GET['action']=='clear') {
unset($_SESSION['cart']);

    }}
}

 if (isset($_GET['category'])) {
    $cat=$_GET['category']; 
    $general='none'; 
    $cart='block'; 
}
else{
    $cat='';
    $general='block';
    $cart='none';
}
 ?>

<body>
<div  class="container p-0 ">
<!---side nav bar end-->
<?php include("common/tittle_online.php")?>
            <!--Nav menu end-->

<!-- Ads Start -->




<?php

include("conn.php");

$sql="select * from menu where id='$id2'";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {
$data=$row['id'];
  $name=$row['name'];
  $category=$row['category'];
  $discription=$row['discription'];
  $image=$row['image'];
  $status=$row['status'];
  $price=$row['price'];
  $discount=$row['discount'];
  $cat=$row['meal_type'];
  $location=$row['itemlocation'];
  $sql2="SELECT * FROM currency ";
  $result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
  $row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];
  
  $item_discount=$price*$discount/100;
  $new_price=round($price-$item_discount);

$details="product_details?r=".urlencode(base64_encode($data));


include('item_data.php');

if ($total_remaining_item <=0 && $location=='Bar') {
  $visible='none';
  $visibles='block';
}
else {
  $visible='block';
  $visibles='none';
}

$text='';

if ($status==='1') {
  $text='Active';
  $read='btn-success';
  $de='deactivate';
  $sta=0;
}
                           else {
  $text='Inactive';
  $read='btn-danger';
 $de='activate';
 $sta=1;
}
$cart_button_text='Add to Cart';
$cart_button_color='bg-warning'; 

$orderid='T'.date('ymdhi').mt_rand(10,100);
}
?>

 <!-- Ads End -->


 <div class="card container mt-0">
        <div class="row py-2">

        <div class="col-sm-6">

       
        <div class="mb-2 text-center">
                        <img  class="img-fluid w-100 rounded mb-2"  src="image/<?php echo "$image";?>" alt="<?php echo $name ?>">
                    </div>
        </div>
        
            <div class="col-sm-6">
            <iframe name="votar" style="display:none;"></iframe>
            <form method="post" action="index.php?id=<?= $data?>"  target="votar">
            <div class="summary bg-light rounded-2 p-4">
                <h5 class="p-2 text-center">Product Details </h5>
                <h5 class="mb-4"><?php echo $name ?></h5>
                <h6><?php echo $discription ?></h6>
              
                <div class="menu-tag row mt-4">
                            <div class="price col-12">
                            <small class="align-top text-center  p-1 rounded" style="font-size: 25px; line-height: 1px;"><?php echo $currency?><?php echo "$new_price";?>
                            <span class="" style="font-size:20px"><s><?php echo $currency?><?php echo "$price";?></s></span></small>
                            </div>
                              
                               <div class="counter col-12">
                               <p>Quantity</p>
                                   <span class="down" onClick='decreaseCount(event, this)'>-</span>
                                   <input type="text" name="quantity" value="1">
                                   <span class="up" onClick='increaseCount(event, this)'>+</span>
               
                                 </div>
                          
                           </div>
                          
                       </div>
                      
                       <input type="hidden" name="name" value="<?=$name?>">
                       <input type="hidden" name="price" value="<?=$price?>">
                        <input type="hidden" name="new_price" value="<?=$new_price?>">
                       <input type="hidden" name="discription" value="<?=$discription?>">
                       <input type="hidden" name="image" value="<?=$image?>">
                       <input type="hidden" name="location" value="restaurant">
                       <input type="hidden" name="dates" value="<?php echo date("F j, Y") ?>">
                       <input type="hidden" name="orderid" value="<?=$orderid?>">
                       <input type="hidden" name="discount" value="<?=$discount?>">
                     <input style="height:30px" class="form-control my-2" type="text" name="note" placeholder="add order Nnte">
                <input id="<?=$data?>"  onClick="reply_click(this)" style="display:<?php echo $visible?>;background-color:#982BAD;" type="submit" class="btn text-white btn-block cart my-1" name="Add_to_cart" value="Add to cart">
                <input style="display:<?php echo $visibles?>;" type="submit" class=" btn btn-warning btn-block   my-1"  value="Out of stock">
                </form>
            </div>
           
            </div>
         
        </div>
    </div>

 
<!-- Ads Start -->

<div class="container-fluid py-0 mb-4 wow fadeInUp" data-wow-delay="0.1s">
        <div class="container py-0">
            <div class="row">

            <div class="  wow col-sm-12 text-center fadeInUp" data-wow-delay="0.6s">
              <a href="#">
                <div class="ads-item  my-0">
                <img class="img-fluid" src="logo/restaurant_delivery.jpg" alt="banner">
                
                </div>
             </a>

            </div>
            </div>
           
        </div>
    </div>
<!---ads end--->

<div class="row no-gutters  m-0">
  <div class="col-sm-12 ">
  <div class="section-title text-center position-relative pb-3 my-3 mx-auto" style="max-width: 600px;">
               
                <h5 class="mb-0">Similar Dishes</h5>
            </div>  
  <div style="display:<?php echo $general ?>; background-color:;" id="general" class=" grid row  no-gutters m-0">
  
                   <!--menu items 1-->
                   <?php

include("conn.php");

$sql="select * from menu  ORDER BY RAND() LIMIT 6";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {
$data=$row['id'];
  $name=$row['name'];
  $category=$row['category'];
  $discription=$row['discription'];
  $image=$row['image'];
  $status=$row['status'];
  $price=$row['price'];
  $discount=$row['discount'];
  $location=$row['itemlocation'];

  $sql2="SELECT * FROM currency ";
  $result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
  $row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];
  
  $item_discount=$price*$discount/100;
  $new_price=round($price-$item_discount);

  $details="product_details?r=".urlencode(base64_encode($data));
$edit_user="edit/edit_user.php?id=".urlencode(base64_encode($data));
$activate="edit/user_status.php?id=".urlencode(base64_encode($data));
$dat=$data;

include('item_data.php');

if ($total_remaining_item <=0 && $location=='Bar') {
  $visible='none';
  $visibles='block';
}
else {
  $visible='block';
  $visibles='none';
}

$text='';

if ($status==='1') {
  $text='Active';
  $read='btn-success';
  $de='deactivate';
  $sta=0;
}
                           else {
  $text='Inactive';
  $read='btn-danger';
 $de='activate';
 $sta=1;
}
$cart_button_text='Add to Cart';
$cart_button_color='bg-warning'; 

$orderid='T'.date('ymdhi').mt_rand(10,100);
?>
 <iframe name="votar" style="display:none;"></iframe>
<form method="post" action="index.php?id=<?= $row['id']?>"  target="votar">
                   <div id="pizza" class="menu-items element-item transition m-3 col-5 col-sm-2 <?php echo $location ?>">
                       <div class="">
                       <div class="blog-img position-relative ">
                       <a style="background-color:#982BAD;" class="position-absolute top-0 start-0  text-white rounded-end mt-5 py-1 px-1" href="<?=$details; ?>"><?php echo $discount?>% Off</a>
                       <a href="<?=$details; ?>"> <img style="width: 100%;height:100px" class="img-fluid" src="image/<?php echo "$image";?>" alt="" /></a>
                        
                    </div>
                 
                           <div class="">
                               <p  style="font-size: 12px;" class=" "><?php echo $name ?></p>
<hr>
                          
                           <P style="font-size: 10px;"class=""><?php echo $discription ?></P>
                         <hr>
                           </div>
                           <div class="menu-tag row">
                            <div class="price col-6">
                            <small class="align-top text-center  p-1 rounded" style="font-size: 13px; line-height: 1px;"><?php echo $currency?><?php echo "$new_price";?>
                            <span class="" style="font-size:10px"><s><?php echo $currency?><?php echo "$price";?></s></span></small>
                            </div>
                              
                               <div class="counter col-6">
                               
                                   <span class="down" onClick='decreaseCount(event, this)'>-</span>
                                   <input type="text" name="quantity" value="1">
                                   <span class="up" onClick='increaseCount(event, this)'>+</span>
               
                                 </div>
                          
                           </div>
                          
                       </div>
                       <input type="hidden" name="name" value="<?=$row['name']?>">
                       <input type="hidden" name="price" value="<?=$row['price']?>">
                        <input type="hidden" name="new_price" value="<?=$new_price?>">
                       <input type="hidden" name="discription" value="<?=$row['discription']?>">
                       <input type="hidden" name="image" value="<?=$row['image']?>">
                       <input type="hidden" name="location" value="<?=$row['itemlocation']?>">
                       <input type="hidden" name="dates" value="<?php echo date("F j, Y") ?>">
                       <input type="hidden" name="orderid" value="<?=$orderid?>">
                       <input type="hidden" name="discount" value="<?=$discount?>">
                     <input style="height:20px" class="form-control" type="text" name="note" placeholder="Note">
                       <input id="<?=$row['id']?>"  onClick="reply_click(this)" style="display:<?php echo $visible?>;background-color:#982BAD;" type="submit" class="btn text-white btn-block cart my-1" name="Add_to_cart" value="Add to cart">
                       <input style="display:<?php echo $visibles?>;" type="submit" class=" btn btn-warning btn-block   my-1"  value="Out of stock">
                   </div>

                   </form>
                   <?php }  ?>
                   
               </div>
  </div>
</div>


<!--item added to added to cart notification--->
<div class="bg-success text-white rounded  w-25" id="popUp" style="display: none;"> Item added to cart <i class="fa fa-check-square-o" aria-hidden="true"></i></div>
<!--item added to added to cart notification end--->
    <div class="pad p-4">

    </div>
 <!-- Ads End -->
<?php include('online_button_nav.php')?>

</div>



<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script src="js/script.js"></script>
    <!-- JavaScript Libraries -->
    <script src="lib/owlcarousel/owl.carousel.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() { /// Wait till page is loaded
setInterval(timingLoad, 3000);
function timingLoad() {
$('#main').load('property-detailed.php #main', function() {
/// can add another function here
});
}
}); //// End of Wait till page is loaded
</script>
<script>


   $(document).ready(function(){
setInterval(function(){
      $(".refreeshmes").load(window.location.href + " .refreeshmes" );
}, 3000);
});

 function reply_click(obj)
  {

    var id = obj.id;
    document.getElementById(id).style.visibility = "hidden";
      $( "#popUp" ).show(); 
   setTimeout(function() {
      $( "#popUp" ).hide();
      $( id ).hide();
    }, 2000);
  }






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