<?php
$pdf->SetFont('Helvetica', 'B', 10);
$pdf->Cell(20, 4, "Pos.", 'B');
$pdf->Cell(135, 4, "Beschreibung", 'B');
$pdf->Cell(25, 4, "G-Preis", 'B', 1, 'R');
$pdf->SetFont('Helvetica', '', 10);

$Gesamtpreis = $ntr['Preis'] * (1 + $ntr['MwSt'] / 100);
$pdf->Cell(20, 4, "1", '');
$pdf->Cell(135, 4, "Gesamtbetrag aus Rechnung " . $ntr['Jahr'] . "_" . $ntr['ID'] . " vom " . $ntr['Datum'], '');
$pdf->Cell(25, 4, number_format($Gesamtpreis, '2', ',', '.') . " €", '', 1, 'R');

$pdf->Cell(20, 4, "2", '');
$pdf->Cell(135, 4, "-Teilzahlungen", '');
$pdf->Cell(25, 4, number_format(-1 * $ntsum['Preis'], '2', ',', '.') . " €", '', 1, 'R');

$pdf->Cell(20, 4, "3", '');
$pdf->Cell(135, 4, "Mahngebühren", '');
$pdf->Cell(25, 4, number_format($_SESSION['Firma']['Gebuehr'], '2', ',', '.') . " €", '', 1, 'R');

$Tage = (strtotime($nt['Bezug_Datum']) - strtotime($ntr['R_Datum'])) / (3600 * 24);
$Zins = ($Gesamtpreis - $ntsum['Preis']) * $Tage / 365 * $_SESSION['Firma']['Zins'] / 100;
$pdf->Cell(20, 4, "4", 'B');
$pdf->Cell(135, 4, "Verzugszinsen anteilig i.H.v. " . $_SESSION['Firma']['Zins'] . "% p.a.", 'B');
$pdf->Cell(25, 4, number_format($Zins, '2', ',', '.') . " €", 'B', 1, 'R');
$y_unten = $pdf->GetY();
$pdf->Line(20, $y_unten, 200, $y_unten);

$Gesamtpreis = $Gesamtpreis - $ntsum['Preis'] + $_SESSION['Firma']['Gebuehr'] + $Zins;
$pdf->SetX(40);
$pdf->SetFont('Helvetica', 'B', 10);
$pdf->Cell(135, 4, "Mahnbetrag", '');
$pdf->Cell(25, 4, number_format($Gesamtpreis, '2', ',', '.') . " €", '', 1, 'R');
$y_unten = $pdf->GetY();
$pdf->Line(40, $y_unten, 200, $y_unten);
$pdf->SetFont('Helvetica', '', 10);
$pdf->Write(4, "\n");