development mode ask for document type

# Conflicts:
#	Application/Model/AbstractClasses/pdfdocumentsGeneric.php
#	Application/Model/Interfaces/pdfdocumentsGenericInterface.php
This commit is contained in:
2025-05-17 22:22:37 +02:00
parent 5d95edf605
commit 31a5674490
9 changed files with 79 additions and 37 deletions

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace D3\PdfDocuments\Application\Controller; namespace D3\PdfDocuments\Application\Controller;
use D3\PdfDocuments\Application\Model\Constants;
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; 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\Application\Model\Order;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; 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\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
@ -36,6 +39,13 @@ class orderOverviewPdfGenerator
{ {
$Pdf = $this->getPdfClass(); $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->setOrder($order);
$Pdf->downloadPdf($iSelLang); $Pdf->downloadPdf($iSelLang);
} }

View File

@ -48,6 +48,13 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
public string $filenameExtension = 'pdf'; public string $filenameExtension = 'pdf';
public ?string $filename = null; public ?string $filename = null;
protected $devMode = false;
public function setDevelopmentMode(bool $devMode)
{
$this->devMode = $devMode;
}
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -347,8 +354,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
*/ */
public function output(Html2Pdf $pdf, string $filename, string $target, string $html): ?string public function output(Html2Pdf $pdf, string $filename, string $target, string $html): ?string
{ {
$moduleSettings = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); if ($this->devMode) {
if ($moduleSettings->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID)) {
return $this->outputDev($pdf, $filename, $target, $html); return $this->outputDev($pdf, $filename, $target, $html);
} else { } else {
return $pdf->output($filename, $target); return $pdf->output($filename, $target);

View File

@ -17,6 +17,8 @@ namespace D3\PdfDocuments\Application\Model\Interfaces;
interface pdfdocumentsGenericInterface interface pdfdocumentsGenericInterface
{ {
public function setDevelopmentMode(bool $devMode);
public function getRequestId(): string; public function getRequestId(): string;
public function getTitleIdent(): string; public function getTitleIdent(): string;

View File

@ -21,11 +21,11 @@ $basicAuthHelp = <<<HELP
HELP; HELP;
return [ return [
'charset' => 'utf-8', 'charset' => 'utf-8',
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'main' => 'Grundeinstellungen',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '. '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.', 'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, '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_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Rechnung',
'SHOP_MODULE_invoicePaymentTerm' => 'Zahlungsziel (in Tagen)', 'SHOP_MODULE_invoicePaymentTerm' => 'Zahlungsziel (in Tagen)',
'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Inhalte', 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'contents' => 'Inhalte',
'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo-Grafik URL', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'LogoUrl' => 'Logo-Grafik URL',
'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => 'Hintergrund-Grafik URL', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'BackgroundUrl' => 'Hintergrund-Grafik URL',
'SHOP_MODULE_GROUP_d3PdfDocumentsdocuments' => 'Dokumente', 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'documents' => 'Dokumente',
'SHOP_MODULE_d3PdfDocumentsDocInvoice' => 'Rechnung', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoice' => 'Rechnung',
'SHOP_MODULE_d3PdfDocumentsDocInvoiceNoLogo' => 'Rechnung ohne Logo', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoiceNoLogo' => 'Rechnung ohne Logo',
'SHOP_MODULE_d3PdfDocumentsDocDeliveryNote' => 'Lieferschein', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNote' => 'Lieferschein',
'SHOP_MODULE_d3PdfDocumentsDocDeliveryNoteNoLogo' => 'Lieferschein ohne Logo', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo' => 'Lieferschein ohne Logo',
'D3_PDFDOCUMENTS' => 'PDF-Dokumente', 'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
@ -53,6 +53,7 @@ return [
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument', 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument',
'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache', 'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache',
'D3_PDFDOCUMENTS_SGML_GENERATE' => 'SGML erstellen',
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen', 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen',
]; ];
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd

View File

@ -23,7 +23,7 @@ $basicAuthHelp = <<<HELP
return [ return [
'charset' => 'utf-8', 'charset' => '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', '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 '. '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.', '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_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Invoice',
'SHOP_MODULE_invoicePaymentTerm' => 'Payment term (in days)', 'SHOP_MODULE_invoicePaymentTerm' => 'Payment term (in days)',
'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Contents', 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'contents' => 'Contents',
'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo image URL', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'LogoUrl' => 'Logo image URL',
'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => 'Background image URL', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'BackgroundUrl' => 'Background image URL',
'SHOP_MODULE_GROUP_d3PdfDocumentsdocuments' => 'Documents', 'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'documents' => 'Documents',
'SHOP_MODULE_d3PdfDocumentsDocInvoice' => 'Invoice', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoice' => 'Invoice',
'SHOP_MODULE_d3PdfDocumentsDocInvoiceNoLogo' => 'Invoice without logo', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocInvoiceNoLogo' => 'Invoice without logo',
'SHOP_MODULE_d3PdfDocumentsDocDeliveryNote' => 'Delivery note', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNote' => 'Delivery note',
'SHOP_MODULE_d3PdfDocumentsDocDeliveryNoteNoLogo' => 'Delivery note without logo', 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo' => 'Delivery note without logo',
'D3_PDFDOCUMENTS' => 'PDF Documents', 'D3_PDFDOCUMENTS' => 'PDF Documents',
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
@ -53,6 +53,7 @@ return [
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document', 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document',
'D3_PDFDOCUMENTS_LANGUAGE' => 'Language', 'D3_PDFDOCUMENTS_LANGUAGE' => 'Language',
'D3_PDFDOCUMENTS_SGML_GENERATE' => 'Create SGML',
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document', 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document',
]; ];
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd

View File

@ -14,6 +14,7 @@
namespace D3\PdfDocuments\Modules\Application\Controller; namespace D3\PdfDocuments\Modules\Application\Controller;
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator; 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\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
@ -30,6 +31,8 @@ use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\TableViewNameGenerator; use OxidEsales\Eshop\Core\TableViewNameGenerator;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; 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\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
@ -63,6 +66,13 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
return parent::render(); 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 * @throws DBALDriverException
*/ */

View File

@ -107,36 +107,36 @@ $aModule = [
'value' => 7, 'value' => 7,
], ],
[ [
'group' => $sModuleId.'contents', 'group' => Constants::OXID_MODULE_ID.'contents',
'name' => $sModuleId.'LogoUrl', 'name' => Constants::OXID_MODULE_ID.'LogoUrl',
'type' => 'str' 'type' => 'str'
], ],
[ [
'group' => $sModuleId.'contents', 'group' => Constants::OXID_MODULE_ID.'contents',
'name' => $sModuleId.'BackgroundUrl', 'name' => Constants::OXID_MODULE_ID.'BackgroundUrl',
'type' => 'str' 'type' => 'str'
], ],
[ [
'group' => $sModuleId.'documents', 'group' => Constants::OXID_MODULE_ID.'documents',
'name' => $sModuleId.'DocInvoice', 'name' => Constants::OXID_MODULE_ID.'DocInvoice',
'type' => 'bool', 'type' => 'bool',
'value' => true 'value' => true
], ],
[ [
'group' => $sModuleId.'documents', 'group' => Constants::OXID_MODULE_ID.'documents',
'name' => $sModuleId.'DocInvoiceNoLogo', 'name' => Constants::OXID_MODULE_ID.'DocInvoiceNoLogo',
'type' => 'bool', 'type' => 'bool',
'value' => true 'value' => true
], ],
[ [
'group' => $sModuleId.'documents', 'group' => Constants::OXID_MODULE_ID.'documents',
'name' => $sModuleId.'DocDeliveryNote', 'name' => Constants::OXID_MODULE_ID.'DocDeliveryNote',
'type' => 'bool', 'type' => 'bool',
'value' => true 'value' => true
], ],
[ [
'group' => $sModuleId.'documents', 'group' => Constants::OXID_MODULE_ID.'documents',
'name' => $sModuleId.'DocDeliveryNoteNoLogo', 'name' => Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo',
'type' => 'bool', 'type' => 'bool',
'value' => true 'value' => true
], ],

View File

@ -1,10 +1,13 @@
[{if $edit && $oView->d3CanExport()}] [{if $edit && $oView->d3CanExport()}]
<br> <br>
[{assign var="devmode" value=$oView->d3PdfDocsIsDevMode()}]
<form name="d3CreatePdf" id="d3CreatePdf" action="[{$oViewConf->getSelfLink()}]" method="post" target="d3ExpPDF"> <form name="d3CreatePdf" id="d3CreatePdf" action="[{$oViewConf->getSelfLink()}]" method="post" target="d3ExpPDF">
[{$oViewConf->getHiddenSid()}] [{$oViewConf->getHiddenSid()}]
<input type="hidden" name="cl" value="order_overview"> <input type="hidden" name="cl" value="order_overview">
<input type="hidden" name="fnc" value="d3CreatePDF"> <input type="hidden" name="fnc" value="d3CreatePDF">
<input type="hidden" name="oxid" value="[{$oxid}]"> <input type="hidden" name="oxid" value="[{$oxid}]">
[{if $devmode}]<input type="hidden" id="devmode" name="devmode" value="0">[{/if}]
<fieldset style="padding: 5px"> <fieldset style="padding: 5px">
<legend>[{oxmultilang ident="D3_PDFDOCUMENTS"}]</legend> <legend>[{oxmultilang ident="D3_PDFDOCUMENTS"}]</legend>
<table style="width: 100%"> <table style="width: 100%">
@ -36,7 +39,10 @@
</tr> </tr>
<tr> <tr>
<td style="text-align: right" class="edittext"><br/> <td style="text-align: right" class="edittext"><br/>
<input type="submit" class="edittext" name="save" value="[{oxmultilang ident="D3_PDFDOCUMENTS_PDF_GENERATE"}]"> [{if $devmode}]
<input type="submit" class="edittext" name="save" value="[{oxmultilang ident="D3_PDFDOCUMENTS_SGML_GENERATE"}]" onclick="document.getElementById('devmode').value = 1;">
[{/if}]
<input type="submit" class="edittext" name="save" value="[{oxmultilang ident="D3_PDFDOCUMENTS_PDF_GENERATE"}]" [{if $devmode}] onclick="document.getElementById('devmode').value = 0;"[{/if}]>
<iframe name="d3ExpPDF" style="width: 0; height: 0; border: none; display:none;"></iframe> <iframe name="d3ExpPDF" style="width: 0; height: 0; border: none; display:none;"></iframe>
</td> </td>
</tr> </tr>

View File

@ -1,10 +1,13 @@
{% if edit and oView.d3CanExport() %} {% if edit and oView.d3CanExport() %}
<br> <br>
{% set devmode = oView.d3PdfDocsIsDevMode() %}
<form name="d3CreatePdf" id="d3CreatePdf" action="{{ oViewConf.getSelfLink() }}" method="post" target="d3ExpPDF"> <form name="d3CreatePdf" id="d3CreatePdf" action="{{ oViewConf.getSelfLink() }}" method="post" target="d3ExpPDF">
{{ oViewConf.getHiddenSid()|raw }} {{ oViewConf.getHiddenSid()|raw }}
<input type="hidden" name="cl" value="order_overview"> <input type="hidden" name="cl" value="order_overview">
<input type="hidden" name="fnc" value="d3CreatePDF"> <input type="hidden" name="fnc" value="d3CreatePDF">
<input type="hidden" name="oxid" value="{{ oxid }}"> <input type="hidden" name="oxid" value="{{ oxid }}">
{% if devmode %}<input type="hidden" id="devmode" name="devmode" value="0">{% endif %}
<fieldset style="padding: 5px"> <fieldset style="padding: 5px">
<legend>{{ translate({ ident: "D3_PDFDOCUMENTS" }) }}</legend> <legend>{{ translate({ ident: "D3_PDFDOCUMENTS" }) }}</legend>
<table style="width: 100%"> <table style="width: 100%">
@ -36,7 +39,10 @@
</tr> </tr>
<tr> <tr>
<td style="text-align: right" class="edittext"><br/> <td style="text-align: right" class="edittext"><br/>
<input type="submit" class="edittext" name="save" value="{{ translate({ ident: "D3_PDFDOCUMENTS_PDF_GENERATE" }) }}"> {% if devmode %}
<input type="submit" class="edittext" name="save" value="{{ translate({ ident: "D3_PDFDOCUMENTS_SGML_GENERATE" }) }}" onclick="document.getElementById('devmode').value = 1;">
{% endif %}
<input type="submit" class="edittext" name="save" value="{{ translate({ ident: "D3_PDFDOCUMENTS_PDF_GENERATE" }) }}" {% if devmode %} onclick="document.getElementById('devmode').value = 0;"{% endif %}>
<iframe name="d3ExpPDF" style="width: 0; height: 0; border: none; display:none;"></iframe> <iframe name="d3ExpPDF" style="width: 0; height: 0; border: none; display:none;"></iframe>
</td> </td>
</tr> </tr>