<?
	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";
	
	if($_GET['id'] == 'asd435-prikaz'){
		
		$la_aktivan = array(' (Neaktivan)', ' (Aktivan)');
		$la_aktivan_2 = array('   :', '(*):', '   :', '   :', '   :', '   :', '   :', '   :', '   :', '   :', '   :');
		$la_bold = array('', '<b>');
		$la_bold_end = array('', '</b>');
		
		
		
		$tables = get_data('select rbr, ime from meta_prikaz order by rbr ', 1);
		//print sizeof($tables['rbr'])."<br>";
		
		for($j = 0; $j < sizeof($tables['rbr']); $j++){
			switch($_GET['type']){
				case 1:
					$x = get_data('select rbr, rbr_atribut, label, aktivan '.
						' from meta_prikaz_item '.
						' where 1 = 1 '.
						' and rbr_meta_prikaz = '.$tables['rbr'][$j].
						' and rbr_atribut > 0 '.
						' order by rbr, rbr_atribut ', 1);
						
					$l_table = 'meta_prikaz_item_lang';
					break;
					
				case 2:
					$la_grupa_rbr = get_data('select meta_grupa.rbr '.
						' from meta_grupa, meta_tab '.
						' where meta_grupa.rbr_meta_tab = meta_tab.rbr '.
						' and meta_tab.rbr_meta_forma = '.$tables['rbr'][$j], 1);
					$la_gr_str = '0';
					for($i = 0; $i < sizeof($la_grupa_rbr['rbr']); $i++){
						$la_gr_str .= ', '.$la_grupa_rbr['rbr'][$i];
					}
				
					$x = get_data('select rbr, rbr_atribut, label, aktivan '.
						' from meta_item '.
						' where rbr_meta_grupa in ('.$la_gr_str.')'.
						' and rbr_atribut > 0 '.
						' order by rbr, rbr_atribut ', 1);
						
					$l_table = 'meta_item_lang';
					break;
			}
				
			$l_ima_li = get_item('select count(*) as zbr from '.$l_table.' where rbr = '.$tables['rbr'][$j].' and rbr_jezik = '.$_GET['lang']);
			if($l_ima_li){
				$y = get_data('select rbr, rbr_atribut, label '.
					' from '.$l_table.
					' where rbr = '.$tables['rbr'][$j].
					' and rbr_atribut > 0 '.
					' and rbr_jezik = '.$_GET['lang'].
					' order by rbr, rbr_atribut ', 1);
			}else{
				$y = $x;
				//print "aaaa";
			}
			
			//print_r($y)."<br>";
			
			
			$l_max_rbr = -1;
			for($i = 0; $i < sizeof($x['rbr']); $i++){
				if($l_max_rbr < $x['rbr_atribut'][$i]){
					$l_max_rbr = $x['rbr_atribut'][$i];
				}
?>'<?=$la_aktivan_2[$x['aktivan'][$i]]?><?=$x['rbr'][$i]?>:<?=$x['rbr_atribut'][$i]?>:<?=$_GET['type']?>:<?=$_GET['lang']
					?>' => '<?=$x['label'][$i]?>' => '<?=$y['label'][$i]?>'
<?
			}
		}
		
		
		
	}
	
?>
