<?php

	include "library.php";

	$cxn = start_code( true );
	
    $cxn_common = db_common_login();
	

	$userid = val( $_SESSION, 'userid' );

	$claim_task = val( $_GET, "claimtask" );
	
	$task_id = val( $_GET, "taskid" );


	page_header( "", $cxn, $cxn_common );

	$date_assigned = date("Y-m-d H:i:s");	

	if ($claim_task == "no")
	{
		echo "Claim task cancelled.<br><br>";
		
		echo show_home_link();
	}
	else
	{
		$query = "SELECT * FROM user WHERE id = '".$userid."'";
		
		$result = run_query( $query, $cxn );
		
		$data = get_row( $result );
		
		$paraplanner = $data['display_name'];
		
		
		$query = "UPDATE task SET paraplanner = '".$paraplanner."', date_assigned = '".$date_assigned."' WHERE id = ".$task_id;
		
		$result = run_query( $query, $cxn );
		
		echo "Task claimed sucessfully.<br><br>";
	
		echo show_home_link();				
	}
?>


