| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web31/web/invoice/ |
Upload File : |
<?php
require_once('../tcpdf/tcpdf.php');
$invoiceNumber = $_POST['invoice_number'];
$invoiceDate = $_POST['invoice_date'];
$deliveryDate = $_POST['delivery_date'];
$recipientKey = $_POST['recipient'];
$config = require 'config.php';
$recipient = nl2br($config['recipients'][$recipientKey]);
$products = $_POST['product_name'];
$quantities = $_POST['product_quantity'];
$descriptions = $_POST['product_description'];
$prices = []; // wird aus config geholt
$footer = '
<div style="text-align:center;">' . $config['company']['address'] . ' - Steuernummer ' . $config['company']['tax_id'] . '</div>';
$html = '
<table style="width: 100%;">
<tr>
<td>
' . nl2br(trim($config['company']['name'] . "\n" . $config['company']['address'] . "\n".
$config['company']['phone'])) . "<br><br>" .
"Steuernummer " . $config['company']['tax_id'] . '
</td>
<td style="text-align: right">
Rechnungs-Nr.: ' . $invoiceNumber . '<br>
Rechnungsdatum: ' . date('d.m.Y', strtotime($invoiceDate)) . '<br>
Lieferdatum: ' . date('d.m.Y', strtotime($deliveryDate)) . '<br>
</td>
</tr>
<tr>
<td style="font-size:1.4em; font-weight: bold;"><br><br><br><br>Rechnung<br></td>
</tr>
<tr>
<td colspan="2">' . $recipient . '</td>
</tr>
</table>
<br><br><br>
<table cellpadding="5" cellspacing="0" style="width: 100%;" border="0">
<tr>
<td style="width: 55%; font-weight: bold;">Bezeichnung</td>
<td style="width: 10%; text-align: center; font-weight: bold;">Menge</td>
<td style="width: 15%; text-align: right; font-weight: bold;">Einzelpreis</td>
<td style="width: 20%; text-align: right; font-weight: bold;">Preis</td>
</tr>
</table>
<hr>
<table cellpadding="5" cellspacing="0" style="width: 100%;" border="0">';
$total = 0;
foreach ($products as $i => $name) {
$qty = isset($quantities[$i]) ? (int)$quantities[$i] : 1;
$price = isset($config['products'][$name]['price']) ? $config['products'][$name]['price'] : 0;
$desc = isset($descriptions[$i]) ? trim($descriptions[$i]) : '';
$lineTotal = $qty * $price;
$total += $lineTotal;
$html .= '<tr>
<td style="width: 55%;"><b>' . htmlspecialchars($name) . '</b>';
if ($desc !== '') {
$html .= '<br><span style="font-size: 1em; color: #555;">' . nl2br($desc) . '</span>';
}
$html .= '</td>
<td style="width: 10%;text-align: center;">' . $qty . '</td>
<td style="width: 15%;text-align: right;">' . number_format($price, 2, ',', '') . ' Euro</td>
<td style="width: 20%;text-align: right;">' . number_format($lineTotal, 2, ',', '') . ' Euro</td>
</tr>';
}
$html .= '</table>
<hr>
<table cellpadding="5" cellspacing="0" style="width: 100%;" border="0">
<tr>
<td colspan="3"><b>Gesamt</b></td>
<td style="text-align: right;"><b>' . number_format($total, 2, ',', '') . ' Euro</b></td>
</tr>
</table>
<br><br><br>
Nach § 19 Abs. 1 UStG wird keine Umsatzsteuer berechnet.
<br><br><br><br><br>
<b>IBAN</b>: ' . $config['company']['bank']['iban'] . ', <b>BIC</b>: ' . $config['company']['bank']['bic'] . ', <b>Empfänger:</b> ' . $config['company']['bank']['owner'].
'<br><br>' . $config['company']['payment_terms'] . '<br><br><br>';
// PDF erzeugen
$pdf = new TCPDF();
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ArNi Solutions');
$pdf->SetTitle('Rechnung ' . $invoiceNumber);
$pdf->SetSubject('Rechnung ' . $invoiceNumber);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('dejavusans', '', 10);
$pdf->AddPage();
$pdf->writeHTML($html, true, false, true, false, '');
// Footer
//$pdf->writeHTML(nl2br($config['company']['payment_terms']), true, false, true, false, '');
#$pdf->Ln(10); // etwas Abstand zum Hauptinhalt
#$pdf->writeHTML(nl2br($footer), true, false, true, false, '');
$pdf->Output("Rechnung_" . $invoiceNumber . ".pdf", 'I');
// Invoices speichern
$lines = [];
$lines[] = '### START ###';
$lines[] = 'invoice_number:' . $invoiceNumber;
$lines[] = 'invoice_date:' . $invoiceDate;
$lines[] = 'delivery_date:' . $deliveryDate;
$lines[] = 'recipient:' . $recipientKey;
foreach ($products as $i => $name) {
$qty = isset($quantities[$i]) ? (int)$quantities[$i] : 1;
$price = isset($config['products'][$name]['price']) ? $config['products'][$name]['price'] : 0;
$desc = isset($descriptions[$i]) ? $descriptions[$i] : '';
$item = implode('|', [$name, $qty, $price, $desc]);
$lines[] = 'item:' . $item;
}
$lines[] = '### END ###';
file_put_contents('invoices.txt', implode("\n", $lines) . "\n", FILE_APPEND);
// Rechnungszähler erhöhen (nur wenn automatisch generiert)
$counterFile = 'counter.txt';
if (strpos($invoiceNumber, '2025-') === 0) {
if (file_exists($counterFile)) {
$num = (int)file_get_contents($counterFile) + 1;
file_put_contents($counterFile, $num);
}
}
?>