<?php
	require_once '../../autoload.php';

	$result = array (
			"status"	=> 'KO',
			"results"	=> array ()
	);

	$doc_id				= $_POST["doc_id"];
	$staff_member_id	= $_POST['staff_member_id'];

	error_log ( " doc_id : " .$doc_id );
	error_log ( " staff_member_id : " .$staff_member_id );

	$pdo = getPDO ();
	
	if ( $pdo )
	{
		$result['status'] = 'OK';

		error_log ( "Set last_reminder...");
		$s1 = $pdo->prepare ( "update action_status_link set last_reminder=NOW() where document_id=:doc_id and staff_member_id=:staff_id returning last_reminder" );
		$s1->bindParam ( ':doc_id', 	$doc_id 			);
		$s1->bindParam ( ':staff_id', 	$staff_member_id 	);

		if ( $s1->execute () == true )
		{
			$last_reminder = $s1->fetchColumn ();
			error_log ( "last_reminder : " .$last_reminder );
			$result['status'] = 'OK';
			array_push ( $result['results'], array ( 	"doc_id" => $doc_id,
														"staff_member_id"	=> $staff_member_id,
														"last_reminder"	=> $last_reminder ) );
		}
		else
			$result['status'] = 'OK';
	}

	header('Content-type: application/json');
	
	echo json_encode ( $result );
?>