<?php
session_start();
include ("includes/security.php");
include ("includes/database.php");
include ("includes/setting.php");

//retrieved logged's user data
$username=$_SESSION["username"];
$dataUser=mysqli_query($con,"SELECT * from tbl_user where username='$username'");
$bil_rekod=mysqli_num_rows($dataUser);
$showData=mysqli_fetch_array($dataUser);



//retrieved tbl_data2

//simpan data rating

if (isset($_POST["pid4"]))
{
	
	mysqli_query($con,"INSERT INTO tbl_feedback (shop_id,feedback_detail, feedback_id) values ('$_POST[pid4]', '$_POST[rate]','$username')")or die (mysqli_error($con));	
	
	
}



?>

<!DOCTYPE html>
<html lang="en">
    <div class="container">
  <link rel="stylesheet" type="text/css" href="styleall.css">
<head>

   <!-- w3school -->
    <style>
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: url(images/pinkk.png);
}

li {
  float: left;
}

li a {
  display: block;
  font-family: verdana;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover {
  background-color: #fff2e6;
}
</style>

    <meta charset="utf-8">

    <title><?php echo $tajuk; ?></title>

    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

<ul>
     <li><a class="active" href="main.php">Home</a></li>
  <li><a href="about.php">About</a></li>
  <li><a href="pilih.php">Choose Shop</a></li>
  <li><a href="profile.php">Profile</a></li>
  <li><a href="feedback.php">Feedback</a></li>
  <li><a href="logout.php">Logout</a></li>
        
</ul>

                        <?php
            
            if (!(isset($_POST ["feedback_id"])))
            {
              ?>
                            
          <form role="form" method="post" enctype="multipart/form-data">
                        
                            <fieldset>
            <div class="box"  align="middle">
              <table class="table table-bordered">
                
              
 <div class="box box-success">
            <div class="box-header">
              <label>Rating</label>
            </div>
            <div class="box-body">
              <!-- radio -->
              <div class="form-group">
                <label>
                  <input type="radio" name="feedback_rating" class="flat-red" value="1" checked> 1 
                </label>
                <label>
                  <input type="radio" name="feedback_rating" class="flat-red" value="2"> 2 
                </label>
                <label>
                  <input type="radio" name="feedback_rating" class="flat-red" value="3"> 3 
                  <label>
                  <input type="radio" name="feedback_rating" class="flat-red" value="4"> 4 
                </label>
                <label>
                  <input type="radio" name="feedback_rating" class="flat-red" value="5"> 5 
            </div>
         
                    

<div class="form-group">
<label>Feedback/Comment</label>
<textarea class="form-control" rows="10" placeholder="Enter feedback or comment about this system..." name="feedback_details" type="text"></textarea>
      </div>

                         

                         <input type="hidden" name="feedback_id">

                                <input type="submit" class="btn btn-lg btn-success btn-block" value="Submit Feedback">
                                <a href="main.php" class="btn btn-lg btn-danger btn-block">Cancel</a>
                                
                            </table></fieldset>
                        </form>
                      
                       <?php
            }
            else
            {
              
              //get data from input
              $feedback_id=$_POST["feedback_id"];   
              $feedback_id2=$_GET["id"];
              //check duplicate
              
              $data=mysqli_query($con, "SELECT * FROM tbl_feedback where feedback_id='$feedback_id'");
              $bil_rekod=mysqli_num_rows($data);
              $show=mysqli_fetch_array($data);
              if ($bil_rekod!=0)
              {
              
              
              ?>
                            
                            <div class="alert alert-danger">
                               Failed. <a href="main.php" class="alert-link">Click here</a> to try again.
                            </div>
                           
                         <?php
              }

              else 
              {

date_default_timezone_set('Asia/Kuala_Lumpur');
$a=date("Y-m-d");
$b=date("h:i:s");
$feedback_details=$_POST["feedback_details"];
$feedback_rating=$_POST["feedback_rating"];

//$dateregister=date("Y-m-d");                
//insert data into database   
mysqli_query($con,"INSERT INTO tbl_feedback (user_id,feedback_details,feedback_rating,feedback_date,feedback_time,shop_id) values ('$username','$feedback_details','$feedback_rating','$a','$b','$feedback_id2')")or die (mysqli_error($con));               
                

                //
              //
                
                ?>
                 
                 <div class="alert alert-success">
                              Feedback submitted. <a href="main.php" class="alert-link">Click here</a> to main menu.
                            </div>
            <?php
              }}
              ?>
            
 


















    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>

</body>

</html>
