<?
include('auth.php');
include('common.php');
//modal win height/width
$x=700;
$y=500;

$lid= $_GET['lid'];		

$SQL="SELECT * 
FROM learner_resource
WHERE learner_id =".$lid." AND alive=1
ORDER by start DESC";
$results = llnb_query($SQL);

$i=0;
while($row = llnb_fetch_assoc($results))
{
	
	if ($i % 2)
		$odd= "class=\"odd\"";
	else
		$odd ="";
	
	if ($row['completed']==1)
		$checked="checked";
	else
		$checked="";
	
	if ($row['res_id']==$_RES_OTHER)
		$other_xtra = " (".$row['other'].")";
	else
		$other_xtra = "";
	
	$TRs .="
      <tr ".$odd.">
        <td class=\"datewidth\">".dispDate($row['start'])."</td>
        <td><input id=\"completed".$i."\" type=\"checkbox\" ".$checked." onClick=\"doComplete(".$row['id'].", 'completed".$i."');\"></td>
        <td><a href=\"learner_resourcelist_m.php?lid=".$lid."&lrid=".$row['id']."\" rel=\"{handler:'iframe',size:{x:".$x.",y:".$y."}}\"  class=\"btnsml_m\">Review</a></td>
        <td>".dispResourceName($row['res_id']).$other_xtra."</td>
        <td><a  onClick=\"return confirm('Are you sure you want to delete?');\"  href=\"do_learnerres.php?mode=delete&lid=".$lid."&lrid=".$row['id']."\" class=\"btnsml btn\">Delete</a></td>
        <td class=\"datewidth\">".dispDate($row['completedon'])."</td>
      </tr>
	";
	  
	$i++;
}
?>




<!doctype html>
<html class="no-js" lang="en">


<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">

  <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">
  function  doComplete(theid, boxID)
  {
  	
  	
  	var c = confirm("Are you sure?");
		
	if (c == true)
	{
		var checkBox = document.getElementById(boxID);
		checkBoxValue = checkBox.value;
		var pg = 'do_learnerres.php?lid=<?=$lid;?>&mode=complete&lrid='+theid;
		self.location.href=pg;
	}
	else
	{	
		self.location.href='learner_resources.php?lid=<?=$lid;?>';
	}
		
  }
   
  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> 
	<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=<?=$lid;?>" class="btn lfl">Learner Overview</a></nav>
  </header>
  <div role="main" id="main" class="clearfix">
  	<div id="location"><a href="learner_resourcelist_m.php?lid=<?=$lid;?>&mode=new"  class="btnlfr_m" rel="{handler:'iframe',size:{x:<?=$x;?>,y:<?=$y;?>}}" style="position:relative; top: 0; right: 10px;">Add Resource</a>
      <H2><span>Learner:</span> <?= fetchLearnerName($lid); ?></H2>
    
    </div> 
    <div>
	<h2>Assigned Resources</h2>
    <p class="tablenote">List of resources attached to this learner.</p>
    <div class="tableend">
    <table  border="0" cellspacing="0" cellpadding="0" class="infotable" id="seesiontable">
      <tr>
        <th scope="col" class="datewidth">Start Date</th>
        <th scope="col" class="delwidth">Completed</th>
        <th scope="col" class="delwidth"> </th>
        <th scope="col">Resource</th>
        <th scope="col" class="delwidth"></th>
        <th scope="col" class="datewidth">Completed</th>
      </tr>

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



</body>
</html>