<?php
if (!in_array("Stammdaten", $_SESSION['Rechte'])) {
	exit(ZUGRIFF_ERROR);
}
if (!isset($_SESSION['ID'])) {
} else {
	echo "<h1>Firmenlogo / Header</h1>\n";
	
	if ("Speichern" == $_POST['action']) {
		$sqls1 = 'UPDATE US SET
			Wert		= "'.$_POST['Wert'].'"
		WHERE ID = "5";';
		$stmts1		= $db->prepare($sqls1);
		if (!$stmts1) {
			die ('Datensatz konnte nicht gespeichert werden: '.$db->error);
		}
		if (!$stmts1->execute()) {
			die ('Datensatz konnte nicht gespeichert werden: '.$stmts1->error);
		}
		if (isset($_POST['Nr1'])) {
			$sqls2 = 'UPDATE Header SET
				Nr1		= "'.$_POST['Nr1'].'",
				Nr2		= "'.$_POST['Nr2'].'",
				Nr3		= "'.$_POST['Nr3'].'",
				Nr4		= "'.$_POST['Nr4'].'"
			WHERE ID = "1";';
			$stmts2		= $db->prepare($sqls2);
			if (!$stmts2) {
				die ('Datensatz konnte nicht gespeichert werden: '.$db->error);
			}
			if (!$stmts2->execute()) {
				die ('Datensatz konnte nicht gespeichert werden: '.$stmts2->error);
			}
		}
		echo "<p class=\"hinweis\">Die Daten wurden gespeichert!</h2>\n";
	}
	
	$sql		= "SELECT Wert FROM US WHERE Sektion = \"header\" AND Name = \"Header\";";
	$result		= $db->query($sql);
	$nt			= $result->fetch_assoc();
	$uploaddir = "../img/";
	if ("breit" == $nt['Wert']) {
		$filename = "../img/hl_breit.jpg";
		$newwidth = 950;
	} elseif ("schmal" == $nt['Wert']) {
		$filename = "../img/hl_schmal.jpg";
		$newwidth = 230;
	}
	include "inhalte/einfoto.php";
	
	
	echo "<br />\n";
	echo "<form action=\"index.php?".$_SERVER['QUERY_STRING']."\" method=\"post\" >\n";
	echo "<fieldset>\n";
	echo "<legend>Layout</legend>\n";
	echo "	<p>Die Auswahl der Menüpunkte 1 bis 4 wirkt sich nur bei der Layoutoption <span class=\"hinweis\">schmales Logo</span> im Headerbereich aus!</p>\n";
	echo "	<label>Layout</label>\n";
	echo "	<input type=\"radio\" name=\"Wert\" value=\"schmal\" ";
	if ("schmal" == $nt['Wert']) {
		echo "checked=\"checked\" ";
	}
	echo "/>schmales Logo \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/hl_schmal.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	<label>&nbsp;</label>\n";
	echo "	<input type=\"radio\" name=\"Wert\" value=\"breit\" ";
	if ("breit" == $nt['Wert']) {
		echo "checked=\"checked\" ";
	}
	echo "/>breites Logo \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/hl_breit.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	&nbsp;<br />\n";
	$sql1		= "SELECT Nr1, Nr2, Nr3, Nr4 FROM Header WHERE ID = \"1\";";
	$result1	= $db->query($sql1);
	$nt1		= $result1->fetch_assoc();
	for ($i=1; $i<5; $i++) {
		echo "	<label>Menüpunkt ".$i."</label>\n";
		echo "	<select name=\"Nr".$i."\" >\n";
		echo "		<option value=\"0\">Kein</option>\n";
		$sqlh		= "SELECT ID, Name FROM HRubriken ORDER BY ID ASC;";
		$resulth	= $db->query($sqlh);
		while ($nth = $resulth->fetch_assoc()) {
			echo "		<option value=\"".$nth['ID']."\"";
			if ($nth['ID'] == $nt1['Nr'.$i]) {
				echo " selected=\"selected\"";
			}
			echo " >".$nth['Name']."</option>\n";
		}
		echo "	</select>\n";
		echo "	<br />\n";
	}
	echo "	&nbsp;<br />\n";
	echo "	<input type=\"submit\" name=\"action\" value=\"Speichern\" />\n";
	echo "</fieldset>\n";
	echo "</form>\n";
	
	
}
?>