<?php

$pdf->SetFont('Helvetica', 'B', 10);
$pdf->Cell(10, 4, "Pos.", 'B');
$pdf->Cell(10, 4, "Anz.", 'B');
$pdf->Cell(110, 4, "Beschreibung", 'B');
$pdf->Cell(25, 4, "E-Preis", 'B', 0, 'R');
$pdf->Cell(25, 4, "G-Preis", 'B', 1, 'R');

$pdf->SetFont('Helvetica', '', 10);
$Gesamtpreis = 0;
while ($ntp = $resultp->fetch_assoc())
{
	$y_oben = $pdf->GetY();
	$Gesamtpreis = $Gesamtpreis + ($ntp['Preis'] * $ntp['Anzahl']);
	$pdf->Cell(10, 4, $ntp['Position']);
	$pdf->Cell(10, 4, $ntp['Anzahl']);
	if (isset($ntab['Preis_aus_Pos']))
	{
		$take_pos = $ntab['Preis_aus_Pos'];
	}
	elseif (isset($nt['Preis_aus_Pos']))
	{
		$take_pos = $nt['Preis_aus_Pos'];
	}
	if (("0" == $ntp['Preis']) OR ("0" == $take_pos))
	{
		$pdf->Cell(135, 4, "-/- €", 0, 0, 'R');
		$pdf->Cell(25, 4, "-/- €", 0, 0, 'R');
	}
	else
	{
		$pdf->Cell(135, 4, number_format($ntp['Preis'], '2', ',', '.') . " €", 0, 0, 'R');
		$pdf->Cell(25, 4, number_format($ntp['Preis'] * $ntp['Anzahl'], '2', ',', '.') . " €", 0, 0, 'R');
	}
	$pdf->SetX(40);
	$pdf->MultiCell(110, 4, $ntp['Bezeichnung'], 0, 'L');
	if (("" != $_SESSION['Firma']['Feld1_Name']) AND (preg_match("/" . $pdf_type . ",/", $_SESSION['Firma']['Feld1'])) AND ("" != $ntp['Feld1']))
	{
		$pdf->SetFont('Helvetica', '', 8);
		$pdf->SetX(40);
		$pdf->MultiCell(110, 3, stripslashes($ntp['Feld1']), 0, 'L');
	}
	if (("" != $_SESSION['Firma']['Feld2_Name']) AND (preg_match("/" . $pdf_type . ",/", $_SESSION['Firma']['Feld2'])) AND ("" != $ntp['Feld2']))
	{
		$pdf->SetFont('Helvetica', 'I', 8);
		$pdf->SetX(40);
		$pdf->MultiCell(110, 3, $_SESSION['Firma']['Feld2_Name'] . ": " . stripslashes($ntp['Feld2']), 0, 'L');
	}
	if (("" != $_SESSION['Firma']['Feld3_Name']) AND (preg_match("/" . $pdf_type . ",/", $_SESSION['Firma']['Feld3'])) AND ("" != $ntp['Feld3']))
	{
		$pdf->SetFont('Helvetica', 'I', 8);
		$pdf->SetX(40);
		$pdf->MultiCell(110, 3, $_SESSION['Firma']['Feld3_Name'] . ": " . stripslashes($ntp['Feld3']), 0, 'L');
	}
	if (("" != $_SESSION['Firma']['Feld4_Name']) AND (preg_match("/" . $pdf_type . ",/", $_SESSION['Firma']['Feld4'])) AND ("" != $ntp['Feld4']))
	{
		$pdf->SetFont('Helvetica', 'I', 8);
		$pdf->SetX(40);
		$pdf->MultiCell(110, 3, $_SESSION['Firma']['Feld4_Name'] . ": " . stripslashes($ntp['Feld4']), 0, 'L');
	}
	if ((("" != $_SESSION['Firma']['Feld5_Name']) AND ("Intern" != $_SESSION['Firma']['Feld5_Name'])) AND (preg_match("/" . $pdf_type . ",/", $_SESSION['Firma']['Feld5'])) AND ("" != $ntp['Feld5']))
	{
		$pdf->SetFont('Helvetica', 'I', 8);
		$pdf->SetX(40);
		$pdf->MultiCell(110, 3, $_SESSION['Firma']['Feld5_Name'] . ": " . stripslashes($ntp['Feld5']), 0, 'L');
	}
	$pdf->SetFont('Helvetica', '', 10);
	$y_unten = $pdf->GetY();
	$pdf->Line(20, $y_unten, 200, $y_unten);
	if ($y_oben > $y_unten)
	{
		$pdf->SetY(45);
		$pdf->SetFont('Helvetica', 'B', 10);
		$pdf->Cell(10, 4, "Pos.", 'B');
		$pdf->Cell(10, 4, "Anz.", 'B');
		$pdf->Cell(110, 4, "Beschreibung", 'B');
		$pdf->Cell(25, 4, "E-Preis", 'B', 0, 'R');
		$pdf->Cell(25, 4, "G-Preis", 'B', 1, 'R');
		$pdf->SetFont('Helvetica', '', 10);
		$pdf->SetY($y_unten);
	}

}