<?
	header("Content-Type: text/html; charset=utf-8");
	
	$g_path = '../../my/';
	
	include $g_path."u_globals.php";
	include $g_path."html/f.php";
	include $g_path."u_spoj_na_bazu.php";
	
	include $g_path."u_headers.php";
	
	
	
	$result = array();
	
	$x = get_data('select * from meta_item where rbr_meta_grupa = '.$_GET['rbr'].' and rbr_atribut = '.$_GET['id'], 0);
	
	
	if(isset($_GET['addition']) && $_GET['addition'] == 1){
		$l_filter = ' and articles.isService = 0 ';
	}else{
		$l_filter = '';
	}
	
	$y = get_data('select '.str_replace('f_', '', $x['polje_select']).' from '.$x['kljuc'].' where 1 = 1 '.$l_filter.' order by '.$x['polje_order'], 1);
	
	//p('select * from meta_item where rbr = '.$_GET['rbr'].' and rbr_atribut = '.$_GET['id']);
	//p($x);
	//p('select '.str_replace('f_', '', $x['polje_select']).' from '.$x['kljuc'].' where 1 = 1 '.$l_filter.' order by '.$x['polje_order']);
	//pe($y);
	
	$la_tmp = array();
	for($i = 0; $i < sizeof($y['rbr']); $i++){
		/*
		if($y['rbr'][$i] == $_GET['selected']){
			$l_selected = 'selected';
		}else{
			$l_selected = '';
		}
		*/
		$la_tmp['rbr'] = $y['rbr'][$i];
		$la_tmp['ime'] = $y['ime'][$i];
		//$la_tmp['selected'] = $l_selected;
		$result []= $la_tmp;
	}
	
	
	$la_json = json_encode($result);
	print $la_json;
	exit;
?>
