diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 15270eb..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; @@ -26,6 +25,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; @@ -185,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 * @@ -322,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); } /** @@ -342,15 +372,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); 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 0000000..08e6f37 Binary files /dev/null and b/assets/out/img/clogo.jpg differ 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": { 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 diff --git a/metadata.php b/metadata.php index c6c34b2..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' => [ @@ -42,41 +40,41 @@ $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' => 'assets/out/src/css/pdfStyling.css', + '@' . Constants::OXID_MODULE_ID . '/assets/d3pdfstyles.css.tpl' => 'views/smarty/assets/pdfStyling.css.tpl', ], 'events' => [], 'blocks' => [ @@ -92,12 +90,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/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..de5a96f 100644 --- a/views/smarty/documents/deliverynote/deliverynote.tpl +++ b/views/smarty/documents/deliverynote/deliverynote.tpl @@ -3,33 +3,33 @@ [{capture append="pdfBlock_style"}] [{block name="pdfStyles"}] - [{include file="@d3PdfDocuments/assets/d3pdfstyles.css"}] + [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{/block}] [{/capture}] [{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/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/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 a801998..018b30e 100644 --- a/views/smarty/documents/invoice/invoice.tpl +++ b/views/smarty/documents/invoice/invoice.tpl @@ -3,49 +3,49 @@ [{capture append="pdfBlock_style"}] [{block name="pdfStyles"}] - [{include file="@d3PdfDocuments/assets/d3pdfstyles.css"}] + [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{/block}] [{/capture}] [{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 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/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 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 %}