15 Commits

20 changed files with 289 additions and 83 deletions

View File

@ -27,6 +27,10 @@ class orderOverviewPdfGenerator
{
$Pdf= $this->getPdfClass();
$Pdf->setDevelopmentMode(
Registry::getConfig()->getConfigParam('d3PdfDocumentsbDev') &&
Registry::getRequest()->getRequestEscapedParameter('devmode')
);
$Pdf->setOrder($order);
$Pdf->downloadPdf($iSelLang);
}

View File

@ -20,6 +20,7 @@ use OxidEsales\Eshop\Core\UtilsView;
use Smarty;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\MyPdf;
abstract class pdfdocumentsGeneric extends Base implements genericInterface
{
@ -41,6 +42,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
/** @var string */
public $filename;
protected $devMode = false;
/**
* pdfDocumentsGeneric constructor.
*/
@ -52,6 +55,11 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$this->oSmarty = Registry::getUtilsView()->getSmarty(true);
}
public function setDevelopmentMode(bool $devMode)
{
$this->devMode = $devMode;
}
public function runPreAction()
{
}
@ -72,11 +80,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
$oPdf->setTestIsImage(false);
$htmlContent = $this->getHTMLContent($iSelLang);
$oPdf->writeHTML($htmlContent);
$oPdf->pdf->SetAuthor(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
$oPdf->pdf->SetTitle(Registry::getLang()->translateString($this->getTitleIdent()));
$oPdf->pdf->SetCreator('D³ PDF Documents for OXID eShop');
$oPdf->pdf->SetSubject(NULL);
/** @var MyPdf $myPdf */
$myPdf = $oPdf->pdf;
$myPdf->setAuthor( Registry::getConfig()->getActiveShop()->getFieldData( 'oxname'));
$myPdf->setTitle( Registry::getLang()->translateString( $this->getTitleIdent()));
$myPdf->setCreator( 'D³ PDF Documents for OXID eShop');
$myPdf->setSubject( NULL);
return $this->output($oPdf, $sFilename, $target, $htmlContent);
}
@ -189,6 +200,27 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
self::$_blIsAdmin = $blCurrentRenderFromAdmin;
$content = $this->addBasicAuth($content);
return $content;
}
protected function addBasicAuth($content)
{
$username = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthUserName'));
$password = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthPassword'));
if ($username && $password) {
$shopUrl = parse_url( Registry::getConfig()->getShopCurrentUrl() );
$pattern = '/(["|\'])'.
'(' . preg_quote( $shopUrl['scheme'], '/' ) . ':\/\/)'.
'(' . preg_quote( $shopUrl['host'], '/' ) . '.*?)'.
'\1/m';
$replace = "$1$2" . urlencode($username). ":" . urlencode($password) . "@$3$1";
$content = preg_replace( $pattern, $replace, $content );
}
return $content;
}
@ -291,7 +323,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
*/
public function output(Html2Pdf $oPdf, $sFilename, $target, $html)
{
if ((bool) Registry::getConfig()->getConfigParam('d3PdfDocumentsbDev') === true) {
if ($this->devMode) {
return $this->outputDev($oPdf, $sFilename, $target, $html);
} else {
return $oPdf->output($sFilename, $target);
@ -307,7 +339,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
*/
public function outputDev(Html2Pdf $oPdf, $sFilename, $target, $html)
{
$sFilename = str_replace('.pdf', '.html', $sFilename);
$sFilename = str_replace('.pdf', '.sgml', $sFilename);
switch($target) {
case 'I': {
@ -332,7 +364,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
break;
}
case 'D': {
// Download PDF as file
// Download PDF as a file
if (ob_get_contents()) {
$oPdf->pdf->Error('Some data has already been output, can\'t send PDF file');
}
@ -348,7 +380,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream', false);
header('Content-Type: application/download', false);
header('Content-Type: text/html', false);
header('Content-Type: text/sgml', false);
// use the Content-Disposition header to supply a recommended filename
header('Content-Disposition: attachment; filename="'.basename($sFilename).'";');
header('Content-Transfer-Encoding: binary');
@ -377,4 +409,4 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
return null;
}
}
}

View File

@ -12,6 +12,8 @@ namespace D3\PdfDocuments\Application\Model\Interfaces;
interface pdfdocumentsGenericInterface
{
public function setDevelopmentMode(bool $devMode);
/**
* @return string
*/

View File

@ -15,15 +15,21 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
use OxidEsales\Eshop\Core\Registry;
class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface
{
public function __construct()
{
$this->addGenerator(invoicePdf::class);
$this->addGenerator(deliverynotePdf::class);
$this->addGenerator(invoicewithoutlogoPdf::class);
$this->addGenerator(deliverynotewithoutlogoPdf::class);
$config = Registry::getConfig();
if ($config->getConfigParam('d3PdfDocumentsDocInvoice'))
$this->addGenerator(invoicePdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocDeliveryNote'))
$this->addGenerator(deliverynotePdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocInvoiceNoLogo'))
$this->addGenerator(invoicewithoutlogoPdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocDeliveryNoteNoLogo'))
$this->addGenerator(deliverynotewithoutlogoPdf::class);
}
/**

View File

@ -15,15 +15,21 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
use OxidEsales\Eshop\Core\Registry;
class registryOrderoverview extends registryAbstract implements registryOrderoverviewInterface
{
public function __construct()
{
$this->addGenerator(invoicePdf::class);
$this->addGenerator(deliverynotePdf::class);
$this->addGenerator(invoicewithoutlogoPdf::class);
$this->addGenerator(deliverynotewithoutlogoPdf::class);
$config = Registry::getConfig();
if ($config->getConfigParam('d3PdfDocumentsDocInvoice'))
$this->addGenerator(invoicePdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocDeliveryNote'))
$this->addGenerator(deliverynotePdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocInvoiceNoLogo'))
$this->addGenerator(invoicewithoutlogoPdf::class);
if ($config->getConfigParam('d3PdfDocumentsDocDeliveryNoteNoLogo'))
$this->addGenerator(deliverynotewithoutlogoPdf::class);
}
/**

View File

@ -13,7 +13,7 @@ $aLang = array(
'charset' => 'utf-8',
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Vielen Dank für Ihren Einkauf!',
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Ihr Team von %1$s',
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Ihr Team von %1$s.',
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'So erreichen Sie uns:',
'D3_PDFDOCUMENTS_TELEFON' => 'Telefon',
@ -65,7 +65,7 @@ $aLang = array(
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Gesamtsumme (brutto)',
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Ihre gewählte Zahlungsweise',
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Zahlbar bis zum',
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Zahlbar bis zum %s.',
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'Den Rechnungsbetrag haben wir dankend erhalten.',
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Geschäftsführer',

View File

@ -12,7 +12,7 @@ $aLang = array(
'charset' => 'utf-8',
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Many thanks for your purchase!',
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Your team from %1$s',
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Your team from %1$s.',
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'You can contact us as follows',
'D3_PDFDOCUMENTS_TELEFON' => 'Telephone',
@ -33,8 +33,8 @@ $aLang = array(
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice without logo',
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Deliverynote',
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Deliverynote without logo',
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Delivery note',
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Delivery note without logo',
'D3_PDFDOCUMENTS_ORDERNR' => 'Order No.',
'D3_PDFDOCUMENTS_ORDER_FROM_AT' => 'Your order from %1$s at "%2$s"',
@ -64,7 +64,7 @@ $aLang = array(
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Total sum (gross)',
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Your chosen payment method',
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Billing till',
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Billing till %s.',
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'We have received the invoice amount with thanks.',
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Managing director',

View File

@ -9,11 +9,32 @@
*/
$sLangName = "Deutsch";
$basicAuthHelp = <<<HELP
Befindet sich der aktuelle Shop hinter einem BasicAuth, können beim Generieren des PDFs die Bilder nicht geladen werden. Tragen Sie hier die Zugangsdaten ein, um die Bilder zu sehen.
HELP;
$aLang = array(
'charset' => 'utf-8',
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
'HELP_SHOP_MODULE_d3PdfDocumentsbDev' => 'Mit aktiviertem Entwicklermodus kann das Dokument im '.
'SGML-Format ausgegeben werden. Inhaltliche Fehler können so besser nachvollzogen werden.',
'SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)',
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => $basicAuthHelp,
'SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)',
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => $basicAuthHelp,
'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Inhalte',
'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo-Grafik URL',
'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => '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',
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
@ -23,5 +44,6 @@ $aLang = array(
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument',
'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache',
'D3_PDFDOCUMENTS_SGML_GENERATE' => 'SGML erstellen',
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen',
);

View File

@ -9,19 +9,41 @@
*/
$sLangName = "English";
$basicAuthHelp = <<<HELP
If the current shop is protected by a BasicAuth, the images cannot be loaded when the PDF is generated. Enter the access data here to view the images.
HELP;
$aLang = array(
'charset' => 'utf-8',
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
'HELP_SHOP_MODULE_d3PdfDocumentsbDev' => 'If developer mode is activated, the document can exported '.
'in SGML format. This makes it much easier to trace content errors.',
'SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => 'BasicAuth of the shop - user name (optional)',
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => $basicAuthHelp,
'SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => 'BasicAuth of the shop - password (optional)',
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => $basicAuthHelp,
'SHOP_MODULE_GROUP_d3PdfDocumentscontents' => 'Contents',
'SHOP_MODULE_d3PdfDocumentsLogoUrl' => 'Logo image URL',
'SHOP_MODULE_d3PdfDocumentsBackgroundUrl' => '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',
'D3_PDFDOCUMENTS' => 'PDF Documents',
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice without logo',
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Deliverynote',
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Deliverynote without logo',
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Delivery note',
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Delivery note without logo',
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document',
'D3_PDFDOCUMENTS_LANGUAGE' => 'Language',
'D3_PDFDOCUMENTS_SGML_GENERATE' => 'Create SGML',
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document',
);

View File

@ -1,10 +1,14 @@
[{if $edit && $oView->d3CanExport()}]
<br>
[{assign var="config" value=$oViewConf->getConfig()}]
[{assign var="devmode" value=$config->getConfigParam('d3PdfDocumentsbDev')}]
<form name="d3CreatePdf" id="d3CreatePdf" action="[{$oViewConf->getSelfLink()}]" method="post" target="d3ExpPDF">
[{$oViewConf->getHiddenSid()}]
<input type="hidden" name="cl" value="order_overview">
<input type="hidden" name="fnc" value="d3CreatePDF">
<input type="hidden" name="oxid" value="[{$oxid}]">
[{if $devmode}]<input type="hidden" id="devmode" name="devmode" value="0">[{/if}]
<fieldset style="padding: 5px">
<legend>[{oxmultilang ident="D3_PDFDOCUMENTS"}]</legend>
<table style="width: 100%">
@ -14,7 +18,7 @@
</td>
<td style="vertical-align: top; text-align: right" class="edittext">
<label for="pdftype">[{oxmultilang ident="D3_PDFDOCUMENTS_PDF_TYPE" suffix="COLON"}]</label>:&nbsp;
<select id="pdftype" name="pdftype" class="editinput" style="width:80px;">
<select id="pdftype" name="pdftype" class="editinput" style="min-width:80px;">
[{block name="d3_pdfdocuments_order_overview_pdfTypeOptions"}]
[{assign var="generatorList" value=$oView->d3getGeneratorList()}]
[{foreach from=$generatorList->getList() item="generator"}]
@ -27,7 +31,7 @@
<tr>
<td style="text-align: right" class="edittext">
<label for="pdflanguage">[{oxmultilang ident="D3_PDFDOCUMENTS_LANGUAGE" suffix="COLON"}]</label>
<select id="pdflanguage" name="pdflanguage" class="saveinnewlanginput" style="width:80px;">
<select id="pdflanguage" name="pdflanguage" class="saveinnewlanginput" style="width:150px;">
[{foreach from=$alangs key=lang item=slang}]
<option value="[{$lang}]" [{if $lang == "0"}]SELECTED[{/if}]>[{$slang}]</option>
[{/foreach}]
@ -35,8 +39,11 @@
</td>
</tr>
<tr>
<td style="text-align: right" class="edittext"><br/>
<input type="submit" class="edittext" name="save" value="[{oxmultilang ident="D3_PDFDOCUMENTS_PDF_GENERATE"}]">
<td style="text-align: right" class="edittext" colspan="2"><br/>
[{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>
</td>
</tr>

View File

@ -10,7 +10,24 @@
[{/foreach}]
</style>
<page backtop="[{$pagePadding.0}]mm" backright="[{$pagePadding.1}]mm" backbottom="[{$pagePadding.2}]mm" backleft="[{$pagePadding.3}]mm" pageset="[{$pageset}]" orientation="[{$orientation}]" format="[{$format}]">
<page
[{block name="pageSettings"}]
backtop="[{$pagePadding.0}]mm"
backright="[{$pagePadding.1}]mm"
backbottom="[{$pagePadding.2}]mm"
backleft="[{$pagePadding.3}]mm"
pageset="[{$pageset}]"
orientation="[{$orientation}]"
format="[{$format}]"
[{if $showLogo && $config->getConfigParam('d3PdfDocumentsBackgroundUrl')}]
backimg="[{$config->getConfigParam('d3PdfDocumentsBackgroundUrl')}]"
[{/if}]
[{* backcolor="#FFF" *}]
[{* backimgx="center" *}]
[{* backimgy="middle" *}]
[{* backimgw="100%" *}]
[{/block}]
>
<page_header>
[{foreach from=$pdfBlock_header item="_block"}]
[{$_block}]

View File

@ -3,36 +3,43 @@
[{block name="pdfFooter"}]
<div class="footer" style="margin: 0 [{$pagePadding.1}]mm 10mm [{$pagePadding.3}]mm">
<table>
<tr>
[{block name="pdfFooterLeft"}]
<td class="footerLeft">
<div>[{$shop->getFieldData('oxname')}]</div>
<div>[{$shop->getFieldData('oxstreet')}]</div>
<div>[{$shop->getFieldData('oxzip')}] [{$shop->getFieldData('oxcity')}]</div>
<div>[{$shop->getFieldData('oxcountry')}]</div>
<div>[{$shop->getFieldData('oxurl')}]</div>
<div>[{$shop->getFieldData('oxinfoemail')}]</div>
</td>
[{/block}]
[{block name="pdfFooterCenter"}]
<td class="footerCenter">
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_MANAGINGDIRECTOR" suffix="COLON"}] [{$shop->getFieldData('oxfname')}] [{$shop->getFieldData('oxlname')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_COURT" suffix="COLON"}] [{$shop->getFieldData('oxcourt')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_HRBNR" suffix="COLON"}] [{$shop->getFieldData('oxhrbnr')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_USTID" suffix="COLON"}] [{$shop->getFieldData('oxvatnumber')}]</div>
</td>
[{/block}]
[{block name="pdfFooterRight"}]
<td class="footerRight">
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_ACCOUNT"}]</div>
<div>[{$shop->getFieldData('oxbankname')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_ACCOUNTNR" suffix="COLON"}] [{$shop->getFieldData('oxibannumber')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_BANKCODE" suffix="COLON"}] [{$shop->getFieldData('oxbiccode')}]</div>
</td>
[{/block}]
</tr>
</table>
[{block name="pdfFooterTable"}]
<table>
<tr>
[{block name="pdfFooterLeft"}]
<td class="footerLeft">
<div>[{$shop->getFieldData('oxname')}]</div>
<div>[{$shop->getFieldData('oxstreet')}]</div>
<div>[{$shop->getFieldData('oxzip')}] [{$shop->getFieldData('oxcity')}]</div>
<div>[{$shop->getFieldData('oxcountry')}]</div>
<div>[{$shop->getFieldData('oxurl')}]</div>
<div>[{$shop->getFieldData('oxinfoemail')}]</div>
</td>
[{/block}]
[{block name="pdfFooterCenter"}]
<td class="footerCenter">
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_MANAGINGDIRECTOR" suffix="COLON"}] [{$shop->getFieldData('oxfname')}] [{$shop->getFieldData('oxlname')}]</div>
[{if $shop->getFieldData('oxcourt')}]
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_COURT" suffix="COLON"}] [{$shop->getFieldData('oxcourt')}]</div>
[{/if}]
[{if $shop->getFieldData('oxhrbnr')}]
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_HRBNR" suffix="COLON"}] [{$shop->getFieldData('oxhrbnr')}]</div>
[{/if}]
[{if $shop->getFieldData('oxvatnumber')}]
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_USTID" suffix="COLON"}] [{$shop->getFieldData('oxvatnumber')}]</div>
[{/if}]
</td>
[{/block}]
[{block name="pdfFooterRight"}]
<td class="footerRight">
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_ACCOUNT"}]</div>
<div>[{$shop->getFieldData('oxbankname')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_ACCOUNTNR" suffix="COLON"}] [{$shop->getFieldData('oxibannumber')}]</div>
<div>[{oxmultilang ident="D3_PDFDOCUMENTS_BANK_BANKCODE" suffix="COLON"}] [{$shop->getFieldData('oxbiccode')}]</div>
</td>
[{/block}]
</tr>
</table>
[{/block}]
</div>
[{/block}]

View File

@ -6,7 +6,8 @@
[{* pdf logo is available only in non admin theme *}]
[{assign var="isAdmin" value=$viewConfig->isAdmin()}]
[{$viewConfig->setAdminMode(false)}]
<img class="logo" alt="Logo" src="[{$viewConfig->getImageUrl('pdf_logo.jpg')}]">
[{assign var="logoUrl" value=$config->getConfigParam('d3PdfDocumentsLogoUrl')|default:$viewConfig->getImageUrl('pdf_logo.jpg')}]
<img class="logo" alt="Logo" src="[{$logoUrl}]">
[{$viewConfig->setAdminMode($isAdmin)}]
[{/if}]
</div>

View File

@ -11,9 +11,11 @@
[{assign var="dateFormat" value='D3_PDFDOCUMENTS_DATE_FORMAT'|oxmultilangassign}]
[{oxmultilang ident="D3_PDFDOCUMENTS_DATE" suffix="COLON"}] [{$order->getFieldData('oxbilldate')|date_format:$dateFormat}]
</div>
<div>
[{oxmultilang ident="D3_PDFDOCUMENTS_USTIDNR" suffix="COLON"}] [{$shop->getFieldData('oxvatnumber')}]
</div>
[{if $shop->getFieldData('oxvatnumber')}]
<div>
[{oxmultilang ident="D3_PDFDOCUMENTS_USTIDNR" suffix="COLON"}] [{$shop->getFieldData('oxvatnumber')}]
</div>
[{/if}]
[{/block}]
</div>
[{/block}]

View File

@ -2,8 +2,7 @@
[{if $payment->getId() == 'oxidinvoice'}]
[{block name="payinfo_billable_till"}]
[{assign var="dateFormat" value='D3_PDFDOCUMENTS_DATE_FORMAT'|oxmultilangassign}]
[{oxmultilang ident="D3_PDFDOCUMENTS_PAYABLEUNTIL"}]
[{$document->getPayableUntilDate()|date_format:$dateFormat}]
[{oxmultilang ident="D3_PDFDOCUMENTS_PAYABLEUNTIL" args=$document->getPayableUntilDate()|date_format:$dateFormat}]
[{/block}]
[{elseif $payment->getId() == 'oxidpayadvance' || $payment->getId() == 'oxidcreditcard'}]
[{block name="payinfo_payed"}]

8
IntelliSenseHelper.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace D3\PdfDocuments\Modules\Application\Controller {
use OxidEsales\EshopCommunity\Application\Controller\Admin\OrderOverview;
class d3_overview_controller_pdfdocuments_parent extends OrderOverview{}
}

View File

@ -14,6 +14,7 @@ use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
use Exception;
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\DatabaseProvider;
@ -21,15 +22,36 @@ use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\TableViewNameGenerator;
if (false) {
class_alias(
d3_overview_controller_pdfdocuments_parent::class,
OrderOverview::class
);
}
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
{
private $generatorError = false;
public function render()
{
if ($this->generatorError) {
echo <<<HTML
<html lang="de">
<body>
<script>
let form = top.basefrm.edit.document.getElementById("transfer");
let input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "generatorError");
input.setAttribute("value", encodeURIComponent('{$this->generatorError}'));
form.appendChild(input);
form.submit();
</script>
</body>
</html>
HTML;
Registry::getUtils()->showMessageAndExit('PDF-Datei konnte nicht erstellt werden');
} elseif ($generatorError = Registry::getRequest()->getRequestParameter('generatorError')) {
Registry::getUtilsView()->addErrorToDisplay(urldecode($generatorError));
}
return parent::render();
}
/**
* @return bool
* @throws DatabaseConnectionException
@ -53,14 +75,19 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
*/
public function d3CreatePDF()
{
$soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) {
/** @var Order $oOrder */
$oOrder = oxNew(Order::class);
if ($oOrder->load($soxId)) {
$generator = oxNew( orderOverviewPdfGenerator::class );
$generator->generatePdf($oOrder, Registry::getRequest()->getRequestEscapedParameter("pdflanguage"));
try {
$soxId = $this->getEditObjectId();
if ( $soxId != "-1" && isset( $soxId ) ) {
/** @var Order $oOrder */
$oOrder = oxNew( Order::class );
if ( $oOrder->load( $soxId ) ) {
$generator = oxNew( orderOverviewPdfGenerator::class );
$generator->generatePdf( $oOrder, Registry::getRequest()->getRequestEscapedParameter( "pdflanguage" ) );
}
}
} catch ( Exception $exception) {
Registry::getLogger()->error($exception->getMessage(), [ 'exception' => $exception ] );
$this->generatorError = 'PDF documents: ' . $exception->getMessage();
}
}

View File

@ -8,7 +8,7 @@ Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Kopfd
An den Bestellungen Ihres OXID-Shops steht Ihnen die Erstellung von Rechnung und Lieferschein zur Verfügung.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder Neue hinzuzufügen. Auch komplett andere Dokumentarten (z.B. Artikeldatenblätter) sind einfach möglich.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder neue hinzuzufügen. Auch komplett andere Dokumentarten (z.B. Artikeldatenblätter) sind einfach möglich.
## Systemanforderungen:

View File

@ -33,7 +33,7 @@
"require": {
"php": "^7.0 || ^8.0",
"oxid-esales/oxideshop-ce": "6.3 - 6.14",
"spipu/html2pdf": "^5.2",
"spipu/html2pdf": "~5.2.8",
"d3/modcfg": "^5.3.6.000 || ^6",
"beberlei/assert": "^3.3.2"
},

View File

@ -85,6 +85,50 @@ $aModule = [
'name' => $sModuleId.'bDev',
'type' => 'bool',
'value' => false
],
[
'group' => $sModuleId.'main',
'name' => $sModuleId.'basicAuthUserName',
'type' => 'str'
],
[
'group' => $sModuleId.'main',
'name' => $sModuleId.'basicAuthPassword',
'type' => 'password'
],
[
'group' => $sModuleId.'contents',
'name' => $sModuleId.'LogoUrl',
'type' => 'str'
],
[
'group' => $sModuleId.'contents',
'name' => $sModuleId.'BackgroundUrl',
'type' => 'str'
],
[
'group' => $sModuleId.'documents',
'name' => $sModuleId.'DocInvoice',
'type' => 'bool',
'value' => true
],
[
'group' => $sModuleId.'documents',
'name' => $sModuleId.'DocInvoiceNoLogo',
'type' => 'bool',
'value' => true
],
[
'group' => $sModuleId.'documents',
'name' => $sModuleId.'DocDeliveryNote',
'type' => 'bool',
'value' => true
],
[
'group' => $sModuleId.'documents',
'name' => $sModuleId.'DocDeliveryNoteNoLogo',
'type' => 'bool',
'value' => true
]
]
];