<? include("../settings.php"); ?>
<? include("session.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SP Admin Panel</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Include all CSS/JS -->
        <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/jquery.dataTables.css" rel="stylesheet">
    <link href="http://cdn.datatables.net/responsive/1.0.1/css/dataTables.responsive.css" rel="stylesheet">
    

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-2.1.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="http://cdn.datatables.net/responsive/1.0.1/js/dataTables.responsive.js"></script>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    
    <!-- End of all CSS/JS -->
    <style>
        hAxis: {
            textStyle:{color: '#FFF'}
        }
    </style>
   </head>
<body>


<? include("nav_menu.php"); ?>
      <div class="well">
<div class="content" bgcolor="#FFFFD0">
<div class="col-12 feature">
<div class="panelCheck">
    <div class="panel-heading">
        <h3 class "panel-title"><strong>Event Portal</strong></h3>
    </div>

    
    <div class="well well-lg">
        <?
            $results = $db->run("select registrant_id from tbl_registrant;"); 
            $total = count($results);

            $results = $db->run("select * from tbl_registrant_attendance where session_id=2;");
            $present = count($results);

            $absent = $total - $present;
        ?>
			 <script type="text/javascript">

				  // Load the Visualization API and the piechart package.
				  google.load('visualization', '1.0', {'packages':['corechart']});

				  // Set a callback to run when the Google Visualization API is loaded.
				  google.setOnLoadCallback(drawChart);

				  // Callback that creates and populates a data table,
				  // instantiates the pie chart, passes in the data and
				  // draws it.
				  function drawChart() {
					  // Create the data table.
					  var data = new google.visualization.DataTable();
					  data.addColumn('string', 'Attendance');
					  data.addColumn('number', 'Description');
					  data.addRows([
						['Turned Up', <?=$present;?>],
						['Absent', <?=$absent;?>],
					   ]);

					  // Set chart options
					  var options = {
							'title':'Nanoman2024',
							backgroundColor: 'transparent',
							'width':500,
							'height':400,
						  is3D:true,
						  legendTextStyle: {color:'#FFFFFF'},
						  titleTextStyle: {color: '#FFFFFF'}
					  };

					  // Instantiate and draw our chart, passing in some options.
					  var chart1 = new google.visualization.PieChart(document.getElementById('piechart_div1'));
					  chart1.draw(data, options);
				   }
			</script>
            <center>
            <br><br>
			<div id="piechart_div1"></div>
				Total Registered : <?=$total;?><br/>	
                Total Turned Up : <?=$present;?><br/>

                Absent : <?=$absent;?><br/><br/>
                
				 <?
        	$results = $db->select("tbl_role");
        	foreach ($results as $result){
        		$count = $db->run("select * from tbl_registrant as a, tbl_registrant_attendance as b where  b.session_id=1 AND a.role_id='".$result['role_id']."' AND a.registrant_id=b.registrant_id");
        		echo $result['role_name']." - ".count($count)."</br>";
        	}
        	?>
			<hr/>	
			<br/><br/>
			<?
				$results = $db->select("tbl_session");
				foreach ($results as $result){
					echo "<u><b>".$result['session_name']."</b></u><br/>";
					$presentcount = count($db->run("select * from tbl_registrant_attendance where session_id=".$result['session_id'].";"));
					$absent = $total - $presentcount;
					echo "Total Registered : $total <br/>";
					echo "Total Present : $presentcount <br/>";
					echo "Total Absent : $absent <br/><br/>";
					$rresults = $db->select("tbl_role");
					foreach ($rresults as $rresult){
						$count = $db->run("select * from tbl_registrant as a, tbl_registrant_attendance as b where  b.session_id=".$result['session_id']." AND a.role_id='".$rresult['role_id']."' AND a.registrant_id=b.registrant_id");
						echo $rresult['role_name']." - ".count($count)."</br>";
					}
					echo "<br/>";
				}
			?>
               
		</div>
        
    </div>
    
<!-- /.modal -->
</div>
</div>
</div>
</div>
</body>
</html>
