<?php
	include'session.php';
	include'connection.php';
	include'functions.php';
?>
<html>
<head>
	<title>Generate API Token</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%;
			margin:1%;
			padding:10px;
			overflow:auto;
		}
		.subDiv{background:white; height:auto; text-align:center; margin:20px 0px 40px 0px; padding:10px 5px 30px 5px; overflow-x:auto; border:1 px solid; box-shadow: 5px 10px 10px #888888; border-radius:2px;}
		.subDiv h3{font-size:20px; margin:10px;}
		.subDiv hr{width:150px;}
		
		.div1 input, .div1 select, p, a{
			height:30px;
			width:auto;
			font-size:16px;
			padding:2px 7px;
			border-radius:5px;
			border:solid #6b5127 1px;
			overflow:hidden;
			margin:10px 10px 0 5px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			transition:1s;
			cursor:pointer;
		}
		input[type=submit]:hover{
			background:white;
			color:#6b5127;
			transition:1s;
		}
		.div2{
			background:#f7f7f7;
			width:30%;
			float:left;
			text-align:center;
			padding:0 10px 10px 10px;
			overflow-x:auto;
		}
		.div2 table{
			width:100%;
			text-align:center;
			font-size:14px;
			border-collapse:collapse;
			padding:2px 10px;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:2px 5px;
		}
		table td{
			background:white;
			height:40px;
			border:solid black 1px;
			padding:2px 5px;
		}
		.data-content{overflow:auto; height:60%;}
		
		#pre{background:gray; color:white; width:400px; padding-top:16px;  height:50px;}
		#inp{width:400px; display:none; border:solid 2px green; height:50px; text-align:center;}
		#btn1{float:right; width:150px;}
		#btn2{float:left; background:green; color:white; width:150px; padding-top:5px;}
		
		.subdiv1{width:100%; height:auto; position:relative;}
		
		@media(max-width:768px)
		{
			.div1{
				background:;
				width:100%;
				height:auto;
				margin:10px 0 0 0;
				padding:0;
				text-align:center;
			}.div1 input{
				width:90%;
				margin:10px;
			}
			.div2{
				width:100%;
				margin:10px 0 0 0;
				padding:0px;
				text-align:center;
			}
			
			
		#pre{float:left; width:90%; margin:5%;}
		#inp{float:left; width:90%; margin:5%;}
		#btn1{float:left; width:90%; margin:5%;}
		#btn2{float:left;  width:90%; margin:5%;}
		}
	</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';
			
			if($_GET['STATUS'])
			{
			    
			    if($_GET['STATUS']=="SUCCESS")
			    {
			        echo "<div class='msg-div'>
							<form method='post'>
							<h3>API Token Generated Successfully !</h3><br>
							<i class='fa fa-check-circle' aria-hidden='true' id='okIcon'></i><br><br>
							<a href='Generate_API_Token.php' class='btnPopup'>OK</a><br><br>
							</form>
						</div>";
			    }
			    else
			    {
			        echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Something Error !</h3><br>
				        <i class='fa fa-ban' aria-hidden='true' id='NotokIcon'></i><br><br>
						<a href='Generate_API_Token.php' class='btnPopup'>OK</a><br><br>
			        </form>
		        </div>";
			    }
			}
			
		    $apiToken=getUser($userid)['ApiToken'];	
		?>
		<div class="content">
			<div class="head">
				<div class="title">Generate API Token :-</div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
			 <script>
	            function copyToken()
	            {   
	                var copyText = document.getElementById("inp");
	                var pt = document.getElementById("pre");
	                pt.style.display="none";
	                copyText.style.display="block";
	                copyText.select();
	                
	                document.execCommand("copy");
	            }
			</script>
					<div class="div1">
					    <div class="subDiv" style="font-size:.9vw">
					        <center><h3>-: Generate & Copy Token :-</h3><hr></center><br>
					        <div class="subdiv1">
					            <center><p id="pre"><?php echo $apiToken; ?> </p></center>
					            <center><input type="text" name="url" value="<?php echo $apiToken; ?>" id="inp" /></center>
					        </div>
					        <a href="createToken.php" id="btn2">Generate Token</a>
					        <input type="submit" name="edit" Value="Copy Token" id="btn1" onclick="copyToken()">
					   
					    </div>
					</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>