<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<title>Yangon Region</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>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<style type="text/css">
		table,td,tr 
		{
			font-family: "Times New Roman", Times, serif;
			font-size: 12px;
		}
			#bo{padding: 5px; border-bottom: 2px solid navy;} 
		.container {
		  height: 100%;
		  margin: 0;
		 font-family: "Times New Roman", Times, serif;
		font-size: 14px;
		}

		#scroll {
		
		overflow: scroll;
		height: 400px; 
		}
		#info{
			font-size: 10px;
			font-weight: bolder;
		}
		#fix
		{
			background-color: #f8ea05;
		}
		#tim{
			color: red;
			font-size: 10px;
			font-weight: bolder;
		}
		.abc
		{
			border:2px solid gray;
			padding: 3px;
			width: 100px;
		}
		img{height: 40px;}
	</style>

</head>
<body>
<?php
	require "dbconnect.php";
	dbhandaler::dbconnect();
	$sex="'M','F'";
	if(isset($_POST['male']))
	{
		$sex="'M'";
	}
	if(isset($_POST['female']))
	{
		$sex="'F'";
	}
	if(isset($_POST['all']))
	{
		$sex="'M','F'";
	}

		$vd1=dbhandaler::selectgenderygna('M');
		$vd2=dbhandaler::selectgenderygna('F');
		$dataPoints = array( 
		array("label"=>"M", "y"=>$vd1),
		array("label"=>"F", "y"=>$vd2),
		);

		$age1=dbhandaler::selectage1ygna($sex);
		$age2=dbhandaler::selectage2ygna($sex);
		$age3=dbhandaler::selectage3ygna($sex);
		$age4=dbhandaler::selectage4ygna($sex);
		$age5=dbhandaler::selectage5ygna($sex);
		$dataPoints1 = array( 
		array("label"=>"<15", "y"=>$age1),
		array("label"=>"15-24", "y"=>$age2),
		array("label"=>"25-44", "y"=>$age3),
		array("label"=>"45-64", "y"=>$age4),
		array("label"=>">65", "y"=>$age5),
		);

		$s1=dbhandaler::selectstatusygna('On Treatment',$sex);
		$s2=dbhandaler::selectstatusygna('Die',$sex);
		$s3=dbhandaler::selectstatusygna('Recovery',$sex);
		$dataPoints2 = array( 
		array("label"=>"On Treatment", "y"=>$s1),
		array("label"=>"Die", "y"=>$s2),
		array("label"=>"Recovery", "y"=>$s3),
		);

		$t=0;
		$array = dbhandaler::selectdateygn($sex);
		foreach ($array as $key => $value) {
			$dataPoints3[$key]=array("label"=>$value[1], "y"=>$value[0]);
			$t=$t+$value[0];
		}

		$d1=dbhandaler::selectgender('M');
		$d2=dbhandaler::selectgender('F');
		$dataPointsx = array( 
		array("label"=>"M", "y"=>$d1),
		array("label"=>"F", "y"=>$d2),
		);

		$ae1=dbhandaler::selectage1($sex);
		$ae2=dbhandaler::selectage2($sex);
		$ae3=dbhandaler::selectage3($sex);
		$ae4=dbhandaler::selectage4($sex);
		$ae5=dbhandaler::selectage5($sex);
		$dataPoints11 = array( 
		array("label"=>"<15", "y"=>$ae1),
		array("label"=>"15-24", "y"=>$ae2),
		array("label"=>"25-44", "y"=>$ae3),
		array("label"=>"45-64", "y"=>$ae4),
		array("label"=>">=65", "y"=>$ae5),
		);

		$x1=dbhandaler::selectstatus('On Treatment',$sex);
		$x2=dbhandaler::selectstatus('Die',$sex);
		$x3=dbhandaler::selectstatus('Recovery',$sex);
		$dataPoints12 = array( 
		array("label"=>"On Treatment", "y"=>$x1),
		array("label"=>"Die", "y"=>$x2),
		array("label"=>"Recovery", "y"=>$x3),
		);

		$to=0;
		$array5 = dbhandaler::selectdate($sex);
		foreach ($array5 as $key => $value) {
			$dataPoints13[$key]=array("label"=>$value[1], "y"=>$value[0]);
			$to=$to+$value[0];
		}
?>
<script type="text/javascript">
function exportTableToExcel(filename){
		    var downloadLink;
		    var dataType = 'application/vnd.ms-excel';
		    var tableSelect = document.getElementById("myatable");
		    var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');
		    filename = filename?filename+'.xls':'excel_data.xls';
		    downloadLink = document.createElement("a"); 
		    document.body.appendChild(downloadLink);		    
		    if(navigator.msSaveOrOpenBlob){
		        var blob = new Blob(['\ufeff', tableHTML], {
		            type: dataType
		        });
		        navigator.msSaveOrOpenBlob( blob, filename);
		    }else{
		        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;
		        downloadLink.download = filename;
		        downloadLink.click();
		    }
		}
window.onload = function() 
{
	var chart = new CanvasJS.Chart("chartContainer", {
		animationEnabled: true,
		title: {
			text: "By Gender - <?php echo $t; ?>",
			fontSize: 15,
		},
		axisY: {
		labelFontSize: 15,
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
	},
	axisX: {labelFontSize: 10,labelFontColor: "black",},
		data: [{
			type: "pie",
			yValueFormatString: "#,##0",
			indexLabel: "{y}",
			indexLabelPlacement: "inside",
			indexLabelFontColor: "white",
			dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart.render();

	var chart1 = new CanvasJS.Chart("chartContainer1", {
		animationEnabled: true,
		title: {
			text: "By Age - <?php echo $t; ?>",
			fontSize: 15,
		},
		axisY: {
		labelFontSize: 15,
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
	},
	axisX: {labelFontSize: 15,labelFontColor: "black",},
		data: [{
			type: "bar",
			yValueFormatString: "#,##0",
			indexLabel: "{y}",
			indexLabelPlacement: "inside",
			indexLabelFontColor: "white",
			dataPoints: <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart1.render();

	var chart2 = new CanvasJS.Chart("chartContainer2", {
		animationEnabled: true,
		title: {
			text: "By Medical Status - <?php echo $t; ?>",
			fontSize: 15,
		},
		axisY: {
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
		labelFontSize: 15,
	},
	axisX: {labelFontSize: 14,labelFontColor: "black",
	    labelFormatter: function (e) {
				return CanvasJS.formatDate( e.value);
			},
			labelAngle: -20
	},
		data: [{
			type: "column",
			yValueFormatString: "#,##0",
		indexLabel: "{y}",
		indexLabelPlacement: "inside",
		indexLabelFontColor: "black",
			dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart2.render();

	var chart3 = new CanvasJS.Chart("chartContainer3", {
		animationEnabled: true,
		title: {
			text: "Time Series - <?php echo $t; ?>",
			fontSize: 15,
		},
		axisY: {
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
		labelFontSize: 15,
	},
	axisX: {labelFontSize:0,labelFontColor: "white",
	    labelFormatter: function (e) {
				return CanvasJS.formatDate( e.value);
			},
			labelAngle: -20
	},
		data: [{
			type: "line",
			yValueFormatString: "#,##0",
		indexLabel: "{y}",
		indexLabelPlacement: "inside",
		indexLabelFontColor: "black",
			dataPoints: <?php echo json_encode($dataPoints3, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart3.render();
	var chartx = new CanvasJS.Chart("chartContainerx", {
		animationEnabled: true,
		title: {
			text: "By Gender - <?php echo $to; ?>",
			fontSize: 15,
		},
		axisY: {
		labelFontSize: 15,
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
	},
	axisX: {labelFontSize: 10,labelFontColor: "black",},
		data: [{
			type: "pie",
			yValueFormatString: "#,##0",
			indexLabel: "{y}",
			indexLabelPlacement: "inside",
			indexLabelFontColor: "white",
			dataPoints: <?php echo json_encode($dataPointsx, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chartx.render();

	var chart11 = new CanvasJS.Chart("chartContainer11", {
		animationEnabled: true,
		title: {
			text: "By Age - <?php echo $to; ?>",
			fontSize: 15,
		},
		axisY: {
		labelFontSize: 15,
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
	},
	axisX: {labelFontSize: 15,labelFontColor: "black",},
		data: [{
			type: "bar",
			yValueFormatString: "#,##0",
			indexLabel: "{y}",
			indexLabelPlacement: "inside",
			indexLabelFontColor: "white",
			dataPoints: <?php echo json_encode($dataPoints11, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart11.render();

	var chart12 = new CanvasJS.Chart("chartContainer12", {
		animationEnabled: true,
		title: {
			text: "By Medical Status - <?php echo $to; ?>",
			fontSize: 15,
		},
		axisY: {
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
		labelFontSize: 15,
	},
	axisX: {labelFontSize: 14,labelFontColor: "black",
	    labelFormatter: function (e) {
				return CanvasJS.formatDate( e.value);
			},
			labelAngle: -20
	},
		data: [{
			type: "column",
			yValueFormatString: "#,##0",
		indexLabel: "{y}",
		indexLabelPlacement: "inside",
		indexLabelFontColor: "black",
			dataPoints: <?php echo json_encode($dataPoints12, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart12.render();

	var chart13 = new CanvasJS.Chart("chartContainer13", {
		animationEnabled: true,
		title: {
			text: "Time Series - <?php echo $to; ?>",
			fontSize: 15,
		},
		axisY: {
		suffix: "%",
		scaleBreaks: {
			autoCalculate: true
		},
		labelFontSize: 15,
	},
	axisX: {labelFontSize: 0,labelFontColor: "white",
	    labelFormatter: function (e) {
				return CanvasJS.formatDate( e.value);
			},
			labelAngle: -20
	},
		data: [{
			type: "line",
			yValueFormatString: "#,##0",
		indexLabel: "{y}",
		indexLabelPlacement: "inside",
		indexLabelFontColor: "black",
			dataPoints: <?php echo json_encode($dataPoints13, JSON_NUMERIC_CHECK); ?>
		}]
	});
	chart13.render();

} 
</script>
<form method="post">
	<div class="row" id="bo">
		<div class="col-md-2 abc" align="center">
			<b>👇 Analysis by Gender</b>
			<input type="submit" name="male" value="Male">
			<input type="submit" name="female" value="Female">
			<input type="submit" name="all" value="All">
	 	 </div>		
		<div class="col-md-7" align="center">
			<img src="image/mohs.jpg" style="width:60px; height:60px;">
			<b> ရန်ကုန်တိုင်း‌‌‌‌‌‌‌‌‌‌‌‌‌ဒေသကြီး ကုသရေးနှင့် ပြည်သူ့ကျန်းမာရေး ဦးစီးဌာန</b>
		</div>	
		<div class="col-md-3" 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>
  	<br>
<div class="container">
	  <div class="row">
		  <div class="col-md-6">
		  	<div class="row">
				<div class="col-md-12">
					 <b> မြန်မာ (MYANMAR - <?php echo $to; ?>)</b> 
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer11" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div><br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer12" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div> <br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer13" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div> <br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainerx" style="height: 250px; border:2px solid gray;"></div>
					</div>
				</div><br>
			</div>

			<div class="col-md-6">
				<div class="row">
					<div class="col-md-12">
					<b> ရန်ကုန် (YANGON - <?php echo $t; ?>)</b>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer1" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div><br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer2" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div> <br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer3" style="height: 350px; border:2px solid green;"></div> 
					</div>
				</div> <br>
				<div class="row">
					<div class="col-md-12">
						<div id="chartContainer" style="height: 250px; border:2px solid gray;"></div>
					</div>
				</div><br>
			</div>
		</div>
		<br>
	<div class="row" id="bo">
		<div class="col-md-6" align="left">
			<input type="submit" name="ygn" value="ရန်ကုန်">
			<input type="submit" name="myn" value="မြန်မာ">
		</div>
		<div class="col-md-6" align="right">
			<button class="btn btn-success" onclick="exportTableToExcel('Covid-19 Patient List');">Excel Export</button>
		</div>
	</div>
	<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(); 
	if(isset($_POST['ygn']))
	{
		dbhandaler::selectcovidygn();
	}
	else{
		dbhandaler::selectcovid();
	}
	?>
	</div>
</div>
</div>
</div>
</form>
</body>
</html>