Added Columns to Invoice CSV Export and added csv to Address/Invoice

This commit is contained in:
Frank Schubert
2024-07-16 13:48:35 +02:00
parent 8e6bbaec54
commit 021ac2cd5a
3 changed files with 25 additions and 28 deletions

View File

@@ -49,6 +49,7 @@
<th>Betrag Brutto</th>
<th>Zahlungsart</th>
<th>Versand</th>
<th></th>
</tr>
<?php foreach($invoices as $invoice): ?>
<tr>
@@ -68,6 +69,7 @@
<td class="<?=($invoice->total_gross < 0) ? "text-danger" : ""?>">€ <?=number_format($invoice->total_gross, 2, ",", ".")?></td>
<td><?=($invoices->billing_type == "sepa") ? "Einzug" : "Einzahlung" ?></td>
<td><?=($invoices->billing_delivery == "email") ? "Email (".$invoice->email.")" : "Postversand" ?></td>
<td><a href="<?=self::getUrl("Invoice", "downloadInvoiceCsv", ["id" => $invoice->id])?>" title="CSV-Download"><i class="fas fa-file-csv fa-fw"></i></a></td>
</tr>
<?php endforeach; ?>

View File

@@ -152,9 +152,7 @@ $pagination_entity_name = "Rechnungen";
<td><?=($invoice->billing_type == "sepa") ? "SEPA" : "Überweisung"?></td>
<td><?=($invoice->billing_delivery == "email") ? "Email" : "Papier"?></td>
<td>
<?php if($invoice->total < 0): ?>
<a class="text-danger" href="<?=self::getUrl("Invoice", "downloadInvoiceCsv", ["id" => $invoice->id])?>"><i class="fas fa-file-csv fa-fw"></i></a>
<?php endif; ?>
<a href="<?=self::getUrl("Invoice", "downloadInvoiceCsv", ["id" => $invoice->id])?>" title="CSV-Download"><i class="fas fa-file-csv fa-fw"></i></a>
</td>
</tr>
<?php endforeach; ?>

View File

@@ -3,36 +3,33 @@ header("Content-type: text/csv");
header('Content-disposition: attachment; filename="'.$invoice->invoice_number.'.csv"');
?>
Rechnungsnummer;Belegdatum;Kundennummer;Firma;Nachname;Vorname;Produktname;Matchcode;Anschluss Name;Bauabschnitt;Anschluss PLZ;Anschluss Ort;Anschluss Strasse;
Rechnungsnummer;Belegdatum;Kundennummer;Firma;Nachname;Vorname;Produktname;Matchcode;Zeitraum;Anzahl;Preis Netto;Ust%;Preis Brutto
<?php
foreach($invoice->positions as $p):
?>
<?=$invoice->invoice_number?>;<?=date("d.m.Y", $invoice->invoice_date)?>;<?=$invoice->customer_number?>;"<?=str_replace(["\n","\r"], " ", $invoice->company)?>";"<?=$invoice->lastname?>";"<?=$invoice->firstname?>";"<?=$p->product_name?>";"<?=str_replace(["\n","\r"], " ", $p->matchcode)?>";<?php
$credit = false;
$contract = false;
if($p->contract_id) {
$credit = $p->contract;
$timerange_month_only = $p->getOption('timerange_month_only');
$start_date = new DateTime($p->start_date);
$end_date = new DateTime($p->end_date);
$amount = (float) number_format($p->amount, 3, ",", ".");
$price = number_format($p->price, 2, ",",".");
$price_total = number_format($p->price_total, 2, ",",".");
$price_gross = number_format($p->price_gross, 2, ",",".");
$vatrate = number_format($p->vatrate, 0, ",",".");
foreach($credit->linkFrom as $link) {
if($link->type == "credit" && $link->origin->termination_id) {
$contract = $link->origin;
break;
$timerange = "";
if($timerange_month_only) {
$timerange = $start_date->format("m.Y");
} elseif($p->billing_period > 1) {
$timerange = $start_date->format("m.Y")?> - <?=$end_date->format("m.Y");
} else {
if($start_date->format("d.m.Y") == $end_date->format("d.m.Y")) {
$timerange = $start_date->format("d.m.Y");
} else {
$timerange = $start_date->format("d.m.Y")." - ".$end_date->format("d.m.Y");
}
}
}
if($contract): ?>
<?php
$term = $contract->termination;
//var_dump($term);
$building = $term->building;
//var_dump($building);
$order = OrderModel::getFirst(["termination_id" => $term->id]);
//var_dump($order);exit;
?>
"<?=($order) ? str_replace(["\n","\r"], " ", $order->owner->getCompanyOrName()) : str_replace(["\n","\r"], " ", $term->contact)?>";"<?=($building->networksection_id) ? $building->networksection->name : ""?>";<?=$building->zip?>;"<?=$building->city?>";"<?=$building->street?>";
<?php else: ?>
;;;;;
<?php endif; ?>
<?=$invoice->invoice_number?>;<?=date("d.m.Y", $invoice->invoice_date)?>;<?=$invoice->customer_number?>;"<?=str_replace(["\n","\r"], " ", $invoice->company)?>";"<?=$invoice->lastname?>";"<?=$invoice->firstname?>";"<?=$p->product_name?>";"<?=str_replace(["\n","\r"], " ", $p->matchcode)?>";"<?=$timerange?>";<?=(float)$p->amount?>;<?=number_format($p->price_total, 2, ",", "")?>;<?=number_format($p->vatrate, 2, ",", "")?>;<?=number_format($p->price_gross, 2, ",", "")?>
<?php
endforeach;