<?php ob_start();?>
<!DOCTYPE html>
<html lang = "en">
<head>
<?php   include('conn.php');
$page='place orders';
include 'common/head.php'; ?>
 <link rel="stylesheet" href="css/dash.css">
</head>



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

body {
  font-family: sans-serif;
}

/* ---- input ---- */

input[type="text"] {
  font-size: 15px;
}

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

.button {
  display: inline-block;
  padding: 0.5em 1.0em;
  margin-bottom: 10px;
  background: #EEE;
  border: none;
  border-radius: 7px;
  background-image: linear-gradient( to bottom, hsla(0, 0%, 0%, 0), hsla(0, 0%, 0%, 0.2) );
  color: #222;
  font-family: sans-serif;
  font-size: 16px;
  text-shadow: 0 1px white;
  cursor: pointer;
}

.button:hover {
  background-color: #8CF;
  text-shadow: 0 1px hsla(0, 0%, 100%, 0.5);
  color: #222;
}

.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:after {
  content: '';
  display: block;
  clear: both;
}

.button-group .button {
  float: left;
  border-radius: 0;
  margin-left: 0;
  margin-right: 1px;
}

.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 ---- */

.grid {
 
  overflow: scroll;
  height: 100vh !important;
  margin-bottom: 0px !important;

}

@media (min-width: 400px) {
    .grid{
     height:100vh !important;
    }
  }

/* clear fix */
.grid:after {
 
}

/* ---- .element-item ---- */

.element-item {

}

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

.element-item .name {

}

.element-item .symbol {

}

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

.element-item .weight {
  position: absolute;
  left: 10px;
  top: 76px;
  font-size: 12px;
}
.cart-details:hover{
cursor: pointer;
}
@media (min-width: 600px) {
  .menu-items{
   margin: 20px !important;

  }
  }

  @media (min-width: 400px) {
    .cart-section{
      margin-top: 30px;
    }
  }


  label{
    font-size:12px;
  }
</style>
<?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]);
                 header('Location:place_order'); 
            }

       }
  }

  if (isset($_GET['action'])) {
    if ($_GET['action']=='clear') {
unset($_SESSION['cart']);
header('Location:place_order'); 
echo 'good';
    }}
}

 if (isset($_GET['category'])) {
    $cat=$_GET['category']; 
    $general='none'; 
    $cart='block'; 
}
else{
    $cat='';
    $general='block';
    $cart='none';
}
 ?>
<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Nav menu end-->
            <!--Main body Start-->
            <div class=" mt-1">



<?php
/*
$yesterday=date("F j, Y,strtotime('-1 day')");
$sql1="select * from account where date=
$yesterday";
$result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
$row1=mysqli_fetch_array($result1);
if ($row1['date']==$yesterday) {
  $display_not='block';
  }else{
    $display_not='none';  
}*/

?>
<div class="bg-warning text-white rounded  w-25" id="notification" style="display:<?php echo 'none' ?>;"> Please Close Your yesterday Account !!!</div>
<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>
        
      




<div class="row no-gutters  m-0">
  <div class="col-sm-7 ">
  <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 20";
$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);

$link="delete/del_blog.php?id=".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-3 <?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=""><?php echo $discount?>% Off</a>
                        <img style="width: 100%;height:100px" class="img-fluid" src="image/<?php echo "$image";?>" alt="" />
                        
                    </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  style="overflow: scroll !important; height:90%;" class="col-sm-5  cart-section">



  <h4 class="text-center">Cart</h4>
 
 <a   href="index.php?action=clear"  class="btn m-2 btn-sm btn-warning">Clear Order</a>
  
    <div id="main" class="di">

    </div>
 
  </div>
</div>




</div>




<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script src="js/script.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>
 function autoResizeDiv()
        {
            document.getElementById('general').style.height = window.innerHeight +'px';
        }
        window.onresize = autoResizeDiv;
        autoResizeDiv();

   $(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>
