<?
	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";
	include $g_path."u_log.php";
	
	
	$l_table = get_item('select meta_tablica_list.ime_tablice '.
		' from meta_prikaz, meta_tablica_list '.
		' where meta_prikaz.rbr_meta_tablica_list = meta_tablica_list.rbr '.
		' and meta_prikaz.ime = "'.$_GET['dest'].'" ', 0);
		
	$l_prikaz_rbr = get_item('select meta_prikaz.rbr '.
		' from meta_prikaz, meta_tablica_list '.
		' where meta_prikaz.rbr_meta_tablica_list = meta_tablica_list.rbr '.
		' and meta_prikaz.ime = "'.$_GET['dest'].'" ', 0);
		
	$l_kljuc = get_item('select distinct(ime_polja) '.
		' from meta_prikaz, meta_prikaz_item '.
		' where meta_prikaz.rbr = meta_prikaz_item.rbr_meta_prikaz '.
		' and meta_prikaz_item.rbr_meta_prikaz = '.$l_prikaz_rbr.
		' and kljuc = "PRI" limit 1');
	
	$l_sql = 'delete from '.$l_table.' where '.$l_kljuc.' = "'.$_GET['value'].'" ';
	$x = sql_exe($l_sql);
	
	$l_err = mysql_errno();
	//echo mysql_errno() . ": " . mysql_error() . "\n<br><br>";
	
	if($x){
			print "deleted";
			
			$l_log_sql = 'insert into meta_log_ajax values(0, '.$g_log_step.', 7, "'.addslashes($l_sql).'", '.$_SESSION['__id'].', now())';
			$g_log_ajax = sql_exe($l_log_sql, true);
			
			$l_log_sql = 'insert into meta_log_data values(0, '.$g_log_step.', '.$g_log_ajax.', 3, "'.addslashes($la_sql[$i]).'", '.$_SESSION['__id'].', now())';
			$g_log_data = sql_exe($l_log_sql, true);
	}else{
		if($l_err == 1451){
			print "foreign_key";
		}else{
			print "error";
		}
	}
	
?>
