<?php include('usersession.php'); ?>
<!DOCTYPE html>
<html lang="en">
  <head>
	<title>ECIMS ADMIN | UPDATE COMPLAINT</title>
    <?php include('includes/head.php'); ?>
    <style>.select2-container{display:none !important;}</style>
  </head>
  <body>
    <div class="container-scroller">
      <div class="horizontal-menu">
        <div class="horizontal-menu">
        <?php $activePage = basename($_SERVER['PHP_SELF'], ".php"); ?>
<nav class="navbar top-navbar col-lg-12 col-12 p-0">
  <div class="container-fluid">
	<div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-start">
	  <a class="navbar-brand brand-logo" href="index.php"><img style="width: 115px;height:auto;" src="assets/images/logo.png" alt="logo" /></a>
	  <a class="navbar-brand brand-logo-mini" href="index.php"><img style="width: 115px;height:auto;" src="assets/images/logo.png" alt="logo" /></a>
	</div>
	<div class="text-center navbar-menu-wrapper d-none d-lg-block d-flex align-items-center justify-content-center">
	  <span style="text-transform:uppercase;font-size: 30px;font-weight: bold;color: #000;">military engineer services <br> HISAR/ALWAR</span>
	</div>
	<div class="navbar-brand-wrapper d-flex align-items-center justify-content-end">
	  <a class="navbar-brand brand-logo d-none d-lg-block" href="index.php"><img style="width: 115px;height:auto;" src="assets/images/logo-right.png" alt="logo" /></a>
	  <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="horizontal-menu-toggle">
		<i class="fa fa-bars text-white"></i>
	  </button>
	</div>
  </div>
</nav>
<p class="text-center p-0 m-1 fw-bolder">Login Date : <?php echo date('d/m/Y'); ?></p>
<nav class="bottom-navbar">
  <div class="container-fluid">
	<ul class="nav page-navigation">
	  <li class="nav-item <?= (($activePage == 'newComplaint')) ? 'active':''; ?>">
		<a class="nav-link" href="newComplaint.php">
		  <span class="menu-title">NEW COMPLAINT</span>
		</a>
	  </li>
	  <li class="nav-item <?= (($activePage == 'userComplaints')) ? 'active':''; ?>">
		<a class="nav-link" href="userComplaints.php">
		  <span class="menu-title">ALL COMPLAINTS LIST</span>
		</a>
	  </li>
	  <li class="nav-item <?= (($activePage == 'pendingComplaints')) ? 'active':''; ?>">
		<a class="nav-link" href="pendingComplaints.php">
		  <span class="menu-title">PENDING COMPLAINTS LIST</span>
		</a>
	  </li>
	  <li class="nav-item <?= (($activePage == 'completeComplaints')) ? 'active':''; ?>">
		<a class="nav-link" href="completeComplaints.php">
		  <span class="menu-title">COMPLETE COMPLAINTS LIST</span>
		</a>
	  </li>
	  <li class="nav-item <?= (($activePage == 'cancelComplaints')) ? 'active':''; ?>">
		<a class="nav-link" href="cancelComplaints.php">
		  <span class="menu-title">CANCELLED COMPLAINTS LIST</span>
		</a>
	  </li>
	  <li class="nav-item">
		<a class="nav-link" href="signout.php">
		  <span class="menu-title">LOGOUT</span>
		</a>
	  </li>
	</ul>
  </div>
</nav>
      </div>
      </div>
      <div class="container-fluid page-body-wrapper">
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title"> Update Department </h3>
            </div>
            <div class="row">
              <div class="col-12 grid-margin stretch-card">
                <div class="card">
                  <div class="card-body">
                      <?php $err = $msg = '';
							if(isset($_POST['submit'])) {
								$user_feedback = mysqli_real_escape_string($conn, $_POST['user_feedback']);
								$user_ratings = mysqli_real_escape_string($conn, $_POST['user_ratings']);
								$id = mysqli_real_escape_string($conn, $_POST['id']);
							    $insert = $conn->query("UPDATE users_complaint SET user_feedback='".$user_feedback."',user_ratings='".$user_ratings."' WHERE ucid='".$id."'");
							if($insert){
						        echo '<script>alert("Data Updated Successfully.");window.location.href="userComplaints.php";</script>';
								$msg = 'Data Updated Successfully.';
							} else {
								$err = $conn->error;
							}
						}
						if(!empty($err)){
						  echo "
							<div class='alert alert-danger alert-dismissible'>
							  <h4><i class='fa fa-warning'></i> Error!</h4>
							  ".$err."
							</div>
						  ";
						}
						if(!empty($msg)){
						  echo "
							<div class='alert alert-success alert-dismissible'>
							  <h4><i class='fa fa-check'></i> Success!</h4>
							  ".$msg."
							</div>
						  ";
						}
                        $department = $conn->query("SELECT * FROM users_complaint WHERE ucid='".$_GET['id']."'")->fetch_assoc();
						?>
                    <form class="forms-sample" method="POST">
                        <input type="hidden" name="id" value="<?php echo $department['ucid']; ?>"/>
                      <div class="form-group">
                        <label for="user_feedback">Feedback</label>
                        <div class="form-check form-check-primary"><label class="form-check-label"><input type="radio" name="user_feedback" class="c_status form-check-input" <?php if($department['user_feedback'] == 'Satisfied') { echo 'checked'; } ?> value="Satisfied"/> Satisfied</label></div>
                        <div class="form-check form-check-primary"><label class="form-check-label"><input type="radio" name="user_feedback" class="c_status form-check-input" <?php if($department['user_feedback'] == 'Not Satisfied') { echo 'checked'; } ?> value="Not Satisfied"/> Not Satisfied</label></div>
                  </div>
                      <div class="form-group">
                        <label for="c_status">Rating</label>
                        <select id="example-css" name="user_ratings" autocomplete="off">
                          <option value="1">1</option>
                          <option value="2">2</option>
                          <option value="3">3</option>
                          <option value="4">4</option>
                          <option value="5">5</option>
                        </select>
                      </div>
                      <button type="submit" name="submit" class="btn btn-primary me-2">Submit</button>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
		  <?php include('includes/footer.php'); ?>
        </div>
      </div>
    </div>
    <?php include('includes/foot.php'); ?>
  </body>
</html>