Files
startup/inhalte/kontakt_show.php

381 lines
14 KiB
PHP

<?php
$sql = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum , DATE_FORMAT(Geb_Datum, '%d.%m.%Y') AS Geb_Datum FROM " . PREFIX . "_Kontakte WHERE ID = \"" . $_POST['ID'] . "\";";
$result = $db->query($sql);
$nt = $result->fetch_assoc();
echo "<fieldset>\n";
echo " <legend>";
if ("" != $nt['Firma'])
{
echo $nt['Firma'];
}
else
{
echo $nt['Anrede'] . " " . $nt['Vorname'] . " " . $nt['Nachname'];
}
echo "</legend>\n";
echo " <h2>Kunde seit: " . $nt['Datum'] . "</h2>\n";
echo " <label>Kundennummer:</label><label class=\"data\">" . $nt['ID'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Firma:</label><label class=\"data\">" . $nt['Firma'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Anrede:</label><label class=\"data\">" . $nt['Anrede'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Name:</label><label class=\"data\">" . $nt['Vorname'] . " " . $nt['Nachname'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Adresse:</label><label class=\"data\">" . $nt['Strasse'] . " " . $nt['Nummer'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Ort:</label><label class=\"data\">" . $nt['PLZ'] . " " . $nt['Ort'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Land:</label><label class=\"data\">" . $nt['Land'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Geburtsdatum:</label><label class=\"data\">" . $nt['Geb_Datum'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " &nbsp;<br />\n";
echo " <label>Telefon:</label><label class=\"data\">" . $nt['Telefon'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Fax:</label><label class=\"data\">" . $nt['Fax'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Mobil:</label><label class=\"data\">" . $nt['Mobil'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Email:</label><label class=\"data\"><a href=\"mailto:" . $nt['Email'] . "\">" . $nt['Email'] . "</a></label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Homepage:</label><label class=\"data\"><a href=\"" . $nt['Homepage'] . "\" target=\"_blank\">" . $nt['Homepage'] . "</a></label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Registergericht:</label><label class=\"data\">" . $nt['Gericht'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>USt-ID / SteuerNr:</label><label class=\"data\">" . $nt['SteuerNr'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <h2>Bankverbindung</h2>\n";
echo " <label>Inhaber:</label><label class=\"data\">" . $nt['Kto_Inhaber'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>IBAN:</label><label class=\"data\">" . $nt['Kto_Nummer'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>BIC:</label><label class=\"data\">" . $nt['BLZ'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Bank:</label><label class=\"data\">" . $nt['Bank'] . "</label>\n";
echo " <br class=\"fix\" />\n";
echo " <label>Datenschutzerklärung:</label><label class=\"data\">";
if ($nt['DSchutz'])
{
echo "liegt vor";
}
else
{
echo "liegt nicht vor";
}
echo "</label>\n";
echo " <br class=\"fix\" />\n";
if ($_SESSION['Firma']['KfZ'])
{
$sqlkfz = "SELECT * FROM " . PREFIX . "_KfZ WHERE Kontakt_ID = \"" . $_POST['ID'] . "\";";
$resultkfz = $db->query($sqlkfz);
while ($ntkfz = $resultkfz->fetch_assoc())
{
var_dump($ntkfz);
}
}
$sqlan = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM " . PREFIX . "_Angebote WHERE Kontakt_ID = \"" . $_POST['ID'] . "\" ORDER BY Jahr DESC, ID DESC;";
$resultan = $db->query($sqlan);
echo " <h2>Angebote</h2>\n";
echo " <table>\n";
echo " <form action=\"index.php?section=angebot\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"view\" />\n";
echo " <input type=\"hidden\" name=\"from\" value=\"" . $nt['ID'] . "\" />\n";
echo " <colgroup>\n";
echo " <col span=\"2\" width=\"10%\" />\n";
echo " <col width=\"60%\" />\n";
echo " <col width=\"20%\" />\n";
echo " </colgroup>\n";
echo " <tr>\n";
echo " <th>#</th>\n";
echo " <th>zu LV</th>\n";
echo " <th>Bearbeiter</th>\n";
echo " <th>Datum</th>\n";
echo " </tr>\n";
while ($ntan = $resultan->fetch_assoc())
{
echo " <tr>\n";
while (strlen($ntan['ID']) < $_SESSION['Firma']['Stellen'])
{
$ntan['ID'] = "0" . $ntan['ID'];
}
while (strlen($ntan['LV_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntan['LV_ID'] = "0" . $ntan['LV_ID'];
}
echo " <td><input type=\"submit\" class=\"button_kunde\" name=\"ID\" value=\"" . $ntan['Jahr'] . "_" . $ntan['ID'] . "\" title=\"Angebot anzeigen\" /></td>\n";
if ((0 == $ntan['LV_Jahr']) AND (0 == $ntan['LV_ID']))
{
echo " <td>&nbsp;</td>\n";
}
else
{
echo " <td>" . $ntan['LV_Jahr'] . "_" . $ntan['LV_ID'] . "</td>\n";
}
$sqltmp = "SELECT Vorname, Nachname FROM Admin WHERE ID = \"" . $ntan['Admin_ID'] . "\";";
$resulttmp = $db->query($sqltmp);
$nttmp = $resulttmp->fetch_assoc();
echo " <td>" . $nttmp['Vorname'] . " " . $nttmp['Nachname'] . "</td>\n";
echo " <td>" . $ntan['Datum'] . "</td>\n";
echo " </tr>\n";
}
echo " </form>\n";
echo " </table>\n";
$sqlau = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM " . PREFIX . "_Auftraege WHERE Kontakt_ID = \"" . $_POST['ID'] . "\" ORDER BY Jahr DESC, ID DESC;";
$resultau = $db->query($sqlau);
echo " <h2>Auftragsbestätigungen</h2>\n";
echo " <table>\n";
echo " <form action=\"index.php?section=bestaet\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"view\" />\n";
echo " <input type=\"hidden\" name=\"from\" value=\"" . $nt['ID'] . "\" />\n";
echo " <colgroup>\n";
echo " <col span=\"2\" width=\"10%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"20%\" />\n";
echo " </colgroup>\n";
echo " <tr>\n";
echo " <th>#</th>\n";
echo " <th>Angebot</th>\n";
echo " <th>Bearbeiter</th>\n";
echo " <th>Auftragspreis</th>\n";
echo " <th>Datum</th>\n";
echo " </tr>\n";
while ($ntau = $resultau->fetch_assoc())
{
echo " <tr>\n";
while (strlen($ntau['Angebot_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntau['Angebot_ID'] = "0" . $ntau['Angebot_ID'];
}
while (strlen($ntau['ID']) < $_SESSION['Firma']['Stellen'])
{
$ntau['ID'] = "0" . $ntau['ID'];
}
echo " <td><input type=\"submit\" class=\"button_kunde\" name=\"ID\" value=\"" . $ntau['Jahr'] . "_" . $ntau['ID'] . "\" title=\"Auftragsbestätigung anzeigen\" /></td>\n";
if ((0 == $ntau['Angebot_Jahr']) AND (0 == $ntau['Angebot_ID']))
{
echo " <td>&nbsp;</td>\n";
}
else
{
echo " <td>" . $ntau['Angebot_Jahr'] . "_" . $ntau['Angebot_ID'] . "</td>\n";
}
$sqltmp = "SELECT Vorname, Nachname FROM Admin WHERE ID = \"" . $ntau['Admin_ID'] . "\";";
$resulttmp = $db->query($sqltmp);
$nttmp = $resulttmp->fetch_assoc();
echo " <td>" . $nttmp['Vorname'] . " " . $nttmp['Nachname'] . "</td>\n";
echo " <td>" . $ntau['Auftrag_Preis'] . " &euro;</td>\n";
echo " <td>" . $ntau['Datum'] . "</td>\n";
echo " </tr>\n";
}
echo " </form>\n";
echo " </table>\n";
$sqlr = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM " . PREFIX . "_Rechnungen WHERE Kontakt_ID = \"" . $_POST['ID'] . "\" ORDER BY Jahr DESC, ID DESC;";
$resultr = $db->query($sqlr);
echo " <h2>Rechnungen</h2>\n";
echo " <table>\n";
echo " <form action=\"index.php?section=rechnung\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"view\" />\n";
echo " <input type=\"hidden\" name=\"from\" value=\"" . $nt['ID'] . "\" />\n";
echo " <colgroup>\n";
echo " <col span=\"2\" width=\"10%\" />\n";
echo " <col width=\"20%\" />\n";
echo " <col width=\"10%\" />\n";
echo " <col width=\"20%\" />\n";
echo " <col width=\"10%\" />\n";
echo " <col width=\"20%\" />\n";
echo " </colgroup>\n";
echo " <tr>\n";
echo " <th>#</th>\n";
echo " <th>Auftrag / Lieferung</th>\n";
echo " <th>Bearbeiter</th>\n";
echo " <th>Typ</th>\n";
echo " <th>Rechnungsbetrag</th>\n";
echo " <th>Bezahlt</th>\n";
echo " <th>Datum</th>\n";
echo " </tr>\n";
while ($ntr = $resultr->fetch_assoc())
{
echo " <tr>\n";
while (strlen($ntr['Auftrag_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntr['Auftrag_ID'] = "0" . $ntr['Auftrag_ID'];
}
while (strlen($ntr['Liefer_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntr['Liefer_ID'] = "0" . $ntr['Liefer_ID'];
}
while (strlen($ntr['ID']) < $_SESSION['Firma']['Stellen'])
{
$ntr['ID'] = "0" . $ntr['ID'];
}
echo " <td><input type=\"submit\" class=\"button_kunde\" name=\"ID\" value=\"" . $ntr['Jahr'] . "_" . $ntr['ID'] . "\" title=\"Rechnung anzeigen\" /></td>\n";
if ((0 != $ntr['Auftrag_Jahr']) OR (0 != $ntau['Auftrag_ID']))
{
echo " <td>A_" . $ntr['Auftrag_Jahr'] . "_" . $ntr['Auftrag_ID'] . "</td>\n";
}
elseif ((0 != $ntr['Liefer_Jahr']) OR (0 != $ntau['Liefer_ID']))
{
echo " <td>L_" . $ntr['Liefer_Jahr'] . "_" . $ntr['Liefer_ID'] . "</td>\n";
}
else
{
echo " <td>&nbsp;</td>\n";
}
$sqltmp = "SELECT Vorname, Nachname FROM Admin WHERE ID = \"" . $ntr['Admin_ID'] . "\";";
$resulttmp = $db->query($sqltmp);
$nttmp = $resulttmp->fetch_assoc();
echo " <td>" . $nttmp['Vorname'] . " " . $nttmp['Nachname'] . "</td>\n";
if ($ntr['Vorkasse'])
{
echo " <td title=\"Vorkasse-Rechnung\">VK</td>\n";
}
elseif ($ntr['Schluss_Rechnung'])
{
echo " <td title=\"Schluss-Rechnung\">SR</td>\n";
}
elseif ((0 == $ntr['Auftrag_Jahr']) AND (0 == $ntau['Auftrag_ID']))
{
echo " <td title=\"Rechnung ohne Auftrag\">OA</td>\n";
}
else
{
echo " <td title=\"Abschlagzahlung\">AZ</td>\n";
}
echo " <td>" . $ntr['Preis'] . " &euro;</td>\n";
if ($ntr['Bezahlt'])
{
echo " <td>ja</td>\n";
}
else
{
echo " <td>nein</td>\n";
}
echo " <td>" . $ntr['Datum'] . "</td>\n";
echo " </tr>\n";
}
echo " </form>\n";
echo " </table>\n";
$sqlli = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM " . PREFIX . "_liefer WHERE Kontakt_ID = \"" . $_POST['ID'] . "\" ORDER BY Jahr DESC, ID DESC;";
$resultli = $db->query($sqlli);
echo " <h2>Lieferscheine</h2>\n";
echo " <table>\n";
echo " <form action=\"index.php?section=liefer\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"view\" />\n";
echo " <input type=\"hidden\" name=\"from\" value=\"" . $nt['ID'] . "\" />\n";
echo " <colgroup>\n";
echo " <col span=\"2\" width=\"10%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"20%\" />\n";
echo " </colgroup>\n";
echo " <tr>\n";
echo " <th>#</th>\n";
echo " <th>Auftrag / Rechnung</th>\n";
echo " <th>Bearbeiter</th>\n";
echo " <th>Auftragspreis</th>\n";
echo " <th>Datum</th>\n";
echo " </tr>\n";
while ($ntli = $resultli->fetch_assoc())
{
echo " <tr>\n";
while (strlen($ntli['Referenz_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntli['Referenz_ID'] = "0" . $ntli['Referenz_ID'];
}
while (strlen($ntli['ID']) < $_SESSION['Firma']['Stellen'])
{
$ntli['ID'] = "0" . $ntli['ID'];
}
echo " <td><input type=\"submit\" class=\"button_kunde\" name=\"ID\" value=\"" . $ntli['Jahr'] . "_" . $ntli['ID'] . "\" title=\"Auftragsbestätigung anzeigen\" /></td>\n";
if ((0 == $ntli['Referenz_Jahr']) AND (0 == $ntli['Referenz_ID']))
{
echo " <td>&nbsp;</td>\n";
}
else
{
if ($ntli['Auftrag'])
{
echo " <td>A_";
}
else
{
echo " <td>R_";
}
echo $ntli['Referenz_Jahr'] . "_" . $ntli['Referenz_ID'] . "</td>\n";
}
$sqltmp = "SELECT Vorname, Nachname FROM Admin WHERE ID = \"" . $ntli['Admin_ID'] . "\";";
$resulttmp = $db->query($sqltmp);
$nttmp = $resulttmp->fetch_assoc();
echo " <td>" . $nttmp['Vorname'] . " " . $nttmp['Nachname'] . "</td>\n";
echo " <td>" . $ntli['Auftrag_Preis'] . " &euro;</td>\n";
echo " <td>" . $ntli['Datum'] . "</td>\n";
echo " </tr>\n";
}
echo " </form>\n";
echo " </table>\n";
$sqlgu = "SELECT *, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM " . PREFIX . "_Gutschriften WHERE Kontakt_ID = \"" . $_POST['ID'] . "\" ORDER BY Jahr DESC, ID DESC;";
$resultgu = $db->query($sqlgu);
echo " <h2>Gutschriften</h2>\n";
echo " <table>\n";
echo " <form action=\"index.php?section=gut\" method=\"post\">\n";
echo " <input type=\"hidden\" name=\"formaction\" value=\"view\" />\n";
echo " <input type=\"hidden\" name=\"from\" value=\"" . $nt['ID'] . "\" />\n";
echo " <colgroup>\n";
echo " <col span=\"2\" width=\"10%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"30%\" />\n";
echo " <col width=\"20%\" />\n";
echo " </colgroup>\n";
echo " <tr>\n";
echo " <th>#</th>\n";
echo " <th>Rechnung</th>\n";
echo " <th>Bearbeiter</th>\n";
echo " <th>Gutschriftbetrag</th>\n";
echo " <th>Datum</th>\n";
echo " </tr>\n";
while ($ntgu = $resultgu->fetch_assoc())
{
echo " <tr>\n";
while (strlen($ntgu['Rechnung_ID']) < $_SESSION['Firma']['Stellen'])
{
$ntgu['Rechnung_ID'] = "0" . $ntgu['Rechnung_ID'];
}
while (strlen($ntgu['ID']) < $_SESSION['Firma']['Stellen'])
{
$ntgu['ID'] = "0" . $ntgu['ID'];
}
echo " <td><input type=\"submit\" class=\"button_kunde\" name=\"ID\" value=\"" . $ntgu['Jahr'] . "_" . $ntgu['ID'] . "\" title=\"Gutschrift anzeigen\" /></td>\n";
if ((0 == $ntgu['Rechnung_Jahr']) AND (0 == $ntgu['Rechnung_ID']))
{
echo " <td>&nbsp;</td>\n";
}
else
{
echo " <td>" . $ntgu['Rechnung_Jahr'] . "_" . $ntgu['Rechnung_ID'] . "</td>\n";
}
$sqltmp = "SELECT Vorname, Nachname FROM Admin WHERE ID = \"" . $ntgu['Admin_ID'] . "\";";
$resulttmp = $db->query($sqltmp);
$nttmp = $resulttmp->fetch_assoc();
echo " <td>" . $nttmp['Vorname'] . " " . $nttmp['Nachname'] . "</td>\n";
echo " <td>" . $ntgu['Preis'] . " &euro;</td>\n";
echo " <td>" . $ntgu['Datum'] . "</td>\n";
echo " </tr>\n";
}
echo " </form>\n";
echo " </table>\n";
echo "</fieldset>\n";
echo "<p>&nbsp;<br />&nbsp;</p>\n";