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

$lid= $_GET['lid'];		

$SQL="SELECT * FROM status 
WHERE usertype=1 AND user_id = ".$lid." AND thedate <= CURDATE()
 ORDER BY thedate DESC, timestamp DESC";
$results = llnb_query($SQL);

$i=0;
while($row = llnb_fetch_assoc($results))
{
	
	if ($i % 2)
		$odd= "class=\"odd\"";
	else
		$odd ="";
		
	if ( $row['thestatus'] == 1)	
	{	$thestatus= "Active";
		$thepg = "make_active_m";
		$h="310";

	}
	else
	{	$thestatus = "Inactive";
		$thepg = "make_inactive_m";
		$h="525";
	}
		
	if ($i==0)
	{
		$currentstatus= $thestatus;
		$currentstatusdate= dispDate($row['thedate']);
		$currentstatusnote= $row['note'];
		$currentstatusreason= $row['reason'];
	}
	
	
	$TRs .="
	<tr ".$odd."\">
        <td class=\"datewidth\">".dispDate($row['thedate'])."</td>
        <td>".$thestatus."</td>
        <td><a rel=\"{handler:'iframe',size:{x:550,y:".$h."}}\"  href=\"".$thepg.".php?utype=1&lid=".$lid."&mode=edit&frompg=learnerstatus&sid=".$row['id']."\" class=\"btnsml_m\">Review</a></td>
      </tr>
      ";
	  
	$i++;
}

    
      

?>


<!doctype html>
<html class="no-js" lang="en"> <!--<![endif]-->
<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>
     	<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 language="javascript">
  
  
window.addEvent('domready', function()
{
	SqueezeBox.assign($$('a.btnlfr_m'), {
		parse: 'rel'
	});
});

window.addEvent('domready', function()
{
	SqueezeBox.assign($$('a.btnsml_m'), {
		parse: 'rel'
	});
});  
</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> 
	<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=<?=$lid;?>" class="btn lfl">Learner Overview</a></nav>
  </header>
  <div role="main" id="main" class="clearfix">
  	<div id="location">

	<?
	$thestatus = fetchCurrentStatus(1, $lid);
	
	if ($thestatus == 1)
	{	
		$thebutton= "Make inactive";
		$thepg = "make_inactive_m";
		$h="575";

	}
	else
	{
		$thebutton= "Make Active";
		$thepg = "make_active_m";
		$h="310";

	}
	?>

  	  	<a href="<?=$thepg;?>.php?utype=1&frompg=learnerstatus&lid=<?=$lid;?>" class="btnlfr_m" rel="{handler:'iframe',size:{x:525,y:<?=$h;?>}}" style="position:relative; top: 0; right: 10px;"><?=$thebutton;?></a>

      <H2><span>Learner:</span> <?= fetchLearnerName($lid); ?></H2>
    
    </div> <!-- end of location -->
    <div>
	<h2>Status Information</h2>
    <p class="tablenote">Current Status</p>
    <table  border="0" cellspacing="0" cellpadding="0" class="infotable">
      <tr>
        <th scope="col">Start Date</th>
        <th scope="col">Current Status</th>
        <th scope="col">Current Status</th>
      </tr>
<?= $TRs;?>
    </table>    
    
    
    

<?
if ($currentstatus == "Inactive")
{
	echo
	"
    <H2>Inactive Status Information</H2>
	<form>
      <div class=\"input\">
        <label>Date Tutoring Ended:</label>
        <input name=\"eneddate\" type=\"text\" value=\"".$currentstatusdate."\" readonly>
      </div>
      <div style=\"clear:both;\"></div>

    
      <div class=\"input\">
        <label>Learner attainment at the end of the tutoring period:</label>
		<textarea name=\"attainment\" cols=\"\" rows=\"3\"  class=\"talrg\" readonly>".$currentstatusnote."</textarea>
      </div>
      <div style=\"clear:both;\"></div>

    
      <div class=\"input\">
        <label>Reason for leaving:</label>
        <input name=\"eneddate\" type=\"text\" value=\"".fetchReasonForLeaving($currentstatusreason)."\" readonly>
      </div>
      <div style=\"clear:both;\"></div>

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


</body>
</html>