<?
	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 folder ".
		" set FolderName = '".addslashes($_GET['naziv'])."' ".$l_ch_add.
		" where guid = '".$_GET['value']."' ");
	
	if($x){
		$la_data = array();
		$x = get_data('select B.guid, B.FolderName as Naziv, B.parent_guid
			from folder A RIGHT outer join folder B On A.guid = B.parent_guid
			order by A.FolderName, B.FolderName ', 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";
	}
	
?>
