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


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

	$SQL = "UPDATE learnergoals 
				SET alive=0, 
				killed=NOW() 
			WHERE id=".$_GET['lgid'];
	$results = llnb_query($SQL);

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

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

	}
	else
	{
		$completed = 1;
		$completed_c = " , completedon = NOW() " ;
	
	}

	
	$SQL = "UPDATE learnergoals SET completed = ".$completed.$completed_c." 
			WHERE id=".$_GET['lgid'];
	$results = llnb_query($SQL);

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

}




?>
