<?
include('auth.php');
include('common.php');

$SQL_x="";


//council
$c = $_GET['council'];
if ($c && $c != -1)
{
	$SQL_x .= " AND council_id=".$c;
}
		
$SQL="SELECT * FROM council";
$results = llnb_query($SQL);

while($row = llnb_fetch_assoc($results))
{
	
	$coordinfo="";
	$SQL="SELECT * FROM coordinator WHERE alive=1 AND council_id=".$row['id'];
	$res = llnb_query($SQL);
	while($rcoord = llnb_fetch_assoc($res))
	{
		
		$coordinfo.= $rcoord['firstname']." ".$rcoord['lastname'].", ".dispPhone($rcoord['homephone'])."<br>";
	}
	
	$TRs .= "  
		<tr>
		  <td><strong>".$row['name']."</strong></td>
		  <td><a href=\"council_overview.php?cid=".$row['id']."\" class=\"btnsml btn\">Overview</a></td>
		  <td>".$coordinfo."</td>
		  <td class=\"phonewidth\">".dispPhone($row['phone'])."</td>
		 </tr>";

}
?>


<!doctype html>
<head>
  <meta charset="utf-8">

  <!-- Use the .htaccess and remove these lines to avoid edge case issues.
       More info: h5bp.com/i/378 -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>LLNB System</title>
  <meta name="description" content="">

  <!-- Mobile viewport optimized: h5bp.com/viewport -->
  <meta name="viewport" content="width=device-width, maximum-scale=1.0">

  <!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->
  <LINK REL="SHORTCUT ICON" HREF="favicon.ico">

  <link rel="stylesheet" href="css/style.css">
  <link rel="stylesheet" href="css/llnb-style.css">

  <!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->

  <script src="js/libs/modernizr-2.5.3.min.js"></script>
</head>
<body>
<div id="wrap">
  <header><a href="index.php" class="btn lfr" style="position:relative; top: 15px; right: 0;">Logout</a>

	<h1>Laubach Literacy - <?=uType();?></h1> 
	<h3><?=fetchCouncilName($_SESSION['council_id']);?></h3>	

	<nav id="menu" class="clearfix navmenu"><a href="home.php" class="btn lfl">Home</a></nav>
  </header>
  <div role="main" id="main" class="clearfix">
  	<div id="location"><a href="council_personalinfo.php?mode=new" class="btn lfr" style="position:relative; top: 0; right: 10px;">Add Council</a>
    <H2>Councils</H2>
    <p style="float:right">To add a coordinator select a council</p>
    <div style="clear:both;"></div>
    </div> <!-- end of location -->
    
    <table  border="0" cellspacing="0" cellpadding="0" class="infotable">
      <tr>
        <th scope="col" width="125">Council</th>
        <th scope="col"></th>
        <th scope="col">Coordinator, Home Phone</th>
        <th scope="col">Phone</th>
      </tr>
		<?= $TRs;?>
    </table>
    
    
    
  </div><!-- end of main -->
    <div style="clear:both;"></div>
  <footer>
	<?php include('footer.php'); ?>
  </footer>
  </div> <!-- end of wrap -->

  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

  <!-- scripts concatenated and minified via build script -->
  <script src="js/plugins.js"></script>
  <script src="js/script.js"></script>
  <!-- end scripts -->

</body>
</html>