<?php
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';

?>
<html>
<head>
	<title>Contact Us</title>
	<!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
	<link rel="icon" href="images/logo.png" type="image/gif" sizes="16x16">
	
	<!-- Admin CSS File Link -->
	<link rel="stylesheet" href="css/style.css">
	
	<!-- User JAVA SCRIPT File Link -->
	<script type="text/javascript" src="js/script.js"></script>
	
	
	<!-- Font Awesome Icone -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<style>
		.div1{
			background:;
			width:98%;
			height:450px;
			margin:0 1%;
			padding:10px;
			overflow:auto;
			margin:10px 0;
		}
		.div1 input, .div1 select{
			height:35px;
			width:200px;
			font-size:15px;
			padding:2px 10px;
			border-radius:5px;
			border:solid #6b5127 1px;
			margin:5px 10px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			cursor:pointer;
			transition:1s;
		}
		input[type=submit]:hover{
			background:white;
			color:#883333;
			border:solid #6b5127 1px;
			transition:1s;
		}
		.div2{
			background:#f7f7f7;
			width:100%;
			height:550px;
			float:left;
			text-align:center;
			padding:10px 20px;
			overflow:auto;
		}
		INPUT{padding:5px 10px; border-radius:4px;}
		.div2 table{
			width:98%;
			text-align:center;
			font-size:14px;
			border-collapse:collapse;
			padding:2px 10px;
			margin:1%;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:2px 5px;
		}
		table td{
			background:;
			height:35px;
			border:solid black 1px;
			padding:2px 5px;
		}
		table tr:hover{background-color:gray; color:white;}
		table tr:hover a{color:white;}
		
		.deactAnchor{background:green; color:white; padding:2px 5px; border-radius:3px; cursor:pointer;}
		
		#lapuList{display:none;}
		.fa-check, .fa-ban{font-size:20px;}
		textarea{width:250px; height:60px; font-size:15px; padding:5px;}
		@media(max-width:768px)
		{
			.div1{
				background:;
				width:100%;
				height:auto;
				margin:10px 0 0 0;
				padding:0;
				text-align:center;
			}
			.div1 input, .div1 select{
				width:90%;
				margin:10px;
			}
			.div2{
				width:100%;
				margin:10px 0 0 0;
				padding:0px;
				text-align:center;
			}
		}
	</style>
	<link rel="stylesheet" href="css/mediaStyle.css">
</head>
<body>
	<!--Header Divison-->
	<?php
		require'header.php';
	?>
	
	<!--Container Division-->
	<div class="container">
		<?php
			include'menu.php';
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Contact Us :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
				<div class="div2" id="downlinePlace">
					<script>
						function deacCont(Arg)
						{
						    var contDeacId = Arg;
						    var contDeacBtnId = contDeacId+"BTN";
							var xmlhttpState = new XMLHttpRequest();
							xmlhttpState.open("GET","Ajax.php?contDeacId="+contDeacId, false)
							xmlhttpState.send(null);
							if(xmlhttpState.responseText=="Deactivate")
							{
							    document.getElementById(contDeacBtnId).style.display = "none";
							}
						}
						
						function deletCont(Arg)
						{
						    var deleteContId = Arg;
						    var deleteRowId = deleteContId+"ROW";
							var xmlhttpState = new XMLHttpRequest();
							xmlhttpState.open("GET","Ajax.php?deleteContId="+deleteContId, false)
							xmlhttpState.send(null);
							if(xmlhttpState.responseText=="DELETED")
							{
							    document.getElementById(deleteRowId).style.display = "none";
							}
						}
					</script>
					
					<table cellpadding="20" border="2"> 
						<tr>
							<th>Sl.</th>
							<th>Id</th>
							<th>Date</th>
							<th>Time</th>
							<th>Name</th>
							<th>Mobile</th>
							<th>E-Mail</th>
							<th>Add.</th>
							<th>Subject</th>
							<th>Message</th>
							<th>#</th>
							<th>#</th>
						</tr>
						<?php
						    
						    $UsrQu="SELECT * FROM contactus ORDER BY Id DESC";
						   	$UsrResult=mysqli_query($con,$UsrQu);
							while($UsrData=mysqli_fetch_array($UsrResult))
							{
								$sl=$sl+1;
								echo "<tr id='".$UsrData['Id']."ROW'>";
									echo "<td>".$sl."</td>";
									echo "<td>".$UsrData['Id']."</td>";
									echo "<td>".$UsrData['Date']."</td>";
									echo "<td>".$UsrData['Time']."</td>";
									echo "<td>".$UsrData['Name']."</td>";
									echo "<td>".$UsrData['Mobile']."</td>";
									echo "<td>".$UsrData['Email']."</td>";
									echo "<td>".$UsrData['Address']."</td>";
									echo "<td>".$UsrData['Subject']."</td>";
									echo "<td><textarea>".$UsrData['Message']."</textarea></td>";
									echo "<td>";
									    if($UsrData['Active']==0)
									    {
									        echo "<a class='deactAnchor' id='".$UsrData['Id']."BTN' onclick='deacCont(".$UsrData['Id'].")'>Deactive</a>";
									    }
								    echo "</td>";
									echo "<td><a class='deactAnchor' id='".$UsrData['Id']."' onclick='deletCont(".$UsrData['Id'].")'>DELETE</a></td>";
								echo "</tr>";
							}
							
						?>
					</table>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>