<?
	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";
	
	$_GET['guid'] == '-1' ? $l_ch_add = '' : $l_ch_add = ", parent_guid = '".addslashes($_GET['guid'])."' ";
	
	$x = sql_exe("update organizacijska_shema_drustva ".
		" set Sifra = '".addslashes($_GET['sifra'])."', Naziv = '".addslashes($_GET['naziv'])."' ".$l_ch_add.
		" where guid = '".$_GET['value']."' ");
	
	if($x){
		$la_data = array();
		$x = get_data("select B.guid, B.Naziv, B.Sifra, B.parent_guid
			from organizacijska_shema_drustva A RIGHT outer join organizacijska_shema_drustva B On A.guid = B.parent_guid
			order by A.sifra, B.sifra", 1);
		for($i = 0; $i < sizeof($x['guid']); $i++){
			$la_data[$i] = array(
				'{v:"'.$x['guid'][$i].'", f:"'.$x['Naziv'][$i].'"}',
				$x['parent_guid'][$i],
				$x['Naziv'][$i]
			);
		}
		
		$l_json = json_encode($la_data);
		
		print "updated::-x-x-::".$l_json;
	}else{
		print "error";
	}
	
?>
