Files
startup/inhalte/neue_firma_reminder.php

149 lines
3.9 KiB
PHP

<?php
if ("start_00" == $_POST['prod'])
{
$month_cost = 10 / 1.19;
$type = "StartUp! ohne Werbung";
}
elseif ("start_01" == $_POST['prod'])
{
$month_cost = 7.5 / 1.19;
$type = "StartUp! mit Werbung im Fußbereich";
}
elseif ("start_02" == $_POST['prod'])
{
$month_cost = 5 / 1.19;
$type = "StartUp! mit Werbung im Kopfbereich";
}
$ein_cost = 0;
if ("3" == $_POST['Zahlung'])
{
$month_cost = $month_cost * 1.2;
$ein_cost = 10 / 1.19;
}
elseif ("6" == $_POST['Zahlung'])
{
$month_cost = $month_cost * 1.1;
$ein_cost = 5 / 1.19;
}
if ("Post" == $_POST['Versand'])
{
$send_cost = 5 / 1.19;
}
else
{
$send_cost = 0;
}
$cost = $month_cost * $_POST['Zahlung'] + $send_cost;
$rech_cost = $cost + $ein_cost;
$sql = "INSERT INTO 1001_Kontakte (ID, Firma, Anrede, Vorname, Nachname, Strasse, Nummer, PLZ, Ort, Land, Telefon, Mobil, Email, DSchutz, Datum) VALUES
(NULL,
'" . $_POST['Firma_Name'] . "',
'" . $_POST['Anrede'] . "',
'" . $_POST['Vorname'] . "',
'" . $_POST['Nachname'] . "',
'" . $_POST['Strasse'] . "',
'" . $_POST['Nummer'] . "',
'" . $_POST['PLZ'] . "',
'" . $_POST['Ort'] . "',
'" . $_POST['Land'] . "',
'" . $_POST['Telefon'] . "',
'" . $_POST['Mobil'] . "',
'" . $_POST['Email'] . "',
'1',
CURDATE());";
$stmt = $db->prepare($sql);
if (!$stmt)
{
die('Kunde konnte nicht angelegt werden: ' . $db->error);
}
if (!$stmt->execute())
{
die('Kunde konnte nicht angelegt werden: ' . $stmt->error);
}
$sql = 'SELECT last_insert_id() AS last';
$result = $db->query($sql);
$nt = $result->fetch_assoc();
$Kont_ID = $nt['last'];
$sql = "INSERT INTO 1001_Reminder (Jahr, ID, Kontakt_ID, Preis, MwSt, Datum) VALUES
(YEAR(CURDATE()),
NULL,
'" . $Kont_ID . "',
'" . $cost . "',
'19',
DATE_ADD(CURDATE(), INTERVAL " . $_POST['Zahlung'] . " MONTH));";
$stmt = $db->prepare($sql);
if (!$stmt)
{
die('Rechnung konnte nicht angelegt werden: ' . $db->error);
}
if (!$stmt->execute())
{
die('Rechnung konnte nicht angelegt werden: ' . $stmt->error);
}
$sql = 'SELECT last_insert_id() AS last';
$result = $db->query($sql);
$nt = $result->fetch_assoc();
$Rem_ID = $nt['last'];
$sql = "INSERT INTO 1001_Reminder_Pos (ID, Jahr, Reminder_ID, Position, Anzahl, Bezeichnung, Preis) VALUES
(NULL, YEAR(CURDATE()), '" . $Rem_ID . "', '1', '" . $_POST['Zahlung'] . "', '" . $type . "', '" . $month_cost . "')";
if ("Post" == $_POST['Versand'])
{
$sql .= ",(NULL, YEAR(CURDATE()), '" . $Rem_ID . "', '2', '1', 'Postversand', '" . $send_cost . "')";
}
$sql .= ";";
$stmt = $db->prepare($sql);
if (!$stmt)
{
die('Rechnung konnte nicht angelegt werden: ' . $db->error);
}
if (!$stmt->execute())
{
die('Rechnung konnte nicht angelegt werden: ' . $stmt->error);
}
$sql = "INSERT INTO 1001_Rechnungen (Jahr, ID, Kontakt_ID, Schluss_Rechnung, Preis, MwSt, Datum) VALUES
(YEAR(CURDATE()),
NULL,
'" . $Kont_ID . "',
'1',
'" . $rech_cost . "',
'19',
CURDATE());";
$stmt = $db->prepare($sql);
if (!$stmt)
{
die('Rechnung konnte nicht angelegt werden: ' . $db->error);
}
if (!$stmt->execute())
{
die('Rechnung konnte nicht angelegt werden: ' . $stmt->error);
}
$sql = 'SELECT last_insert_id() AS last';
$result = $db->query($sql);
$nt = $result->fetch_assoc();
$Rech_ID = $nt['last'];
$sql = "INSERT INTO 1001_Rechnung_Pos (ID, Jahr, Rechnung_ID, Position, Anzahl, Bezeichnung, Preis) VALUES
(NULL, YEAR(CURDATE()), '" . $Rech_ID . "', '1', '" . $_POST['Zahlung'] . "', '" . $type . "', '" . $month_cost . "')";
if ("Post" == $_POST['Versand'])
{
$sql .= ",(NULL, YEAR(CURDATE()), '" . $Rech_ID . "', '2', '1', 'Postversand', '" . $send_cost . "')";
}
if ("0" != $ein_cost)
{
$sql .= ",(NULL, YEAR(CURDATE()), '" . $Rech_ID . "', '3', '1', 'Einrichtungsgebühr', '" . $ein_cost . "')";
}
$sql .= ";";
$stmt = $db->prepare($sql);
if (!$stmt)
{
die('Kunde konnte nicht angelegt werden: ' . $db->error);
}
if (!$stmt->execute())
{
die('Kunde konnte nicht angelegt werden: ' . $stmt->error);
}