<?
	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 = '';
	
	$la_value = explode(', ', rawurldecode($_GET['value']));
	
	if($_GET['rules']){
		$la_tmp = explode(':', $_GET['rules']);
		
		switch($la_tmp[0]){
			case '_filter_':
				$l_filter = ' and '.$la_tmp[1];
				
				if($la_tmp[2]){
					$x = get_data('select guid, '.$la_tmp[3].' as DisplayName from '.$la_tmp[2].' where 1 = 1 '.$l_filter.' order by '.$la_tmp[4], 1);
				}else{
					$x = get_data('select guid, DisplayName from zaposlenik where 1 = 1 '.$l_filter.' order by Prezime ', 1);
				}
			
				break;
			
			default:
				$x = get_data('select guid, '.$la_tmp[1].' as DisplayName from '.$la_tmp[0].' order by '.$la_tmp[2], 1);
		}
		
	}else{
		$x = get_data('select guid, DisplayName from zaposlenik order by Prezime ', 1);
	}
	
	$result .= '<div class="multiddULWrap" id="fmultidd_'.$_GET['id'].'"><ul class="multiddUL">'."\n";
	for($i = 0; $i < sizeof($x['guid']); $i++){
		if(in_array($x['DisplayName'][$i], $la_value)){
			$l_checked = ' checked';
		}else{
			$l_checked = '';
		}
		$result .= '<li><input type="checkbox" name="cb_'.$x['guid'][$i].'" value="'.$x['DisplayName'][$i].'"'.$l_checked.'><p>'.$x['DisplayName'][$i].'</p></li>'."\n";
	}
	$result .= '</ul></div>'."\n";
	
	$result .= '<a href="#" onclick="close_layer(\'multidd_'.$_GET['id'].'\'); return false;" class="multiddButtonCancel">Odustani</a>'."\n";
	$result .= '<a href="#" onclick="setMultiDD(\''.$_GET['id'].'\'); return false;" class="multiddButtonOK">Ok</a>'."\n";
	
	print $result;
?>
