<?
	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";
	
	ob_start();
		$x = get_data("select guid, Sifra, Naziv, parent_guid from organizacijska_shema_drustva where guid = '".$_GET['value']."' ");
		
?>
		<div class="content">
<?
			$l_children = substr(get_children($x['guid'], "select guid, Naziv from organizacijska_shema_drustva where parent_guid = '{_REPLACE_VALUE_}' "), 1);
			$var_filter_parent_guid = ' and organizacijska_shema_drustva.guid not in ('.$l_children.')';
			
			$var_value_parent_guid = $x['guid'];
			$l_forma_ch = gen_form('organizacijska_shema_drustva', 'tablica_osd', $_GET['value']);
?>
			<div id="adddata"></div>
			<div id="chdata">
				<?=$l_forma_ch?>
			</div>
		</div>
		
<?
	$output = ob_get_contents();
	ob_end_clean();
	
	$la_data = array();
	$la_data[0] = $output;
	
	$la_data[1] = ' &nbsp; || &nbsp; '.$g_term[$g_language_sign]['top_organizacijska_jedinica'].': "'.$x['Naziv'].'"';
	$la_data[2] = $g_term[$g_language_sign]['top_akcija_promijeni_podatke'];
	
	ob_start();
?>
		<div class="buttons">
			<a href="#" onclick="osd_get_ch('<?=$_GET['value']
				?>'); return false;" title="<?=$g_term[$g_language_sign]['top_promijeni_podatke_org_jed']?> '<?=$x['Naziv']
				?>'"><img src="<?=$g_path_sl_res?>images/b-edit.gif" border="0"></a>
			<a href="#" onclick="osd_get_add('<?=$_GET['value']
				?>'); return false;" title="<?=$g_term[$g_language_sign]['top_dodaj_novu_org_jed_unutar']?> '<?=$x['Naziv']
				?>'"><img src="<?=$g_path_sl_res?>images/b-add.gif" border="0"></a>
			<a href="#" onclick="osd_del('<?=$x['guid']
				?>'); return false;" title="<?=$g_term[$g_language_sign]['top_obrisi_org_jed']?> '<?=$x['Naziv']
				?>'"><img src="<?=$g_path_sl_res?>images/b-del.gif" border="0"></a>
			<img src="<?=$g_path_sl_res?>images/b-separator.gif" border="0">
			<a href="#" onclick="submitThisForm(); return false;" title="<?=$g_term[$g_language_sign]['spremi']
				?>"><img src="<?=$g_path_sl_res?>images/b-spremi.gif" border="0"></a>
		</div>
<?
	$output = ob_get_contents();
	ob_end_clean();
	$la_data[3] = $output;
	
		
	$l_json = json_encode($la_data);
	print $l_json;
	
	
	/*
	$x = get_data("select guid, Sifra, Naziv, parent_guid from organizacijska_shema_drustva where guid = '".$_GET['value']."' ");
	
	//$l_children = substr(get_children($x['guid']), 1);
	$l_children = substr(get_children($x['guid'], "select guid, Naziv from organizacijska_shema_drustva where parent_guid = '{_REPLACE_VALUE_}' "), 1);
	
	//print $l_children." === \n";
	
	//print "select guid, Naziv from organizacijska_shema_drustva where guid not in \"".$l_children."\" order by Sifra \n";
	
	$y = get_data("select guid, Naziv from organizacijska_shema_drustva where guid not in (".$l_children.") order by Sifra ", 1);
	
?>
	<div class="content">
		<p><b><?=$x['Sifra']?>. <?=$x['Naziv']?></b></p>
		<form name="formdata" method="post" action="" onsubmit="osd_upd('<?=$x['guid']?>', 'chdata'); return false;">
		<p>
			<a href="#" onclick="osd_open_layer('chdata'); return false;">Promijeni podatke</a>
			<span id="chdata">
				Nadređeni
				<select name="guid">
<?
					if(!$x['parent_guid']){
?>
						<option value="-1">--</option>
<?
					}
					for($i = 0; $i < sizeof($y['guid']); $i++){
						$y['guid'][$i] == $x['parent_guid'] ? $l_selected = ' selected' : $l_selected = '';
?>
						<option value="<?=$y['guid'][$i]?>"<?=$l_selected?>><?=$y['Naziv'][$i]?></option>
<?
					}
?>
				</select>
				<br>
				Šifra <input type="text" name="sifra" value="<?=$x['Sifra']?>"><br>
				Naziv <input type="text" name="naziv" value="<?=$x['Naziv']?>">
				<input type="submit" value="Promijeni"><br>
			</span>
		</p>
		</form>
		<form name="formdataadd" method="post" action="" onsubmit="osd_ins('<?=$x['guid']?>', 'adddata'); return false;">
		<p>
			<a href="#" onclick="osd_open_layer('adddata'); return false;">Dodaj novu podorganizacijsku jedinicu</a>
			<span id="adddata">
				Šifra <input type="text" name="sifra" value=""><br>
				Naziv <input type="text" name="naziv" value="">
				<input type="submit" value="Promijeni"><br>
			</span>
		</p>
		</form>
		<p><a href="#" onclick="osd_del('<?=$x['guid']?>'); return false;">Obriši jedinicu <b><?=$x['Sifra']?>. <?=$x['Naziv']?></b></a></p>
	</div>
<?
	*/
?>