Datenstand V1.0

This commit is contained in:
2016-07-05 20:38:34 +00:00
parent 5a75f609e5
commit 5ea463a308
1027 changed files with 141480 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
<?php
$sql = "SELECT * FROM ".PREFIX."_Rechnungen WHERE (Auftrag_Jahr = \"".$Jahr."\" AND Auftrag_ID = \"".$ID."\");";
$result = $db->query($sql);
while ($nt = $result->fetch_assoc()) {
while (strlen($nt['ID']) < $_SESSION['Firma']['Stellen']) {
$nt['ID'] = "0".$nt['ID'];
}
if ($nt['Schluss_Rechnung']) {
exit("<h1>Zu dieser Auftragsbestätigung existiert bereits eine Abschluss-Rechnung mit der Nummer: ".$nt['Jahr']."_".$nt['ID']."!</h1>");
} else {
if (isset($_POST['Rechnung']) AND ("VK" == $_POST['Rechnung'])) {
if ($nt['Vorkasse']) {
exit("<h1>Zu dieser Auftragsbestätigung existiert bereits eine Vorkasse-Rechnung mit der Nummer: ".$nt['Jahr']."_".$nt['ID']."!</h1>");
}
}
}
}
if (!isset($_POST['step'])) {
echo "<fieldset>\n";
echo " <legend>Rechnungstyp festlegen</legend>\n";
echo " <form action=\"index.php?".$_SERVER['QUERY_STRING']."\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"step\" value=\"1\" />\n";
echo " <input type=\"hidden\" name=\"ID\" value=\"".$_POST['ID']."\" />\n";
echo " <input type=\"radio\" name=\"Rechnung\" value=\"VK\" />Vorkasserechnung<br />\n";
echo " <input type=\"radio\" name=\"Rechnung\" value=\"AZ\" />Abschlagzahlung<br />\n";
echo " <input type=\"radio\" name=\"Rechnung\" value=\"SR\" />Schlussrechnung<br />\n";
echo " <input type=\"submit\" class=\"button_ok\" name=\"formaction\" value=\"rcreate\" title=\"Weiter\" />\n";
echo " <a href=\"index.php?section=".$_GET['section']."\"><img src=\"img/stop.png\" alt=\"Abbrechen\" title=\"Abbrechen\" /></a>\n";
echo " <br />\n";
echo " </form>\n";
echo "</fieldset>\n";
} else {
if ("VK" == $_POST['Rechnung']) {
$VK = 1;
$SR = 0;
} elseif ("SR" == $_POST['Rechnung']) {
$VK = 0;
$SR = 1;
} else {
$VK = 0;
$SR = 0;
}
$sql = "SELECT * FROM ".PREFIX."_Auftraege WHERE (Jahr = \"".$Jahr."\" AND ID = \"".$ID."\");";
$result = $db->query($sql);
$nt = $result->fetch_assoc();
echo "<br />\n";
$sql = 'INSERT INTO '.PREFIX.'_Rechnungen (Jahr, ID, Kontakt_ID, Auftrag_Jahr, Auftrag_ID, Admin_ID, Vorkasse, Schluss_Rechnung, MwSt, Text, Datum) VALUES (YEAR(CURDATE()), NULL, "'.$nt['Kontakt_ID'].'", "'.$Jahr.'", "'.$ID.'", "'.$nt['Admin_ID'].'", "'.$VK.'", "'.$SR.'", "'.$nt['MwSt'].'", "'.addslashes(stripslashes($nt['Text'])).'", CURDATE())';
$stmt = $db->prepare($sql);
if (!$stmt) {
die ('Datensatz konnte nicht angelegt werden: '.$db->error);
}
if (!$stmt->execute()) {
die ('Datensatz konnte nicht angelegt werden: '.$stmt->error);
}
$sql = 'SELECT last_insert_id() AS last';
$result = $db->query($sql);
$nttemp = $result->fetch_assoc();
$ID_New = $nttemp['last'];
if ($SR) {
$sqlp = "SELECT * FROM ".PREFIX."_Auftrag_Pos WHERE (Jahr = \"".$Jahr."\" AND Auftrag_ID = \"".$ID."\");";
$resultp = $db->query($sqlp);
while ($ntp = $resultp->fetch_assoc()) {
$sql = "INSERT INTO ".PREFIX."_Rechnung_Pos (ID, Jahr, Rechnung_ID, Position, Anzahl, Bezeichnung, Preis, Feld1, Feld2, Feld3, Feld4, Feld5) VALUES (NULL, YEAR(CURDATE()), \"".$ID_New."\", \"".$ntp['Position']."\", \"".$ntp['Anzahl']."\", \"".addslashes(stripslashes($ntp['Bezeichnung']))."\", \"".$ntp['Preis']."\", \"".addslashes(stripslashes($ntp['Feld1']))."\", \"".addslashes(stripslashes($ntp['Feld2']))."\", \"".addslashes(stripslashes($ntp['Feld3']))."\", \"".addslashes(stripslashes($ntp['Feld4']))."\", \"".addslashes(stripslashes($ntp['Feld5']))."\");";
$stmt = $db->prepare($sql);
if (!$stmt) {
die ('Datensatz konnte nicht angelegt werden: '.$db->error);
}
if (!$stmt->execute()) {
die ('Datensatz konnte nicht angelegt werden: '.$stmt->error);
}
}
}
echo "<fieldset>\n";
echo " <legend>Rechnung wurde erstellt</legend>\n";
echo " <form action=\"index.php?section=rechnung\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"ID\" value=\"".date("Y")."_".$ID_New."\" />\n";
echo " <input type=\"submit\" class=\"button_edit\" name=\"formaction\" value=\"edit\" title=\"Rechnung bearbeiten\" />\n";
echo " </form>\n";
echo "</fieldset>\n";
}
?>