<?php
if ("" != $_POST['Feld1_Name'])
{
	$Feld1 = "Feld1 = \"" . $_POST['Feld1_Lvs'] . $_POST['Feld1_Ang'] . $_POST['Feld1_Best'] . $_POST['Feld1_Rech'] . $_POST['Feld1_Liefer'] . $_POST['Feld1_Gut'] . "\",";
}
else
{
	$Feld1 = "";
}
if ("" != $_POST['Feld2_Name'])
{
	$Feld2 = "Feld2 = \"" . $_POST['Feld2_Lvs'] . $_POST['Feld2_Ang'] . $_POST['Feld2_Best'] . $_POST['Feld2_Rech'] . $_POST['Feld2_Liefer'] . $_POST['Feld2_Gut'] . "\",";
}
else
{
	$Feld2 = "";
}
if ("" != $_POST['Feld3_Name'])
{
	$Feld3 = "Feld3 = \"" . $_POST['Feld3_Lvs'] . $_POST['Feld3_Ang'] . $_POST['Feld3_Best'] . $_POST['Feld3_Rech'] . $_POST['Feld3_Liefer'] . $_POST['Feld3_Gut'] . "\",";
}
else
{
	$Feld3 = "";
}
if ("" != $_POST['Feld4_Name'])
{
	$Feld4 = "Feld4 = \"" . $_POST['Feld4_Lvs'] . $_POST['Feld4_Ang'] . $_POST['Feld4_Best'] . $_POST['Feld4_Rech'] . $_POST['Feld4_Liefer'] . $_POST['Feld4_Gut'] . "\",";
}
else
{
	$Feld4 = "";
}
if ("" != $_POST['Feld5_Name'])
{
	$Feld5 = "Feld5 = \"" . $_POST['Feld5_Lvs'] . $_POST['Feld5_Ang'] . $_POST['Feld5_Best'] . $_POST['Feld5_Rech'] . $_POST['Feld5_Liefer'] . $_POST['Feld5_Gut'] . "\",";
}
else
{
	$Feld5 = "";
}
$sql = "UPDATE Firma SET
				Firma_Name =	\"" . $_POST['Firma_Name'] . "\",
				Firma_Zusatz =	\"" . $_POST['Firma_Zusatz'] . "\",
				Vertreter =		\"" . $_POST['Vertreter'] . "\",
				Adresse =		\"" . $_POST['Adresse'] . "\",
				PLZ =			\"" . $_POST['PLZ'] . "\",
				Ort =			\"" . $_POST['Ort'] . "\",
				Telefon =		\"" . $_POST['Telefon'] . "\",
				Mobil =			\"" . $_POST['Mobil'] . "\",
				Email =			\"" . $_POST['Email'] . "\",
				Homepage =		\"" . $_POST['Homepage'] . "\",
				Bank1 =			\"" . $_POST['Bank1'] . "\",
				BLZ1 =			\"" . $_POST['BLZ1'] . "\",
				Konto1 =		\"" . $_POST['Konto1'] . "\",
				Bank2 =			\"" . $_POST['Bank2'] . "\",
				BLZ2 =			\"" . $_POST['BLZ2'] . "\",
				Konto2 =		\"" . $_POST['Konot2'] . "\",
				Steuernummer =	\"" . $_POST['Steuernummer'] . "\",
				Gerichtsstand =	\"" . $_POST['Gerichtsstand'] . "\",
				Feld =			\"" . $_POST['Feld'] . "\",
				Anzeige_Browser = \"" . $_POST['Anzeige_Browser'] . "\",
				ASP =			\"" . $_POST['ASP'] . "\",
				MwSt =			\"" . $_POST['MwSt'] . "\",
				A_Bis =			\"" . $_POST['A_Bis'] . "\",
				Z_Bis =			\"" . $_POST['Z_Bis'] . "\",
				Zins =			\"" . $_POST['Zins'] . "\",
				Gebuehr =		\"" . $_POST['Gebuehr'] . "\",
				S_Bis =			\"" . $_POST['S_Bis'] . "\",
				Skonto =		\"" . addslashes($_POST['Skonto']) . "\",
				Stellen =		\"" . $_POST['Stellen'] . "\",
				Gruss =			\"" . addslashes($_POST['Gruss']) . "\",
				Email_Kopie =	\"" . $_POST['Email_Kopie'] . "\",
				Email_Signatur =\"" . addslashes($_POST['Email_Signatur']) . "\",
				" . $Feld1 . "
				" . $Feld2 . "
				" . $Feld3 . "
				" . $Feld4 . "
				" . $Feld5 . "
				Feld1_Name =	\"" . $_POST['Feld1_Name'] . "\",
				Feld2_Name =	\"" . $_POST['Feld2_Name'] . "\",
				Feld3_Name =	\"" . $_POST['Feld3_Name'] . "\",
				Feld4_Name =	\"" . $_POST['Feld4_Name'] . "\",
				Feld5_Name =	\"" . $_POST['Feld5_Name'] . "\",
				F1_Red =		\"" . $_POST['F1_Red'] . "\",
				F1_Green =		\"" . $_POST['F1_Green'] . "\",
				F1_Blue =		\"" . $_POST['F1_Blue'] . "\",
				F2_Red =		\"" . $_POST['F2_Red'] . "\",
				F2_Green =		\"" . $_POST['F2_Green'] . "\",
				F2_Blue =		\"" . $_POST['F2_Blue'] . "\",
				UStG_13 =		\"" . $_POST['UStG_13'] . "\"
			WHERE ID = \"" . PREFIX . "\";";
$stmt = $db->prepare($sql);
if (!$stmt)
{
	die ('Datensatz konnte nicht gespeichert werden: ' . $db->error);
}
if (!$stmt->execute())
{
	die ('Datensatz konnte nicht gespeichert werden: ' . $stmt->error);
}
echo "<h2>Daten wurden gespeichert</h2>\n";
$sql = "SELECT * FROM Firma WHERE ID = \"" . PREFIX . "\";";
$result = $db->query($sql);
$nt = $result->fetch_assoc();
unset($_SESSION['Firma']);
$_SESSION['Firma'] = $nt;

include __DIR__ . "/stamm_fd_edit.php";