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


<?php
if (!isset($_SESSION['customers_id'])) {
    echo"<script>alert('You should login to give feedback '); window.location.href='online_login'</script>";
}

if (isset($_GET['i'])) {
   $orderid = base64_decode($_GET['i']) ;
}
else{
    $orderid = 0 ;
}
      
      if (isset($_POST['submit'])) {
       $customer_id=base64_decode($_POST["userid"]);
       $rate=$_POST["rate"];
       $date=$_POST["date"];
       $message=$_POST["message"];
      $order_id=base64_decode($_POST["order_id"]);
    
    //to prevent php injection
    
    
    
    
       
             $sql = "INSERT INTO `cfeedback`( `customerid`, `orderid`, `massage`, `rating`, `date`) VALUES ('$customer_id','$order_id','$message','
             $rate','$date')";
         if(mysqli_query($conn,$sql)){
            echo"<script>alert('Thank you for sharing your thoughts with us.');</script>";
         
         }
         else{
           echo 'Error: '.mysqli_error($conn);
         }
            
           
      
       
    
          
           
           }
  
      
        ?>


<body>
<div  class="container p-0 ">
<!---side nav bar end-->

            <!--Nav menu end-->
          
<!-- Ads Start -->



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

        <div class="col-sm-12">
        <div class="container-fluid py-2 wow fadeInUp" data-wow-delay="0.1s">
        <div id="contact" class="container py-0">
            <div class="section-title text-center position-relative pb-3 mb-5 mx-auto" style="max-width: 600px;">
                <h5 class="fw-bold text-primary text-uppercase">Customer feedback</h5>
                <h6 class="mb-0">We value your opinion and would greatly appreciate any feedback
                you may have regarding your recent experience with our services</h6>
            </div>
  
          
        </div>
          
        </div>

        <div class="col-lg-12 wow slideInUp" data-wow-delay="0.3s">
                    <form  method="post">
                        <div class="row g-1">
                        <div class="form-group col-12">
      <label for="inputState">Select rating</label>
      <select id="inputState" name="rate" class="form-control">
        <option selected>Choose...</option>
        <option value="5">Excellent</option>
        <option value="4">Good</option>
        <option value="3">Fair</option>
        <option value="2">Poor</option>
        <option value="1">Very Poor</option>
      </select>
    </div>
                            <div class="col-12">
                                <label for="textarea">Your feedback:</label>
                                <textarea class="form-control border  px-4 py-3" rows="4" placeholder="Feedback message" name="message" required></textarea>
                            </div>
 
                            <input type="hidden" name="userid" value="<?php echo base64_encode($_SESSION['customers_id'])?>">
                            <input type="hidden" name="order_id" value="<?php echo base64_encode($orderid)?>">
                                    <input type="hidden" name="date" value=" <?php echo date("F j, Y h:ia") ?>">
                            <div class="col-12">
                                <button class="btn btn-primary w-100 py-2 my-2" name="submit" type="submit">Submit</button>
                            </div>
                        </div>
                    </form>
                </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="pad p-1">

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