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

//council- fetch council code associated with learner
$SQL="SELECT firstname, lastname, council_id FROM learner WHERE id=".$_GET['lid'];
$results = llnb_query($SQL);
$rowlearner = llnb_fetch_assoc($results);
$c=$rowlearner['council_id'];




$SQL="SELECT id, firstname, lastname, homephone, startdate FROM tutor WHERE council_id=".$c." AND active=1 
		AND id IN (SELECT tutor_id FROM tutor_learner WHERE learner_id=".$_GET['lid']." AND alive=1)"; 
$results = llnb_query($SQL);

//echo $SQL;

while($row = llnb_fetch_assoc($results))
{

	$odd="";
	if ($i % 2)
	$odd ="class=\"odd\"";
	
	$TRs .= "  
		<tr>
		 <td ".$odd .">".$row['firstname']." ".$row['lastname']."</a></td>
		 <td ".$odd .">".dispPhone($row['homephone'])."</td>
		 <td ".$odd .">".dispDate($row['startdate'])."</td>
       	 <td ".$odd ."><a  onClick=\"return confirm('Are you sure you want to unmatch?');\"  href=\"do_unmatch_tutor.php?lid=".$_GET['lid']."&tid=".$row['id']."\" class=\"btnsml btn\">Unmatch</a></td>
		 </tr>";
	$i++;
}

?>




<!doctype html>

<head>
  <meta charset="utf-8">


  <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>
    	<link href="scripts/SqueezeBox.css" rel="stylesheet" type="text/css" />
    	<script src="scripts/mootools.js" type="text/javascript" ></script>
	<script src="scripts/SqueezeBox.js" type="text/javascript"></script>
	
	<script type="text/javascript">

		window.addEvent('domready', function()
		{
			SqueezeBox.assign($$('a.btnlfr_m'), {
				parse: 'rel'
			});
		});

	</script>
  
</head>
<body>
<div id="wrap">
  <!-- Prompt IE 6 users to install Chrome Frame. Remove this if you support IE 6.
       chromium.org/developers/how-tos/chrome-frame-getting-started -->
  <!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
  <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><a href="learner_list.php" class="btn lfl">Learner List</a>
	<a href="learner_overview.php?lid=<?=$_GET['lid'];?>" class="btn lfl">Learner Overview</a></nav>
	
  </header>
  <div role="main" id="main" class="clearfix">
  	<div id="location">
  	<a class="btnlfr_m" rel="{handler:'iframe',size:{x:550,y:400}}" style="position:relative; top: 0; right: 10px;" href="learner_addtutor_m.php?lid=<?=$_GET['lid'];?>&c=<?=$c;?>" >Add Tutor</a>

      <H2><span>Learner:</span> <? echo $rowlearner['firstname']." ".$rowlearner['lastname']; ?></H2>
    
    </div> <!-- end of location -->
    <div>
	<h2>Assigned Tutor Information</h2>
    <p class="tablenote">List of active tutors assigned to this learner.</p>
    <table  border="0" cellspacing="0" cellpadding="0" class="infotable" id="seesiontable">
      <tr>
        <th scope="col">Tutor Name</th>
        <th scope="col">Phone</th>
        <th scope="col">Start Date</th>
        <th scope="col">Remove</th>
      </tr>

      <?= $TRs; ?>
    </table>
    
    </div>
  </div> <!-- end of main -->
<aside>
</aside>
    <div style="clear:both;"></div>
<footer>
  <?php include('footer.php'); ?>
</footer>
</div>
<!-- end of wrap --> 

<script>
    $("a").click(function () {
      $("#note1").toggleClass("note visuallyhidden");
    });
</script>


</body>
</html>