38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
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;
|
|
<?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;
|
|
|
|
foreach($credit->linkFrom as $link) {
|
|
if($link->type == "credit" && $link->origin->termination_id) {
|
|
$contract = $link->origin;
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
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; ?>
|
|
<?php
|
|
endforeach;
|