<?
	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";
	
	$uuid = get_item('SELECT UUID() as uuid');
	
	$x = sql_exe("insert into folder values('".$uuid."', '".$uuid."', '".$uuid."', '', now(), '', '".addslashes($_GET['naziv'])."', '', '', now(), '', '', '', 0, '".$_GET['value']."') ");
	
	print "insert into folder values('".$uuid."', '".$uuid."', '".$uuid."', '', now(), '', '".addslashes($_GET['naziv'])."', '', '', now(), '', '', '', 0, '".$_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 "inserted::-x-x-::".$l_json;
	}else{
		print "error";
	}
	
?>
