<?php

  require_once('../../../../../Config/config.php');
  require_once('../../../../../Config/odbc.php');

  $conn = get_dbconnectionRIS();

  $arr = array (
			"result"		=> 'Error',
			"users"	=> array ()
	);

	if ( $conn )
	{
		$wherecond = '';

    if(isset($_GET['type']) && $_GET['type'] != '')
		{
			$wherecond .= ' and type ='.$_GET['type'] ;
		}

		$sql = "select '' as name,-1 as mod_id union select label as name, mod_id from xmodality  where mod_id != -1 and removed = false order by name asc";

		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$arr1 = array ( "name" => $row[0], "mod_id" => $row[1] );

				$arr["result"] = "OK";
				array_push ( $arr["users"], $arr1 );
			}
		}
	}

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

?>
