<? 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">
 

    <!-- 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 type="text/javascript" src="https://www.google.com/jsapi"></script>
     <script type="text/javascript" src="js/tooltip.jquery.js"></script>
	 <!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.pack.js"></script><![endif]-->
 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	<script type="text/javascript">
		$(function(){
          $('[title]').tooltip({
            content: function(){
              var element = $( this );
              return element.attr('title')
            }
          });
        })
	</script>
   
	 <!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.pack.js"></script><![endif]-->
    <!-- End of all CSS/JS -->
   </head>
<body>


			<br><br>
			<div id="piechart_div"></div><? 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>Table Layouts</strong></h3>
    </div>

    
    <div class="well well-lg">
        
        <b><u>Floor Plan</u></b><br><br>
			<table width='100%'  id='tableone'>
			<tr>
				<td colspan='13' align='center'><b>STAGE</b></td>
			</tr>
			<?
				$x=1;
				for ($i=0;$i<6;$i++){
					echo "<tr>";
						for ($j=0;$j<12;$j++){
							echo "<td width='8%' align='center'>";
                            $bind = array(":search1"=>$x);
                            $results = $db->select("tbl_table","tbl_id=:search1",$bind);
							$result = $results[0];
							if ($result['tbl_active']=='0'){
								echo "&nbsp;";
							}else{
                                $bind = array(":search1"=>$x);
                                $results = $db->select("tbl_registrant","table_id=:search1",$bind);
								$total = count($results);
				 $results = $db->run("select distinct a.registrant_id from tbl_registrant as a, tbl_registrant_attendance as b where a.table_id=$x AND a.registrant_id=b.registrant_id");				
                               // $results = $db->select("tbl_registrant as a, tbl_registrant_attendance as b","a.table_id=:search1 AND a.registrant_id=b.registrant_id",$bind);
								$total_present = count($results);
								$data = "<u>$total_present / $total</u><br>";
                                $results = $db->select("tbl_registrant","table_id=:search1 ORDER BY registrant_fullname",$bind);
								foreach ($results as $result){
                                    $bind = array (":search1"=>$result['registrant_id']);
                                    $aresults = $db->select("tbl_registrant_attendance","registrant_id=:search1",$bind);
									if (count($aresults)>0){
										$data.="<font color='green'>".$result['registrant_fullname']."</font><br>";
									}else{
										$data.="<font color='red'>".$result['registrant_fullname']."</font><br>";
									}
								}
                                $bind = array(":search1"=>$x);
                                $results = $db->select("tbl_table","tbl_id=:search1",$bind);
								$result = $results[0];
								$table_name = $result['tbl_name']." ($total_present/$total)";
                                $absent = $total - $total_present;
                                echo "<script type='text/javascript'>";
				
                                      // Load the Visualization API and the piechart package.
                                      echo "google.load('visualization', '1.0', {'packages':['corechart']});";

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

                                      // Callback that creates and populates a data table, 
                                      // instantiates the pie chart, passes in the data and
                                      // draws it.
                                      echo "function drawChart$x() {";

                                      // Create the data table.
                                      echo "var data = new google.visualization.DataTable();";
                                      echo "data.addColumn('string', ' ');";
                                      echo "data.addColumn('number', 'Description');";
                                      echo "data.addRows([['Turned Up',$total_present],['Absent', $absent,]]);";

                                      // Set chart options
                                     echo " var options = {'title':' ','width':80,'height':80,'legend':'none',backgroundColor: 'transparent',titleTextStyle: {color: '#FFFFFF',fontSize:'10'},is3D:true};";

                                      // Instantiate and draw our chart, passing in some options.
                                      echo "var chart$x = new google.visualization.PieChart(document.getElementById('piechart_div$x'));";
                                      echo "chart$x.draw(data, options);";
                                echo "}";
                                echo"</script>";
                                
                                echo "<div id='piechart_div$x'></div>";
                                
								echo "<div id='table".$x."status' class='tooltip'>Test</div><div id='data_table".$x."status' style='display:none;'>".$data."</div><span title=\"$data\">$table_name</span></td>";
							}
							$x++;
						}
					echo "</tr>";
				}
			?>

			</table>
    </div>
<!-- /.modal -->
</div>
</div>
</div>
</div>
</body>
</html>

