<?php
	session_start();
	if($_SESSION['rid'])
	{
		$userid=$_SESSION['rid'];
		include'connection.php';
		include'time.php';
	}
	else
	{
		header('location:../login.php');
	}
	
	$quUsr="select * from retailer where Userid='$userid'";
	$reUsr=mysqli_query($con,$quUsr);
	$dataUsr=mysqli_fetch_array($reUsr);
	$UsrName=$dataUsr['Name'];
	$UsrMobile=$dataUsr['Mobile'];
	$UsrEmail=$dataUsr['Email'];
	$UsrAddress=$dataUsr['Address'];
	$UsrPincode=$dataUsr['Pincode'];
	$UsrBusinessname=$dataUsr['Businessname'];
	$UsrPan=$dataUsr['Pan'];
	$UsrGst=$dataUsr['Gst'];
	$UsrState=$dataUsr['State'];
	$UsrCity=$dataUsr['City'];
?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Recharge History</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">
    <link href="dist/css/my-css-code.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="vendor/morrisjs/morris.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]-->
<style>
	#tbl{width:100%; text-align:center;}
	#tbl th{padding:5px; background:dodgerblue; color:white; text-align:center;}
	#tbl td{padding:5px; text-align:center;}
	#tbl tr:nth-child(odd){background:#f7f8fe;}
	#tbl tr:nth-child(even){background:white; }
	.row select{height:35px; font-size:18px; padding:5px; margin:0px 0px 10px 20px;}
	.row input{height:35px; font-size:18px; padding:5px; margin:10px;}
	.content2{background:white; float:right; text-align:center; width:100%; padding:15px; border-radius:3px; overflow:auto;}
	@media (max-width: 768px)
	{
		.content2{width:100%;}
	}
	
	.input-container {
  display: -ms-flexbox; /* IE10 */
  display: flex;
  width: 100%;
  margin-bottom: 15px;
  line-height:100%;
}

.icon {
  padding: 10px;
  background: dodgerblue;
  color: white;
  min-width: 50px;
  text-align: center;
  font-size:25px;
}

.input-field {
  width: 100%;
  padding: 10px;
  outline: none;
}

.input-field:focus {
  border: 2px solid dodgerblue;
}

/* Set a style for the submit button */
.btnForm {
  background-color: dodgerblue;
  color: white;
  padding: 10px 20px;
  border: none;
  cursor: pointer;
  width: 100%;
  opacity: 0.9;
  font-size:25px;
}

.btnForm:hover {
  opacity: 1;
}
#page-wrapper{background:#f8f8f8;}

.form-control{float:left;}
</style>
</head>

<body onload="GetBal()">

    <div id="wrapper">
        <!-- Navigation -->
		<?php
			include'navigation.php';
		?>
        <!-- Navigation -->
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">View Complain History</h1>
                </div>
                <div class="col-lg-12">
                    <form method="post">
	    			    <input type="date" name="fdate" value="<?php echo $date; ?>">
		    		    <input type="date" name="ldate" value="<?php echo $date; ?>">
			    	    <select name="Acc">
    			    		<option value="All">All</option>
		    		    	<option value="CompId">Complain Id</option>
			    		    <option value="OrdId">Order Id</option>
    				    </select>
        				<input type="text" name="SearchNo" placeholder="Enter Search">
	        			<input type="submit" name="submit" value="Search">
			    	</form>
				</div>
            </div>
            <!-- /.row -->
			<div class="content2">
              <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                  <thead>
						<tr>
							<th>Complain Id</th>
							<th>Order Id</th>
							<th>Complain Date</th>
							<th>Complain Time</th>
							<th>Messege</th>
							<th>Solve Date</th>
							<th>Solve Time</th>
							<th>Response Msg</th>
							<th>Status</th>
						</tr>
                  </thead>
                  <tfoot>
						<tr>
							<th>Complain Id</th>
							<th>Order Id</th>
							<th>Complain Date</th>
							<th>Complain Time</th>
							<th>Messege</th>
							<th>Solve Date</th>
							<th>Solve Time</th>
							<th>Response Msg</th>
							<th>Status</th>
						</tr>
                  </tfoot>
                  <tbody>
                    <?php
					        if(isset($_POST['submit']))
					        {
					            $fdate=$_POST['fdate'];
					            $ldate=$_POST['ldate'];
					            $Acc=$_POST['Acc'];
					            $SearchNo=$_POST['SearchNo'];
					            
					            if($Acc=="CompId")
					            {
					                $quComp="select * from complain where Id='$SearchNo' and Userid='$userid'";
					            }
					            elseif($Acc=="OrdId")
					            {
					                $quComp="select * from complain where Rechargeid='$SearchNo'  and Userid='$userid'";
					            }
					            else
					            {
					                $quComp="select * from complain where Compdate>='$fdate' and Compdate<='$ldate'  and Userid='$userid'";
					            }
					            
    	    				        $reReceTxn=mysqli_query($con,$quComp);
	    	    			        while($dataReceTxn=mysqli_fetch_array($reReceTxn))
		    	    		        {
			    	    	           echo "<tr>
				    	                    <td>".$dataReceTxn['Id']."</td>
					                        <td>".$dataReceTxn['Rechargeid']."</td>
					                        <td>".$dataReceTxn['Compdate	']."</td>
					                        <td>".$dataReceTxn['CompTime']."</td>
					                        <td>".$dataReceTxn['Messege']."</td>
					                        <td>".$dataReceTxn['Solvedate']."</td>
					                        <td>".$dataReceTxn['SolveTime']."</td>
    					                    <td>".$dataReceTxn['Responsemsg']."</td>
	    				                    <td>".$dataReceTxn['Status']."</td>
		    			                   </tr>";
			    		            }
					            
					        }
					        else
					        {
    					        $quReceTxn="select * from complain where Userid='$userid' order by Id desc limit 10";
	    				        $reReceTxn=mysqli_query($con,$quReceTxn);
		    			        while($dataReceTxn=mysqli_fetch_array($reReceTxn))
			    		        {
				    	           echo "<tr>
					                    <td>".$dataReceTxn['Id']."</td>
					                    <td>".$dataReceTxn['Rechargeid']."</td>
					                    <td>".$dataReceTxn['Compdate	']."</td>
					                    <td>".$dataReceTxn['CompTime']."</td>
					                    <td>".$dataReceTxn['Messege']."</td>
					                    <td>".$dataReceTxn['Solvedate']."</td>
					                    <td>".$dataReceTxn['SolveTime']."</td>
					                    <td>".$dataReceTxn['Responsemsg']."</td>
					                    <td>".$dataReceTxn['Status']."</td>
					                   </tr>";
					            }
					        }
					    ?>
                  </tbody>
                </table>
              </div>
				</div>
            <!-- /.row -->
            
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

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

    <!-- Morris Charts JavaScript -->
    <script src="vendor/raphael/raphael.min.js"></script>
    <script src="vendor/morrisjs/morris.min.js"></script>
    <script src="data/morris-data.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>
    
    
    
    
   <!-- Bootstrap core JavaScript-->
    <!--<script src="vendor/jquery/jquery.min.js"></script>
    <!--<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <!--<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Page level plugin JavaScript-->
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>

    <!-- Demo scripts for this page-->
    <script src="js/demo/datatables-demo.js"></script>


</body>

</html>
