<!doctype html>
<html>
<head>
	<title>League</title>
	<!-- CSS are placed here -->
        <?php echo HTML::style('css/bootstrap.css'); ?>
        <?php echo HTML::style('css/bootstrap-responsive.css'); ?>
	<?php echo HTML::script('js/jquery-1.11.0.min.js'); ?>
        <?php echo HTML::script('js/bootstrap.min.js'); ?>
        <?php echo HTML::script('js/highcharts.js'); ?>
        <?php echo HTML::script('js/modal.js?v2'); ?>
	<?php echo $__env->make('header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<!-- Scripts are placed here -->
	League gemiddelde: <?php echo number_format($average,2);; ?>
	Laatst bijgewerkte speelavond: <?php echo date('d-M-Y', strtotime($lastupdate));; ?>
	
	<!-- Large modal -->

	<div id="modal-graph" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="true" style="width:75%">
	  <div class="modal-dialog" style="width:100%">
	    <div class="modal-content">
	      <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-labelled-by="modal-graph" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              </div>
	      <div id="modal-body">
	      </div>
	      <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	      </div>
	    </div>
	  </div>
	</div>

	<br>
	<br>
	<div class="btn-group">
	  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Kies seizoen<span class="caret"></span>
	  </button>
	  <ul class="dropdown-menu">
	    <li><a href="/leagues/<?php echo $id; ?>/2015">Seizoen 2014-2015</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2016">Seizoen 2015-2016</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2017">Seizoen 2016-2017</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2018">Seizoen 2017-2018</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2019">Seizoen 2018-2019</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2020">Seizoen 2019-2020</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2021">Seizoen 2020-2021</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2022">Seizoen 2021-2022</a></li>
            <li><a href="/leagues/<?php echo $id; ?>/2023">Seizoen 2022-2023</a></li>
	    <li><a href="/leagues/<?php echo $id; ?>/2024">Seizoen 2023-2024</a></li>
            <li><a href="/leagues/<?php echo $id; ?>/2025">Seizoen 2024-2025</a></li>
            <li><a href="/leagues/<?php echo $id; ?>">Seizoen 2025-2026</a></li>
	  </ul>
	</div>
	<h4>Team standen</h4>
	<?php $cnt = 1; if (isset($_GET['debug'])) {
	//test meuk hier;
	}?>
	<table class="table table-condensed table-hover">
	  <thead>
	    <tr>
	      <td>Plaats</td>
	      <td>Naam</td>
	      <td>Punten</td>
	      <!-- <td>p1</td>
	      <td>p2</td>
	      <td>p3</td> -->
	    </tr>
	  </thead>
	  <tbody>
	<?php foreach ($teams as $team): ?>
	    <tr>
	      <td><?php echo $cnt++; ?></td>  
	      <td><a href="/teams/<?php echo $team->id; ?>"><?php echo $team->screenname; ?></a></td>
	      <td><?php echo $team->score; ?></td>
	      <!-- <td><?php echo $team->periodPoints[0]; ?> (<?php echo $team->periodRankPoints[0]; ?>)</td>
	      <td><?php echo $team->periodPoints[1]; ?> (<?php echo $team->periodRankPoints[1]; ?>)</td>
	      <td><?php echo $team->periodPoints[2]; ?> (<?php echo $team->periodRankPoints[2]; ?>)</td>-->
	    </tr>
	<?php endforeach; ?>
	  </tbody>
	</table>
	<h4>Uitslagen laatste avond</h4>
	<table class="table table-condensed table-hover">
	  <tbody>
<?
		for ($i = 0; $i < count($lastgames); $i++) {
                  if ($lastgames[$i]->id != 0 && $lastgames[$i]->team_id != '667') {//ugly hack for team X if it's in the results more than once

                    echo '<tr><td><a href="/teams/'.$lastgames[$i]->team_id.'">'.$lastgames[$i]->screenname.'</a> - ';
                    $competitor = $lastgames[$i]->competitor_team_id;
		    
		    if ($competitor == '667') { echo '<a href="/teams/667">Team X </a><td>'.$lastgames[$i]->score.'-0</td></tr>';continue; } //ugly hack for team X if it's in the results more than once :(
                    
		    for ($c = 0; $c < count($lastgames); $c++) {
                      if ($lastgames[$c]->team_id == $competitor) {
                        echo '<a href="/teams/'.$lastgames[$c]->team_id.'">'.$lastgames[$c]->screenname.'</a><td>'.$lastgames[$i]->score.'-'.$lastgames[$c]->score.'</td></tr>';
                        $lastgames[$c]->id = 0;
                      }
                    }
                  }
		}
?>
	</tbody>
	</table>
	<h4>Individuele standen</h4>
	<?php $cnt = 1; ?>
	<table class="table table-hover table-condensed">
	 <thead>
	   <tr><td>Plaats</td><td>Naam</td><td>Gemiddelde</td><td>Hoogste game</td></tr>
	</thead>
	<tbody>
	  <tr><td>Heren</td><td></td><td></td><td></td></tr>
	<?php foreach ($men as $man): ?>
	  <tr>
	    <td><?php echo $cnt++; ?></td><td><a data-username="<?php echo $man->screenname; ?>" data-userid="<?php echo $man->id; ?>" data-year="<?php echo $year; ?>" data-toggle="modal" data-target="#modal-graph" class="btn btn-primary"><?php echo $man->screenname; ?></a></td><td><?php echo number_format($man->average,2); ?></td><td><?php echo $man->max; ?></td>
	  </tr>
        <?php endforeach; ?>
	<?php $cntw = 1; ?>
	<tr><td>Dames</td><td></td><td></td><td></td></tr>
	<?php foreach ($women as $woman): ?> 
	  <tr>
	    <td><?php echo $cntw++; ?></td><td><a data-username="<?php echo $woman->screenname; ?>" data-userid="<?php echo $woman->id; ?>" data-year="<?php echo $year; ?>" data-toggle="modal" data-target="#modal-graph" class="btn btn-primary"><?php echo $woman->screenname; ?></a></td><td><?php echo number_format($woman->average,2); ?></td><td><?php echo $woman->max; ?></td>
	  </tr>
	<?php endforeach; ?>
	</tbody>
       </table>
</div>
</div>
</body>
</html>

