<?php
$page='Cart ';
$tittle='Cart';
include('conn.php')
?>
<?php include('common/head.php'); ?>
<body>
 

<!-- Modal Add users -->
<div style="display:;"  class="" >
  <div class="modal-dialog" role="document">
    <div class="modal-content text-center">
      <div class="modal-header ">
      </div>

      <div class="">

    
  <h4 class="text-center">Edit Cart</h4>
 
  <a   href="carts.php"  class="btn  btn-sm btn-primary">Continue Order</a>

  <?php
   if (isset($_GET['action'])) {
    if ($_GET['action']=='remove') {
         foreach($_SESSION['cart'] as  $key =>$value){
              if ($value['id']==$_GET['id']) {
                $id=$_GET['id'];
                   unset($_SESSION['cart'][$key]);
                  
              }
  
         }
    }
  }
   $sql2="SELECT * FROM currency ";
  $result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
  $row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];
?>
  <div style="background-color:#DDD8DCFF; border-radius:20px;" class="  m-2 ">
  <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 where id=$id ORDER BY RAND()";
$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-10 col-sm-10 <?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>
                         
                           </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">
                                 <!--  <p class="menu-price "><b>₵<?= number_format($price,2) ?></b></p>
                                   <p class="menu-price "><b>₵<?= number_format($new_price,2) ?></b></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="<?=$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>
                 
                   
             
  </div>



  

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


</body>
