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

	$result = array (
			"status"	=> 'KO',
			"results"	=> array ()
	);
	
	$conn = get_dbconnection();
		
	if ( $conn )
	{
		$sql = "select id,name from staff_role order by name";
		
		if ( $query = pg_query($conn,$sql) )
		{
			$result['status'] ='OK';

			while ( $row = pg_fetch_row($query) )
			{
				$res = array (	"id" 	=> $row[0],
								"name"	=> $row[1] );

				array_push ( $result['results'], $res );
			}
		}
	}
	
	header('Content-type: application/json');
	
	echo json_encode ( $result );
?>