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


if ($_GET['mode'] == 'delete')
{

	$SQL = "UPDATE learner_resource 
				SET alive=0, 
				killed=NOW() 
			WHERE id=".$_GET['lrid'];
	$results = llnb_query($SQL);
	header("Location: ./learner_resources.php?lid=".$_GET['lid']);

}
else if  ($_GET['mode'] == 'complete')
{
	
	//fetch current status then do opposite
	$SQL = "SELECT completed FROM learner_resource
		WHERE id =".$_GET['lrid'];
	$results = llnb_query($SQL);
	$row = llnb_fetch_assoc($results);
	
	if ( $row['completed'] == 1)
	{
		$completed = 0;
		$completeddate = "NULL";
	}
	else
	{
		$completeddate = "NOW()";
		$completed = 1;
	}

	
	$SQL = "UPDATE learner_resource SET completed = ".$completed.", completedon = ".$completeddate."
			WHERE id=".$_GET['lrid'];
	$results = llnb_query($SQL);

	header("Location: ./learner_resources.php?lid=".$_GET['lid']);

}




?>
