<?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>
</head>
<body>
<?php
require "dbconnect.php";
	dbhandaler::dbconnect();
	if(isset($_SESSION["case_no"]))
	{
		$case_no=$_SESSION["case_no"];
	}
	else
	{
		echo "<script> location.assign('log_in.php'); </script>";
	}

	
	if(isset($_POST["btn"]))
	{
	$Age	=	$_POST["Age"];
	$Gender	= $_POST["Gender"];
	$TH		= $_POST["TH"];
	$TC		= $_POST["TC"];
	$Announce =	$_POST["Announce"];
	$CS 	= $_POST["CS"];
	$Twsp	= $_POST["Twsp"];
	$State  = dbhandaler::selectregions($Twsp);
	dbhandaler::updatebyid($case_no,$Age,$Gender,$TH,$TC,$Announce,$CS,$Twsp,$State);
	echo "<script> location.assign('data_input.php'); </script>";
	}

	if(isset($_POST["btn1"]))
	{
	dbhandaler::deletebyid($case_no);
	echo "<script> location.assign('data_input.php'); </script>";
	}
?>
<form method="post">
<div class="container">
<br>
<div class="row">
	<div class="col-md-11"></div>
	<div class="col-md-1" align="right"><h5><a href="data_input.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="value" style="width:300px; height:30Px;" name="case_no" value="<?php echo $case_no; ?> - read only" readonly>
		</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" value="<?php echo dbhandaler::selectcovidbyage($case_no); ?>" 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="<?php echo dbhandaler::selectcovidbygender($case_no); ?>"><?php echo dbhandaler::selectcovidbygender($case_no); ?></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;" value="<?php echo dbhandaler::selectcovidbyth($case_no); ?>" 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;" value="<?php echo dbhandaler::selectcovidbytc($case_no); ?>" 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;" value="<?php echo dbhandaler::selectcovidbyan($case_no); ?>" 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="<?php echo dbhandaler::selectcovidbycs($case_no); ?>"><?php echo dbhandaler::selectcovidbycs($case_no); ?></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="<?php echo dbhandaler::selectcovidbytwsp($case_no); ?>"><?php echo dbhandaler::selectcovidbytwsp($case_no); ?></option>
				<?php
				$array = dbhandaler::selecttwspall($Region);
				foreach ($array as $key => $value) { ?>
				<option value="<?php echo $value[0];?>"> <?php echo $value[0];?> </option>
				<?php 
				}
				?>	
		</select>
		<br>
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-6"></div>
		<div class="col-md-3" align="left">
		<input type="submit" name="btn" value="update" class="btn btn-warning" style="width:300px; height:30Px;">
		</div>
	</div>
	<br>
	<div class="row">
		<div class="col-md-6"></div>
		<div class="col-md-3" align="left">
		<input type="submit" name="btn1" value="delete" class="btn btn-danger" style="width:300px; height:30Px;">
		</div>
	</div>
	<br> <br> <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>
</form>
</body>
</html>