<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

sec_session_start();
?>

<!DOCTYPE html>
<html>
    <head>
	<meta charset="UTF-8">
        <title>SkillCourt</title>
        <link rel="stylesheet" type="text/css" href="style/Main.css">
	<script type="text/javascript" src="https://www.google.com/jsapi"></script>
	<script type="text/javascript">
    	    google.load('visualization', '1.1', {packages: ['line']});
    	    google.setOnLoadCallback(drawChart);

    	    function drawChart() {
		var data = new google.visualization.DataTable();
      		data.addColumn('date', 'Date');
      		data.addColumn('number', 'Accuracy (%)');
		$data = getData('$_SESSION['username']');
      		data.addRows([
      		]);

      		var options = {
        	    chart: {
          		title: 'Box Office Earnings in First Two Weeks of Opening',
          		subtitle: 'in millions of dollars (USD)'
		    },
        	    width: 600,
        	    height: 300
	    	};

	    var chart = new google.charts.Line(document.getElementById('linechart_material'));

	    chart.draw(data, options);
    	}
    </script>
    </head>
    <body>
	<div id="fb-root"></div>
	<script>
	    (function(d, s, id) {
  		var js, fjs = d.getElementsByTagName(s)[0];
		if (d.getElementById(id)) return;
		js = d.createElement(s); js.id = id;
		js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=304568816231285";
		fjs.parentNode.insertBefore(js, fjs);
	    }(document, 'script', 'facebook-jssdk'));
	</script>
        <div id="MainData">
            <div id="Header">SkillCourt</div>

            <div id="User">
                <?php if (login_check($mysqli) == true) : ?>
		    <br><p><a href="profile.php"><?php echo htmlentities($_SESSION['username']); ?></a>
		    <br><a href="includes/logout.php">Logout</a></p>
		<?php else : ?>
		    <?php header('Location: ./index.php'); ?>
		<?php endif; ?>
            </div>
            <div id="Menu">
                <h2><a href="Main.php">Home</a></h2>
		<?php
		    if (htmlentities($_SESSION['usertype']) == "coach")
			echo "<h2><a href='myplayers.php'>My Players</a></h2>";
		    else
			echo "<h2><a href='statistics.php'>My Stats</a></h2>";
		?>
                <h2><a href="routines.php">Routines</a></h2>
            </div>
            <div id="Content">
		<h1>Statistics:</h1>
		<div id="linechart_material"></div>
		<div class="fb-share-button" data-href=<?php echo "'http://skillcourt-dev.cis.fiu.edu/player.php?player=" . $_SESSION['username'] . "'"; ?> data-layout="button">
		</div>
	    </div>
            <div id="Footer">Copyright 2015 SkillCourt</div>
        </div>
    </body>
</html>

