<?php session_start(); ?>

<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<title>Data Input Covid -19 </title>
	<script type="text/javascript" src="../bootstrap4/js/bootstrap.min.js"></script>
	<link rel="stylesheet" type="text/css" href="../bootstrap4/css/bootstrap.min.css">
	<style type="text/css">
	.container{
		 font-family: Arial, Helvetica, sans-serif;
		 font-size: 12px;
	}
	h5{
		font-color: red;
	}
	#scroll {
		
		overflow: scroll;
		height: 400px; 
		}
	</style>
	
<meta name="viewport" content="width=device-width, initial-scale=.6">

</head>
<body>
<?php
require "dbconnect.php";
	dbhandaler::dbconnect();
	if(isset($_SESSION["Reg"]))
	{
		$Region=$_SESSION["Reg"];
	}
	else
	{
		echo "<script> location.assign('log_in.php'); </script>";
	}

	
	if(isset($_POST["btn"]))
	{
	$No	    =	$_POST["No"];
	$Age	=	$_POST["Age"];
	$Gender	= $_POST["Gender"];
	$TH		= $_POST["TH"];
	$TC		= $_POST["TC"];
	$Announce =	$_POST["Announce"];
	$CS 	= $_POST["CS"];
	$Twsp	= $_POST["Twsp"];
	$id = dbhandaler::selectptid();
	$id = dbhandaler::selectptid();
	$a=0;
	foreach ($id as $key => $value) {
		 if($value[0]==$No) {$a=$a+1;}
		}
	if($a>0) {echo"<script>alert('This patient is already iserted!');</script>";}
	else{dbhandaler::insertcmdata($No,$Age,$Gender,$TH,$TC,$Announce,$CS,$Twsp,$Region);}
	}

	if(isset($_POST["btn1"]))
	{
		$case_no = $_POST["case_no"];
		$_SESSION["case_no"]=$case_no;
		echo "<script>location.assign('update_delete.php');</script>";
	}

?>
<div class="container">
<form method="post">
<br>
<div class="row">
	<div class="col-md-11"></div>
	<div class="col-md-1" align="right"><h5><a href="log_in.php">Exit</a></h5></div>
</div>
	<div class="row">
		<div class="col-md-12" align="center">
		<h5> COVID-19 Data Input </h5>
		</div>
	</div>
	<br>
	<div class="row">
	<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Case_No
		</div>
		<div class="col-md-6" align="left">
		<input type="number" style="width:300px; height:30Px;" name="No" required>
		</div>
	</div>
	<br>
	<div class="row">
	<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Age
		</div>
		<div class="col-md-6" align="left">
		<input type="number" style="width:300px; height:30Px;" name="Age" required>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Gender
		</div>
		<div class="col-md-6" align="left">
		<select name="Gender" style="width:300px; height:30Px;" required>
			<option value="">Select...</option>
			<option value="M">M</option>
			<option value="F">F</option>
		</select>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left" >
		Travel History
		</div>
		<div class="col-md-6" align="left">
			<input type="text" name="TH" style="width:300px; height:30Px;" required>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Treatment Center
		</div>
		<div class="col-md-6" align="left">
			<input type="text" name="TC" style="width:300px; height:30Px;" required>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Announce Date
		</div>
		<div class="col-md-6" align="left">
			<input type="Date" name="Announce" style="width:300px; height:30Px;" required>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Current Status
		</div>
		<div class="col-md-6" align="left">
		<select name="CS" style="width:300px; height:30Px;" required>
			<option value="">Select...</option>
			<option value="On Treatment">On Treatment</option>
			<option value="Die">Die</option>
			<option value="Recovery">Recovery</option>
		</select>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-2"></div>
		<div class="col-md-4" align="left">
		Township 
		</div>
		<div class="col-md-6" align="left">
		<select name="Twsp" style="width:300px; height:30Px;" required>
				<option value="">Select...</option>
				<?php
				$array = dbhandaler::selecttwsp($Region);
				foreach ($array as $key => $value) { ?>
				<option value="<?php echo $value[0];?>"> <?php echo $value[0];?> </option>
				<?php 
				}
				?>	
		</select>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-6"></div>
		<div class="col-md-6" align="left">
		<input type="submit" name="btn" value="Insert" class="btn btn-success" style="width:300px; height:30Px;">
		</div>
	</div>
</form>
	<br>
	<form method="post">
	<div class="row">
		<div class="col-md-2">
		    <br>
		<select name="case_no" required style="height:30Px;" class="container-fluid">
			<option value="">Select...</option>
			<?php 
			$array = dbhandaler::selectcovidcaseno();
			foreach ($array as $key => $value) { ?>
			<option value="<?php echo $value[0]; ?>"> <?php echo $value[0]; ?></option>
			<?php	} ?>
		</select>
		</div>
		<div class="col-md-2">
		    <br>
		<input type="submit" name="btn1" value="Edit" class="btn btn-warning container-fluid" style="height:30Px;">
		</div>
	</div>
	</form>
	<br>
	<div class="row">
	<table> 
		<tr> 
		<th width="50px" align="left"><u> No. </u> </th> 
		<th width="50px" align="left"><u> Age </u></th>
		<th width="100px" align="left"><u> Gender </u></th>
		<th width="250px" align="left"><u> Travel History </u></th>
		<th width="400px" align="left"><u> Treatment Center </u></th>
		<th width="250px" align="left"><u> Announcement Date</u></th>
		<th width="250px" align="left"><u> Current Status</u></th>
		<th width="250px" align="left"><u> Township </u></th>
		<th width="250px" align="left"><u> State/Region </u></th>
		</tr>
	</table>
	</div>
	<div class="row" id="scroll">
	<?php
	dbhandaler::selectcovid();
	?>
	</div>
</div>
</body>
</html>