Rev 8214 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
/**
* Template für die PDF Rechnung
*/
require_once WPSG_PATH_LIB.'FPDF_1.81/fpdf.php';
require_once WPSG_PATH_LIB.'FPDI_2.2.0/autoload.php';
require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $rhead_left, $rhead_top, $sum_multi_offset, $pdf, $data;
// Positionierung der Absenderadresszeile
$absender_left = 25;
$absender_top = 50;
// Positionierung der Zieladress
$adress_left = 25;
$adress_top = 55;
// Positionierung des Rechnungskopfes
$rdata_left = 25;
$rdata_top = 90;
// Positionierung des Teilrechnungskopfes
$rhead_left = 25;
$rhead_top = 110;
// Positionierung der Produktdaten
$prod_left = 25;
$prod_top = 120;
// Anzahl an Produkten pro Seite
$prod_break = $this->get_option('wpsg_rechnungen_pdfperpage');
/*
$arCalculation = $this->view['basket']['arCalculation'];
$data = $this->view['multi_data']['orders'][0]['data'];
$sum = $this->view['multi_data']['orders'][0]['sum'];
*/
$arCalculation = array_values($this->view['multi_data']['order_data'])[0]['arCalculation'];
$data = $this->view['data'];
$sum = $arCalculation['sum'];
if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto';
else $taxdisplay = 'brutto';
if (!function_exists('AddRechnungPage')) {
function AddRechnungPage($shop, $pdf) {
global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $offset, $sum_multi_offset, $data;
$pdf->AddPage();
$sum_multi_offset = 0;
if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_bp.pdf")) {
$pdf->setSourceFile($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_bp.pdf");
$tplidx = $pdf->importPage(1, '/MediaBox');
$pdf->useTemplate($tplidx, 0, 0, 210);
} else if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_bp.jpg")) {
$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_bp.jpg", 0, 0, 210, 297, 'jpg');
}
if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_logo.jpg"))
{
list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_logo.jpg");
// Umrechnung von Inch zu Pixel
$wPix = (25.4 * (int)$width) / 96;
$hPix = (25.4 * (int)$height) / 96;
$leftPos = 110 - $wPix;
$midPos = $wPix * 2.6 - $width / 2;
$rightPos = 210 - $wPix;
$abscissa = $rightPos;
$ordinate = 0;
$transparency = str_replace("%", "", $shop->get_option('wpsg_rechnungen_logo_transparency'));
if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
$alpha = 1;
if(!is_null($transparency) && $transparency !== "100") $alpha = "0.$transparency";
if(!is_null($transparency) && $transparency === "100") $alpha = $transparency;
$logo_pos = $shop->get_option('wpsg_rechnungen_logo_position');
if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }
$pdf->SetAlpha($alpha);
$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getPaperPath', array())."wpsg_rechnungen_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
$pdf->SetAlpha(1);
}
// Absenderadresszeile (Wird in der Konfiguration hinterlegt)
$pdf->SetFont('Arial', '', 6);
$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter(__($shop->get_option("wpsg_rechnungen_adresszeile"), 'wpsg'), $data['id']));
if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
// Adresse des Kunden
$pdf->SetFont('Arial', '', 12);
$pdf->Text($adress_left, $adress_top, $shop->view['kunde']['firma']);
$pdf->Text($adress_left, $adress_top + 5, $shop->view['kunde']['vname'].' '.$shop->view['kunde']['name']);
$pdf->Text($adress_left, $adress_top + 10, $shop->view['kunde']['strasse'].' '.wpsg_getStr($shop->view['kunde']['nr']));
$pdf->Text($adress_left, $adress_top + 15, $shop->view['kunde']['plz'].' '.$shop->view['kunde']['ort']);
if ($shop->get_option("wpsg_mod_rechnungen_hideCountry") == '0') {
$pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getInvoiceCountryName()));
}
// Rechnungsdaten
$pdf->SetFont('Arial', 'B', 16);
$pdf->Text($rdata_left, $rdata_top, __('Rechnung', 'wpsg'));
$pdf->SetFont('Arial', 'B', 9);
$pdf->Text($rdata_left, $rdata_top + 6, $shop->view['rnr']);
$pdf->SetFont('Arial', '', 9);
// Fälligkeitsdatum
if (isset($shop->view['faelligkeitdatum']))
{
$pdf->Text($rdata_left + 35, $rdata_top, __("Fällig am", "wpsg"));
$pdf->Text($rdata_left + 35, $rdata_top + 6, $shop->view['faelligkeitdatum']);
}
// Kunden-Nr
$pdf->Text($rdata_left + 55, $rdata_top, __("Kunden-Nr", "wpsg"));
$pdf->Text($rdata_left + 55, $rdata_top + 6, (($shop->view['kunde']['knr'] != '')?$shop->view['kunde']['knr']:$shop->view['kunde']['id']));
// Datum
$pdf->Text($rdata_left + 75, $rdata_top, __("Rechnungsdatum", "wpsg"));
$pdf->Text($rdata_left + 75, $rdata_top + 6, $shop->view['rDatum']);
// InnerEu Hinweistext
if ($shop->view['oOrder']->isInnerEu()) {
$pdf->SetFont('Arial', '', 9);
$pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
$offset += 11.5;
}
// Benutzerdefinierte Felder
$arTexte = $shop->callMod('wpsg_mod_rechnungen', 'getRechnungstexte', array($data['id']));
foreach ((array)$arTexte as $text)
{
if (isset($text['aktiv']) && $text['aktiv'] == 1)
{
$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
$pdf->wpsg_SetTextColor($text['color']);
$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
$pdf->wpsg_SetTextColor("#000000");
}
}
}
}
$pdf = new wpsg_fpdf();
$pdf->SetAutoPageBreak(false, 5);
AddRechnungPage($this, $pdf);
$checkPageBreak = function($shop, $offset, $lines) use ($pdf, $prod_top) {
if ($prod_top + $offset + ($lines * 5) > 290) {
AddRechnungPage($this, $pdf);
return 0;
} else return $offset;
};
$rhead_count = 1;
$sum_multi_offset = 0;
// $orders = $this->view['multi_data']['orders'];
// noMwSt
$head_data = array_values($this->view['multi_data']['order_data'])[0];
if ( ($head_data['oCalculation']->getTaxMode() === \wpsg\wpsg_calculation::TAXMODE_B2B) && ($head_data['oOrder']->isInnerEu()) ) {
$bNoTax = true;
} else {
$bNoTax = false;
}
$bTaxCol = false;
if ($this->get_option('wpsg_showMwstAlways') === '1') $bTaxCol = true;
else {
foreach ($this->view['multi_data']['order_data'] as $order_data) {
if (sizeof($order_data['arCalculation']['tax']) > 1) { $bTaxCol = true; break; }
}
}
// FOREACH ORDER START
foreach ($this->view['multi_data']['order_data'] as $order_data) {
/** @var wpsg_order $oOrder */
$oOrder = $order_data['oOrder'];
/** @var \wpsg\wpsg_calculation $arCalculation */
$arCalculation = $order_data['arCalculation'];
// Sammelrechnung Zähler
$pdf->SetFont('Arial', 'B', 12);
$pdf->Text($rhead_left, $rhead_top + $sum_multi_offset, $rhead_count);
$pdf->Text($rhead_left + 6, $rhead_top + $sum_multi_offset, __("Bestellung", "wpsg"));
$rhead_count++;
$pdf->SetFont('Arial', '', 9);
// Bestelltag anzeigen
$pdf->Text($rhead_left + 85, $rhead_top + $sum_multi_offset, __("Bestelldatum", "wpsg"));
$pdf->Text($rhead_left + 85, $rhead_top + $sum_multi_offset + 6, date("d.m.Y", strtotime($oOrder->cdate)));
// Zahlungsbedingung anzeigen
$pdf->Text($rhead_left + 115, $rhead_top + $sum_multi_offset, __("Zahlungsbedingungen", "wpsg"));
$pdf->Text($rhead_left + 115, $rhead_top + $sum_multi_offset + 6, $oOrder->getPaymentLabel());
// Bestellnummer anzeigen
$pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset, __("Best. Nr.", "wpsg"));
$pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset + 6, $oOrder->getNr());
$bKopf = false; $pnr = 1; $offset = 0; $count = 0;
foreach ($oOrder->getOrderProducts() as $oOrderProduct) {
$product_id = $oOrderProduct->getProductId();
if (!$bKopf) {
$pdf->SetFont('Arial', 'B', 9);
$pdf->setXY($prod_left, $prod_top + $sum_multi_offset);
$pdf->Cell(10, 8, __("Nr.", "wpsg"), 1, 0, 'C');
$pdf->setXY($prod_left + 10, $prod_top + $sum_multi_offset);
$pdf->Cell((($bTaxCol)?87:102), 8, "Name", 1, 0, 'L');
if ($bTaxCol) {
$pdf->setXY($prod_left + 97, $prod_top + $sum_multi_offset);
$pdf->Cell(15, 8, __("MwSt.", "wpsg"), 1, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $sum_multi_offset);
$pdf->Cell(15, 8, __("Menge", "wpsg"), 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $sum_multi_offset);
$pdf->Cell(25, 8, __("Einzelpreis", "wpsg"), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $sum_multi_offset);
$pdf->Cell(25, 8, __("Gesamtpreis", "wpsg"), 1, 0, 'R');
$offset = 8;
$bKopf = true;
}
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') {
$pdf->Cell(10, 8, $oOrderProduct->getProduct()->getNr(), 0, 0, 'C');
} else {
$pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
}
if ($this->get_option('wpsg_rechnungen_pdetailname') == '1') {
$produkt_text = $this->getProductName($product_id, true);
} else {
$produkt_text = $this->getProductName($product_id, false);
}
$produktBeschreibung = trim(strip_tags($oOrderProduct->getProduct()->getShortDescription()));
if ($this->isOtherLang()) {
$trans_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($product_id)."' AND `lang_code` = '".wpsg_q($this->getCurrentLanguageCode())."'");
if (is_array($trans_db) && sizeof($trans_db) > 0) {
$produkt_text = $trans_db['name'];
$produktBeschreibung = trim(strip_tags($trans_db['beschreibung']));
}
}
$height = 0; // Höhe der Zeile für den Rahmen
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
// Produktvariablen
if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1") {
$arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($oOrder->getId(), $oOrderProduct->getProductIndex()));
if (wpsg_isSizedArray($arPV)) {
foreach ($arPV as $pv) {
if ($pv['value'] != '') {
$produkt_text .= "\r\n".$pv['name'].': '.$pv['value'];
$height += 5;
}
}
}
}
if ($this->get_option('wpsg_mod_rechnungen_anr') === '2') {
$anr = $this->getProductAnr($oOrderProduct->getProductKey());
$produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr);
}
if ($bTaxCol) $produkt_text_cell_width = 87;
else $produkt_text_cell_width = 102;
$produkt_text_width = $pdf->GetStringWidth($produkt_text);
$height += 5 * ceil($produkt_text_width / $produkt_text_cell_width) + 3;
$height_y = $pdf->getY();
$height = 2 + $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $offset + 1.5 + $sum_multi_offset, 5, $produkt_text, 0, 'L', 0, $produkt_text_cell_width);
if ($bTaxCol) {
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, (($bNoTax)?'0.00 %':wpsg_ff($arCalculation['tax'][$oOrderProduct->getTaxKey().'_'.$oOrder->getInvoiceCountry()->getId()]['tax_value'], '%')), 0, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, $oOrderProduct->getAmount(), 0, 0, 'C');
$preis = $oOrderProduct->getPrice(wpsg_ShopController::getShop()->getFrontendTaxview());
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($preis, $this->get_option('wpsg_currency')), 0, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($oOrderProduct->getPriceSum(wpsg_ShopController::getShop()->getFrontendTaxview()), $this->get_option('wpsg_currency')), 0, 0, 'R');
/**
* Produktbeschreibung anzeigen Ja/Nein
*/
$pBeschreibungHeight = 0;
if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($oOrderProduct->getProduct()->getShortDescription())) != '') {
$produktBeschreibung = nl2br($produktBeschreibung);
preg_match_all('/\<br \/\>/', $produktBeschreibung, $treffer);
$produktBeschreibung = strip_tags($produktBeschreibung);
$pBeschreibungWidth = $pdf->getStringWidth($produktBeschreibung);
$pBeschreibungHeight = 5 * (ceil($pBeschreibungWidth / $produkt_text_cell_width) + @sizeof($treffer[0]));
$pdf->SetFont('Arial', 'I', 9);
$cellY = $pdf->getY();
$pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 1 + $sum_multi_offset, 5, $produktBeschreibung, 0, 'L', 0, $produkt_text_cell_width);
$pBeschreibungHeight = $pdf->getY() - $cellY - $height + 1;
$pdf->SetFont('Arial', '', 9);
}
$height += $pBeschreibungHeight;
/**
* Produktattribute ?
*/
if ($this->get_option('wpsg_rechnungen_produktattribute') == '1') {
$attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($oOrderProduct->getId())));
foreach ($attributeInfo as $pa) {
$pa_text = $pa['name'].': '.$pa['value'];
$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, $pa_text, 0, 'L', 0, $produkt_text_cell_width);
}
}
/**
* Variante ?
*/
if (preg_match('/pv_(.*)/', $oOrderProduct->getProductKey())) {
$variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($oOrderProduct->getProductKey()));
$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Variante: #1#', 'wpsg'), $variInfo['key']), 0, 'L', 0, $produkt_text_cell_width);
//$height += 5;
}
/**
* Lieferschein ?
*/
if ($this->hasMod('wpsg_mod_deliverynote')) {
$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($oOrder->getId()));
if (sizeof($arDN_order) > 1) {
$deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($oOrder->getId(), $oOrderProduct->getProductIndex()));
if ($deliveryTimeProduct !== false) {
$height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Lieferdatum: #1#', 'wpsg'), date('d.m.Y', $deliveryTimeProduct)), 0, 'L', 0, $produkt_text_cell_width);
}
}
}
// Jetzt die Rahmen zeichnen
$pdf->Rect($prod_left, $prod_top + $offset + $sum_multi_offset, 10, $height);
$pdf->Rect($prod_left + 10, $prod_top + $offset + $sum_multi_offset, (($bTaxCol == '1')?87:102), $height);
if ($bTaxCol) {
$pdf->Rect($prod_left + 97, $prod_top + $offset + $sum_multi_offset, 15, $height);
}
$pdf->Rect($prod_left + 112, $prod_top + $offset + $sum_multi_offset, 15, $height);
$pdf->Rect($prod_left + 127, $prod_top + $offset + $sum_multi_offset, 25, $height);
$pdf->Rect($prod_left + 152, $prod_top + $offset + $sum_multi_offset, 25, $height);
$offset += $height;
$pnr ++;
$count ++;
if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($oOrder->getOrderProducts()) > ($pnr - 1))) {
AddRechnungPage($this, $pdf);
$bKopf = false; $count = 0; $offset = 0;
}
} // produkte
// Gutschein
if (wpsg_isSizedArray($arCalculation['voucher'])) {
foreach ($arCalculation['voucher'] as $v) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L');
if ($bTaxCol) {
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, __('anteilig', 'wpsg'), 1, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, '1', 1, 0, 'C');
$gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
$gs_value_gesamt = wpsg_ff($v[$taxdisplay], $this->get_option('wpsg_currency'));
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, $gs_value_einzel, 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, $gs_value_gesamt, 1, 0, 'R');
$offset += 8;
}
}
// Versandkosten
$cost_shipping = ((wpsg_ShopController::getShop()->getFrontendTaxview() === WPSG_BRUTTO)?$arCalculation['sum']['shipping_brutto']:$arCalculation['sum']['shipping_netto']);
if ($arCalculation['sum']['shipping_brutto'] > 0) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $oOrder->getShippingLabel()), 1, 0, 'L');
if ($bTaxCol) {
if ($bNoTax) {
$mwst = wpsg_ff(0.00, '%');
} else {
if ($arCalculation['shipping'][0]['tax_key'] === '0') {
$mwst = _('anteilig');
} else {
$mwst = wpsg_ff($arCalculation['shipping'][0]['tax'], '%');
$mwst = wpsg_ff($arCalculation['tax'][$arCalculation['shipping'][0]['tax_key']]['tax_value'], '%');
}
}
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, '1', 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$offset += 8;
}
// Zahlungskosten
$cost_payment = ((wpsg_ShopController::getShop()->getFrontendTaxview() === WPSG_BRUTTO)?$arCalculation['sum']['payment_brutto']:$arCalculation['sum']['payment_netto']);
if ($cost_payment > 0) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, $oOrder->getPaymentLabel(), 1, 0, 'L');
if ($bTaxCol) {
if ($bNoTax) {
$mwst = wpsg_ff(0.00, '%');
} else {
if ($arCalculation['payment'][0]['tax_key'] === '0') {
$mwst = _('anteilig');
} else {
$mwst = wpsg_ff($arCalculation['payment'][0]['tax'], '%');
$mwst = wpsg_ff($arCalculation['tax'][$arCalculation['payment'][0]['tax_key']]['tax_value'], '%');
}
}
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, '1', 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($cost_payment, $this->get_option('wpsg_currency')), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($cost_payment, $this->get_option('wpsg_currency')), 1, 0, 'R');
$offset += 8;
}
// Rabatt
if ($arCalculation['sum']['discount_brutto'] < 0) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, _('Rabatt'), 1, 0, 'L');
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, _('anteilig'), 1, 0, 'C');
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, '1', 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['discount_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['discount_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$offset += 8;
}
// Wertgutschein
foreach ($arCalculation['coupon'] as $c) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, _('Wertgutschein').' ('.$c['code'].')', 1, 0, 'L');
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, _('anteilig'), 1, 0, 'C');
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, $c['amount'], 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($c[$taxdisplay.'_single'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 1, 0, 'R');
$offset += 8;
}
// Gebühr
if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0) {
$pdf->SetFont('Arial', '', 9);
$pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
$label = __('Bearbeitungsgebühr', 'wpsg');
if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell( (($bTaxCol)?87:102), 8, $label, 1, 0, 'L');
if ($bTaxCol) {
if ($bNoTax) {
$mwst = wpsg_ff(0.00, '%');
} else {
$mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
}
$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
}
$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(15, 8, '1', 1, 0, 'C');
$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
$offset += 8;
}
// Bestellbetrag einer einzelnen Bestellung
if ($bNoTax) {
$pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (NETTO):", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
} else {
$pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (BRUTTO):", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
}
$sum_multi_offset += ($offset + 30);
} // FOREACH ORDER END
$arCalculation = $this->view['arCalculationSum'];
$offset = $sum_multi_offset - 30;
$pdf->SetFont('Arial', '', 9);
if ($this->view['kunde']['ustidnr'] != "") {
$offset += 13;
$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
}
$offset += 10;
$offset = $checkPageBreak($this, $offset, 6);
if ($this->get_option('wpsg_kleinunternehmer')) {
$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
$offset += 5;
} else {
if ($bNoTax) {
$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("BRUTTOBETRAG GESAMT", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
$offset += 5;
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. GESAMT", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
} else {
$pdf->Text($prod_left, $prod_top + $offset + 10, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("NETTOBETRAG GESAMT", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
if (sizeof($arCalculation['tax']) > 1) {
$offset += 5;
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. GESAMT", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['tax'], $this->get_option('wpsg_currency')), 0, 0, 'R');
}
}
}
// Wertgutschein
if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
$offset += 5;
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Bruttobetrag GESAMT", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->setFont('Arial', '', '9');
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
$pdf->setFont('Arial', '', '9');
foreach ($this->view['multi_data']['order_data'] as $order_data) {
$arCalculationOrder = $order_data['arCalculation'];
foreach ($arCalculationOrder['coupon'] as $c) {
$offset += 5;
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
$pdf->setFont('Arial', '', '9');
$pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
$pdf->setFont('Arial', '', '9');
}
}
$offset += 5;
$pdf->setFont('Arial', 'B', '9');
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("ZU ZAHLEN", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
/* Endbetrag wird fett ausgegeben */
$pdf->setFont('Arial', 'B', '9');
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
$pdf->setFont('Arial', '', '9');
} else {
$offset += 5;
$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("GESAMTSUMME", "wpsg"));
$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
/* Endbetrag wird fett ausgegeben */
$pdf->setFont('Arial', 'B', '9');
$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
$pdf->setFont('Arial', '', '9');
}
if ($this->get_option('wpsg_kleinunternehmer') == '1')
{
$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 15, 5, $this->get_option('wpsg_kleinunternehmer_text'));
$offset += 15;
}
if ($this->hasMod('wpsg_mod_deliverynote'))
{
$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($data['id']));
$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($data['id']));
// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
if ($delivery_date !== false && sizeof($arDN_order) == 1)
{
$offset += 10;
$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset + 10, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
$offset += 5;
}
}
$offset += 5;
if ($this->view['fussText'] != "")
{
//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));
$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $this->view['fussText']);
$pdf->SetFont('Arial', 'B', 9);
$offset += 10;
}
$shipping_adress = false;
$offset += 5;
$filename = $this->view['filename'].".pdf";
if ($this->view['preview']) {
$pdf->Output();
exit;
} else {
$pdf->Output($this->view['file_path'], 'F');
}