<?
	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 = '';
	
	
	$l_table = get_item('select kljuc from meta_item where rbr =  '.$_GET['rbr'].' and rbr_atribut = '.$_GET['rbr_atribut']);
	
	$x1 = get_item('select rbr from meta_tablica_list where ime_tablice = "'.$l_table.'" ');
	$x2 = get_item('select rbr from meta_forma where rbr_meta_tablica_list = '.$x1);
	$x3 = get_item('select rbr from meta_tab where rbr_meta_forma = '.$x2);
	$x4 = get_item('select rbr from meta_grupa where rbr_meta_tab= '.$x3);
	
	$y = get_data('select * from meta_item where rbr_meta_grupa = '.$x4.' and aktivan = 1 order by redoslijed ', 1);
	
	
	$result .= '<div class="forma-new-item">';
	$result .= '<ul>';
	for($i = 0; $i < sizeof($y['rbr']); $i++){
		$result .= '<li><p>'.$y['label'][$i].'</p><input type="text" name="item-'.$y['rbr_atribut'][$i].'" id="item-'.$y['rbr_atribut'][$i].'" value=""></li>';
	}
	$result .= '<li><p>&nbsp;</p><input type="submit" value="Snimi" onclick="save_new_item_in_dd(this, 1); return false;"> '.
		'<input type="submit" value="Odustani" onclick="save_new_item_in_dd(this, 2); return false;"></li>';
	$result .= '<input type="hidden" name="rbr" id="rbr" value="'.$_GET['rbr'].'">';
	$result .= '<input type="hidden" name="rbr_atribut" id="rbr_atribut" value="'.$_GET['rbr_atribut'].'">';
	$result .= '</ul>';
	$result .= '</div>';
	
	$la_data = array();
	$la_data['result'] = $result;
	
	$la_json = json_encode($la_data);
	print $la_json;
	exit;
?>