diff --git a/Application/Controller/orderOverviewPdfGenerator.php b/Application/Controller/orderOverviewPdfGenerator.php index fcb2bc9..8777a7e 100644 --- a/Application/Controller/orderOverviewPdfGenerator.php +++ b/Application/Controller/orderOverviewPdfGenerator.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace D3\PdfDocuments\Application\Controller; +use D3\PdfDocuments\Application\Model\Constants; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; @@ -23,6 +24,8 @@ use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Registry; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -36,6 +39,13 @@ class orderOverviewPdfGenerator { $Pdf = $this->getPdfClass(); + /** @var ModuleSettingService $settingsService */ + $settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); + + $Pdf->setDevelopmentMode( + $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID) && + Registry::getRequest()->getRequestEscapedParameter('devmode') + ); $Pdf->setOrder($order); $Pdf->downloadPdf($iSelLang); } diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index b0a2810..1872f2d 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -48,6 +48,13 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface public string $filenameExtension = 'pdf'; public ?string $filename = null; + protected $devMode = false; + + public function setDevelopmentMode(bool $devMode) + { + $this->devMode = $devMode; + } + /** * @codeCoverageIgnore */ @@ -347,8 +354,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface */ public function output(Html2Pdf $pdf, string $filename, string $target, string $html): ?string { - $moduleSettings = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); - if ($moduleSettings->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID)) { + if ($this->devMode) { return $this->outputDev($pdf, $filename, $target, $html); } else { return $pdf->output($filename, $target); diff --git a/Application/Model/Interfaces/pdfdocumentsGenericInterface.php b/Application/Model/Interfaces/pdfdocumentsGenericInterface.php index 4cd4a28..a365d0b 100644 --- a/Application/Model/Interfaces/pdfdocumentsGenericInterface.php +++ b/Application/Model/Interfaces/pdfdocumentsGenericInterface.php @@ -17,6 +17,8 @@ namespace D3\PdfDocuments\Application\Model\Interfaces; interface pdfdocumentsGenericInterface { + public function setDevelopmentMode(bool $devMode); + public function getRequestId(): string; public function getTitleIdent(): string; diff --git a/Application/views/de/translations.php b/Application/views/de/translations.php index 861f7d8..88339f3 100644 --- a/Application/views/de/translations.php +++ b/Application/views/de/translations.php @@ -21,11 +21,11 @@ $basicAuthHelp = << 'utf-8', + 'charset' => 'utf-8', - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '. + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'main' => 'Grundeinstellungen', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '. 'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)', 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, @@ -35,15 +35,15 @@ return [ 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Rechnung', 'SHOP_MODULE_invoicePaymentTerm' => 'Zahlungsziel (in Tagen)', - 'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Inhalte', - 'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo-Grafik URL', - 'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => 'Hintergrund-Grafik URL', + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'contents' => 'Inhalte', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'LogoUrl' => 'Logo-Grafik URL', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'BackgroundUrl' => 'Hintergrund-Grafik URL', - 'SHOP_MODULE_GROUP_d3PdfDocumentsdocuments' => 'Dokumente', - 'SHOP_MODULE_d3PdfDocumentsDocInvoice' => 'Rechnung', - 'SHOP_MODULE_d3PdfDocumentsDocInvoiceNoLogo' => 'Rechnung ohne Logo', - 'SHOP_MODULE_d3PdfDocumentsDocDeliveryNote' => 'Lieferschein', - 'SHOP_MODULE_d3PdfDocumentsDocDeliveryNoteNoLogo' => 'Lieferschein ohne Logo', + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'documents' => 'Dokumente', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoice' => 'Rechnung', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoiceNoLogo' => 'Rechnung ohne Logo', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNote' => 'Lieferschein', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo' => 'Lieferschein ohne Logo', 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', @@ -53,6 +53,7 @@ return [ 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument', 'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache', + 'D3_PDFDOCUMENTS_SGML_GENERATE' => 'SGML erstellen', 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen', ]; // @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/en/translations.php b/Application/views/en/translations.php index dcb0c70..84bce8b 100644 --- a/Application/views/en/translations.php +++ b/Application/views/en/translations.php @@ -23,7 +23,7 @@ $basicAuthHelp = << 'utf-8', - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'main' => 'Basic settings', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'If developer mode is activated, the document is output in '. 'HTML format. This makes it much easier to trace content errors.', @@ -35,15 +35,15 @@ return [ 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Invoice', 'SHOP_MODULE_invoicePaymentTerm' => 'Payment term (in days)', - 'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Contents', - 'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo image URL', - 'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => 'Background image URL', + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'contents' => 'Contents', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'LogoUrl' => 'Logo image URL', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'BackgroundUrl' => 'Background image URL', - 'SHOP_MODULE_GROUP_d3PdfDocumentsdocuments' => 'Documents', - 'SHOP_MODULE_d3PdfDocumentsDocInvoice' => 'Invoice', - 'SHOP_MODULE_d3PdfDocumentsDocInvoiceNoLogo' => 'Invoice without logo', - 'SHOP_MODULE_d3PdfDocumentsDocDeliveryNote' => 'Delivery note', - 'SHOP_MODULE_d3PdfDocumentsDocDeliveryNoteNoLogo' => 'Delivery note without logo', + 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'documents' => 'Documents', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoice' => 'Invoice', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoiceNoLogo' => 'Invoice without logo', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNote' => 'Delivery note', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo' => 'Delivery note without logo', 'D3_PDFDOCUMENTS' => 'PDF Documents', 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', @@ -53,6 +53,7 @@ return [ 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document', 'D3_PDFDOCUMENTS_LANGUAGE' => 'Language', + 'D3_PDFDOCUMENTS_SGML_GENERATE' => 'Create SGML', 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document', ]; // @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php index 236dbb3..c6dde32 100644 --- a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php +++ b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php @@ -14,6 +14,7 @@ namespace D3\PdfDocuments\Modules\Application\Controller; use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator; +use D3\PdfDocuments\Application\Model\Constants; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; @@ -30,6 +31,8 @@ use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\TableViewNameGenerator; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -63,6 +66,13 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu return parent::render(); } + public function d3PdfDocsIsDevMode(): bool + { + /** @var ModuleSettingService $settingsService */ + $settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); + return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID); + } + /** * @throws DBALDriverException */ diff --git a/metadata.php b/metadata.php index aa09382..37b6c7b 100644 --- a/metadata.php +++ b/metadata.php @@ -107,36 +107,36 @@ $aModule = [ 'value' => 7, ], [ - 'group' => $sModuleId.'contents', - 'name' => $sModuleId.'LogoUrl', + 'group' => Constants::OXID_MODULE_ID.'contents', + 'name' => Constants::OXID_MODULE_ID.'LogoUrl', 'type' => 'str' ], [ - 'group' => $sModuleId.'contents', - 'name' => $sModuleId.'BackgroundUrl', + 'group' => Constants::OXID_MODULE_ID.'contents', + 'name' => Constants::OXID_MODULE_ID.'BackgroundUrl', 'type' => 'str' ], [ - 'group' => $sModuleId.'documents', - 'name' => $sModuleId.'DocInvoice', + 'group' => Constants::OXID_MODULE_ID.'documents', + 'name' => Constants::OXID_MODULE_ID.'DocInvoice', 'type' => 'bool', 'value' => true ], [ - 'group' => $sModuleId.'documents', - 'name' => $sModuleId.'DocInvoiceNoLogo', + 'group' => Constants::OXID_MODULE_ID.'documents', + 'name' => Constants::OXID_MODULE_ID.'DocInvoiceNoLogo', 'type' => 'bool', 'value' => true ], [ - 'group' => $sModuleId.'documents', - 'name' => $sModuleId.'DocDeliveryNote', + 'group' => Constants::OXID_MODULE_ID.'documents', + 'name' => Constants::OXID_MODULE_ID.'DocDeliveryNote', 'type' => 'bool', 'value' => true ], [ - 'group' => $sModuleId.'documents', - 'name' => $sModuleId.'DocDeliveryNoteNoLogo', + 'group' => Constants::OXID_MODULE_ID.'documents', + 'name' => Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo', 'type' => 'bool', 'value' => true ], diff --git a/views/smarty/admin/orderoverview_pdfform.tpl b/views/smarty/admin/orderoverview_pdfform.tpl index 2ba4a0f..a58f6f6 100644 --- a/views/smarty/admin/orderoverview_pdfform.tpl +++ b/views/smarty/admin/orderoverview_pdfform.tpl @@ -1,10 +1,13 @@ [{if $edit && $oView->d3CanExport()}]
+ [{assign var="devmode" value=$oView->d3PdfDocsIsDevMode()}] +
[{$oViewConf->getHiddenSid()}] + [{if $devmode}][{/if}]
[{oxmultilang ident="D3_PDFDOCUMENTS"}] @@ -36,7 +39,10 @@ diff --git a/views/twig/admin/orderoverview_pdfform.html.twig b/views/twig/admin/orderoverview_pdfform.html.twig index e4df40c..92cc814 100644 --- a/views/twig/admin/orderoverview_pdfform.html.twig +++ b/views/twig/admin/orderoverview_pdfform.html.twig @@ -1,10 +1,13 @@ {% if edit and oView.d3CanExport() %}
+ {% set devmode = oView.d3PdfDocsIsDevMode() %} + {{ oViewConf.getHiddenSid()|raw }} + {% if devmode %}{% endif %}
{{ translate({ ident: "D3_PDFDOCUMENTS" }) }}

- + [{if $devmode}] + + [{/if}] +
@@ -36,7 +39,10 @@

- + {% if devmode %} + + {% endif %} +