From ec6a0920d07e4c9709f4d23f18e2925da2d051af Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 9 Sep 2024 14:48:01 +0200 Subject: [PATCH 1/7] don't include stylesheet as file reference, use it as included template --- metadata.php | 2 +- .../smarty/assets/pdfStyling.css.tpl | 0 .../documents/deliverynote/deliverynote.tpl | 2 +- views/smarty/documents/invoice/invoice.tpl | 2 +- views/twig/assets/pdfStyling.css.twig | 219 ++++++++++++++++++ .../deliverynote/deliverynote.html.twig | 3 +- .../twig/documents/invoice/invoice.html.twig | 3 +- 7 files changed, 224 insertions(+), 7 deletions(-) rename assets/out/src/css/pdfStyling.css => views/smarty/assets/pdfStyling.css.tpl (100%) create mode 100644 views/twig/assets/pdfStyling.css.twig diff --git a/metadata.php b/metadata.php index c6c34b2..3aa8547 100644 --- a/metadata.php +++ b/metadata.php @@ -76,7 +76,7 @@ $aModule = [ '@' . Constants::OXID_MODULE_ID . '/documents/inc/helper/rulers.tpl' => 'views/smarty/flow/documents/inc/helper/rulers.tpl', // Frontend - Flow - Inc - Styles - '@' . Constants::OXID_MODULE_ID . '/assets/d3pdfstyles.css' => 'assets/out/src/css/pdfStyling.css', + '@' . Constants::OXID_MODULE_ID . '/assets/d3pdfstyles.css.tpl' => 'views/smarty/assets/pdfStyling.css.tpl', ], 'events' => [], 'blocks' => [ diff --git a/assets/out/src/css/pdfStyling.css b/views/smarty/assets/pdfStyling.css.tpl similarity index 100% rename from assets/out/src/css/pdfStyling.css rename to views/smarty/assets/pdfStyling.css.tpl diff --git a/views/smarty/documents/deliverynote/deliverynote.tpl b/views/smarty/documents/deliverynote/deliverynote.tpl index 76a1b21..8bd8d6e 100644 --- a/views/smarty/documents/deliverynote/deliverynote.tpl +++ b/views/smarty/documents/deliverynote/deliverynote.tpl @@ -3,7 +3,7 @@ [{capture append="pdfBlock_style"}] [{block name="pdfStyles"}] - [{include file="@d3PdfDocuments/assets/d3pdfstyles.css"}] + [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{/block}] [{/capture}] diff --git a/views/smarty/documents/invoice/invoice.tpl b/views/smarty/documents/invoice/invoice.tpl index a801998..f4034c8 100644 --- a/views/smarty/documents/invoice/invoice.tpl +++ b/views/smarty/documents/invoice/invoice.tpl @@ -3,7 +3,7 @@ [{capture append="pdfBlock_style"}] [{block name="pdfStyles"}] - [{include file="@d3PdfDocuments/assets/d3pdfstyles.css"}] + [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{/block}] [{/capture}] diff --git a/views/twig/assets/pdfStyling.css.twig b/views/twig/assets/pdfStyling.css.twig new file mode 100644 index 0000000..315fa53 --- /dev/null +++ b/views/twig/assets/pdfStyling.css.twig @@ -0,0 +1,219 @@ +table{ + font-family: "helvetica"; +} + +.header { + padding: 5mm; + height: 35mm; + width: 100%; + position: relative; +} +.header img.logo { + float: right; + margin: 10mm; + margin-right: 0; +} + +.addressarea, +.deliveryaddress { + left: 0; + width: 80mm; + height: 45mm; + position: relative; +} +.deliveryaddress { + margin-top: 10mm; + height: 27.3mm; +} +.addressarea .returnAddress, +.addressarea .recipientAddress { + position: relative; +} +.addressarea .returnAddress { + height: 17.7mm; + font-size: 8px; +} +.addressarea .returnAddress div { + padding-top: 3mm; +} +.addressarea .recipientAddress { + height: 27.3mm; +} +.addressarea .recipientAddress .location, +.deliveryaddress .location { + font-weight: bold; +} +.addressarea .recipientAddress .country { + padding-top: 5mm; +} +.deliveryaddress .headline { + font-size: 10px; + padding-bottom: 2mm; +} + +.informations { + width: 75mm; + right: 0; + top: 5mm; + position: absolute; +} +.contactinformations, +.bankaccountinformations, +.documentinformations { + margin-bottom: 5mm; +} +.contactinformations div, +.bankaccountinformations div, +.documentinformations div { + text-align: right; + font-size: 11px; +} +.contactinformations div.headline, +.bankaccountinformations div.headline, +.documentinformations div.headline { + font-weight: bold; +} + +.salutation { + margin-top: 5mm; +} +.salutation .documenttype { + font-weight: bold; + margin-bottom: 5mm; +} + +.article_table, +.article_table_prices { + width: 100%; + margin-top: 5mm; + border-spacing: 0; + border-collapse: collapse; +} +.article_table th, +.article_table td, +.article_table_prices th, +.article_table_prices td { + padding-bottom: 2mm; + vertical-align: top; +} +.article_table th, +.article_table_prices th { + border-bottom: solid 0.75pt #000; + font-weight: normal; + font-size: 11px; +} +.article_table td, +.article_table_prices td { + padding-top: 2mm; + font-size: 12px; +} +.article_table th.amount, +.article_table td.amount { + width: 10%; +} +.article_table_prices th.amount, +.article_table_prices td.amount, +.article_table_prices th.tax, +.article_table_prices td.tax { + width: 10%; +} +.article_table_prices th.tax, +.article_table_prices td.tax { + text-align: right; + padding-right: 0; +} +.article_table th.description, +.article_table td.description { + width: 90%; +} +.article_table_prices th.description, +.article_table_prices td.description { + width: 50%; +} +.article_table td.description .artnr, +.article_table_prices td.description .artnr { + font-size: 9px; +} +.article_table_prices th.unitPrice, +.article_table_prices td.unitPrice, +.article_table_prices th.totalPrice, +.article_table_prices td.totalPrice { + width: 15%; + text-align: right; +} +.article_table td.amount, +.article_table_prices td.amount { + text-align: right; + padding-right: 10mm; +} +.article_table_prices td.unitPrice, +.article_table_prices td.totalPrice { + text-align: right; + padding-right: 0; +} + +.article_costs_table{ + width: 100%; + border-spacing: 0; + border-collapse: collapse; +} +.article_costs_table .indent { + width: 10%; +} +.article_costs_table .description { + width: 75%; +} +.article_costs_table td { + padding-bottom: 5px; + padding-top: 5px; + font-size: 12px; +} +.article_costs_table .values { + width: 15%; + margin-right: -2.2px; + text-align: right; +} +.article_costs_table .sumnetto td { + border-top: 0.75pt solid #000; +} +.article_costs_table .voucherdiscount td, +.article_costs_table .sumbrutto td { + border-bottom: solid 0.75pt #000; +} +.article_costs_table .totalseparator td { + height: 0; + line-height: 0; +} +.article_costs_table .totalseparator td, +.article_costs_table .totalsum td { + border-bottom: solid 0.75pt #000; + font-weight: bold; +} +.article_costs_table .totalsum td { + border-bottom: double 2pt #000; +} + +.conclusion_payment, +.conclusion_thankyou { + margin-top: 5mm; + font-size: 12px; +} + +.footer{ + width: 173mm; + font-size: 9px; + position: relative; + margin: 0; + padding: 0; +} +.footer table { + border-top: solid 0.75pt #000; + width: 100%; + position: relative; +} +.footerLeft, +.footerCenter, +.footerRight { + width: 33%; + padding: 0 2mm; +} \ No newline at end of file diff --git a/views/twig/documents/deliverynote/deliverynote.html.twig b/views/twig/documents/deliverynote/deliverynote.html.twig index 312b082..7645ebe 100644 --- a/views/twig/documents/deliverynote/deliverynote.html.twig +++ b/views/twig/documents/deliverynote/deliverynote.html.twig @@ -3,8 +3,7 @@ {% set pdfBlock_style %} {% block pdfStyles %} - {{ style({ include: oViewConf.getModuleUrl('d3PdfDocuments', 'out/src/css/pdfStyling.css') }) }} - {{ style() }} + {% include "@d3PdfDocuments/assets/pdfStyling.css.twig" %} {% endblock %} {% endset %} diff --git a/views/twig/documents/invoice/invoice.html.twig b/views/twig/documents/invoice/invoice.html.twig index 5d70c83..b7402a2 100644 --- a/views/twig/documents/invoice/invoice.html.twig +++ b/views/twig/documents/invoice/invoice.html.twig @@ -3,8 +3,7 @@ {% set pdfBlock_style %} {% block pdfStyles %} - {{ style({ include: oViewConf.getModuleUrl('d3PdfDocuments', 'out/src/css/pdfStyling.css') }) }} - {{ style() }} + {% include "@d3PdfDocuments/assets/pdfStyling.css.twig" %} {% endblock %} {% endset %} From beaa79c0e98e66d6c9c7db07bb427ed7527d2095 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 9 Sep 2024 16:29:13 +0200 Subject: [PATCH 2/7] get dev mode from module setting service --- .../Model/AbstractClasses/pdfdocumentsGeneric.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 15270eb..93412ff 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -26,6 +26,8 @@ use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterf use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Smarty; use Spipu\Html2Pdf\Exception\Html2PdfException; use Spipu\Html2Pdf\Html2Pdf; @@ -342,15 +344,19 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface /** * @param Html2Pdf $oPdf - * @param $sFilename - * @param $target - * @param $html + * @param $sFilename + * @param $target + * @param $html + * * @return string|null * @throws Html2PdfException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function output(Html2Pdf $oPdf, $sFilename, $target, $html) { - if ((bool) Registry::getConfig()->getConfigParam('d3PdfDocumentsbDev') === true) { + $moduleSettings = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); + if ($moduleSettings->getBoolean( 'd3PdfDocumentsbDev', Constants::OXID_MODULE_ID )) { return $this->outputDev($oPdf, $sFilename, $target, $html); } else { return $oPdf->output($sFilename, $target); From d89b00843f83161770e6b986e822cf2adc0925d0 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 9 Sep 2024 22:44:49 +0200 Subject: [PATCH 3/7] add template block overloadable company logo --- .../AbstractClasses/pdfdocumentsGeneric.php | 25 ------------------ .../admin_smarty/de/pdfdocuments_lang.php | 8 +++--- .../admin_smarty/en/pdfdocuments_lang.php | 8 +++--- .../views/admin_twig/de/pdfdocuments_lang.php | 6 +---- .../views/admin_twig/en/pdfdocuments_lang.php | 8 +++--- README.en.md | 3 ++- README.md | 1 + assets/out/img/clogo.jpg | Bin 0 -> 4538 bytes metadata.php | 6 ----- views/smarty/documents/inc/page/header.tpl | 8 +++--- .../twig/documents/inc/page/header.html.twig | 11 +++----- 11 files changed, 19 insertions(+), 65 deletions(-) create mode 100644 assets/out/img/clogo.jpg diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 93412ff..da6ecce 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -187,37 +187,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface unset($iSelLang); $this->oTemplateEngine->addGlobal('config', Registry::getConfig()); - $this->oTemplateEngine->addGlobal('sAlternativePdfLogo', $this->getAlternativePdfLogoFileName()); $this->oTemplateEngine->addGlobal('oViewConf', Registry::getConfig()->getActiveView()->getViewConfig()); $this->oTemplateEngine->addGlobal('shop', Registry::getConfig()->getActiveShop()); $this->oTemplateEngine->addGlobal('lang', Registry::getLang()); $this->oTemplateEngine->addGlobal('document', $this); } - /** - * @return string - */ - public function getAlternativePdfLogoFileName() :string - { - $sStandardLogoFile = 'pdf_logo.jpg'; - $oViewConf = Registry::getConfig()->getActiveView()->getViewConfig(); - $moduleSettingService = ContainerFacade::get(ModuleSettingServiceInterface::class); - $sAlternativePdfLogoName = $moduleSettingService->getString(Constants::OXID_MODULE_ID."_sAlternativePdfLogoName", Constants::OXID_MODULE_ID); - - $sAlternativePdfLogoName = trim($sAlternativePdfLogoName) ?: $sStandardLogoFile; - - $bAlternativeFileExists = file_exists(Registry::getConfig()->getImagePath($sAlternativePdfLogoName)); - $bFileExists = file_exists(Registry::getConfig()->getImagePath($sStandardLogoFile)); - - return $bAlternativeFileExists - ? $oViewConf->getImageUrl($sAlternativePdfLogoName, true) - : ( - $bFileExists - ? $oViewConf->getImageUrl($sStandardLogoFile, true) - : "" - ); - } - /** * @param int $iSelLang * diff --git a/Application/views/admin_smarty/de/pdfdocuments_lang.php b/Application/views/admin_smarty/de/pdfdocuments_lang.php index d77afd1..8556b65 100644 --- a/Application/views/admin_smarty/de/pdfdocuments_lang.php +++ b/Application/views/admin_smarty/de/pdfdocuments_lang.php @@ -8,16 +8,14 @@ * @link http://www.oxidmodule.com */ +use D3\PdfDocuments\Application\Model\Constants; + $sLangName = "Deutsch"; $aLang = array( 'charset' => 'utf-8', 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternativer PDF-Logo Name

- Ohne Angabe ( leer ) wird automatisch folgender Datei-Name gewählt: pdf_logo.jpg
- Diese Datei muss sich im source/out/THEME/img/ Ordner befinden und muss aus technischen Gründen PNG/ JPG sein.

- Notfalls wird kein Bild eingefügt!', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', diff --git a/Application/views/admin_smarty/en/pdfdocuments_lang.php b/Application/views/admin_smarty/en/pdfdocuments_lang.php index 67947a8..bd868d4 100644 --- a/Application/views/admin_smarty/en/pdfdocuments_lang.php +++ b/Application/views/admin_smarty/en/pdfdocuments_lang.php @@ -8,16 +8,14 @@ * @link http://www.oxidmodule.com */ +use D3\PdfDocuments\Application\Model\Constants; + $sLangName = "English"; $aLang = array( 'charset' => 'utf-8', 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternative PDF Logo Name

- Without specification (empty) the following file name will be automatically selected: pdf_logo.jpg
- This file must be located in the source/out/THEME/img/ folder and must be PNG or JPG for technical reasons.

- If necessary, no image will be inserted!', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', 'D3_PDFDOCUMENTS' => 'PDF Documents', 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', diff --git a/Application/views/admin_twig/de/pdfdocuments_lang.php b/Application/views/admin_twig/de/pdfdocuments_lang.php index 4849bc9..2ecffb8 100644 --- a/Application/views/admin_twig/de/pdfdocuments_lang.php +++ b/Application/views/admin_twig/de/pdfdocuments_lang.php @@ -15,11 +15,7 @@ $aLang = array( 'charset' => 'utf-8', 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternativer PDF-Logo Name

- Ohne Angabe ( leer ) wird automatisch folgender Datei-Name gewählt: pdf_logo.jpg
- Diese Datei muss sich im source/out/THEME/img/ Ordner befinden und muss aus technischen Gründen PNG oder JPG sein.

- Notfalls wird kein Bild eingefügt!', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', diff --git a/Application/views/admin_twig/en/pdfdocuments_lang.php b/Application/views/admin_twig/en/pdfdocuments_lang.php index 5f5819c..bd868d4 100644 --- a/Application/views/admin_twig/en/pdfdocuments_lang.php +++ b/Application/views/admin_twig/en/pdfdocuments_lang.php @@ -8,16 +8,14 @@ * @link http://www.oxidmodule.com */ +use D3\PdfDocuments\Application\Model\Constants; + $sLangName = "English"; $aLang = array( 'charset' => 'utf-8', 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternative PDF Logo Name

- Without specification (empty) the following file name will be automatically selected: pdf_logo.jpg
- This file must be located in the source/out/THEME/img/ folder and must be PNG/ JPG for technical reasons.

- If necessary, no image will be inserted!', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', 'D3_PDFDOCUMENTS' => 'PDF Documents', 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', diff --git a/README.en.md b/README.en.md index b4a88ab..56b7fa7 100644 --- a/README.en.md +++ b/README.en.md @@ -38,7 +38,8 @@ Detailed installation instructions can be found [online](https://docs.oxidmodule ## Credits: -- PDF logo made by Dimitriy Morilubov from www.flaticon.com +- PDF logo made by Dimitriy Morilubov by www.flaticon.com +- example company logo by https://www.logologo.com/ ## License diff --git a/README.md b/README.md index 329093a..ccc9cfb 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Eine detaillierte Installationsanleitung finden Sie [online](https://docs.oxidmo ## Danksagung: - PDF-Logo erstellt von Dimitriy Morilubov von www.flaticon.com +- Beispielfirmenlogo von https://www.logologo.com/ ## Lizenz diff --git a/assets/out/img/clogo.jpg b/assets/out/img/clogo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..08e6f370cb3ebebdc711bf8ed0c3144c01bcc542 GIT binary patch literal 4538 zcmbVO2UJtp*1kw@(o~R|At>^YKqvtcf)nW?AVoon7(xg!CO|@ystAk&0@8~L3M#`; zMnF0Q=_sf`D4~ebf^-D|=`T1%XRSB?`rrH3y?5<%&i=l=&$)ZAb@u3cV}O`}Ki&-h zOica-Z~@=2HxCHu`(Oyy02Y9aIjsW#dtaAjo@1%h_f4D!QWW&e6>5|8^x3_YdH!EXCUj`z_!9C`_@r=809d!cshZ$QUfs z9lTHWgzJ&9Xm1a)jfcn8KTq+TyN9<2#ofabq-PBSov_7|Ts{0K3Sa%r%-|*@iZ_~s z!J6nJWtj>PJl++qsj81sSJBso85n3op$3L17)%`n(}SYa4AoTi)D8dS>U&^(h**;M zpIp~(T+}~u_e+83$&9RzCF6auu7+d}BIxUu;rM^fMe`r^{@}X)b1qu{$W>-0qrCrP zzx&aDPBE)z-~6j=nS;LyA4_6ZJDFM5dyBxquf+hFD57` zCVp7xu=rmK|6gP8IUvLZcmcn%vIqeOgjiUGSoWHM`^+9^Wnto5`*Uz|v9lduP6A&) z-xgTe4zP2ua0&t}tZXa?SeZLw<=$W2cNAh{=ivN77>W|HM0?2|;<^#9dfLh*?C?V} zxHutOP0w1+=7F#2=t2OW}tNvLYNG(Ox&=i@U89Lp^D~;^D%)g!Sye}@@StFgMsy_cAXPB`%xV*c5J9Q^8 zZCR*dRgWTq%B||=8WCvCr`OqlYGyhg(+5TLSDu7w71V)Kecooc*_k?$(C?nS#vK^s z+5<}Ee_Yvq#2J_z?U!A6&#^prW^Ti7E>4Q-)ifcAK*O!o5BwcmyX#eUSH$1Gc9{=| z!-Aic7xK}lb@4a9oNs&aAUVS4bE{$%U-HGf#Ux$I%cIeUN}N5?#}q>&}_g6-^p^~>K9h(=FG!I z$gW{V+0C(m(epzmX{OVgk#*^voeLjwR&(n!>}M9TDH!kDn7A1x#IIih=e;bkrQPA}HY@U_v%*rPjK zMM1~H&h!=DDbMQpw99T;cLhJ(@Htq(F-Kd(z>?+*_T!H83p%+dJUQb_;8q#LBTCcO zIANFxFA|r>wOwCf)}1oW&io^gRYQ@w_RVPH+hrlx%H8V9kkXDZog-0C8R5)E{f47C zix#+G##`b|%pUN`OOX56Jnwv2u~PtoT8Fn#0pbe zPk^5#Pu({-F{GP`teg0?ap7<$WJWwP%WeMrp#cMj;`G@V>PS-2L6K7gt zODUOdQw0-lAAKfI`h;FL5HZ^R*ZuZS2qJ`fuTG1cxz+%tg~e-rhTV2wKX}8@%VCT95#4aNzCUf({iQ|tf4=}lhID{X@B%&yo@4#q$+_Rx>0 z1nsrg{j`MTmdumm!tuwc1tk}U zt51jCYVHYbam=OsTrV?tL2|0+Qnujta9ygbm86dvWqv*Y>KJaJh|JKaFfQq?;2atu zZX=mcTt=I*EiU_Mw!7A+w4oHAR{M-}Fu~YCibm)wZAKi!?>=-6%S>+-=j;0oGTD>k z=V;#4;uz_BPe=EO@S1I1GH1_1+PW!TK_-_m+w^fwFuza4z^--LGNs-yP-)6m7amw) zF@>H8nfS8E=u5aHQNtU?nMe8}r6h1)Ml{fPo62KXXKF^#@3hv^cbRk1u8&(DC@gte zRhi-E1G0ZD-XAwIeWW{Q^nxW>o?NyAU;Q;8|2B9$ZO{#x`jkp=NHLLg!fNE=&TK#L zifeJpZmaPj( z)FAfAOC5TX-XFzIY&$!lMeTln{X2x!Gcpmr)4!$+sz{EiS5HXU3s_|*psdGc0fp^` zvJX#-?xFp_>C5@U+qi(RadWG>u2PYUld|z&O!E-rBT2G$$8ayP7=8f?erRoD`*dW~ zM-nC7xXv89okOvqPx>t6@Xrl)cqFwrmB;R=8om#*U#oe(Wj}VV;A$%3yvA@oNxhHj zxI=j5*h;nAShIdc+IWha(eC?T&i7B3^CoM|3)62k<(J6t^?#%jj2dE|MZFve>hT4- z@Qn4$-0|_!Ten7XeRuqD;*2ZFCUwgc*$QeSfwmsqAFO+NS8aLoe17(=IO!!$#9){I zFZsWP!>ahgn^y;x!?PA@Vx~1u?G%~Iw%ZLDM8q^kv^+02jSA%=+Pxt<21h7aw=Cvm z3{JJZ`PlW+?aq&X1M0$ZE{99`hD=I}aVP1y(Pn~RFmDErfSqQ()6}eHp^jd)6?|cw zKBcxoXu2>I@{(ue(v-9gHNlI2O)jo4_=@8k?#9?#x!`WZ`(5hPK@n4mS%+p0e{%3B zV`UGJ57524+|_}yuw3h(dY9&YX(J)ldswFi`{J&~3yI!$XO2-jd!vRORMHGWe~#BE zzOh7JIhvF-REi@BouN&{l@B(5a$UFTZ*7#4J|fSVDm1n#Trriqtdg-&)2yIS_DWA9 zuXQfexd~-(=v;GqHU<*~i!_n|2=@I^0Pq3eaZAC8_UL@yYF};t$BpR6iG3-JLnc9i zZ+Rt`IwKf-<5QNcmntV>VH}2CtpXg+0M7TK1;?F@zrRBKFp~9BOB&gv7n%@D=;)X+ zC|47`!de7zJ5_f5i@J>;;ypZpMW8KagZ1)IRwxI>irPmi80ITh{kUG@KfUxYW+y(V z^YgAR?eS>=TB5cE>jS%sFM|2jH_kq)x46|bSV3jX+TSqLr1K7OuU}_5eha*r1?Sx< z8n7Pr$zRaZj>m^6q{a#lk6c%z4`%dR?k*15J`Vha%UJ32i}$jSS6`2TKbtnxuueG^7*q>5~N6l4l9wM_VKVx1-@cO47jx z+JEmU)R~>;xnbpXC&hq9jLcoq!=R0&Pv@RdaZQTZet8lGCJQRo59Dm%N$hO2SZ#A! zP{K~X*4ZbJo|dQm6AD0u@C$`dZ!ci_rvUWL8pev0pq};{?qWJA0|y@WqTmWO(vQa} zMwfG#-r#$$*&hkgb?I_)M)T_)27#+?7n!DClQ+&{xzRr1vtz!pm1(MxSg{#URbn9j zP_%P40nHB*@9j?_8av+0LC#Bhl~NlOa8zH_S%mQe%%k|87rf~*1aaP<7d=0s?iFv_ zmJT_(Ye}3WObqzxgh0$*%cJBwAP`J2=zi}b^T1<#ETeLk?7yu|N4Jkb?}l(Jz78~o zZb_}Ljj3Dw99I_V9@8xfNH*Gy^9J~!8X5eju=HyK#$tEx&g+{!t#z$oPlEWDBNO2f zlfLThx)y1>lSeE>Kcy(geH^%OBsKM@VnGCLsYF|%jnhnh8Q_i4p*q7e60U?5bkdg% z+umHfJu1RZ^ts(X&mrB;h-oQ&_GD6P#FXVKX;sQvj-)g*Y~hXqZMjCfHC@>tD!P

Constants::OXID_MODULE_ID.'bDev', 'type' => 'bool', 'value' => false - ], - [ - 'group' => Constants::OXID_MODULE_ID.'main', - 'name' => Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName', - 'type' => 'str', - 'value' => '' ] ] ]; diff --git a/views/smarty/documents/inc/page/header.tpl b/views/smarty/documents/inc/page/header.tpl index 8e864ac..773ec53 100644 --- a/views/smarty/documents/inc/page/header.tpl +++ b/views/smarty/documents/inc/page/header.tpl @@ -3,11 +3,9 @@ [{block name="pdfHeader"}]

[{if $showLogo}] - [{* pdf logo is available only in non admin theme *}] - [{assign var="isAdmin" value=$viewConfig->isAdmin()}] - [{$viewConfig->setAdminMode(false)}] - - [{$viewConfig->setAdminMode($isAdmin)}] + [{block name="pdfHeaderLogo"}] + + [{/block}] [{/if}]
[{/block}] \ No newline at end of file diff --git a/views/twig/documents/inc/page/header.html.twig b/views/twig/documents/inc/page/header.html.twig index 04018bb..458c11d 100644 --- a/views/twig/documents/inc/page/header.html.twig +++ b/views/twig/documents/inc/page/header.html.twig @@ -1,16 +1,11 @@ {% set showLogo = showLogo|default(1) %} -{% set sPdfLogo = sAlternativePdfLogo %} {% block pdfHeader %}
{% if showLogo %} - {# pdf logo is available only in non admin theme #} - {% set isAdmin = oViewConf.isAdmin() %} - {{ oViewConf.setAdminMode(false) }} - {% if sPdfLogo %} - - {% endif %} - {{ oViewConf.setAdminMode(isAdmin) }} + {% block pdfHeaderLogo %} + + {% endblock %} {% endif %}
{% endblock %} \ No newline at end of file From 0b4c6343521c20f3bc3a4724011dd74b81561b03 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 9 Sep 2024 23:22:51 +0200 Subject: [PATCH 4/7] add development manual --- development.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 development.md diff --git a/development.md b/development.md new file mode 100644 index 0000000..97310b7 --- /dev/null +++ b/development.md @@ -0,0 +1,29 @@ +# Entwicklungen + +Um das Modul anzupassen, gibt es verschiedene Möglichkeiten: + +## Grundsätzliches + +Wir empfehlen dringend, alle Veränderungen bestehender Dokumente und auch neue Dokumente in einem eigenen Modul abzulegen, +um die Updatefähigkeit zu behalten. + +## neue Dokumente hinzufügen + +Neue Dokumente können analog zu den Bestehenden angelegt werden. Jedes Dokument besteht aus der entsprechenden +PHP-Klasse (unter Application/Model/Documents) und deren Template (unter views/.../documents). Verwenden Sie die +Bestandsdokumente als Implementierungsreferenz. + +Dokumentlisten sind für den Bestellbereich im Shopadmin sowie für die Generierung über den D3 Auftragsmanagers +enthalten (unter Application/Model/Registries). Überladen Sie die Klassen und ergänzen Sie im Konstruktor Ihre neuen +Dokumente. + +## bestehende Dokumente verändern + +Die Grundangaben eines Dokuments sind in dessen PHP-Datei definiert. Überladen Sie diese bei Bedarf und ändern die +Einstellung. + +Die Inhalte der Dokumente sind in Templates definiert. In den Templates sind Blöcke eingerichtet, die mit den +Überladungsmöglichkeiten des Shops ergänzt oder ersetzt werden können. + +Bei umfangreichen Anpassungen kann es sinnvoll sein, eigene Templates anzulegen, die in der PHP-Klasse des Dokuments als +Quelle definiert wird. \ No newline at end of file From ec7d3f56228265bc884870c36d6bd94ff048ef8c Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 10 Sep 2024 09:15:51 +0200 Subject: [PATCH 5/7] adjust Smarty templates --- metadata.php | 54 +++++++++---------- .../documents/deliverynote/deliverynote.tpl | 16 +++--- .../deliverynote/deliverynoteNoLogo.tpl | 2 +- .../documents/inc/elements/addressarea.tpl | 4 +- .../documents/inc/elements/articlelist.tpl | 2 +- .../documents/invoice/inc/conclusion.tpl | 2 +- views/smarty/documents/invoice/invoice.tpl | 20 +++---- .../documents/invoice/invoiceNoLogo.tpl | 2 +- 8 files changed, 48 insertions(+), 54 deletions(-) diff --git a/metadata.php b/metadata.php index 3aa8547..70d5f20 100644 --- a/metadata.php +++ b/metadata.php @@ -42,38 +42,38 @@ $aModule = [ '@' . Constants::OXID_MODULE_ID . '/admin/d3orderoverview_pdfform.tpl' => 'views/smarty/admin/orderoverview_pdfform.tpl', // Frontend - Flow - Deliverynote - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/deliverynote.tpl' => 'views/smarty/flow/documents/deliverynote/deliverynote.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/deliverynoteNoLogo.tpl' => 'views/smarty/flow/documents/deliverynote/deliverynoteNoLogo.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/informations.tpl' => 'views/smarty/flow/documents/deliverynote/inc/informations.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/recipientAddress.tpl' => 'views/smarty/flow/documents/deliverynote/inc/recipientAddress.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/salutation.tpl' => 'views/smarty/flow/documents/deliverynote/inc/salutation.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/conclusion.tpl' => 'views/smarty/flow/documents/deliverynote/inc/conclusion.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/deliverynote.tpl' => 'views/smarty/documents/deliverynote/deliverynote.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/deliverynoteNoLogo.tpl' => 'views/smarty/documents/deliverynote/deliverynoteNoLogo.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/informations.tpl' => 'views/smarty/documents/deliverynote/inc/informations.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/recipientAddress.tpl' => 'views/smarty/documents/deliverynote/inc/recipientAddress.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/salutation.tpl' => 'views/smarty/documents/deliverynote/inc/salutation.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/deliverynote/conclusion.tpl' => 'views/smarty/documents/deliverynote/inc/conclusion.tpl', // Frontend - Flow - Invoice - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/invoice.tpl' => 'views/smarty/flow/documents/invoice/invoice.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/invoiceNoLogo.tpl' => 'views/smarty/flow/documents/invoice/invoiceNoLogo.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/informations.tpl' => 'views/smarty/flow/documents/invoice/inc/informations.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/salutation.tpl' => 'views/smarty/flow/documents/invoice/inc/salutation.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/conclusion.tpl' => 'views/smarty/flow/documents/invoice/inc/conclusion.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/invoice/payinfo.tpl' => 'views/smarty/flow/documents/invoice/inc/payinfo.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/invoice.tpl' => 'views/smarty/documents/invoice/invoice.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/invoiceNoLogo.tpl' => 'views/smarty/documents/invoice/invoiceNoLogo.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/informations.tpl' => 'views/smarty/documents/invoice/inc/informations.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/salutation.tpl' => 'views/smarty/documents/invoice/inc/salutation.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/conclusion.tpl' => 'views/smarty/documents/invoice/inc/conclusion.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/invoice/payinfo.tpl' => 'views/smarty/documents/invoice/inc/payinfo.tpl', // Frontend - Flow - Inc - Page - '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/base.tpl' => 'views/smarty/flow/documents/inc/page/base.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/header.tpl' => 'views/smarty/flow/documents/inc/page/header.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/footer.tpl' => 'views/smarty/flow/documents/inc/page/footer.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/returnaddress.tpl' => 'views/smarty/flow/documents/inc/page/returnaddress.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/base.tpl' => 'views/smarty/documents/inc/page/base.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/header.tpl' => 'views/smarty/documents/inc/page/header.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/footer.tpl' => 'views/smarty/documents/inc/page/footer.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/page/returnaddress.tpl' => 'views/smarty/documents/inc/page/returnaddress.tpl', // Frontend - Flow - Inc - Elements - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/addressarea.tpl' => 'views/smarty/flow/documents/inc/elements/addressarea.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/recipientAddress.tpl' => 'views/smarty/flow/documents/inc/elements/recipientAddress.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/informations.tpl' => 'views/smarty/flow/documents/inc/elements/informations.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/deliveryaddress.tpl' => 'views/smarty/flow/documents/inc/elements/deliveryaddress.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/articlelist.tpl' => 'views/smarty/flow/documents/inc/elements/articlelist.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/articlecostssummary.tpl' => 'views/smarty/flow/documents/inc/elements/articlecostssummary.tpl', - '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/foldmarks.tpl' => 'views/smarty/flow/documents/inc/elements/foldmarks.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/addressarea.tpl' => 'views/smarty/documents/inc/elements/addressarea.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/recipientAddress.tpl' => 'views/smarty/documents/inc/elements/recipientAddress.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/informations.tpl' => 'views/smarty/documents/inc/elements/informations.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/deliveryaddress.tpl' => 'views/smarty/documents/inc/elements/deliveryaddress.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/articlelist.tpl' => 'views/smarty/documents/inc/elements/articlelist.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/articlecostssummary.tpl' => 'views/smarty/documents/inc/elements/articlecostssummary.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/elements/foldmarks.tpl' => 'views/smarty/documents/inc/elements/foldmarks.tpl', // Frontend - Flow - Inc - Helper - '@' . Constants::OXID_MODULE_ID . '/documents/inc/helper/rulers.tpl' => 'views/smarty/flow/documents/inc/helper/rulers.tpl', + '@' . Constants::OXID_MODULE_ID . '/documents/inc/helper/rulers.tpl' => 'views/smarty/documents/inc/helper/rulers.tpl', // Frontend - Flow - Inc - Styles '@' . Constants::OXID_MODULE_ID . '/assets/d3pdfstyles.css.tpl' => 'views/smarty/assets/pdfStyling.css.tpl', @@ -92,12 +92,6 @@ $aModule = [ 'name' => Constants::OXID_MODULE_ID.'bDev', 'type' => 'bool', 'value' => false - ], - [ - 'group' => Constants::OXID_MODULE_ID.'main', - 'name' => Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName', - 'type' => 'str', - 'value' => '' ] ] ]; diff --git a/views/smarty/documents/deliverynote/deliverynote.tpl b/views/smarty/documents/deliverynote/deliverynote.tpl index 8bd8d6e..de5a96f 100644 --- a/views/smarty/documents/deliverynote/deliverynote.tpl +++ b/views/smarty/documents/deliverynote/deliverynote.tpl @@ -9,27 +9,27 @@ [{capture append="pdfBlock_header"}] [{block name="pdfHeader"}] - [{include file="@d3PdfDocuments/documents/inc/page/header" showLogo=$showLogo}] + [{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}] [{/block}] [{/capture}] [{capture append="pdfBlock_content"}] - [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks" pagePadding=$pagePadding}] + [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}] [{block name="pdfAddressArea"}] - [{include file="@d3PdfDocuments/documents/inc/elements/addressarea" addressfile="@d3PdfDocuments/documents/deliverynote/recipientAddress"}] + [{include file="@d3PdfDocuments/documents/inc/elements/addressarea.tpl" addressfile="@d3PdfDocuments/documents/deliverynote/recipientAddress.tpl"}] [{/block}] [{block name="pdfInformations"}] - [{include file="@d3PdfDocuments/documents/inc/elements/informations" documentinformationfile="@d3PdfDocuments/documents/deliverynote/informations"}] + [{include file="@d3PdfDocuments/documents/inc/elements/informations.tpl" documentinformationfile="@d3PdfDocuments/documents/deliverynote/informations.tpl"}] [{/block}] [{block name="pdfSalutation"}] - [{include file="@d3PdfDocuments/documents/deliverynote/salutation"}] + [{include file="@d3PdfDocuments/documents/deliverynote/salutation.tpl"}] [{/block}] [{block name="pdfArticleList"}] - [{include file="@d3PdfDocuments/documents/inc/elements/articlelist" showPrices=false}] + [{include file="@d3PdfDocuments/documents/inc/elements/articlelist.tpl" showPrices=false}] [{/block}] [{block name="pdfConclusion"}] @@ -39,8 +39,8 @@ [{capture append="pdfBlock_footer"}] [{block name="pdfFooter"}] - [{include file="@d3PdfDocuments/documents/inc/page/footer" pagePadding=$pagePadding}] + [{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}] [{/block}] [{/capture}] -[{include file="@d3PdfDocuments/documents/inc/page/base" pagePadding=$pagePadding}] \ No newline at end of file +[{include file="@d3PdfDocuments/documents/inc/page/base.tpl" pagePadding=$pagePadding}] \ No newline at end of file diff --git a/views/smarty/documents/deliverynote/deliverynoteNoLogo.tpl b/views/smarty/documents/deliverynote/deliverynoteNoLogo.tpl index 5daca64..c68baeb 100644 --- a/views/smarty/documents/deliverynote/deliverynoteNoLogo.tpl +++ b/views/smarty/documents/deliverynote/deliverynoteNoLogo.tpl @@ -1 +1 @@ -[{include file="@d3PdfDocuments/documents/deliverynote/deliverynote" showLogo=false}] \ No newline at end of file +[{include file="@d3PdfDocuments/documents/deliverynote/deliverynote.tpl" showLogo=false}] \ No newline at end of file diff --git a/views/smarty/documents/inc/elements/addressarea.tpl b/views/smarty/documents/inc/elements/addressarea.tpl index 7d69c83..167099c 100644 --- a/views/smarty/documents/inc/elements/addressarea.tpl +++ b/views/smarty/documents/inc/elements/addressarea.tpl @@ -1,5 +1,5 @@ -[{assign var="backaddressfile" value=$backaddressfile|default:"@d3PdfDocuments/documents/inc/page/returnaddress"}] -[{assign var="addressfile" value=$addressfile|default:"@d3PdfDocuments/documents/inc/elements/recipientAddress"}] +[{assign var="backaddressfile" value=$backaddressfile|default:"@d3PdfDocuments/documents/inc/page/returnaddress.tpl"}] +[{assign var="addressfile" value=$addressfile|default:"@d3PdfDocuments/documents/inc/elements/recipientAddress.tpl"}]
diff --git a/views/smarty/documents/inc/elements/articlelist.tpl b/views/smarty/documents/inc/elements/articlelist.tpl index 01547dd..897edf8 100644 --- a/views/smarty/documents/inc/elements/articlelist.tpl +++ b/views/smarty/documents/inc/elements/articlelist.tpl @@ -54,7 +54,7 @@ [{block name="d3_article_costs_summary"}] - [{include file="@d3PdfDocuments/documents/inc/elements/articlecostssummary"}] + [{include file="@d3PdfDocuments/documents/inc/elements/articlecostssummary.tpl"}] [{/block}]
diff --git a/views/smarty/documents/invoice/inc/conclusion.tpl b/views/smarty/documents/invoice/inc/conclusion.tpl index 69201e0..706d61d 100644 --- a/views/smarty/documents/invoice/inc/conclusion.tpl +++ b/views/smarty/documents/invoice/inc/conclusion.tpl @@ -5,7 +5,7 @@ [{oxmultilang ident="D3_PDFDOCUMENTS_USED_PAYMENTMETHOD" suffix="COLON"}] [{$payment->getFieldData('oxdesc')}]
- [{include file="@d3PdfDocuments/documents/invoice/payinfo"}] + [{include file="@d3PdfDocuments/documents/invoice/payinfo.tpl"}]
[{/block}] diff --git a/views/smarty/documents/invoice/invoice.tpl b/views/smarty/documents/invoice/invoice.tpl index f4034c8..018b30e 100644 --- a/views/smarty/documents/invoice/invoice.tpl +++ b/views/smarty/documents/invoice/invoice.tpl @@ -9,43 +9,43 @@ [{capture append="pdfBlock_header"}] [{block name="pdfHeader"}] - [{include file="@d3PdfDocuments/documents/inc/page/header" showLogo=$showLogo}] + [{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}] [{/block}] [{/capture}] [{capture append="pdfBlock_content"}] [{* include file="@d3PdfDocuments/documents/inc/helper/rulers" pagePadding=$pagePadding *}] - [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks" pagePadding=$pagePadding}] + [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}] [{block name="pdfAddressArea"}] - [{include file="@d3PdfDocuments/documents/inc/elements/addressarea"}] + [{include file="@d3PdfDocuments/documents/inc/elements/addressarea.tpl"}] [{/block}] [{block name="pdfInformations"}] - [{include file="@d3PdfDocuments/documents/inc/elements/informations" documentinformationfile="@d3PdfDocuments/documents/invoice/informations"}] + [{include file="@d3PdfDocuments/documents/inc/elements/informations.tpl" documentinformationfile="@d3PdfDocuments/documents/invoice/informations.tpl"}] [{/block}] [{block name="pdfDeliveryAddress"}] - [{include file="@d3PdfDocuments/documents/inc/elements/deliveryaddress"}] + [{include file="@d3PdfDocuments/documents/inc/elements/deliveryaddress.tpl"}] [{/block}] [{block name="pdfSalutation"}] - [{include file="@d3PdfDocuments/documents/invoice/salutation"}] + [{include file="@d3PdfDocuments/documents/invoice/salutation.tpl"}] [{/block}] [{block name="pdfArticleList"}] - [{include file="@d3PdfDocuments/documents/inc/elements/articlelist"}] + [{include file="@d3PdfDocuments/documents/inc/elements/articlelist.tpl"}] [{/block}] [{block name="pdfConclusion"}] - [{include file="@d3PdfDocuments/documents/invoice/conclusion"}] + [{include file="@d3PdfDocuments/documents/invoice/conclusion.tpl"}] [{/block}] [{/capture}] [{capture append="pdfBlock_footer"}] [{block name="pdfFooter"}] - [{include file="@d3PdfDocuments/documents/inc/page/footer" pagePadding=$pagePadding}] + [{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}] [{/block}] [{/capture}] -[{include file="@d3PdfDocuments/documents/inc/page/base" pagePadding=$pagePadding}] +[{include file="@d3PdfDocuments/documents/inc/page/base.tpl" pagePadding=$pagePadding}] diff --git a/views/smarty/documents/invoice/invoiceNoLogo.tpl b/views/smarty/documents/invoice/invoiceNoLogo.tpl index f093401..0772c97 100644 --- a/views/smarty/documents/invoice/invoiceNoLogo.tpl +++ b/views/smarty/documents/invoice/invoiceNoLogo.tpl @@ -1 +1 @@ -[{include file="@d3PdfDocuments/documents/invoice/invoice" showLogo=false}] \ No newline at end of file +[{include file="@d3PdfDocuments/documents/invoice/invoice.tpl" showLogo=false}] \ No newline at end of file From 4c9dbbdabc70e7647b466faf3b20d0fde64bf663 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 10 Sep 2024 12:00:45 +0200 Subject: [PATCH 6/7] remove ModCfg dependency because of minimal usage --- .../AbstractClasses/pdfdocumentsGeneric.php | 88 ++++++++++++------- composer.json | 1 - 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 93412ff..d0e9c8c 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -11,7 +11,6 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses; use Assert\InvalidArgumentException; -use D3\ModCfg\Application\Model\d3filesystem; use D3\PdfDocuments\Application\Model\Constants; use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface; @@ -187,37 +186,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface unset($iSelLang); $this->oTemplateEngine->addGlobal('config', Registry::getConfig()); - $this->oTemplateEngine->addGlobal('sAlternativePdfLogo', $this->getAlternativePdfLogoFileName()); $this->oTemplateEngine->addGlobal('oViewConf', Registry::getConfig()->getActiveView()->getViewConfig()); $this->oTemplateEngine->addGlobal('shop', Registry::getConfig()->getActiveShop()); $this->oTemplateEngine->addGlobal('lang', Registry::getLang()); $this->oTemplateEngine->addGlobal('document', $this); } - /** - * @return string - */ - public function getAlternativePdfLogoFileName() :string - { - $sStandardLogoFile = 'pdf_logo.jpg'; - $oViewConf = Registry::getConfig()->getActiveView()->getViewConfig(); - $moduleSettingService = ContainerFacade::get(ModuleSettingServiceInterface::class); - $sAlternativePdfLogoName = $moduleSettingService->getString(Constants::OXID_MODULE_ID."_sAlternativePdfLogoName", Constants::OXID_MODULE_ID); - - $sAlternativePdfLogoName = trim($sAlternativePdfLogoName) ?: $sStandardLogoFile; - - $bAlternativeFileExists = file_exists(Registry::getConfig()->getImagePath($sAlternativePdfLogoName)); - $bFileExists = file_exists(Registry::getConfig()->getImagePath($sStandardLogoFile)); - - return $bAlternativeFileExists - ? $oViewConf->getImageUrl($sAlternativePdfLogoName, true) - : ( - $bFileExists - ? $oViewConf->getImageUrl($sStandardLogoFile, true) - : "" - ); - } - /** * @param int $iSelLang * @@ -324,14 +298,68 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface /** * Gets proper file name * - * @param string $sFilename file name + * @param $filename * * @return string */ - public function makeValidFileName($sFilename) + public function makeValidFileName($filename) { - $fs = oxNew(d3filesystem::class); - return $fs->filterFilename($sFilename); + // sanitize filename + $filename = preg_replace( + '~ + [<>:"/\\\\|?*]| # file system reserved + [\x00-\x1F]| # control characters + [\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN + [#\[\]@!$&\'()+,;=]| # URI reserved + [{}^\~`] # URL unsafe characters + ~x', + '-', + $filename + ); + + // avoids ".", ".." or ".hiddenFiles" + $filename = ltrim($filename, '.-'); + + $filename = $this->beautifyFilename($filename); + + // maximize filename length to 255 bytes + $ext = pathinfo($filename, PATHINFO_EXTENSION); + $filename = mb_strcut( + pathinfo($filename, PATHINFO_FILENAME), + 0, + 255 - ($ext ? strlen($ext) + 1 : 0), + mb_detect_encoding($filename) + ) . ($ext ? '.' . $ext : ''); + + return $filename; + } + + public function beautifyFilename($filename) + { + // reduce consecutive characters + $filename = preg_replace([ + // "file name.zip" becomes "file-name.zip" + '/ +/', + // "file___name.zip" becomes "file-name.zip" + '/_{2,}/', + // "file---name.zip" becomes "file-name.zip" + '/-+/', + ], '-', $filename); + + $filename = preg_replace([ + // "file--.--.-.--name.zip" becomes "file.name.zip" + '/-*\.-*/', + // "file...name..zip" becomes "file.name.zip" + '/\.{2,}/', + ], '.', $filename); + + // lowercase for windows/unix interoperability + $filename = mb_strtolower($filename, mb_detect_encoding($filename)); + + // ".file-name.-" becomes "file-name" + $filename = trim($filename, '.-'); + + return trim($filename); } /** diff --git a/composer.json b/composer.json index 0c9bfe0..ae97422 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,6 @@ "php": "^8.0", "oxid-esales/oxideshop-ce": "7.0 - 7.1", "spipu/html2pdf": "~5.2.8", - "d3/modcfg": "^7.1", "beberlei/assert": "^3.3.2" }, "autoload": { From adadf94f74307be290e4ded25c417eb00ceea850 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 10 Sep 2024 12:08:03 +0200 Subject: [PATCH 7/7] remove unparsable logo from metadata --- metadata.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/metadata.php b/metadata.php index 70d5f20..81eae74 100644 --- a/metadata.php +++ b/metadata.php @@ -17,19 +17,17 @@ use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview; */ $sMetadataVersion = '2.1'; -$logo = '(D3)'; - /** * Module information */ $aModule = [ 'id' => Constants::OXID_MODULE_ID, 'title' => [ - 'de' => $logo.' PDF-Dokumente', - 'en' => $logo.' PDF documents', + 'de' => '(D3) PDF-Dokumente', + 'en' => '(D3) PDF documents', ], 'version' => '2.0.0', - 'author' => $logo.' Data Development (Inh.: Thomas Dartsch)', + 'author' => 'D3 Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', 'extend' => [