<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<title>Map</title>
	<script type="text/javascript" src="../bootstrap4/js/bootstrap.min.js"></script>
	<link rel="stylesheet" type="text/css" href="../bootstrap4/css/bootstrap.min.css">
	<script type="text/javascript" src="../bootstrap4/canvasjs.min.js"></script>
	<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
  	<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
	<style type="text/css">
		.container{
		  height: 100%;
		  margin: 0;
		 font-family: "Times New Roman", Times, serif;
		font-size: 14px;
		}
		img{height: 40px;}
		#info{
			border: 2px solid navy; 
			padding: 5px;
		}
		#bo{padding: 5px; border-bottom: 2px solid navy;} 
		#mapid{height: calc(var(--vh, 1vh) * 85);}
	</style>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
</head>
<body>
<?php
	require "dbconnect.php";
	dbhandaler::dbconnect();
	$sex = "'M','F'";

?>	
<script type="text/javascript">

let vh = window.innerHeight * 0.0085;
document.documentElement.style.setProperty('--vh', `${vh}px`);

	function toggle(source) {
    var checkboxes = document.querySelectorAll('input[id="check"]');
    for (var i = 0; i < checkboxes.length; i++) {
        if (checkboxes[i] != source)
            checkboxes[i].checked = source.checked;
    }
}
</script>
<form method="post">
	<div class="row" id="bo">
		<div class="col-md-8" align="center">
			<img src="image/mohs.jpg" style="width:60px; height:60px;">
			<b> ရန်ကုန်တိုင်း‌‌‌‌‌‌‌‌‌‌‌‌‌ဒေသကြီး ကုသရေးနှင့် ပြည်သူ့ကျန်းမာရေး ဦးစီးဌာန</b>
		</div>	
		<div class="col-md-4" align="center">
			<a href="home.php"><img src="homeh.gif"></a>
			<a href="covid-19.php"><img src="earthmap.gif"></a>
			<a href="patient.php"><img src="vgraph.gif"></a>
			<a href="other.php"><img src="datad.gif"></a>
	 	 </div>						
	</div>
	<div class="container content">
	<br>
	<div class="row">
		<div class="col-md-11">
			<?php 
			$select = dbhandaler::selectreg();
			foreach ($select as $key => $value) 
			{ ?> <input type="checkbox" id="check" name='lang[]' value="<?php echo "'".$value."',"; ?>"> <?php echo $value; ?>
			<?php } ?>
			<input type="checkbox" onclick="toggle(this);">All
			</div>
			<div class="col-md-1"><input type="submit" value="submit" name="btn" class="btn btn-primary"> </div>
		</div>
		<br>
	<div class="row">
		<div class="col-md-8">
			 <div id="mapid" class="container-fluid"></div>
		</div>
		<div class="col-md-4" id="info">
	<?php 
	if(isset($_POST["btn"]))
	{
		if(!empty($_POST['lang'])) {    
       	$s =implode("", $_POST['lang']);
       	$state1 =rtrim($s,','); 
    	$state = str_replace("'", " ", $state1);
    }
    	?>
			<div class="row">
			<div class="col-md-12" align="left">
					<b> <?php echo "<i>".$state."</i>"; ?>: 
					(<?php echo dbhandaler::selectgenderygn('M',$state1)+dbhandaler::selectgenderygn('F',$state1); ?>)</b>
			</div>
			</div>
			<br>
			<div class="row">
			<div class="col-md-12" align="center">
			<table class="container-fluid">
			<tr>
				<td width="60%"> Male </td> <td width="10%"> - </td><td width="30%" align="right"><?php echo dbhandaler::selectgenderygn('M',$state1); ?></td>
			</tr>
			<tr>
				<td> Female</td> <td> - </td><td align="right"><?php echo dbhandaler::selectgenderygn('F',$state1); ?></td>
			</tr>
			<tr>
				<td colspan="3" style="border-bottom: 2px solid black"></td>
			</tr>
			<tr>
				<td> Under 15 year </td> <td> - </td><td align="right"><?php echo dbhandaler::selectage1ygn($sex,$state1); ?></td>
			</tr>
			<tr>
				<td> 15 - 24 year</td> <td> - </td><td align="right"><?php echo dbhandaler::selectage2ygn($sex,$state1); ?></td>
			</tr>
			<tr>
				<td> 25 - 44 year </td><td> - </td><td align="right"><?php echo dbhandaler::selectage3ygn($sex,$state1); ?></td>
			</tr>
			<tr>
				<td> 45 - 64 year </td><td> - </td><td align="right"><?php echo dbhandaler::selectage4ygn($sex,$state1); ?></td>
			</tr>
			<tr>
				<td> 65 and above year </td><td> - </td><td align="right"><?php echo dbhandaler::selectage5ygn($sex,$state1); ?></td>
			</tr>
			<tr>
				<td colspan="3" style="border-bottom: 2px solid black"></td>
			</tr>
			<tr>
				<td><font color="orange"> On Treatment</font></td> <td> - </td><td align="right"><?php echo dbhandaler::selectstatusygn('On Treatment',$sex,$state1); ?></td>
			</tr>
			<tr>
				<td><font color="red"> Died</font></td> <td> - </td><td align="right"><?php echo dbhandaler::selectstatusygn('Die',$sex,$state1); ?></td>
			</tr>
			<tr>
				<td><font color="green"> Recovery</font></td> <td> - </td><td align="right"><?php echo dbhandaler::selectstatusygn('Recovery',$sex,$state1); ?></td>
			</tr>
			<tr>
				<td colspan="3" style="border-bottom: 2px solid black"></td>
			</tr>
			</table>
			</div>
			</div>
	 <?php  }
	?>
	</div>
	</div>
</div>
</form>
<script>
	var greenIcon = L.icon({
    iconUrl: 'center1.png',
    iconSize:     [35,40],
});
  var mymap = L.map('mapid').setView([16.807, 96.12], 4);
  L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoiaHRldGF1bmdobGFpbmcxOTkyIiwiYSI6ImNscW1oNmQ3ZzA0cGQycW13ZHljdm96dTEifQ.pXEh2bcRm3ADiY5qnyvzOA', {
    maxZoom: 18,
    id: 'mapbox/streets-v11',
    tileSize: 512,
    zoomOffset: -1
  }).addTo(mymap);
  
  <?php 
  if(isset($_POST["btn"]))
  {
  	if(!empty($_POST['lang'])) {    
     $s =implode("", $_POST['lang']);
     $region=rtrim($s,','); }
    $select1 = "SELECT DISTINCT(a.Township) as Township, b.lon as lon, b.lat as lat FROM location b, patient_data a WHERE a.Township = b.Township and b.Region in ($region)";
    $sql1= mysqli_query(dbhandaler::$con,$select1);
    while($arr=mysqli_fetch_assoc($sql1)) 
    { $town = $arr['Township'];
		$case = dbhandaler::counttwp($town);
		if($case>9){?>
    L.marker([<?php echo $arr["lat"]; ?>, <?php echo $arr["lon"]; ?>],{icon:greenIcon}).addTo(mymap).bindPopup("<?php echo $town; ?><br /> <?php echo 'On Treatment- '.dbhandaler::counttwptreat($town); ?><br /> <?php echo 'Recovery- '.dbhandaler::counttwpcure($town); ?><br /> <?php echo 'Dead- '.dbhandaler::counttwpdie($town); ?> <br /> <?php echo 'Total- '.dbhandaler::counttwp($town); ?>").openPopup();
 <?php  }
 else{ ?>
 L.marker([<?php echo $arr["lat"]; ?>, <?php echo $arr["lon"]; ?>]).addTo(mymap).bindPopup("<?php echo $town; ?><br /> <?php echo 'On Treatment- '.dbhandaler::counttwptreat($town); ?><br /> <?php echo 'Recovery- '.dbhandaler::counttwpcure($town); ?><br /> <?php echo 'Dead- '.dbhandaler::counttwpdie($town); ?> <br /> <?php echo 'Total- '.dbhandaler::counttwp($town); ?>").openPopup();
<?php }
} ?>
 <?php }
  ?>
  var popup = L.popup();

  function onMapClick(e) {
    popup
      .setLatLng(e.latlng)
      .setContent(e.latlng.toString())
      .openOn(mymap);
  }
  mymap.on('click', onMapClick);
</script>
</body>
</html>