<?php
$sql = "SELECT ID, Firma, Nachname FROM " . PREFIX . "_Kontakte ORDER BY Nachname ASC, Firma ASC;";
$resultkn = $db->query($sql);
$sql = "SELECT ID, Vorname, Nachname FROM Admin WHERE Firma_ID =\"" . PREFIX . "\" ORDER BY ID ASC";
$resultan = $db->query($sql);

echo "<fieldset>\n";
echo "	<legend>Rechnung aus anderem Programm hinzufügen</legend>\n";
echo "	<form action=\"index.php?" . $_SERVER['QUERY_STRING'] . "\" method=\"post\" />\n";
echo "		<label>Kunde</label>\n";
echo "		<select name=\"Kontakt_ID\">\n";
while ($ntkn = $resultkn->fetch_assoc())
{
	echo "			<option value=\"" . $ntkn['ID'] . "\">" . $ntkn['Nachname'] . ", " . $ntkn['Firma'] . "</option>\n";
}
echo "		</select>\n";
echo "		<br style=\"clear: left;\" />\n";
echo "		<label>Ansprechpartner</label>\n";
echo "		<select name=\"Admin_ID\">\n";
while ($ntan = $resultan->fetch_assoc())
{
	echo "			<option value=\"" . $ntan['ID'] . "\">" . $ntan['Nachname'] . ", " . $ntan['Vorname'] . "</option>\n";
}
echo "		</select>\n";
echo "		<br style=\"clear: left;\" />\n";
echo "		<label>Rechnungsnummer</label>\n";
echo "		<input type=\"text\" name=\"Re_Nr\" />\n";
echo "		<br />\n";
echo "		<label>Rechnungsdatum</label>\n";
echo "		<input type=\"text\" name=\"Re_Datum\" />\n";
echo "		<img src=\"img/small_info.png\" alt=\"<TT.MM.JJJJ>\" title=\"Datum der Form: <TT.MM.JJJJ>\" />\n";
echo "		<br />\n";
echo "		<label>Nettobetrag</label>\n";
echo "		<input type=\"text\" name=\"Preis\" value=\"0.00\" />\n";
echo "		<br />\n";
echo "		<label>Mehrwertsteuersatz in %</label>\n";
echo "		<input type=\"text\" name=\"MwSt\" value=\"" . $_SESSION['Firma']['MwSt'] . "\" />\n";
echo "		<br />\n";
echo "		<label>Bezahlt am</label>\n";
echo "		<input type=\"text\" name=\"Bezahlt_am\" />\n";
echo "		<img src=\"img/small_info.png\" alt=\"<TT.MM.JJJJ>\" title=\"Datum der Form: <TT.MM.JJJJ>! Falls die Rechnung noch nicht bezahlt wurde, lassen Sie dieses Feld leer.\" />\n";
echo "		<br />\n";
echo "		<input type=\"submit\" class=\"button_save\" name=\"formaction\" value=\"save\" title=\"Übernehmen\" />\n";
echo "	</form>\n";
echo "</fieldset>\n";