<?
	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";
	
	$l_table = get_item('select meta_tablica_list.ime_tablice '.
		' from meta_forma, meta_tablica_list '.
		' where meta_forma.rbr_meta_tablica_list = meta_tablica_list.rbr '.
		' and meta_forma.rbr = '.$_GET['rbr']);
		
		
	//print $_GET['rbr'];
	
	$l_child = get_item('select rbr_meta_forma_child from meta_subforma where rbr_meta_forma = '.$_GET['rbr']);
	if($l_child){
		$l_table_child = get_item('select meta_tablica_list.ime_tablice '.
			' from meta_forma, meta_tablica_list '.
			' where meta_forma.rbr_meta_tablica_list = meta_tablica_list.rbr '.
			' and meta_forma.rbr = '.$l_child);
			
		if($l_table_child == 'receivings'){
			$l_table_child = 'receiving';
		}
		if($l_table_child == 'medjus'){
			$l_table_child = 'medju';
		}
	}
	
	//$_GET['parent_pk_rbr'] == 0 ? $var_value_document_guid = '_{get_last_inserted_id()}_' : $var_value_document_guid = $_GET['parent_pk_rbr'];
	//$_GET['parent_pk_rbr'] == 0 ? $var_value_zadatak_guid = '_{get_last_inserted_id()}_' : $var_value_zadatak_guid = $_GET['parent_pk_rbr'];
	
	
	//print $l_table_child;
	
	if($_GET['parent_pk_rbr'] == 0){
		$l_tmp = '$'.'var_value_'.$l_table_child.'_id = "_{get_last_inserted_id()}_"; ';
		eval($l_tmp);
	}else{
		$l_tmp = '$'.'var_value_'.$l_table_child.'_id = "'.$_GET['parent_pk_rbr'].'"; ';
		eval($l_tmp);
	}
	
	//print $l_tmp."<br><br>";
	//print $var_value_zadatak_guid;
	//exit;
	
	$l_tab_str = '_'.$_GET['tab_rbr'];
	
	$result = '<div class="subFormRedak">'.gen_tabs($_GET['rbr'], $_GET['default_tab'], $_GET['pk_rbr'], $l_table, $_GET['redak'], 1, zbroji($_GET['tab_rbr'])).'</div>'.
		'<div id="subformRedak'.zbroji($_GET['redak']).$l_tab_str.'"></div>';
		
	print $result;
?>
