<?PHP
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
	
	$quGetTxnId="SELECT * FROM wallet WHERE Userid='$userid' AND TxnType='Generate_Amount' ORDER BY Id DESC";
	$reGetTxnId=mysqli_query($con,$quGetTxnId);
	$dataGetTxnId=mysqli_fetch_array($reGetTxnId);
	$OldTxnId=$dataGetTxnId['TxnId'];
	$NewTxnId=$OldTxnId+1;
	
?>
<html>
<head>
	<title>Add Alert Msg</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:#f7f7f7;
			width:96%;
			height:auto;
			float:left;
			text-align:center;
			padding:10px;
			margin:2%;
		}
		.div1 input,.div1 select{
			width:150px;
			height:45px;
			margin:5px 10px;
			padding:2px 10px;
			border-radius:5px;
			border:1px solid #6b5127;
			font-size:16px;
			float:left;
		}
		.div1 textarea{
		    width:400px;
			height:100px;
			padding:5px 10px;
			float:left;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			font-size:30px;
			transition:1s;
		}
		input[type=submit]:hover{
			background:white;
			color:#6b5127;
			border:1px solid #6b5127;
			cursor:pointer;
			transition:1s;
		}
		
		.div2{
			background:#f7f7f7;
			width:96%;
			height:auto;
			float:left;
			text-align:center;
			padding:10px;
			margin:2%;
		}
		.div2 table{
			width:98%;
			text-align:center;
			font-size:13px;
			border-collapse:collapse;
			margin:1%;
			padding:5px;
		}
		.div2 hr
		{
		    width:96%;
			margin:5px 2%;
			padding:0 10px;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:4px 8px;
		}
		table td{
			background:white;
			height:40px;
			border:solid black 1px;
			padding:4px 8px;
		}
		
		@media(max-width:768px)
		{
			.div1{
				width:100%;
				height:auto;
			}
			.nav,.container{
				height:auto;
			}
		}
	</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>Add Alert Msg :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
		    <?php
			    if(isset($_POST['submit']))
			    {
			        $msg=$_POST['msg'];
			        $msgUser=$_POST['msgUser'];
				
				    $InsertMsg="INSERT INTO messege (Date,Time,Messege,Users) VALUES ('$date','$time','$msg','$msgUser')";
				    if(mysqli_query($con,$InsertMsg))
				    {
						echo "<div class='msg-div'>
					            <form method='post'>
					                <h3>Message Added Successfully !</h3><br>
					                <i class='fa fa-check-circle' aria-hidden='true' id='okIcon'></i><br><br>
					                <button type='submit' class='btnPopup'>OK</button><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>
			            	        <button type='submit' class='btnPopup'>OK</button><br><br>
			                    </form>
		                    </div>";
			        }
			    }
			?>
			<div class="div1">
				<form method="post">
				    <textarea type="text" name="msg" Placeholder="Enter Message..." required></textarea>
				    <select name="msgUser">
			            <option>ALL</option>
			            <option>MDIS</option>
			            <option>DIS</option>
			            <option>RET</option>
			            <option>API</option>
    		        </select>
					<input type="submit" name="submit" value="Submit"  onclick='showLoader()'>
				</form>
			</div>
			<div class="div2">
				<center><h1>Msg Details</h1></center><hr>
				<table cellpadding="20" border="2">
				    <tr>
					    <th>Sl.</th>
					    <th>Date</th>
					    <th>Time</th>
					    <th>Message</th>
						<th>Msg For</th>
						<th>Action</th>
					</tr>
					<?php
					    $sl=0;
					    $quMsg="SELECT * FROM messege";
		                $reMsg=mysqli_query($con,$quMsg);
		                while($dataMsg=mysqli_fetch_array($reMsg))
		                {
		                    $sl=$sl+1;
		                    echo "<tr>";
		                        echo "<td>".$sl."</td>";
		                        echo "<td>".$dataMsg['Date']."</td>";
		                        echo "<td>".$dataMsg['Time']."</td>";
		                        echo "<td>".$dataMsg['Messege']."</td>";
		                        echo "<td>".$dataMsg['Users']."</td>";
		                        echo "<td><a href='Action.php?msgId=".$dataMsg['Id']."'>DELETE</a></td>";
		                    echo "</tr>";
		                }
					?>
				</table>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>