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

<!-- Modal Add users -->
<div  class="" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header ">
      </div>

      <div class="">

    
  <h4 class="text-center">Cart</h4>
 
  <a   href="index.php?action=clear"  class="btn  btn-sm btn-warning">Clear Order</a>
  <a   href="place_order"  class="btn  btn-sm btn-success">Continue Order</a>
  <form class=" " method="post" action="submit_order.php">
  <?php
  $month = date("F");
  $order_id='T'.date('ymdhi').mt_rand(10,100);
  $real_id=substr($order_id,-2);
  $ord = sprintf('%03d',$real_id);  
   $sql2="SELECT * FROM currency ";
  $result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
  $row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];
$total=0;
$total_price=0;
if (!empty($_SESSION['cart'])) {
     foreach($_SESSION['cart'] as$key => $value) {
       $arr=count($_SESSION['cart']);
       $total_new_item_price=    ($value['new_price'] * $value['quantity']);
       $total_old_item_price=   ($value['price'] * $value['quantity']);
          $total=   $total + ($value['new_price'] * $value['quantity']);
          $total_price=  $total_price + ($value['price'] * $value['quantity']);
          $discount=$total_price-$total;
        $real_id= $value['orderid'];
$ord = sprintf('%03d',$real_id);
?>
  <div style="background-color:#DDD8DCFF; border-radius:20px;" class="  m-2 ">
  <div class="row no-gutters rounded-3 p-2 m-1 border-0 ">
                    <div class="col-4 p-0  col-sm-2">
                        <div class="blog-img position-relative overflow-hidden">
                            <img style="width: 70px;" class="img-cart " src="image/<?php echo $value['image'] ?>" alt="">
                           </div>
                    </div>
                    <div class="col-6  col-sm-8">
                        <p style="font-size: 15px;" class="tittle" class="mb-1"><?php echo $value['name']?>   </p>
                <h3 class="my-2">
                    <small  id="" class="align-top " style="font-size:15px; line-height: 1px; "><b><?php echo $currency?><?php echo number_format($value['price'])?></b> <span class="" style="font-size:small;">x</span><?php echo $value['quantity']?></small>
                </h3>

                <p style="font-size: 12px;" ><u><?php echo $value['note']?></u></p>
                <input type="hidden" name="food_name[]" value="<?php echo $value['name']?>">
                            <input type="hidden" name="quantity[]" value="<?php echo $value['quantity']?>">
                            <input type="hidden" name="item_total[]" value="<?php echo $total_new_item_price?>">
                            <input type="hidden" name="price[]" value="<?php echo $value['price']?>">
                            <input type="hidden" name="new_price[]" value="<?php echo $value['new_price']?>">
                            <input type="hidden" name="item_id[]" value="<?php echo $value['id']?>">
                            <input type="hidden" name="location[]" value="<?php echo $value['location']?>">
                            <input type="hidden" name="dates[]" value="<?php echo $value['date']?>">
                            <input type="hidden" name="month[]" value="<?php echo  date("F");?>">
                            <input type="hidden" name="orderid[]" value="<?php echo $order_id?>">
                            <input  type="hidden" name="note[]" value="<?php echo $value['note']?>  ">


                    </div>
                    <div class="col-2 col-sm-2 text-center">
                        <a class="p-2"  style="font-size: 30px;" href="index.php?action=remove&id=<?=$value['id']?>"><i class="bi bi-trash text-danger   "></i></a>
                      <!--  <a class="p-2"  style="font-size: 30px;" href="edit_cart.php?action=remove&id=<?=$value['id']?>"><i class="bi bi-pencil text-success   "></i></a> --->
                    </div>
                </div>
  </div>
  <?php }}?>


  
    <div  style=" border-radius:20px;"  class="customer-details  ">
    <h6 class="text-center">Customer Details</h6>
  <div class=" row no-gutters">
    <div class="col-6">
    <label class="m-1"for="number">Full Name:</label>
                <div class="input-group col-12 mb-1">
                    <span class="input-group-text  text-success" id="addon-wrapping"><i class="bi bi-person text-success"></i></span>
                    <input  type="text" class="form-control "value="" aria-label="fname" name="fname" aria-describedby="addon-wrapping">
                  </div>
    </div>
 
                  <div class="col-6">
                  <label class="m-1"for="number">Contact:</label>
                <div class="input-group flex-nowrap col-12 mb-1">
                    <span class="input-group-text  text-success" id="addon-wrapping"><i class="bi bi-telephone"></i></span>
                    <input type="text" class="form-control "value="" aria-label="Username"   name="contact" aria-describedby="addon-wrapping">
                  </div>
                  </div>
                  
                  <div class="col-6">
                  <label class="m-1"for="number">Select Table:</label>
                  <div class="input-group flex-nowrap col-12 mb-1">
                    <span class="input-group-text  text-success" id="addon-wrapping"><i class="bi bi-geo-alt"></i></i></span>
                     <select class="form-control" name="table">
                       <option value="">Select a table ...</option>
                       <option value="0">Home</option>
                       <option value="1"> Table 1</option>
                       <option value="2">Table 2</option>
                       <option value="3">Table 3</option>
                       <option value="4">Table 4</option>
                     </select>
                     </div>
                  </div>

                  <div class="col-6">
                  <label class="m-1"for="number">Payment Method:</label>
                  <div class="input-group flex-nowrap col-12 mb-1">
                    <span class="input-group-text  text-success" id="addon-wrapping"><i class="bi  bi-cash"></i></span>
                     <select class="form-control" name="payment">
                       <option value="">payment Method</option>
                       <option value="0">Cash</option>
                       <option value="1">Momo</option>
                      
                     </select>
                     </div>
                  </div>
               
  </div>
    </div>
  <div style="background-color: white; border-radius:20px;" class="p-2 text-dark ">
                <p class="my-1">Items Total:  <span style="float: right;font-size:20px; line-height: 2px;"><b><?php echo $currency?><?php echo number_format($total)?></b></span></p>
                <p class="my-1">Discount:  <span style="float: right;font-size:20px; line-height: 2px;"><b><?php echo $currency?><?php echo number_format($discount)?></b></span></p>
                <p class="my-1">Subtotal:  <span style="float: right;font-size:20px; line-height: 2px;"><b><?php echo $currency?><?php echo number_format($total)?></b></span></p>
                <input type="hidden" name="total" value="<?php echo $total?>">
                        <input type="hidden" name="discount" value="<?php echo $discount?>">
                       <input type="hidden" name="order_id" value="<?php echo $order_id?>">
                       <input type="hidden" name="order_type" value="0">
                       <input type="hidden" name="by" value="<?php echo $id_user?>">
                       <input type="hidden" name="time" value="<?php echo date("G:i")?>">
            </div>
            <button  name="submit" style="background-color:#982BAD;" id="payBtn"  class="btn  btn-block  text-white my-2">Submit Order</button>
            </form>

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


</body>
