<?php
@session_start();

if ( ( $_SESSION[ "benutzer_anmeldename" ] == "superuser" ) and ( $_SESSION[ "mandant_name" ] == "Standard" ) )
{
	header( "Location: su_uebersicht.php" );
	exit;
}



//$benutzer_anmeldename = $_SESSION[ "benutzer_anmeldename" ];

if ( strlen( $_SESSION[ "benutzer_anmeldename" ] ) > 0 )
{
	include_once( "f_admin.php" );
	include_once( "f_wfl.php" );
	
	$benutzer = liefere_benutzerinformationen( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ] );
	
	////////////////////////////////////////
	// Javascript-Dateien
	$_SESSION[ "javascript_dateien" ] = "jquery.dataTables.min.js|globalize.js|globalize.culture.de-DE.js|jquery.fancybox.pack.js?v=2.1.5|jstree.min.js";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// Javascript-Startup
	$_SESSION[ "javascript_startup" ] = '$(function() { $( "#dialogconfirm" ).dialog({ autoOpen: false, width: 600, modal: true, buttons: { "\"'.$_SESSION[ "fav_ordnername" ].'\" löschen": function() { window.location.href=\'su_web.php?cmd=favoritenordner_loeschen&alpha_01='.urlencode( $_SESSION[ "mandant_name" ] ).'&alpha_02='.urlencode( $_SESSION[ "benutzer_anmeldename" ] ).'&alpha_03='.urlencode( $_SESSION[ "fav_ordnername" ] ).'\'; },
"Abbrechen": function() { $( this ).dialog( "close" ); } } }); $( "#opener" ).click(function() { $( "#dialogconfirm" ).dialog( "open" ); }); });';
	////////////////////////////////////////
	
	////////////////////////////////////////
	// CSS-Dateien
	$_SESSION[ "css_dateien" ] = "jquery.fancybox.css?v=2.1.5|style.jstree.css|jquery.dataTables_themeroller.css|jquery.dataTables.min.css";
	////////////////////////////////////////
	

	$_SESSION[ "title" ] = "Favoriten von ".$benutzer[ 2 ][ "benutzer_name" ];
	include( 'ssi_header.php' );
	$_SESSION[ "title" ] = "";
	
	////////////////////////////////////////
	// Javascript-Dateien
	$_SESSION[ "javascript_dateien" ] = "";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// Javascript-Startup
	$_SESSION[ "javascript_startup" ] = "";
	////////////////////////////////////////
	
	////////////////////////////////////////
	// CSS-Dateien
	$_SESSION[ "css_dateien" ] = "style.jstree.css";
	////////////////////////////////////////
	
	//onclick=\"$( '#ergebnis_3' ).load('su_web.php?cmd=benutzer_anlegen', function() { $( '.date-pick' ).datepicker({ showAnim: 'clip', buttonImageOnly: true,  showOn: 'both', buttonImage: 'img/kalender.png', showWeek: true } ); } );
	
	
	if ( $_SESSION[ "fav_ordnername" ] == "" )
	{
		$_SESSION[ "fav_ordnername" ] = "root";
	}
	//$_SESSION[ "fav_ordnername" ] = "root";
	
	//xlog( 5, "Ordnername: ".$_SESSION[ "fav_ordnername" ] );
	
	$us_rech_imp_button = liefere_benutzerspezifische_einstellung( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], "us_rech_imp_button" );
	
	if ( $us_rech_imp_button == "ja" )
	{
		echo "<div style='margin-left:200px; padding-bottom:30px;  min-height:550px;'  >";
		include( "us_menu.php" );
	}
	else
	{
		echo "<div style='margin-left:20px; padding-bottom:30px;  min-height:550px;'  >";
	}
	/*
	
	
	
	
	*/
	$zstr = liefere_zufaelligen_string( );
	
	echo "<h2>Favoriten von <i>".$name."</i></h2>";
	
	
	echo "<hr style='margin-top:30px;' />";
	
	
	
	
	if ( $_SESSION[ "fav_ordnername" ] == "root" )
	{
		$ordner_top = "<form name='fav_ordner_anlegen' action='su_web.php?cmd=fav_ordner_anlegen' method='post' > <input type='hidden' name='alpha_01' value='".$_SESSION[ "mandant_name" ]."' /><input type='hidden' name='alpha_02' value='".$_SESSION[ "benutzer_anmeldename" ]."' /><input type='hidden' name='alpha_03' value='".$_SESSION[ "fav_ordnername" ]."' />Ordnername: <input type='text' name='alpha_04' maxlength='20' style='height:90%; width:200px;'/><input type='submit' value='Ordner anlegen'></form>";
	}
	else
	{
		$ordner_top = "<div id='dialogconfirm' title='Ordner ".$_SESSION[ "fav_ordnername" ]." löschen?' ><p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>Soll der Ordner <b>".$_SESSION[ "fav_ordnername" ]."</b> gelöscht werden? (Favoriten in diesem Ordner werden dann ebenfalls gelöscht!)</p>
</div><input type='button' id='opener' value='Ordner ".$_SESSION[ "fav_ordnername" ]." löschen' />";
	}
	
	echo "<div id='ordner_top' style='display:inline;'>".$ordner_top."</div>";
	echo "<hr />";
	echo "<h4>Ordnerliste</h4>";
	
	$ergebnis = liefere_favoriten_ordner( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], $_SESSION[ "fav_ordnername" ] );
	
	if ( $ergebnis[ 0 ] == 0 )
	{
		if ( $_SESSION[ "fav_ordnername" ] != "root" )
		{
			echo "<td><form name='benutzer_aendern' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='root' /><input type='submit' style='width:180px; height:40px;' value='zum Hauptordner' ></form></td>";
		}
		else
		{
			echo "<p>Derzeit sind keine Ordner angelegt.</p>";
		}
	}
	else
	{
		echo "<table><tr>";
		if ( $_SESSION[ "fav_ordnername" ] != "root" )
		{
			/*echo "<td>";
			$e = explode( "|", $_SESSION[ "fav_ordnername" ] );
			
			foreach ( $e as $pfadeintrag )
			{
				if ( $pfadeintrag == "root" )
				{
					$wert = "/";
				}
				else
				{
					$wert = $pfadeintrag;
				}
				
				echo "<form name='ordner_wechseln' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='".$pfadeintrag."' /><input type='submit' style='width:80px; height:40px;' value='".$wert."' ></form>";
				
			}
			echo "</td>";*/
			echo "<td><form name='ordner_wechseln' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='root' /><input type='submit' style='width:80px; height:40px;' value='/' ></form></td>";
		}
		foreach ( $ergebnis[ 2 ] as $ordner )
		{
			//echo "Ordnername: ".$ordner[ "ordnername" ]." ansicht ".$ordner[ "ansicht" ]."</br>";
			
			$k = strlen( $ordner[ "ordnername" ] );
			/*
			if ( $k <= 8 )
			{			
				//echo "<input type='button' style='width:80px; height:40px;' value='".$ordner[ "ordnername" ]."' onclick='ajaxFunction_2( \"su_web.php?cmd=oeffne_fav_ordner&alpha_01=".urlencode( $ordner[ "ordnername" ] )."\" ); document.location.href=\"us_favoriten.php\";' />";
				echo "<td><form name='benutzer_aendern' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='".urlencode( $ordner[ "ordnername" ] )."' /><input type='hidden' name='alpha_02' value='".urlencode( $_SESSION[ "fav_ordnername" ] )."' /><input type='submit' style='width:80px; height:40px;' value='".$ordner[ "ordnername" ]."' ></form></td>";
			}
			else
			*/	
			if ( $k <= 12 )
			{
				echo "<td><form name='benutzer_aendern' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='".$ordner[ "ordnername" ]."' /><input type='submit' style='width:140px; height:40px;' value='".$ordner[ "ordnername" ]."' ></form></td>";
			}
			else
			{
				echo "<td><form name='benutzer_aendern' action='su_web.php?cmd=oeffne_fav_ordner' method='post'><input type='hidden' name='alpha_01' value='".$ordner[ "ordnername" ]."' /><input type='submit' style='width:280px; height:40px;' value='".$ordner[ "ordnername" ]."' ></form></td>";
			}
			
		}
		echo "</tr></table>";
	}
	echo "<hr style='margin-top:20px;' />";
	
	echo "<h4>Favoriten</h4>";
	
	$fav_ansicht = liefere_benutzerspezifische_einstellung( $_SESSION[ "mandant_name" ], $_SESSION[ "benutzer_anmeldename" ], "favordner_ansicht_".$_SESSION[ "fav_ordnername" ] );
	
	if ( $fav_ansicht == "" )
	{
		$fav_ansicht = "Liste";
	}
	
	switch( $fav_ansicht )
	{
		case "Liste":
			$liste_aktiv		= "checked";
			$miniatur_aktiv		= "";
			break;
		case "verkleinerte Darstellung":
			$liste_aktiv		= "";
			$miniatur_aktiv		= "checked";
			break;
	}
	
	
	echo "
	<div id='fav_ansicht' style='display:inline;'>
	<input type='radio' name='fav_ansicht_radio' onclick='$( \"#favoriten\" ).load( \"su_web.php?cmd=lade_favoriten&alpha_01=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=".urlencode( $_SESSION[ "benutzer_anmeldename" ] )."&alpha_03=".urlencode( $_SESSION[ "fav_ordnername" ] )."&alpha_04=Liste\" );' ".$liste_aktiv." >Liste</input>
	<input type='radio' name='fav_ansicht_radio' onclick='$( \"#favoriten\" ).load( \"su_web.php?cmd=lade_favoriten&alpha_01=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=".urlencode( $_SESSION[ "benutzer_anmeldename" ] )."&alpha_03=".urlencode( $_SESSION[ "fav_ordnername" ] )."&alpha_04=".urlencode( "verkleinerte Darstellung" )."\" );' ".$miniatur_aktiv." >verkleinerte Darstellung</input>
	</div>
	<br/>
	<div id='favoriten' style='margin-top:15px;'>Lade Favoriten ...</div>
	<script>$( \"#favoriten\" ).load( \"su_web.php?cmd=lade_favoriten&alpha_01=".urlencode( $_SESSION[ "mandant_name" ] )."&alpha_02=".urlencode( $_SESSION[ "benutzer_anmeldename" ] )."&alpha_03=".urlencode( $_SESSION[ "fav_ordnername" ] )."&alpha_04=".urlencode( $fav_ansicht )."\" );</script>
	
	<div id='dokumentanzeige' style='min-height:500px;' ></div>
	
	";
	
	
	
	echo '<div name="ergebnis_3" id="ergebnis_3" style=" display:hidden; margin-top:10px;" >'.$_SESSION[ "meldung_ad" ].'</div>';
	$_SESSION[ "meldung_ad" ] = "";
	
	
	?>
	
	
	<?php
	
	echo '</div>';
	
	
	echo "<p style='clear:both;' />";
	include( 'ssi_footer.php' );

}
else
{
	header("Location: index.php");
}
?>      