<?php

if ( $_SESSION['IsAdmin'] )
{
	echo "<h1>Kontakt</h1>\n";
	if ( isset ( $_POST['formaction'] ) AND ( "Speichern" == $_POST['formaction'] ) ) {
		if (isset($_POST['ii'])) {
			$sql11 = 'UPDATE
						US
					SET
						Wert = "on"
					WHERE ID = "6";';
		} else {
			$sql11 = 'UPDATE
						US
					SET
						Wert = ""
					WHERE ID = "6";';
		}
			
		$stmt11 = $db->prepare($sql11);
		if (!$stmt11) {
			die ('Es konnte kein SQL-Query vorbereitet werden: '.$db->error);
		}
		if (!$stmt11->execute()) {
			die ('Query konnte nicht ausgeführt werden: '.$stmt11->error);
		}
		
		if (isset($_POST['vv'])) {
			$sql12 = 'UPDATE
						US
					SET
						Wert = "on"
					WHERE ID = "7";';
		} else {
			$sql12 = 'UPDATE
						US
					SET
						Wert = ""
					WHERE ID = "7";';
		}
			
		$stmt12 = $db->prepare($sql12);
		if (!$stmt12) {
			die ('Es konnte kein SQL-Query vorbereitet werden: '.$db->error);
		}
		if (!$stmt12->execute()) {
			die ('Query konnte nicht ausgeführt werden: '.$stmt12->error);
		}
	
		$sqls2 = 'UPDATE Uns SET
			Titel		= "'.$_POST['Titel'].'",
			Text		= "'.$_POST['Text'].'",
			Foto_Layout	= "'.$_POST['Foto_Layout'].'"
		WHERE ID = "3";';
		$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";
	}
	$sql2		= "SELECT Titel, Text, Foto_Layout FROM Uns WHERE ID = \"3\" ";
	$result2	= $db->query($sql2);
	$nt2		= $result2->fetch_assoc();
	
	$uploaddir = "../img/team/";
	if ("oben" == $nt2['Foto_Layout']) {
		$newwidth = 690;
		$filename = "../img/team/ko_oben.jpg";
	} elseif (("links" == $nt2['Foto_Layout']) OR ("rechts" == $nt2['Foto_Layout'])) {
		$newwidth = 300;
		$filename = "../img/team/ko.jpg";
	} else {
		$filename = "";
	}
	
	include "inhalte/einfoto.php";
	
	echo "<form action=\"index.php?".$_SERVER['QUERY_STRING']."\" method=\"post\">\n";
	echo "	<label>Layout</label>\n";
	echo "	<input type=\"radio\" name=\"Foto_Layout\" value=\"ohne\" ";
	if ("ohne" == $nt2['Foto_Layout']) {
		echo "checked=\"checked\" ";
	}
	echo "/>ohne Foto \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/ko_ohne.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	<label>&nbsp;</label>\n";
	echo "	<input type=\"radio\" name=\"Foto_Layout\" value=\"links\" ";
	if ("links" == $nt2['Foto_Layout']) {
		echo "checked=\"checked\" ";
	}
	echo "/>Foto links \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/ko_links.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	<label>&nbsp;</label>\n";
	echo "	<input type=\"radio\" name=\"Foto_Layout\" value=\"rechts\" ";
	if ("rechts" == $nt2['Foto_Layout']) {
		echo "checked=\"checked\" ";
	}
	echo "/>Foto rechts \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/ko_rechts.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	<label>&nbsp;</label>\n";
	echo "	<input type=\"radio\" name=\"Foto_Layout\" value=\"oben\" ";
	if ("oben" == $nt2['Foto_Layout']) {
		echo "checked=\"checked\" ";
	}
	echo "/>Foto oben \n";
	echo "<a>\n";
	echo "	<img class=\"drueber\" src=\"../img/help.gif\" />\n";
	echo "	<img class=\"drunter\" src=\"img/ko_oben.jpg\" />\n";
	echo "</a>\n";
	echo "	<br />\n";
	echo "	&nbsp;<br />\n";
	echo "	<label>Überschrift</label>\n";
	echo "	<input type=\"text\" name=\"Titel\" value=\"".$nt2['Titel']."\" />\n";
	echo "	<br />\n";
	echo "	<label>Einleitender Text</label>\n";
	echo "	<br />\n";
	echo "	<textarea name=\"Text\" rows=\"5\">".$nt2['Text']."</textarea>\n";
	echo "	<br />\n";
	echo "	&nbsp;<br />\n";
/*
	$sql3		= "SELECT Kurz, Name, Wert FROM US WHERE Sektion = \"kontakt\" ORDER BY ID ASC";
	$result3	= $db->query($sql3);

	echo "<fieldset>\n";
	echo "<legend>Formularservice</legend>\n";
	echo "	<p>Folgende Formulate können auf der Kontaktseite verlinkt werden:</p>\n";
	while ($nt3 = $result3->fetch_assoc()) {
		echo "	<label>".$nt3['Name']."</label>\n";
		echo "	<input type=\"checkbox\" name=\"".$nt3['Kurz']."\" ";
		if ("on" == $nt3['Wert']) {
			echo "checked=\"checked\" ";
		}
		echo " />\n";
		echo "	<br />\n";
	}
	echo "</fieldset>\n";
*/
	echo "	&nbsp;<br />\n";
	echo "	<input type=\"submit\" name=\"formaction\" value=\"Speichern\" />\n";
	echo "	<input type=\"reset\" value=\"Rücksetzen\" />\n";
	echo "</form>\n";
		
}

?>