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

	$result = array (
			"status"	=> 'KO',
			"results"	=> array ()
	);
	
	$conn = get_dbconnection();
		
	if ( $conn )
	{
		$sql = "select lro_id, name from login_role where removed = false union select null, '' order by name asc;";
		
		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 );
?>