From 068a4be41664a167aeb88656110d44fe4948466a Mon Sep 17 00:00:00 2001 From: Daniel Schmitzer Date: Mon, 15 Aug 2022 09:51:48 +0000 Subject: - Rechnungen Sammel git-svn-id: https://[internal]/wordpress/plugins/wpsg4@8069 0d5edaf7-2b12-4e95-93f4-047927463d4b --- views/mods/mod_rechnungen/multi_invoice_pdf.phtml | 557 ++++++++-------------- views/order/index.phtml | 46 +- 2 files changed, 246 insertions(+), 357 deletions(-) diff --git a/views/mods/mod_rechnungen/multi_invoice_pdf.phtml b/views/mods/mod_rechnungen/multi_invoice_pdf.phtml index 2b1f0d1..c1a6c7a 100644 --- a/views/mods/mod_rechnungen/multi_invoice_pdf.phtml +++ b/views/mods/mod_rechnungen/multi_invoice_pdf.phtml @@ -9,8 +9,8 @@ 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; - + global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $rhead_left, $rhead_top, $sum_multi_offset, $pdf; + // Positionierung der Absenderadresszeile $absender_left = 25; $absender_top = 50; @@ -41,19 +41,9 @@ if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto'; else $taxdisplay = 'brutto'; - // Damit die Steuer bei der Kleinunternehmerregelung nicht angezeigt wird leer ich den Array sicherheitshalber - if ($this->get_option('wpsg_kleinunternehmer') == '1') - { - - unset($this->view['basket']['mwst']); + if (!function_exists('AddRechnungPage')) { - } - - if (!function_exists('AddRechnungPage')) - { - - function AddRechnungPage($shop, $pdf) - { + function AddRechnungPage($shop, $pdf) { global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $offset, $sum_multi_offset; @@ -148,8 +138,7 @@ $pdf->Text($rdata_left + 75, $rdata_top + 6, $shop->view['rDatum']); // InnerEu Hinweistext - if ($shop->view['oOrder']->isInnerEu()) - { + if ($shop->view['oOrder']->isInnerEu()) { $pdf->SetFont('Arial', '', 9); $pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg")); @@ -184,9 +173,21 @@ // wpsg_debug($this->view['multi_data']['orders']); // DEBUG $pdf = new wpsg_fpdf(); - $pdf->SetAutoPageBreak(true, 5); + //$pdf->SetAutoPageBreak(true, 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']; @@ -199,32 +200,31 @@ $sum_shipping_netto = 0; $sum_payment_brutto = 0; $sum_payment_netto = 0; - - foreach ($orders as $oSum) { - - // Produktgesamtsumme - foreach ($oSum['arCalculation']['product'] as $p) { - $sum_productsum_brutto += $p['brutto']; - $sum_productsum_netto += $p['netto']; - } - - // Zahlungssumme gesamt - $sum_topay_brutto += $oSum['arCalculation']['sum']['topay_brutto']; - $sum_topay_netto += $oSum['arCalculation']['sum']['topay_netto']; - - // Gesamtzahlungskosten - $sum_payment_brutto += $oSum['arCalculation']['sum']['payment_brutto']; - $sum_payment_netto += $oSum['arCalculation']['sum']['payment_netto']; - - // Gesamtversandkosten - $sum_shipping_brutto += $oSum['arCalculation']['sum']['shipping_brutto']; - $sum_shipping_netto += $oSum['arCalculation']['sum']['shipping_netto']; - - } - + + // moMwSt + $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 ($orders as $oOrder) { + 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); @@ -233,40 +233,32 @@ $pdf->SetFont('Arial', '', 9); // Zahlungsbedingung anzeigen - if (isset($oOrder['arCalculation']['payment'][0]['payment_key'])) - { - - $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset, __("Zahlungsbedingungen", "wpsg")); - $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset + 6, $this->arPayment[$oOrder['arCalculation']['payment'][0]['payment_key']]['name']); - - } - + $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset, __("Zahlungsbedingungen", "wpsg")); + $pdf->Text($rhead_left + 120, $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, ((trim($oOrder['data']['onr']) != '')?$oOrder['data']['onr']:$oOrder['data']['id'])); + $pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset + 6, $oOrder->getNr()); $summe = 0; - $mwst_value = array_values($oOrder['arCalculation']['tax'])[0]; $bKopf = false; $pnr = 1; $offset = 0; $count = 0; - foreach ($oOrder['produkte'] as $p) - { + foreach ($oOrder->getOrderProducts() as $oOrderProduct) { - if (!$bKopf) - { + $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); - if(is_array($mwst_value['tax_value'])) { - $pdf->Cell( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, "Name", 1, 0, 'L'); - } - - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { + + $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'); @@ -290,34 +282,26 @@ $pdf->SetFont('Arial', '', 9); $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset); - if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') - { + if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') { - $pdf->Cell(10, 8, $p['anr'], 0, 0, 'C'); + $pdf->Cell(10, 8, $oOrderProduct->getProduct()->getProductNr(), 0, 0, 'C'); - } - else - { + } else { $pdf->Cell(10, 8, $pnr.".", 0, 0, 'C'); } /* Wenn Detailname vorhanden, wird der Detailname auf Rechnung verwendet */ - $produkt_text = $this->getProductName($this->getProduktID($p['id']), true); - - /* Falls Detailname vorhanden, wird jetzt der Produktname verwendet */ - /* $produkt_text = $this->getProductName($this->getProduktID($p['id']), false); */ + $produkt_text = $this->getProductName($product_id, true); - $produktBeschreibung = trim(strip_tags($p['beschreibung'])); + $produktBeschreibung = trim(strip_tags($oOrderProduct->getProduct()->getShortDescription())); - if ($this->isOtherLang()) - { + if ($this->isOtherLang()) { - $trans_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($this->getProduktID($p['id']))."' AND `lang_code` = '".wpsg_q($this->getCurrentLanguageCode())."'"); + $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) - { + if (is_array($trans_db) && sizeof($trans_db) > 0) { $produkt_text = $trans_db['name']; $produktBeschreibung = trim(strip_tags($trans_db['beschreibung'])); @@ -331,16 +315,13 @@ $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") - { + if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1") { - $arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($oOrder['data']['id'], $p['product_index'])); + $arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($oOrder->getId(), $oOrderProduct->getProductIndex())); - if (wpsg_isSizedArray($arPV)) - { + if (wpsg_isSizedArray($arPV)) { - foreach ($arPV as $pv) - { + foreach ($arPV as $pv) { $produkt_text .= "\r\n".$pv['name'].': '.$pv['value']; $height += 5; @@ -351,64 +332,46 @@ } - if ($this->get_option('wpsg_mod_rechnungen_anr') === '2') - { + if ($this->get_option('wpsg_mod_rechnungen_anr') === '2') { - $anr = $this->getProductAnr($p['productkey']); + $anr = $this->getProductAnr($oOrderProduct->getProductKey()); $produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr); } - - $produkt_text_cell_width = 102; - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { - $produkt_text_cell_width = 87; - } + + if ($bTaxCol) $produkt_text_cell_width = 87; + else $produkt_text_cell_width = 102; $produkt_text_width = $pdf->GetStringWidth($produkt_text); - //$produkt_text_cell_width = (($this->arMwSt == "-1")?87:102); $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); - - //$height += 3 + 5 + $pdf->getY() - $height_y; - //$pdf->Cell((($this->arMwSt == "-1")?102:87), 8, $produkt_text, 0, 0, 'L'); - - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') { + + if ($bTaxCol) { $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset); - $pdf->Cell(15, 8, (($this->view['basket']['noMwSt'] == '1')?'0.00 %':wpsg_ff($p['mwst_value'], '%')), 0, 0, 'C'); + $pdf->Cell(15, 8, (($bNoTax)?'0.00 %':wpsg_ff($oOrderProduct->getTaxValue(), '%')), 0, 0, 'C'); } $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset); - $pdf->Cell(15, 8, $p['menge'], 0, 0, 'C'); + $pdf->Cell(15, 8, $oOrderProduct->getAmount(), 0, 0, 'C'); - if (wpsg_ShopController::get_option('wpsg_preisangaben') == WPSG_NETTO) - { - $preis = $p['preis_netto']; - - //TODO - } - else - { - $preis = $p['preis_brutto']; - } + $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($preis * $p['menge'], $this->get_option('wpsg_currency')), 0, 0, 'R'); + $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($p['beschreibung'])) != '') - { + if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($p['beschreibung'])) != '') { $produktBeschreibung = nl2br($produktBeschreibung); preg_match_all('/\
/', $produktBeschreibung, $treffer); @@ -431,13 +394,11 @@ /** * Produktattribute ? */ - if ($this->get_option('wpsg_rechnungen_produktattribute') == '1') - { + if ($this->get_option('wpsg_rechnungen_produktattribute') == '1') { $attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($p['id']))); - foreach ($attributeInfo as $pa) - { + 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); @@ -448,8 +409,7 @@ /** * Variante ? */ - if (preg_match('/pv_(.*)/', $p['productkey'])) - { + if (preg_match('/pv_(.*)/', $p['productkey'])) { $variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['productkey'])); @@ -462,18 +422,15 @@ /** * Lieferschein ? */ - if ($this->hasMod('wpsg_mod_deliverynote')) - { + if ($this->hasMod('wpsg_mod_deliverynote')) { - $arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($oOrder['data']['id'])); + $arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($oOrder->getId())); - if (sizeof($arDN_order) > 1) - { + if (sizeof($arDN_order) > 1) { - $deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($oOrder['data']['id'], $p['product_index'])); + $deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($oOrder->getId(), $oOrderProduct->getProductIndex())); - if ($deliveryTimeProduct !== false) - { + 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); @@ -486,10 +443,9 @@ // 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, ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), $height); + $pdf->Rect($prod_left + 10, $prod_top + $offset + $sum_multi_offset, (($bTaxCol == '1')?87:102), $height); - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { + if ($bTaxCol) { $pdf->Rect($prod_left + 97, $prod_top + $offset + $sum_multi_offset, 15, $height); @@ -506,8 +462,7 @@ $summe += $p['price'] * $p['menge']; - if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($oOrder['arCalculation']['produkte']) > ($pnr - 1))) - { + if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($oOrder->getOrderProducts()) > ($pnr - 1))) { AddRechnungPage($this, $pdf); $bKopf = false; $count = 0; $offset = 0; @@ -515,26 +470,23 @@ } } // produkte - wpsg_debug($oOrder['arCalculation']); + // Gutschein - if (wpsg_isSizedArray($oOrder['arCalculation']['voucher'])) { + if (wpsg_isSizedArray($arCalculation['voucher'])) { - foreach ($oOrder['arCalculation']['voucher'] as $v) { + 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( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L'); + $pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L'); - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { - - $mwst = __('anteilig', 'wpsg'); + if ($bTaxCol) { $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset); - $pdf->Cell(15, 8, $mwst, 1, 0, 'C'); + $pdf->Cell(15, 8, __('anteilig', 'wpsg'), 1, 0, 'C'); } @@ -557,41 +509,38 @@ } // Versandkosten - if ($oOrder['arCalculation']['sum']['preis_shipping'] != '' && $oOrder['arCalculation']['sum']['preis_shipping'] != 0) - { + $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( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $this->view['oOrder']->getShippingLabel()), 1, 0, 'L'); + $pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $oOrder->getShippingLabel()), 1, 0, 'L'); - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { - - if ($this->arShipping[$oOrder['data']['type_shipping']]['mwst_null'] == '1' && $oOrder['basket']['noMwSt'] == '1') - { + if ($bTaxCol) { + + if ($bNoTax) { $mwst = 0; - } - else - { + } else { - if ($oOrder['arCalculation']['shipping'][0]['tax_key'] === '0') { + if ($arCalculation['shipping'][0]['tax_key'] === '0') { $mwst = _('anteilig'); } else { - $mwst = wpsg_ff($oOrder['arCalculation']['shipping'][0]['tax'], '%'); - $mwst = wpsg_ff($oOrder['arCalculation']['tax'][$oOrder['arCalculation']['shipping'][0]['tax_key']]['tax_value'], '%'); + $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'); @@ -601,85 +550,43 @@ $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($oOrder['arCalculation']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R'); + $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($oOrder['arCalculation']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R'); + $pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R'); $offset += 8; - // Zusammengesetzte Versandarten darstellen - /* - if (wpsg_isSizedArray($this->view['basket']['shipping']['methods'])) { - - foreach ($this->view['basket']['shipping']['methods'] as $shipping) { - - $pdf->SetFont('Arial', '', 9); - $pdf->setXY($prod_left, $prod_top + $offset); - $pdf->Cell(10, 8, '', 1, 0, 'C'); $pnr ++; - - $pdf->setXY($prod_left + 10, $prod_top + $offset); - $pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->getShippingName($shipping), 1, 0, 'L'); - - if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1') - { - - if ($this->view['basket']['shipping'][$shipping]['tax_rata'] == 1) { $mwst = __('Anteilig', 'wpsg'); } - else { $mwst = wpsg_ff($this->view['basket']['shipping'][$shipping]['mwst'], '%'); } - - $pdf->setXY($prod_left + 97, $prod_top + $offset); - $pdf->Cell(15, 8, $mwst, 1, 0, 'C'); - - } - - $pdf->setXY($prod_left + 112, $prod_top + $offset); - $pdf->Cell(15, 8, '1', 1, 0, 'C'); - - $pdf->setXY($prod_left + 127, $prod_top + $offset); - $pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R'); - - $pdf->setXY($prod_left + 152, $prod_top + $offset); - $pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R'); - - $offset += 8; - - } - - } - */ - - } // Zahlungskosten - if ($oOrder['arCalculation']['sum']['preis_payment'] != '' && $oOrder['arCalculation']['sum']['preis_payment'] != 0) - { + $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( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->arPayment[$oOrder['data']['type_payment']]['name'], 1, 0, 'L'); + $pdf->Cell( (($bTaxCol)?87:102), 8, $oOrder->getPaymentLabel(), 1, 0, 'L'); - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { + if ($bTaxCol) { - if ($this->arPayment[$oOrder['data']['type_payment']]['mwst_null'] == '1' && $this->view['basket']['noMwSt'] == '1') - { + if ($bNoTax) { + $mwst = 0; - } - else - { + + } else { - if ($oOrder['arCalculation']['payment'][0]['tax_key'] === '0') { + if ($arCalculation['payment'][0]['tax_key'] === '0') { $mwst = _('anteilig'); } else { - $mwst = wpsg_ff($oOrder['arCalculation']['payment'][0]['tax'], '%'); - $mwst = wpsg_ff($oOrder['arCalculation']['tax'][$oOrder['arCalculation']['payment'][0]['tax_key']]['tax_value'], '%'); + $mwst = wpsg_ff($arCalculation['payment'][0]['tax'], '%'); + $mwst = wpsg_ff($arCalculation['tax'][$arCalculation['payment'][0]['tax_key']]['tax_value'], '%'); } @@ -694,18 +601,43 @@ $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($oOrder['arCalculation']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R'); + $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($oOrder['arCalculation']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R'); + $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; + + } + // Gebühr - if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0) - { + if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0) { $pdf->SetFont('Arial', '', 9); $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset); @@ -716,18 +648,15 @@ 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( ((sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $label, 1, 0, 'L'); + $pdf->Cell( (($bTaxCol)?87:102), 8, $label, 1, 0, 'L'); - if (sizeof($oOrder['arCalculation']['tax']) >= 2 || $this->get_option('wpsg_showMwstAlways') == '1') - { + if ($bTaxCol) { - if ($this->view['basket']['noMwSt'] == '1') - { + if ($bNoTax) { + $mwst = 0; - } - else - { - + + } else { $mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%'); @@ -752,79 +681,84 @@ } // Bestellbetrag einer einzelnen Bestellung - if ($arCalculation['noMwSt'] == '1') - { + 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($oOrder['arCalculation']['sum']['productsum_netto'] + $oOrder['arCalculation']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); - } - else - { + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['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($oOrder['arCalculation']['sum']['productsum_brutto'] + $oOrder['arCalculation']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['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 += 10; + 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; - if ($this->get_option('wpsg_kleinunternehmer')) - { + + $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($sum_productsum_brutto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); + $offset += 5; - } - else - { + } else { - if ($arCalculation['noMwSt'] == '1') - { + 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", "wpsg")); $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5); - $pdf->Cell(37, 8, wpsg_ff($sum_topay_brutto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); + $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, __("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 - { + } 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($sum_topay_netto + $arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['netto'], $this->get_option('wpsg_currency')), 0, 0, 'R'); - if (sizeof($arCalculation['tax']) >= 1) - { + if (sizeof($arCalculation['tax']) >= 1) { - foreach ($arCalculation['tax'] as $mw) - { + foreach ($arCalculation['tax'] as $k => $mw) { + + if ($k === 0) continue; $offset += 5; - $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%')); + + $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. ", "wpsg").wpsg_ff($mw['tax_value'], '%')); $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5); $pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R'); @@ -832,31 +766,18 @@ } - if (sizeof($arCalculation['tax']) > 1) - { + 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($sum_productsum_brutto - $sum_productsum_netto, $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['tax'], $this->get_option('wpsg_currency')), 0, 0, 'R'); } } } - - // Rabatt - if ($arCalculation['sum']['preis_rabatt'] > 0) - { - - $offset += 5; - - $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Rabatt", "wpsg")); - $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5); - $pdf->Cell(37, 8, '-'.wpsg_ff($arCalculation['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R'); - - } // Wertgutschein if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) { @@ -866,7 +787,7 @@ $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5); $pdf->setFont('Arial', '', '9'); - $pdf->Cell(37, 8, wpsg_ff($sum_productsum_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R'); $pdf->setFont('Arial', '', '9'); foreach ($orders as $oCoupons){ @@ -892,7 +813,7 @@ /* Endbetrag wird fett ausgegeben */ $pdf->setFont('Arial', 'B', '9'); - $pdf->Cell(37, 8, wpsg_ff($sum_topay_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R'); $pdf->setFont('Arial', '', '9'); } else { @@ -902,7 +823,7 @@ $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($sum_topay_brutto, $this->get_option('wpsg_currency')), 0, 0, 'R'); + $pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R'); $pdf->setFont('Arial', '', '9'); } @@ -948,102 +869,30 @@ } $shipping_adress = false; - - if ($this->hasMod('wpsg_mod_shippingadress') && $this->callMod('wpsg_mod_shippingadress', 'check_different_shippingadress', array('k_id' => $data['k_id'], 'o_id' => $data['id']))) { - - $pdf->setFont('Arial', 'B', 9); - $pdf->Text($prod_left, $prod_top + $offset + 10, __("Lieferanschrift", "wpsg").":"); - $offset += 5; - - $pdf->setFont('Arial', '', 9); - - $shipping_adress = ""; - if ($data['shipping_firma'] != "") - { - $shipping_adress .= $data['shipping_firma']."\r\n"; - } - $shipping_adress .= $data['shipping_vname'].' '.$data['shipping_name']."\r\n"; - $shipping_adress .= $data['shipping_strasse'].' '.$data['shipping_nr']."\r\n"; - //$shipping_adress .= $data['shipping_land']['kuerzel'].'-'; - - $shipping_adress .= $data['shipping_plz'].' '.$data['shipping_ort']."\r\n"; - $shipping_adress .= $data['shipping_land']['name']; - - - $start = $pdf->getY(); - $pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $shipping_adress, 0, 'L', 0, 100); - $offset += $pdf->getY() - $start; - - $shipping_adress = true; - } - $offset += 5; - - // Bestellvariablen - if ($this->hasMod('wpsg_mod_ordervars') && $this->get_option('wpsg_mod_rechnungen_showov') == '1') - { - $bvars = @unserialize($data['bvars']); - if (!is_array($bvars)) $bvars = array(); - - $strBVars = ""; - foreach ($bvars as $bvars_id => $bvars_value) - { - - $bvars = $this->db->fetchRow("SELECT * FROM `".wpsg_q(WPSG_TBL_ORDERVARS)."` WHERE `id` = '".wpsg_q($bvars_id)."' ORDER BY `pos` ASC, `id` ASC "); - - if ($bvars['typ'] == "1") // Auswahl - { - if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg"); - } - else if ($bvars['typ'] == "2") // Texteingabe - { - if (trim($bvars_value) == "") $bvars_value = __("Keine Angabe", "wpsg"); - } - else if ($bvars['typ'] == "3") // Checkbox - { - if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg"); - } - - $bvars_name = $this->callMod('wpsg_mod_ordervars', 'getNameById', array($bvars_id)); - $strBVars .= "\r\n".$bvars_name.": ".$bvars_value; - - } - - $pdf->SetFont('Arial', 'B', 9); - $pdf->Text($prod_left, $prod_top + $offset + 10, __("Angaben während der Bestellung", "wpsg").":"); - $pdf->SetFont('Arial', '', 9); - $pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $strBVars); - - } - - if (!file_exists($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])))) - { + if (!file_exists($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])))) { mkdir($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])), 0777, true); } - - $this->callMods('wpsg_mod_rechnungen_pdf', array(&$pdf, &$data['id'], &$this->view['preview'], &$this->view['invoice'])); - + $filename = $this->view['filename'].".pdf"; - - //ob_end_clean(); - - // wpsg_debug("Generierter Dateipfad: ".$this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])).$filename, 'F'); // DEBUG - + if ($this->view['preview']) { + + //$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array('multi')).$filename, 'F'); + $pdf->Output(); - $pdf->Output($filename, 'I'); + exit; } else { - $pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($data['id'])).$filename, 'F'); + $pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array('multi')).$filename, 'F'); // Hier wird der Dateiname an FPD übergeben. Er soll sich aus der Rechnungsnummer ergeben, auch wenn das Dokument über die ID gespeichert ist. if ($this->view['output'] === true) $pdf->Output($this->view['filename_out'], 'I'); } - -?> \ No newline at end of file + \ No newline at end of file diff --git a/views/order/index.phtml b/views/order/index.phtml index da8a62e..74f6c5b 100644 --- a/views/order/index.phtml +++ b/views/order/index.phtml @@ -235,7 +235,7 @@
-
+ view['arData']) && sizeof($this->view['arData']) > 0) { ?> @@ -451,7 +451,7 @@ let el_customer_inform = document.getElementById('customer_inform'); document.getElementById('wpsg_action').addEventListener('change', (event) => { - + if (parseInt(event.target.value) >= 0) { el_customer_inform.style.display = 'inline-block'; @@ -462,6 +462,18 @@ } + let el_doaction = document.getElementById('doaction'); + + if (event.target.value === 'writeMultiRechnung') { + + el_doaction.style.display = 'none'; + + } else { + + el_doaction.style.display = 'block'; + + } + }); @@ -484,6 +496,34 @@
+ +
+ + + + + + + +
-- cgit v1.2.3