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

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

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

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

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

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

		if ( $s1->execute () != true )
		{
			$result['status'] = 'KO';
			array_push ( $result['results'], array ( 	"doc_id" => $doc_id,
														"staff_member_id"	=> $staff_member_id ) );
		}
	}

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