From 8d0a9e6facaf893b06c96c3ba59d2fbc2aa465ce Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 2 Jul 2020 01:21:14 +0200 Subject: [PATCH] add payment informations --- .../AbstractClasses/pdfdocumentsGeneric.php | 9 +++-- .../AbstractClasses/pdfdocumentsOrder.php | 35 +++++++++++++++++-- .../translations/de/pdfdocuments_lang.php | 1 + .../translations/en/pdfdocuments_lang.php | 9 ++--- .../documents/deliverynote/deliverynote.tpl | 2 +- .../documents/deliverynote/inc/conclusion.tpl | 9 ++--- .../tpl/documents/invoice/inc/conclusion.tpl | 35 ++++++++----------- .../tpl/documents/invoice/inc/payinfo.tpl | 16 +++++++++ .../views/tpl/documents/invoice/invoice.tpl | 2 +- metadata.php | 1 + out/src/css/pdfStyling.css | 10 ++---- 11 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 Application/views/tpl/documents/invoice/inc/payinfo.tpl diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 4989655..3e66377 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -133,12 +133,17 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface return null; } - public function setSmartyVars() + /** + * @param int $iSelLang + */ + public function setSmartyVars($iSelLang) { + unset($iSelLang); $this->oSmarty->assign('oConfig', Registry::getSession()->getConfig()); $this->oSmarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig()); $this->oSmarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop()); $this->oSmarty->assign('lang', Registry::getLang()); + $this->oSmarty->assign('document', $this); } /** @@ -156,7 +161,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface $currTplLang = $lang->getTplLanguage(); $lang->setTplLanguage($iSelLang); - $this->setSmartyVars(); + $this->setSmartyVars($iSelLang); $content = $this->oSmarty->fetch($this->getTemplate()); diff --git a/Application/Model/AbstractClasses/pdfdocumentsOrder.php b/Application/Model/AbstractClasses/pdfdocumentsOrder.php index 3029148..d920c9b 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsOrder.php +++ b/Application/Model/AbstractClasses/pdfdocumentsOrder.php @@ -22,6 +22,7 @@ use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface as o use \OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Payment; use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Core\Registry; use Spipu\Html2Pdf\Exception\Html2PdfException; abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface @@ -45,9 +46,12 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt return $this->oOrder; } - public function setSmartyVars() + /** + * @param int $iSelLang + */ + public function setSmartyVars($iSelLang) { - parent::setSmartyVars(); + parent::setSmartyVars($iSelLang); $this->oSmarty->assign('order', $this->getOrder()); @@ -56,7 +60,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt $this->oSmarty->assign('user', $oUser); $oPayment = oxNew(Payment::class); - $oPayment->load($this->getOrder()->getFieldData('oxpaymenttype')); + $oPayment->loadInLang($iSelLang, $this->getOrder()->getFieldData('oxpaymenttype')); $this->oSmarty->assign('payment', $oPayment); } @@ -110,4 +114,29 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt return parent::genPdf($sFilename, $iSelLang, $target); } + + /** + * @return int + */ + public function getPaymentTerm() + { + if (null === $iPaymentTerm = Registry::getConfig()->getConfigParam('iPaymentTerm')) { + $iPaymentTerm = 7; + } + + return $iPaymentTerm; + } + + /** + * @return false|string + */ + public function getPayableUntilDate() + { + return strtotime( + '+' . $this->getPaymentTerm() . ' day', + strtotime( + $this->getOrder()->getFieldData('oxbilldate') + ) + ); + } } \ No newline at end of file diff --git a/Application/translations/de/pdfdocuments_lang.php b/Application/translations/de/pdfdocuments_lang.php index 65c2781..ee1ac5a 100644 --- a/Application/translations/de/pdfdocuments_lang.php +++ b/Application/translations/de/pdfdocuments_lang.php @@ -68,6 +68,7 @@ $aLang = array( 'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Gesamtsumme (brutto)', 'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Ihre gewählte Zahlungsweise', + 'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Zahlbar bis zum', 'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'Den Rechnungsbetrag haben wir dankend erhalten.', 'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Geschäftsführer', diff --git a/Application/translations/en/pdfdocuments_lang.php b/Application/translations/en/pdfdocuments_lang.php index dd76647..3d2f93c 100644 --- a/Application/translations/en/pdfdocuments_lang.php +++ b/Application/translations/en/pdfdocuments_lang.php @@ -56,17 +56,18 @@ $aLang = array( 'D3_PDFDOCUMENTS_UNDEFINED_TAX' => 'plus VAT', 'D3_PDFDOCUMENTS_PROPORTIONAL_TAX' => 'plus VAT (proportionally calculated)', 'D3_PDFDOCUMENTS_VOUCHERDISCOUNT' => 'Coupon', - 'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Shipping costs (net)', + 'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Shipping costs (excl. tax)', 'D3_PDFDOCUMENTS_DELIVERY' => 'Shipping costs', - 'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Additional Charge Payment Method (net)', + 'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Additional Charge Payment Method (excl. tax)', 'D3_PDFDOCUMENTS_PAYMENT' => 'Additional Charge Payment Method', - 'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Gift Wrapping (net)', + 'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Gift Wrapping (excl. tax)', 'D3_PDFDOCUMENTS_WRAPPING' => 'Gift Wrapping', - 'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Greeting Card (net)', + 'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Greeting Card (excl. tax)', 'D3_PDFDOCUMENTS_GIFTCARD' => 'Greeting Card', 'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Total sum (gross)', 'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Your chosen payment method', + 'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Billing till', 'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'We have received the invoice amount with thanks.', 'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Managing director', diff --git a/Application/views/tpl/documents/deliverynote/deliverynote.tpl b/Application/views/tpl/documents/deliverynote/deliverynote.tpl index f0820fa..215e32f 100644 --- a/Application/views/tpl/documents/deliverynote/deliverynote.tpl +++ b/Application/views/tpl/documents/deliverynote/deliverynote.tpl @@ -1,4 +1,4 @@ -[{assign var="pagePadding" value=","|explode:"45,15,25,25"}] [{* top, right, bottom, left *}] +[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}] [{assign var="showLogo" value=$showLogo|default:true}] [{capture append="pdfBlock_style"}] diff --git a/Application/views/tpl/documents/deliverynote/inc/conclusion.tpl b/Application/views/tpl/documents/deliverynote/inc/conclusion.tpl index c79a7a7..45544e6 100644 --- a/Application/views/tpl/documents/deliverynote/inc/conclusion.tpl +++ b/Application/views/tpl/documents/deliverynote/inc/conclusion.tpl @@ -1,11 +1,6 @@ [{block name="conclusion"}] - - - - -
- [{oxmultilang ident="D3_DELIVERYNOTE_PDF_PAYABLEUNTIL"}] 20.05.2020 -
+ [{block name="conclusion_thankyou"}] + [{/block}]
[{/block}] \ No newline at end of file diff --git a/Application/views/tpl/documents/invoice/inc/conclusion.tpl b/Application/views/tpl/documents/invoice/inc/conclusion.tpl index e7541c3..2d79b32 100644 --- a/Application/views/tpl/documents/invoice/inc/conclusion.tpl +++ b/Application/views/tpl/documents/invoice/inc/conclusion.tpl @@ -1,24 +1,19 @@ [{block name="conclusion"}] - - [{block name="conclusion_paymethod"}] - - - - [{/block}] - - - - - - -
- [{oxmultilang ident="D3_PDFDOCUMENTS_USED_PAYMENTMETHOD" suffix="COLON"}] - [{$payment->getFieldData('oxdesc')}] -
- [{oxmultilang ident="D3_PDFDOCUMENTS_THANKYOU_1"}] -
- [{oxmultilang ident="D3_PDFDOCUMENTS_THANKYOU_2" args=$shop->getFieldData('oxname')}] -
+ [{block name="conclusion_paymethod"}] +
+ [{oxmultilang ident="D3_PDFDOCUMENTS_USED_PAYMENTMETHOD" suffix="COLON"}] + [{$payment->getFieldData('oxdesc')}]
+ + [{include file="d3invoice_pdf_payinfo.tpl"}] +
+ [{/block}] + + [{block name="conclusion_thankyou"}] +
+ [{oxmultilang ident="D3_PDFDOCUMENTS_THANKYOU_1"}]
+ [{oxmultilang ident="D3_PDFDOCUMENTS_THANKYOU_2" args=$shop->getFieldData('oxname')}] +
+ [{/block}]
[{/block}] diff --git a/Application/views/tpl/documents/invoice/inc/payinfo.tpl b/Application/views/tpl/documents/invoice/inc/payinfo.tpl new file mode 100644 index 0000000..01c6918 --- /dev/null +++ b/Application/views/tpl/documents/invoice/inc/payinfo.tpl @@ -0,0 +1,16 @@ +[{block name="payinfo"}] + [{if $payment->getId() == 'oxidinvoice'}] + [{block name="payinfo_billable_till"}] + [{assign var="dateFormat" value='D3_PDFDOCUMENTS_DATE_FORMAT'|oxmultilangassign}] + [{oxmultilang ident="D3_PDFDOCUMENTS_PAYABLEUNTIL"}] + [{$document->getPayableUntilDate()|date_format:$dateFormat}] + [{/block}] + [{elseif $payment->getId() == 'oxidpayadvance' || $payment->getId() == 'oxidcreditcard'}] + [{block name="payinfo_payed"}] + [{oxmultilang ident="D3_PDFDOCUMENTS_RECEIVED_PAYMENT"}] + [{/block}] + [{else}] + [{block name="payinfo_other"}] + [{/block}] + [{/if}] +[{/block}] diff --git a/Application/views/tpl/documents/invoice/invoice.tpl b/Application/views/tpl/documents/invoice/invoice.tpl index 748ffa8..999559a 100644 --- a/Application/views/tpl/documents/invoice/invoice.tpl +++ b/Application/views/tpl/documents/invoice/invoice.tpl @@ -1,4 +1,4 @@ -[{assign var="pagePadding" value=","|explode:"45,15,25,25"}] [{* top, right, bottom, left *}] +[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}] [{assign var="showLogo" value=$showLogo|default:true}] [{capture append="pdfBlock_style"}] diff --git a/metadata.php b/metadata.php index 022bc2d..5952b46 100644 --- a/metadata.php +++ b/metadata.php @@ -61,6 +61,7 @@ $aModule = [ 'd3invoice_pdf_informations.tpl'=> 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/informations.tpl', 'd3invoice_pdf_salutation.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/salutation.tpl', 'd3invoice_pdf_conclusion.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/conclusion.tpl', + 'd3invoice_pdf_payinfo.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/payinfo.tpl', 'd3pdfbase.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/base.tpl', 'd3pdfheader.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/header.tpl', diff --git a/out/src/css/pdfStyling.css b/out/src/css/pdfStyling.css index a841539..97f079c 100644 --- a/out/src/css/pdfStyling.css +++ b/out/src/css/pdfStyling.css @@ -189,13 +189,9 @@ table{ font-weight: bold; } -.conclusion_table { - width: 100%; - border-spacing: 0; - border-collapse: collapse; - padding-top: 10mm -} -.conclusion_table td { +.conclusion_payment, +.conclusion_thankyou { + margin-top: 5mm; font-size: 12px; }