<?php
include('includes/session.php');
include('includes/config.php');
if(isset($_POST['submit']))
{
$category=$_POST['category'];
$subcat=$_POST['subcategory'];
$location=mysqli_real_escape_string($conn, $_POST['location']);
$noc=mysqli_real_escape_string($conn, $_POST['noc']);
$priority=$_POST['priority'];
$complaintdetials=mysqli_real_escape_string($conn, $_POST['complaindetails']);
$sql2=mysqli_query($conn,"select * from category where id='$category'");
while($row2=mysqli_fetch_array($sql2))
{
 $role=$row2['Role'];
}
$date= date("d/m/Y");
$month = date("F Y");
$query=mysqli_query($conn,"insert into tblcomplaints(userId,category,subcategory,Location,role,noc,complaintDetails,priority,regDate,Month) values('$user_id','$category','$subcat','$location','$role','$noc','$complaintdetials','$priority','$date','$month')");
// code for show complaint number
$sql=mysqli_query($conn,"select complaintNumber from tblcomplaints  order by complaintNumber desc limit 1");
while($row=mysqli_fetch_array($sql))
{
 $cmpn=$row['complaintNumber'];
}
$complainno=$cmpn;
echo '<script> alert("Your complaint has been successfully Registered. Your Complaint No is  "+"'.$complainno.'")</script>';
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Dashboard">
    <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">

    <title>AVIT | User Register Complaint</title>

    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/nav.css" rel="stylesheet">
    <!--external css-->
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="assets/js/bootstrap-datepicker/css/datepicker.css" />
    <link rel="stylesheet" type="text/css" href="assets/js/bootstrap-daterangepicker/daterangepicker.css" />
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/style-responsive.css" rel="stylesheet">
    <script>
function getCat(val) {
  //alert('val');

  $.ajax({
  type: "POST",
  url: "getsubcat.php",
  data:'catid='+val,
  success: function(data){
    $("#subcategory").html(data);
    
  }
  });
  }
  </script>
  
  </head>

  <body>

  <section id="container" >
     <?php include("includes/header.php");?>
      <?php include("includes/sidebar.php");?>
      <section id="main-content">
          <section class="wrapper">
          	<h3><i class="fa fa-angle-right"></i><i class="fa fa-angle-right"></i> Register Complaint</h3>
          	
          	<!-- BASIC FORM ELELEMNTS -->
          	<div class="row mt">
          		<div class="col-lg-12">
                  <div class="form-panel">
                  	<div class="col-sm-12">
					  <h5 style="text-align:justify; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; color:#ff6347;"><strong>
Note: An asterisk (✱) indicates a required field. On submission, mandatory fields which are empty / Fields with Invalid values are highlighted in red</strong><br/><br/></h5>
                      </div>

                      <form class="form-horizontal style-form" method="post" name="complaint" enctype="multipart/form-data" >

<div class="form-group">

<label class="col-sm-2 col-sm-2 control-label">Category<span style="color:#F00;"> ✱</span></label>
<div class="col-sm-4">
<select name="category" id="category" class="form-control" onChange="getCat(this.value);" required>
<option value="">Select Category</option>
<?php $sql=mysqli_query($conn,"select id,categoryName from category ");
while ($rw=mysqli_fetch_array($sql)) {
  ?>
  <option value="<?php echo htmlentities($rw['id']);?>"><?php echo htmlentities($rw['categoryName']);?></option>
<?php
}
?>
</select>
</div>
<label class="col-sm-2 col-sm-2 control-label">Sub Category<span style="color:#F00;"> ✱</span> </label>
 <div class="col-sm-4">
<select name="subcategory" id="subcategory" class="form-control" required>
<option value="">Select Subcategory</option>
<option value="others">Others</option>
</select>
</div>
</div>



<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Nature of Complaint<span style="color:#F00;"> ✱</span></label>
<div class="col-sm-4">
<input type="text" name="noc" required="required" value="" required="" class="form-control" maxlength="200">
</div>
<label class="col-sm-2 col-sm-2 control-label">Location<span style="color:#F00;"> ✱</span></label>
<div class="col-sm-4">
<input type="text" name="location" required="required" value="" required="" class="form-control">
</div>
</div>


<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Complaint Details (max 500 Characters) </label>
<div class="col-sm-4">
<textarea  name="complaindetails" cols="5" rows="5" class="form-control" maxlength="500"></textarea>
</div>
<label class="col-sm-2 col-sm-2 control-label">Set Priority<span style="color:#F00;"> ✱</span> </label>
<div class="col-sm-4">
<select name="priority" id="priority" class="form-control" required>
<option value="">Select Priority</option>
<option value="Critical">Critical- 30 minutes</option>
<option value="High">High- 1 hour</option>
<option value="Medium">Medium- 4 hour</option>
<option value="Normal">Normal- 24 hour</option>
</select>
</div>
</div>



                          <div class="form-group">
                           <div class="col-sm-10">
                           <center>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
 <button type="reset" name="submit" class="btn btn-warning">Reset</button></center>
</div>
</div>

                          </form>
                          </div>
                          </div>
                          </div>
                          
          	
          	
		</section>
      </section>
    <?php include("includes/footer.php");?>
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="assets/js/jquery.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="assets/js/jquery.scrollTo.min.js"></script>
    <script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>


    <!--common script for all pages-->
    <script src="assets/js/common-scripts.js"></script>

    <!--script for this page-->
    <script src="assets/js/jquery-ui-1.9.2.custom.min.js"></script>

	<!--custom switch-->
	<script src="assets/js/bootstrap-switch.js"></script>
	
	<!--custom tagsinput-->
	<script src="assets/js/jquery.tagsinput.js"></script>
	
	<!--custom checkbox & radio-->
	
	<script type="text/javascript" src="assets/js/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	<script type="text/javascript" src="assets/js/bootstrap-daterangepicker/date.js"></script>
	<script type="text/javascript" src="assets/js/bootstrap-daterangepicker/daterangepicker.js"></script>
	
	<script type="text/javascript" src="assets/js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
	
	
	<script src="assets/js/form-component.js"></script>    
    
    
  <script>
      //custom select box

      $(function(){
          $('select.styled').customSelect();
      });

  </script>

  </body>
</html>
