Compare commits
107 Commits
1.0.3.1
...
dev_2.x_da
Author | SHA1 | Date | |
---|---|---|---|
3a0db1dfb6 | |||
b6fc417016 | |||
5e1195aa40 | |||
ea2dc48b89 | |||
58e9079a82 | |||
4f4776e3a2 | |||
2670fa6179 | |||
7db34b7a06
|
|||
5b93104682
|
|||
22f9b2b34b
|
|||
77cf661b05 | |||
b3e99e51c7 | |||
3a34411c6b | |||
e95c0f6506 | |||
c42b5a1dec | |||
247218a609
|
|||
81d7eebefb | |||
c1ad0a1665 | |||
31a5674490 | |||
5d95edf605 | |||
2d8b744656 | |||
096584c95d | |||
8183189fd0 | |||
fd5896b5af | |||
ba519af750 | |||
cf465f91c6 | |||
34fa47c817 | |||
d64784bc55 | |||
3675d501f5 | |||
e1714a8dd7
|
|||
2ab279afbd
|
|||
234c760d11
|
|||
0bbd74a883 | |||
d277717d46 | |||
ce84c8a38c | |||
cd97bd5993 | |||
0015d17dc2 | |||
6cc376125a
|
|||
07621472c7
|
|||
de770d2c41
|
|||
97735bab3b
|
|||
524eb9be7b
|
|||
88bfa2f9e0 | |||
4a538bcec3 | |||
a5c618c34f | |||
7c132bb412 | |||
fb6e9fbe5d | |||
c097e06ac1 | |||
10c08da415 | |||
e9c88117da | |||
1bcad628ec | |||
1f97025fa3 | |||
9666276018 | |||
bd01cf8d3b | |||
875f8e2464 | |||
4e91c42910 | |||
35f6048a37 | |||
14aa855bb7 | |||
40fb77b376 | |||
c34a9067a6 | |||
ec914da45e | |||
2f72319820 | |||
79ec86cdda | |||
28d7e692a2 | |||
99810c9cba | |||
9a4d09678c | |||
813fbb208d | |||
146b68ef1c | |||
f58298ae24 | |||
adadf94f74 | |||
72e14257eb | |||
4c9dbbdabc | |||
ec7d3f5622 | |||
0b4c634352
|
|||
d89b00843f
|
|||
beaa79c0e9 | |||
ec6a0920d0 | |||
57a1e62248 | |||
4eabe55faa | |||
785637254b | |||
d555656a38 | |||
ce3d8c3e29 | |||
5fa706fa3a | |||
d8a1050371 | |||
84225165de | |||
5c0f3b1f77 | |||
7c3eb1895f | |||
7b898aef8f | |||
4bd3b75931 | |||
cb355033f8 | |||
a32d8bc498 | |||
8392de0566 | |||
ce05a811a9 | |||
9cdd4dfb1c | |||
04e466b999 | |||
dfd22940c8 | |||
6ae437ab56 | |||
6da3e99a0e | |||
e320d0f303 | |||
3d1389843d | |||
2e45d644fe | |||
be1a961f88 | |||
18b055c7f7 | |||
f52ed2c95e | |||
e9987b5221
|
|||
010dda9050
|
|||
1e91990a28
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.phpunit.result.cache
|
||||
Tests/.phpunit.result.cache
|
||||
Tests/result
|
31
.php-cs-fixer.php
Normal file
31
.php-cs-fixer.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
;
|
||||
|
||||
$fileHeaderComment = <<<EOF
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
https://www.d3data.de
|
||||
|
||||
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
@author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
@link https://www.oxidmodule.com
|
||||
EOF;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'header_comment' => [
|
||||
'header' => $fileHeaderComment,
|
||||
'comment_type' => 'PHPDoc',
|
||||
'location' => 'after_open'
|
||||
],
|
||||
'@PHP80Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
@ -1,45 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
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\Interfaces\pdfdocumentsOrderInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
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;
|
||||
|
||||
class orderOverviewPdfGenerator
|
||||
{
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param int $iSelLang
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws noPdfHandlerFoundException
|
||||
*/
|
||||
public function generatePdf(Order $order, $iSelLang = 0)
|
||||
public function generatePdf(Order $order, int $iSelLang = 0): void
|
||||
{
|
||||
$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->downloadPdf($iSelLang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pdfdocumentsOrderInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws noPdfHandlerFoundException
|
||||
*/
|
||||
public function getPdfClass()
|
||||
public function getPdfClass(): pdfdocumentsOrderInterface
|
||||
{
|
||||
$requestedType = Registry::getRequest()->getRequestParameter('pdftype');
|
||||
|
||||
$generatorList = oxNew(registryOrderoverview::class);
|
||||
/** @var registryOrderoverview $generatorList */
|
||||
$generatorList = ContainerFactory::getInstance()->getContainer()->get(registryOrderoverviewInterface::class);
|
||||
/** @var pdfdocumentsOrderInterface $generator */
|
||||
foreach ($generatorList->getList() as $generator) {
|
||||
if ($generator->getRequestId() == $requestedType) {
|
||||
@ -48,7 +69,10 @@ class orderOverviewPdfGenerator
|
||||
}
|
||||
|
||||
/** @var noPdfHandlerFoundException $e */
|
||||
$e = oxNew(noPdfHandlerFoundException::class, Registry::getRequest()->getRequestParameter('pdftype'));
|
||||
$e = oxNew(
|
||||
noPdfHandlerFoundException::class,
|
||||
Registry::getRequest()->getRequestParameter('pdftype')
|
||||
);
|
||||
throw($e);
|
||||
}
|
||||
}
|
@ -1,248 +1,292 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
|
||||
|
||||
use D3\ModCfg\Application\Model\d3filesystem;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||
use Exception;
|
||||
use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use Smarty;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
|
||||
abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
{
|
||||
const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser
|
||||
const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download
|
||||
const PDF_DESTINATION_FILE = 'F'; // save as local file
|
||||
const PDF_DESTINATION_FILEANDSTDOUT = 'FI'; // output as local file and show in browser plugin
|
||||
const PDF_DESTINATION_FILEANDDOWNLOAD = 'FD'; // output as local file and force download in browser
|
||||
const PDF_DESTINATION_STRING = 'S'; // output as string
|
||||
public const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser
|
||||
public const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download
|
||||
public const PDF_DESTINATION_FILE = 'F'; // save as a local file
|
||||
public const PDF_DESTINATION_FILEANDSTDOUT = 'FI'; // output as a local file and show in browser plugin
|
||||
public const PDF_DESTINATION_FILEANDDOWNLOAD = 'FD'; // output as a local file and force download in browser
|
||||
public const PDF_DESTINATION_STRING = 'S'; // output as string
|
||||
|
||||
const PDF_ORIENTATION_PORTRAIT = 'P';
|
||||
const PDF_ORIENTATION_LANDSCAPE = 'L';
|
||||
public const PDF_ORIENTATION_PORTRAIT = 'P';
|
||||
public const PDF_ORIENTATION_LANDSCAPE = 'L';
|
||||
|
||||
public $filenameExtension = 'pdf';
|
||||
public string $filenameExtension = 'pdf';
|
||||
public ?string $filename = null;
|
||||
|
||||
/** @var Smarty */
|
||||
public $oSmarty;
|
||||
protected bool $devMode = false;
|
||||
|
||||
/** @var string */
|
||||
public $filename;
|
||||
|
||||
/**
|
||||
* pdfDocumentsGeneric constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
public function setDevelopmentMode(bool $devMode): void
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/** @var Smarty $oSmarty */
|
||||
$this->oSmarty = Registry::getUtilsView()->getSmarty(true);
|
||||
$this->devMode = $devMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function runPreAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function runPostAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sFilename
|
||||
* @param int $iSelLang
|
||||
* @param string $target
|
||||
* @return mixed|string|null
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
|
||||
public function genPdf(string $filename, int $language = 0, string $target = self::PDF_DESTINATION_STDOUT): ?string
|
||||
{
|
||||
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
||||
$oPdf = $this->getHtml2Pdf();
|
||||
$oPdf->getSecurityService()->addAllowedHost(
|
||||
parse_url(Registry::getConfig()->getShopCurrentUrl())['host']
|
||||
);
|
||||
$oPdf->setTestIsImage(false);
|
||||
$htmlContent = $this->getHTMLContent($iSelLang);
|
||||
$htmlContent = $this->getHTMLContent($language);
|
||||
$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);
|
||||
return $this->output($oPdf, $sFilename, $target, $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);
|
||||
return $this->output($oPdf, $filename, $target, $htmlContent);
|
||||
}
|
||||
|
||||
protected function getHtml2Pdf(): Html2Pdf
|
||||
{
|
||||
return oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iLanguage
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function downloadPdf($iLanguage = 0)
|
||||
public function downloadPdf(int $language = 0): void
|
||||
{
|
||||
try {
|
||||
$this->runPreAction();
|
||||
$sFilename = $this->getFilename();
|
||||
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
|
||||
$this->genPdf($sFilename, $language, self::PDF_DESTINATION_DOWNLOAD);
|
||||
$this->runPostAction();
|
||||
Registry::getUtils()->showMessageAndExit('');
|
||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Registry::getLogger()->error($e);
|
||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param int $iLanguage
|
||||
*
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function savePdfFile($path, $iLanguage = 0)
|
||||
public function savePdfFile(string $path, int $language = 0): void
|
||||
{
|
||||
try {
|
||||
$this->runPreAction();
|
||||
$sFilename = $this->getFilename();
|
||||
$this->genPdf(
|
||||
rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$sFilename,
|
||||
$iLanguage,
|
||||
$language,
|
||||
self::PDF_DESTINATION_FILE
|
||||
);
|
||||
$this->runPostAction();
|
||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||
Registry::getLogger()->error($e);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iLanguage
|
||||
*
|
||||
* @return null|string
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPdfContent($iLanguage = 0)
|
||||
public function getPdfContent(int $language = 0): ?string
|
||||
{
|
||||
try {
|
||||
$this->runPreAction();
|
||||
$sFilename = $this->getFilename();
|
||||
$ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING );
|
||||
$ret = $this->genPdf($sFilename, $language, self::PDF_DESTINATION_STRING);
|
||||
$this->runPostAction();
|
||||
return $ret;
|
||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||
Registry::getLogger()->error($e);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iSelLang
|
||||
*/
|
||||
public function setSmartyVars($iSelLang)
|
||||
public function getTemplateEngineVars(int $language): array
|
||||
{
|
||||
unset($iSelLang);
|
||||
$this->oSmarty->assign('config', Registry::getSession()->getConfig());
|
||||
$this->oSmarty->assign('viewConfig', Registry::getSession()->getConfig()->getActiveView()->getViewConfig());
|
||||
$this->oSmarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop());
|
||||
$this->oSmarty->assign('lang', Registry::getLang());
|
||||
$this->oSmarty->assign('document', $this);
|
||||
unset($language);
|
||||
|
||||
return [
|
||||
'config' => Registry::getConfig(),
|
||||
'oViewConf' => Registry::getConfig()->getActiveView()->getViewConfig(),
|
||||
'shop' => Registry::getConfig()->getActiveShop(),
|
||||
'lang' => Registry::getLang(),
|
||||
'utilsUrl' => Registry::getUtilsUrl(),
|
||||
'document' => $this,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iSelLang
|
||||
*
|
||||
* @return mixed
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getHTMLContent($iSelLang = 0)
|
||||
public function getHTMLContent(int $language = 0): string
|
||||
{
|
||||
$blCurrentRenderFromAdmin = self::$_blIsAdmin;
|
||||
self::$_blIsAdmin = $this->renderTemplateFromAdmin();
|
||||
|
||||
$lang = Registry::getLang();
|
||||
|
||||
$currTplLang = $lang->getTplLanguage();
|
||||
$lang->setTplLanguage($iSelLang);
|
||||
$lang->setTplLanguage($language);
|
||||
|
||||
$this->setSmartyVars($iSelLang);
|
||||
|
||||
$content = $this->oSmarty->fetch($this->getTemplate());
|
||||
$content = $this->getTemplateRenderer()->renderTemplate(
|
||||
$this->getTemplate(),
|
||||
$this->getTemplateEngineVars($language)
|
||||
);
|
||||
|
||||
$lang->setTplLanguage($currTplLang);
|
||||
|
||||
self::$_blIsAdmin = $blCurrentRenderFromAdmin;
|
||||
|
||||
return $this->addBasicAuth($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function addBasicAuth(string $content): string
|
||||
{
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
$username = trim(
|
||||
(string) $settingsService->getString('d3PdfDocumentsbasicAuthUserName', Constants::OXID_MODULE_ID)
|
||||
);
|
||||
$password = trim(
|
||||
(string) $settingsService->getString('d3PdfDocumentsbasicAuthPassword', Constants::OXID_MODULE_ID)
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* arguments for Html2Pdf class constructor
|
||||
* - $orientation = 'P',
|
||||
* - $format = 'A4',
|
||||
* - $lang = 'fr',
|
||||
* - $unicode = true,
|
||||
* - $encoding = 'UTF-8',
|
||||
* - $margins = array(5, 5, 5, 8),
|
||||
* - $pdfa = false
|
||||
* @return string[]
|
||||
* @codeCoverageIgnore
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPdfProperties()
|
||||
protected function getTemplateRenderer(): TemplateRenderer
|
||||
{
|
||||
$orientation = self::PDF_ORIENTATION_PORTRAIT;
|
||||
$format = 'A4';
|
||||
$lang = 'de';
|
||||
$unicode = true;
|
||||
$encoding = 'UTF-8';
|
||||
$margins = [0, 0, 0, 0];
|
||||
$pdfa = true;
|
||||
return [$orientation, $format, $lang, $unicode, $encoding, $margins, $pdfa];
|
||||
return ContainerFactory::getInstance()->getContainer()
|
||||
->get(TemplateRendererBridgeInterface::class)
|
||||
->getTemplateRenderer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setFilename($filename)
|
||||
public function getPdfProperties(): array
|
||||
{
|
||||
return [
|
||||
'orientation' => self::PDF_ORIENTATION_PORTRAIT,
|
||||
'format' => 'A4',
|
||||
'lang' => 'de',
|
||||
'unicode' => true,
|
||||
'encoding' => 'UTF-8',
|
||||
'margins' => [0, 0, 0, 0],
|
||||
'pdfa' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): void
|
||||
{
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename()
|
||||
public function getFilename(): string
|
||||
{
|
||||
// forced filename from setFilename()
|
||||
if ($this->filename) {
|
||||
return $this->makeValidFileName(
|
||||
return $this->sanitizeFileName(
|
||||
$this->addFilenameExtension(
|
||||
$this->filename
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->makeValidFileName(
|
||||
return $this->sanitizeFileName(
|
||||
$this->addFilenameExtension(
|
||||
$this->getTypeForFilename()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function addFilenameExtension($filename)
|
||||
public function addFilenameExtension(string $filename): string
|
||||
{
|
||||
$extension = $this->filenameExtension;
|
||||
$extensionLength = (strlen($extension) + 1) * -1;
|
||||
if ((bool) strlen($extension) && substr($filename, $extensionLength) != '.'.$extension) {
|
||||
if (strlen($extension) && substr($filename, $extensionLength) != '.'.$extension) {
|
||||
$filename .= '.'.$extension;
|
||||
}
|
||||
|
||||
@ -250,120 +294,213 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets proper file name
|
||||
*
|
||||
* @param string $sFilename file name
|
||||
*
|
||||
* @return string
|
||||
* Gets a proper file name
|
||||
*/
|
||||
public function makeValidFileName($sFilename)
|
||||
public function sanitizeFileName(string $filename): string
|
||||
{
|
||||
$fs = oxNew(d3filesystem::class);
|
||||
return $fs->filterFilename($sFilename);
|
||||
// replace transliterations (umlauts, accents ...)
|
||||
$filename = mb_detect_encoding($filename) == 'UTF-8' ? (string) (new UnicodeString($filename))->ascii() : $filename;
|
||||
|
||||
// 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);
|
||||
return mb_strcut(
|
||||
pathinfo($filename, PATHINFO_FILENAME),
|
||||
0,
|
||||
255 - ($ext ? strlen($ext) + 1 : 0),
|
||||
mb_detect_encoding($filename)
|
||||
) . ($ext ? '.' . $ext : '');
|
||||
}
|
||||
|
||||
public function beautifyFilename(string $filename): string
|
||||
{
|
||||
// reduce consecutive characters
|
||||
$filename = preg_replace([
|
||||
// "file name.zip" becomes "file-name.zip"
|
||||
'/\s+/',
|
||||
// "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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function renderTemplateFromAdmin()
|
||||
public function renderTemplateFromAdmin(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Html2Pdf $oPdf
|
||||
* @param $sFilename
|
||||
* @param $target
|
||||
* @param $html
|
||||
* @return string|null
|
||||
* @throws Html2PdfException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function output(Html2Pdf $oPdf, $sFilename, $target, $html)
|
||||
public function output(Html2Pdf $pdf, string $filename, string $target, string $html): ?string
|
||||
{
|
||||
if ((bool) Registry::getConfig()->getConfigParam('d3PdfDocumentsbDev') === true) {
|
||||
return $this->outputDev($oPdf, $sFilename, $target, $html);
|
||||
if ($this->devMode) {
|
||||
return $this->outputDev($pdf, $filename, $target, $html);
|
||||
} else {
|
||||
return $oPdf->output($sFilename, $target);
|
||||
return $pdf->output($filename, $target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Html2Pdf $oPdf
|
||||
* @param $sFilename
|
||||
* @param $target
|
||||
* @param $html
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function outputDev(Html2Pdf $oPdf, $sFilename, $target, $html)
|
||||
public function outputDev(Html2Pdf $pdf, string $filename, string $target, string $html): ?string
|
||||
{
|
||||
$sFilename = str_replace('.pdf', '.html', $sFilename);
|
||||
$filename = str_replace('.pdf', '.sgml', $filename);
|
||||
|
||||
switch($target) {
|
||||
case 'I': {
|
||||
// Send PDF to the standard output
|
||||
if (ob_get_contents()) {
|
||||
$oPdf->pdf->Error('Some data has already been output, can\'t send PDF file');
|
||||
}
|
||||
if (substr(php_sapi_name(), 0, 3) != 'cli') {
|
||||
//We send to a browser
|
||||
header('Content-Type: text/html');
|
||||
if (headers_sent()) {
|
||||
$oPdf->pdf->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||
}
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
header('Content-Length: '.strlen($html));
|
||||
header('Content-Disposition: inline; filename="'.basename($sFilename).'";');
|
||||
}
|
||||
echo $html;
|
||||
break;
|
||||
}
|
||||
case 'D': {
|
||||
// Download PDF as file
|
||||
if (ob_get_contents()) {
|
||||
$oPdf->pdf->Error('Some data has already been output, can\'t send PDF file');
|
||||
}
|
||||
header('Content-Description: File Transfer');
|
||||
if (headers_sent()) {
|
||||
$oPdf->pdf->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||
}
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
// force download dialog
|
||||
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);
|
||||
// use the Content-Disposition header to supply a recommended filename
|
||||
header('Content-Disposition: attachment; filename="'.basename($sFilename).'";');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Length: '.strlen($html));
|
||||
echo $html;
|
||||
break;
|
||||
}
|
||||
case 'F': {
|
||||
// Save PDF to a local file
|
||||
$f = fopen($sFilename, 'wb');
|
||||
if (!$f) {
|
||||
$oPdf->pdf->Error('Unable to create output file: '.$sFilename);
|
||||
}
|
||||
fwrite($f, $html, strlen($html));
|
||||
fclose($f);
|
||||
break;
|
||||
}
|
||||
case 'S': {
|
||||
// Returns PDF as a string
|
||||
switch ($target) {
|
||||
case self::PDF_DESTINATION_STDOUT:
|
||||
return $this->outputDev_stdout($pdf, $filename, $html);
|
||||
case self::PDF_DESTINATION_DOWNLOAD:
|
||||
return $this->outputDev_download($pdf, $filename, $html);
|
||||
case self::PDF_DESTINATION_FILE:
|
||||
return $this->outputDev_saveLocal($pdf, $filename, $html);
|
||||
case self::PDF_DESTINATION_STRING:
|
||||
return $html;
|
||||
}
|
||||
default: {
|
||||
$oPdf->pdf->Error('Incorrect output destination: '.$target);
|
||||
}
|
||||
default:
|
||||
$pdf->pdf->Error('Incorrect output destination: '.$target);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Html2Pdf $pdf
|
||||
* @param string $html
|
||||
* @param array|string $filename
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function outputDev_stdout(Html2Pdf $pdf, array|string $filename, string $html)
|
||||
{
|
||||
if (ob_get_contents()) {
|
||||
$pdf->pdf->Error('Some data has already been output, can\'t send PDF file');
|
||||
}
|
||||
if (!$this->isCli()) {
|
||||
header('Content-Type: text/html');
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->headersSent()) {
|
||||
$pdf->pdf->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Content-Length: ' . strlen($html));
|
||||
header('Content-Disposition: inline; filename="' . basename($filename) . '";');
|
||||
}
|
||||
echo $html;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Html2Pdf $pdf
|
||||
* @param array|string $filename
|
||||
* @param string $html
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function outputDev_download(Html2Pdf $pdf, array|string $filename, string $html)
|
||||
{
|
||||
if (ob_get_contents()) {
|
||||
$pdf->pdf->Error('Some data has already been output, can\'t send PDF file');
|
||||
}
|
||||
header('Content-Description: File Transfer');
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->headersSent()) {
|
||||
$pdf->pdf->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
|
||||
header('Pragma: public');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
// force download dialog
|
||||
header('Content-Type: application/force-download');
|
||||
header('Content-Type: application/octet-stream', false);
|
||||
header('Content-Type: application/download', false);
|
||||
header('Content-Type: text/sgml', false);
|
||||
// use the Content-Disposition header to supply a recommended filename
|
||||
header('Content-Disposition: attachment; filename="' . basename($filename) . '";');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Length: ' . strlen($html));
|
||||
echo $html;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $filename
|
||||
* @param Html2Pdf $pdf
|
||||
* @param string $html
|
||||
* @return null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function outputDev_saveLocal(Html2Pdf $pdf, array|string $filename, string $html)
|
||||
{
|
||||
$f = fopen($filename, 'wb');
|
||||
if (!$f) {
|
||||
$pdf->pdf->Error('Unable to create output file: ' . $filename);
|
||||
return null;
|
||||
}
|
||||
fwrite($f, $html, strlen($html));
|
||||
fclose($f);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function isCli(): bool
|
||||
{
|
||||
return str_starts_with(php_sapi_name(), 'cli');
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function headersSent(): bool
|
||||
{
|
||||
return headers_sent();
|
||||
}
|
||||
}
|
@ -1,128 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
||||
use Assert\Assert;
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface as orderInterface;
|
||||
use \OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Application\Model\Payment;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
||||
{
|
||||
/** @var Order */
|
||||
public $oOrder;
|
||||
public ?Order $order = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* don't use order as constructor argument because of the same method interface for all document types
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setOrder(Order $order)
|
||||
public function __construct()
|
||||
{
|
||||
$this->oOrder = $order;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setOrder(Order $order): void
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Order
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getOrder()
|
||||
public function getOrder(): Order
|
||||
{
|
||||
return $this->oOrder;
|
||||
Assert::that($this->order)->isInstanceOf(Order::class, 'no order for pdf generator set');
|
||||
Assert::that($this->order->isLoaded())->true('given order is not loaded');
|
||||
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iSelLang
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setSmartyVars($iSelLang)
|
||||
public function getTemplateEngineVars(int $language): array
|
||||
{
|
||||
parent::setSmartyVars($iSelLang);
|
||||
|
||||
$this->oSmarty->assign('order', $this->getOrder());
|
||||
|
||||
$oUser = oxNew(User::Class);
|
||||
$oUser = oxNew(User::class);
|
||||
$oUser->load($this->getOrder()->getFieldData('oxuserid'));
|
||||
$this->oSmarty->assign('user', $oUser);
|
||||
|
||||
$oPayment = oxNew(Payment::class);
|
||||
$oPayment->loadInLang($iSelLang, $this->getOrder()->getFieldData('oxpaymenttype'));
|
||||
$this->oSmarty->assign('payment', $oPayment);
|
||||
$oPayment->loadInLang($language, $this->getOrder()->getFieldData('oxpaymenttype'));
|
||||
|
||||
return array_merge(
|
||||
parent::getTemplateEngineVars($language),
|
||||
[
|
||||
'order' => $this->getOrder(),
|
||||
'user' => $oUser,
|
||||
'payment' => $oPayment,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getFilename()
|
||||
public function getFilename(): string
|
||||
{
|
||||
// forced filename from setFilename()
|
||||
if ($this->filename) {
|
||||
return $this->makeValidFileName(
|
||||
if (!$this->filename || !trim($this->filename)) {
|
||||
$sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname'));
|
||||
|
||||
$this->filename = implode(
|
||||
'_',
|
||||
[
|
||||
$this->getTypeForFilename(),
|
||||
$this->getOrder()->getFieldData('oxordernr'),
|
||||
$sTrimmedBillName,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $this->sanitizeFileName(
|
||||
$this->addFilenameExtension(
|
||||
$this->filename
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname'));
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ModuleSettingNotFountException
|
||||
*/
|
||||
public function getPaymentTerm(): int
|
||||
{
|
||||
/** @var ModuleConfigurationDaoBridge $configurationBridge */
|
||||
$configurationBridge = ContainerFactory::getInstance()->getContainer()
|
||||
->get(ModuleConfigurationDaoBridgeInterface::class);
|
||||
$configuration = $configurationBridge->get(Constants::OXID_MODULE_ID);
|
||||
|
||||
return $this->makeValidFileName(
|
||||
$this->addFilenameExtension(
|
||||
implode(
|
||||
'_',
|
||||
[
|
||||
$this->getTypeForFilename(),
|
||||
$this->getOrder()->getFieldData('oxordernr'),
|
||||
$sTrimmedBillName
|
||||
]
|
||||
)
|
||||
)
|
||||
return max(
|
||||
$configuration->hasModuleSetting('invoicePaymentTerm') ?
|
||||
(int)$configuration->getModuleSetting('invoicePaymentTerm')->getValue() :
|
||||
7,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sFilename
|
||||
* @param int $iSelLang
|
||||
* @param string $target
|
||||
* @return mixed|string|null
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
|
||||
public function getPayableUntilDate(): false|int
|
||||
{
|
||||
if (false == $this->getOrder()) {
|
||||
throw oxNew(noBaseObjectSetException::class);
|
||||
$startDate = $this->getOrder()->getFieldData('oxbilldate');
|
||||
|
||||
try {
|
||||
Assert::that($startDate)->date('Y-m-d');
|
||||
$startDate = strtotime($startDate);
|
||||
} catch (InvalidArgumentException) {
|
||||
$startDate = strtotime(date('Y-m-d'));
|
||||
}
|
||||
|
||||
return parent::genPdf($sFilename, $iSelLang, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPaymentTerm()
|
||||
{
|
||||
if (null === $iPaymentTerm = Registry::getConfig()->getConfigParam('iPaymentTerm')) {
|
||||
$iPaymentTerm = 7;
|
||||
}
|
||||
|
||||
return $iPaymentTerm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
*/
|
||||
public function getPayableUntilDate()
|
||||
{
|
||||
return strtotime(
|
||||
'+' . $this->getPaymentTerm() . ' day',
|
||||
strtotime(
|
||||
$this->getOrder()->getFieldData('oxbilldate')
|
||||
)
|
||||
$startDate
|
||||
);
|
||||
}
|
||||
}
|
21
Application/Model/Constants.php
Normal file
21
Application/Model/Constants.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model;
|
||||
|
||||
class Constants
|
||||
{
|
||||
public const OXID_MODULE_ID = 'd3PdfDocuments';
|
||||
}
|
84
Application/Model/Documents/articleDataSheet.php
Normal file
84
Application/Model/Documents/articleDataSheet.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Documents;
|
||||
|
||||
use Assert\Assert;
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
use OxidEsales\Eshop\Application\Model\Article;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridge;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use OxidEsales\Twig\TwigEngine;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class articleDataSheet extends pdfdocumentsGeneric
|
||||
{
|
||||
protected ?Article $article = null;
|
||||
|
||||
public function genPdf( string $filename, int $language = 0, string $target = self::PDF_DESTINATION_STDOUT ): ?string
|
||||
{
|
||||
/** @var TemplateRendererBridge $bridge */
|
||||
$bridge = ContainerFactory::getInstance()->getContainer()->get(TemplateRendererBridgeInterface::class);
|
||||
Assert::that($bridge->getTemplateRenderer()->getTemplateEngine())
|
||||
->isInstanceOf(
|
||||
TwigEngine::class,
|
||||
<<<MSG
|
||||
The article data sheet is only provided by the Twig Engine.
|
||||
Please contact the author for further assistance.
|
||||
MSG
|
||||
);
|
||||
|
||||
return parent::genPdf( $filename, $language, $target );
|
||||
}
|
||||
|
||||
public function setArticle(Article $article): void
|
||||
{
|
||||
$this->article = $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getArticle(): Article
|
||||
{
|
||||
Assert::that($this->article)->isInstanceOf(Article::class, 'no article for pdf generator set');
|
||||
Assert::that($this->article->isLoaded())->true('given article is not loaded');
|
||||
return $this->article;
|
||||
}
|
||||
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'article_datasheet';
|
||||
}
|
||||
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return "D3_PDFDOCUMENTS_ARTICLE_DATASHEET";
|
||||
}
|
||||
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return '@d3PdfDocuments/documents/article/datasheet';
|
||||
}
|
||||
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return "article_datasheet";
|
||||
}
|
||||
}
|
@ -1,48 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Documents;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class deliverynotePdf extends pdfdocumentsOrder
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId()
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'dnote';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleIdent()
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return "D3_PDFDOCUMENTS_DELIVERYNOTE";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTypeForFilename()
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'delnote';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate()
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return 'd3deliverynote_pdf.tpl';
|
||||
return '@d3PdfDocuments/documents/deliverynote/deliverynote';
|
||||
}
|
||||
}
|
@ -1,46 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Documents;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class deliverynotewithoutlogoPdf extends deliverynotePdf
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId()
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'dnote_without_logo';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleIdent()
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return "D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTypeForFilename()
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'delnote-nl';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate()
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return 'd3deliverynoteNoLogo_pdf.tpl';
|
||||
return '@d3PdfDocuments/documents/deliverynote/deliverynoteNoLogo';
|
||||
}
|
||||
}
|
@ -1,49 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Documents;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderinvoiceInterface;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
|
||||
class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceInterface
|
||||
{
|
||||
protected $blIsNewOrder = false;
|
||||
protected bool $orderIsChanged = false;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getRequestId()
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'invoice';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTitleIdent()
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return "D3_PDFDOCUMENTS_INVOICE";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTypeForFilename()
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'invoice';
|
||||
}
|
||||
|
||||
public function runPreAction()
|
||||
public function runPreAction(): void
|
||||
{
|
||||
parent::runPreAction();
|
||||
|
||||
@ -52,50 +55,51 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
|
||||
$this->saveOrderOnChanges();
|
||||
}
|
||||
|
||||
public function setInvoiceNumber()
|
||||
public function setInvoiceNumber(): void
|
||||
{
|
||||
if (!$this->getOrder()->getFieldData('oxbillnr')) {
|
||||
$this->getOrder()->assign(['oxbillnr' => $this->getOrder()->getNextBillNum()]);
|
||||
|
||||
$this->blIsNewOrder = true;
|
||||
$this->orderIsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function setInvoiceDate()
|
||||
public function setInvoiceDate(): void
|
||||
{
|
||||
if ($this->getOrder()->getFieldData('oxbilldate') == '0000-00-00') {
|
||||
$this->getOrder()->assign([
|
||||
"oxbilldate" => date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')))
|
||||
"oxbilldate" => date('Y-m-d'),
|
||||
]);
|
||||
|
||||
$this->blIsNewOrder = true;
|
||||
$this->orderIsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function saveOrderOnChanges()
|
||||
public function saveOrderOnChanges(): void
|
||||
{
|
||||
if ($this->blIsNewOrder) {
|
||||
if ($this->orderIsChanged) {
|
||||
$this->getOrder()->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplate(){
|
||||
return 'd3invoice_pdf.tpl';
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return '@d3PdfDocuments/documents/invoice/invoice';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename()
|
||||
public function getFilename(): string
|
||||
{
|
||||
$filename = parent::getFilename();
|
||||
|
||||
$filename = str_replace(
|
||||
$this->getOrder()->getFieldData('oxordernr'),
|
||||
$this->getOrder()->getFieldData('oxbillnr'),
|
||||
(string) $this->getOrder()->getFieldData('oxordernr'),
|
||||
(string) $this->getOrder()->getFieldData('oxbillnr'),
|
||||
$filename
|
||||
);
|
||||
|
||||
return $this->makeValidFileName($filename);
|
||||
return $this->sanitizeFileName($filename);
|
||||
}
|
||||
}
|
@ -1,45 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Documents;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class invoicewithoutlogoPdf extends invoicePdf
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId()
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'invoice_without_logo';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleIdent()
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return "D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTypeForFilename()
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'invoice-nl';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate(){
|
||||
return 'd3invoiceNoLogo_pdf.tpl';
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return '@d3PdfDocuments/documents/invoice/invoiceNoLogo';
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class noBaseObjectSetException extends pdfGeneratorExceptionAbstract
|
||||
{
|
||||
public function __construct( $sMessage = "no base object (e.g. order) for pdf generator set", $iCode = 0, Exception $previous = null )
|
||||
{
|
||||
parent::__construct( $sMessage, $iCode, $previous );
|
||||
}
|
||||
}
|
@ -1,30 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class noPdfHandlerFoundException extends pdfGeneratorExceptionAbstract
|
||||
{
|
||||
/**
|
||||
* d3noPdfHandlerFoundException constructor.
|
||||
*
|
||||
* @param $requestId
|
||||
* @param string $sMessage
|
||||
* @param int $iCode
|
||||
* @param Exception|null $previous
|
||||
*/
|
||||
public function __construct( $requestId, $sMessage = "no pdf handler defined for given request id", $iCode = 0, Exception $previous = null )
|
||||
{
|
||||
$sMessage .= ' "'.$requestId.'"';
|
||||
parent::__construct( $sMessage, $iCode, $previous );
|
||||
public function __construct(
|
||||
$requestId,
|
||||
string $message = "no pdf handler defined for given request id",
|
||||
int $code = 0,
|
||||
?Exception $previous = null
|
||||
) {
|
||||
$message .= ' "'.$requestId.'"';
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Exceptions;
|
||||
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
|
||||
abstract class pdfGeneratorExceptionAbstract extends StandardException
|
||||
{
|
||||
|
||||
}
|
@ -1,23 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class wrongPdfGeneratorInterface extends pdfGeneratorExceptionAbstract
|
||||
{
|
||||
public function __construct( $requiredInterface, $sMessage = "generator class doesn't fulfilled the interface", $iCode = 0, Exception $previous = null ) {
|
||||
|
||||
$sMessage .= $requiredInterface;
|
||||
|
||||
parent::__construct( $sMessage, $iCode, $previous );
|
||||
public function __construct(
|
||||
string $requiredInterface,
|
||||
string $message = "generator class doesn't fulfilled the interface",
|
||||
int $code = 0,
|
||||
Exception $previous = null
|
||||
) {
|
||||
$message .= ' '.$requiredInterface;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -1,81 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Interfaces;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
||||
|
||||
interface pdfdocumentsGenericInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId();
|
||||
public function setDevelopmentMode(bool $devMode);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleIdent();
|
||||
public function getRequestId(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate();
|
||||
public function getTitleIdent(): string;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHTMLContent();
|
||||
public function getTemplate(): string;
|
||||
|
||||
/**
|
||||
* @param int $iLanguage
|
||||
*/
|
||||
public function downloadPdf($iLanguage = 0);
|
||||
public function getHTMLContent(): string;
|
||||
|
||||
/**
|
||||
* @param int $iLanguage
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPdfContent($iLanguage = 0);
|
||||
public function downloadPdf(int $language = 0): void;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param int $iLanguage
|
||||
*/
|
||||
public function savePdfFile($path, $iLanguage = 0);
|
||||
public function getPdfContent(int $language = 0): ?string;
|
||||
|
||||
/**
|
||||
* @param $sFilename
|
||||
* @param int $iSelLang
|
||||
* @param string $target
|
||||
*
|
||||
* @return mixed
|
||||
* @throws noBaseObjectSetException
|
||||
*/
|
||||
public function genPdf($sFilename, $iSelLang = 0, $target = 'I');
|
||||
public function savePdfFile(string $path, int $language = 0): void;
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*/
|
||||
public function setFilename($filename);
|
||||
public function genPdf(string $filename, int $language = 0, string $target = 'I'): ?string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename();
|
||||
public function setFilename(string $filename): void;
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function addFilenameExtension($filename);
|
||||
public function getFilename(): string;
|
||||
|
||||
public function addFilenameExtension(string $filename): string;
|
||||
|
||||
public function getTypeForFilename(): string;
|
||||
}
|
@ -1,31 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Interfaces;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
interface pdfdocumentsOrderInterface extends pdfdocumentsGenericInterface
|
||||
{
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setOrder(Order $order);
|
||||
public function setOrder(Order $order): void;
|
||||
|
||||
/**
|
||||
* @return Order
|
||||
*/
|
||||
public function getOrder();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTypeForFilename();
|
||||
public function getOrder(): Order;
|
||||
}
|
@ -1,18 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Interfaces;
|
||||
|
||||
interface pdfdocumentsOrderinvoiceInterface extends pdfdocumentsOrderInterface
|
||||
{
|
||||
public function setInvoiceNumber();
|
||||
public function setInvoiceNumber(): void;
|
||||
|
||||
public function setInvoiceDate();
|
||||
public function setInvoiceDate(): void;
|
||||
}
|
@ -1,13 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
@ -16,53 +21,54 @@ use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
|
||||
abstract class registryAbstract implements registryGenericInterface
|
||||
{
|
||||
protected $_aRegistry = array();
|
||||
protected array $registry = [];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getRequiredGeneratorInterfaceClassName()
|
||||
public function getRequiredGeneratorInterfaceClassName(): string
|
||||
{
|
||||
return pdfdocumentsGenericInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
*/
|
||||
public function addGenerator($className)
|
||||
public function addGenerator(string $className): void
|
||||
{
|
||||
if (false == $this->hasGenerator($className)) {
|
||||
if (!$this->hasGenerator($className)) {
|
||||
/** @var pdfdocumentsGenericInterface $generator */
|
||||
$generator = oxNew( $className );
|
||||
|
||||
$this->addItem( $className, $generator );
|
||||
$generator = oxNew($className);
|
||||
$this->addItem($generator);
|
||||
} else {
|
||||
throw oxNew(StandardException::class, 'generator still exists in registry');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param pdfdocumentsGenericInterface $item
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
*/
|
||||
protected function addItem($className, pdfdocumentsGenericInterface $item)
|
||||
protected function addItem(pdfdocumentsGenericInterface $item): void
|
||||
{
|
||||
$requiredInterface = $this->getRequiredGeneratorInterfaceClassName();
|
||||
|
||||
if (false == $item instanceof $requiredInterface) {
|
||||
throw oxNew(wrongPdfGeneratorInterface::class, $requiredInterface);
|
||||
if (!$item instanceof $requiredInterface) {
|
||||
/** @var wrongPdfGeneratorInterface $exception */
|
||||
$exception = oxNew(wrongPdfGeneratorInterface::class, $requiredInterface);
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$this->_aRegistry[$className] = $item;
|
||||
$this->registry[$item::class] = $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param string $className * generator fully qualified class name
|
||||
*/
|
||||
public function removeGenerator($className)
|
||||
public function removeGenerator(string $className): void
|
||||
{
|
||||
if ($this->hasGenerator($className)) {
|
||||
unset( $this->_aRegistry[ $className ] );
|
||||
unset($this->registry[ $className ]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,21 +76,18 @@ abstract class registryAbstract implements registryGenericInterface
|
||||
* @param $className * generator fully qualified class name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasGenerator($className)
|
||||
public function hasGenerator(string $className): bool
|
||||
{
|
||||
return array_key_exists($className, $this->_aRegistry);
|
||||
return array_key_exists($className, $this->registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getList()
|
||||
public function getList(): array
|
||||
{
|
||||
return $this->_aRegistry;
|
||||
return $this->registry;
|
||||
}
|
||||
|
||||
public function clearList()
|
||||
public function clearList(): void
|
||||
{
|
||||
$this->_aRegistry = [];
|
||||
$this->registry = [];
|
||||
}
|
||||
}
|
@ -1,38 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface;
|
||||
|
||||
interface registryGenericInterface
|
||||
{
|
||||
public function getRequiredGeneratorInterfaceClassName();
|
||||
public function getRequiredGeneratorInterfaceClassName(): string;
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
*/
|
||||
public function removeGenerator($className);
|
||||
public function removeGenerator(string $className): void;
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
*/
|
||||
public function hasGenerator($className);
|
||||
public function hasGenerator(string $className): bool;
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
*/
|
||||
public function getGenerator($className);
|
||||
public function getGenerator(string $className): pdfdocumentsGenericInterface;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getList();
|
||||
public function getList(): array;
|
||||
|
||||
public function clearList();
|
||||
public function clearList(): void;
|
||||
}
|
@ -1,45 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
use registryTrait;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getRequiredGeneratorInterfaceClassName()
|
||||
public function getRequiredGeneratorInterfaceClassName(): string
|
||||
{
|
||||
return pdfdocumentsOrderInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param string $className * generator fully qualified class name
|
||||
* @return pdfdocumentsOrderInterface
|
||||
*/
|
||||
public function getGenerator($className)
|
||||
public function getGenerator(string $className): pdfdocumentsOrderInterface
|
||||
{
|
||||
return $this->_aRegistry[$className];
|
||||
return $this->registry[$className];
|
||||
}
|
||||
}
|
@ -1,19 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
interface registryOrdermanagerActionsInterface extends registryGenericInterface
|
||||
{
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param string $className * generator fully qualified class name
|
||||
*/
|
||||
public function addGenerator($className);
|
||||
public function addGenerator(string $className): void;
|
||||
}
|
@ -1,45 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
use registryTrait;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getRequiredGeneratorInterfaceClassName()
|
||||
public function getRequiredGeneratorInterfaceClassName(): string
|
||||
{
|
||||
return pdfdocumentsOrderInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param string $className * generator fully qualified class name
|
||||
* @return pdfdocumentsOrderInterface
|
||||
*/
|
||||
public function getGenerator($className)
|
||||
public function getGenerator(string $className): pdfdocumentsOrderInterface
|
||||
{
|
||||
return $this->_aRegistry[$className];
|
||||
return $this->registry[$className];
|
||||
}
|
||||
}
|
@ -1,19 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
interface registryOrderoverviewInterface extends registryGenericInterface
|
||||
{
|
||||
/**
|
||||
* @param $className * generator fully qualified class name
|
||||
* @param string $className * generator fully qualified class name
|
||||
*/
|
||||
public function addGenerator($className);
|
||||
public function addGenerator(string $className): void;
|
||||
}
|
41
Application/Model/Registries/registryTrait.php
Normal file
41
Application/Model/Registries/registryTrait.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace D3\PdfDocuments\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
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\Exceptions\wrongPdfGeneratorInterface;
|
||||
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;
|
||||
|
||||
trait registryTrait
|
||||
{
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID)) {
|
||||
$this->addGenerator(invoicePdf::class);
|
||||
}
|
||||
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID)) {
|
||||
$this->addGenerator(deliverynotePdf::class);
|
||||
}
|
||||
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID)) {
|
||||
$this->addGenerator(invoicewithoutlogoPdf::class);
|
||||
}
|
||||
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID)) {
|
||||
$this->addGenerator(deliverynotewithoutlogoPdf::class);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$sLangName = "Deutsch";
|
||||
$aLang = array(
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Vielen Dank für Ihren Einkauf!',
|
||||
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Ihr Team von %1$s',
|
||||
$aLang = include __DIR__."/pdfdocuments_translations.php";
|
||||
|
||||
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'So erreichen Sie uns:',
|
||||
'D3_PDFDOCUMENTS_TELEFON' => 'Telefon',
|
||||
'D3_PDFDOCUMENTS_FAX' => 'Fax',
|
||||
'D3_PDFDOCUMENTS_EMAIL' => 'e-Mail',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNT' => 'Bankverbindung',
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNTNR' => 'IBAN',
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE_HEADER' => 'BIC',
|
||||
|
||||
'D3_PDFDOCUMENTS_ORDERBILLNR' => 'Rechnungs-Nr.',
|
||||
'D3_PDFDOCUMENTS_CUSTOMERNR' => 'Kundennummer',
|
||||
'D3_PDFDOCUMENTS_DATE' => 'Datum',
|
||||
'D3_PDFDOCUMENTS_DATE_FORMAT' => '%d.%m.%Y',
|
||||
'D3_PDFDOCUMENTS_USTIDNR' => 'Ust.-ID-Nr.',
|
||||
|
||||
'D3_PDFDOCUMENTS_DELIVERYADDRESS' => 'Lieferadresse',
|
||||
|
||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo',
|
||||
'D3_PDFDOCUMENTS_ORDERNR' => 'Bestellnr.',
|
||||
'D3_PDFDOCUMENTS_ORDER_FROM_AT' => 'Ihre Bestellung vom %1$s bei "%2$s"',
|
||||
|
||||
'D3_PDFDOCUMENTS_AMOUNT' => 'Menge',
|
||||
'D3_PDFDOCUMENTS_DESCRIPTION' => 'Beschreibung',
|
||||
'D3_PDFDOCUMENTS_USTPERCENTAGE' => 'Ust. %',
|
||||
'D3_PDFDOCUMENTS_UNITPRICE' => 'Einzelpreis',
|
||||
'D3_PDFDOCUMENTS_TOTALPRICE' => 'Gesamtpreis',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTNR' => 'Art.-Nr.',
|
||||
|
||||
'D3_PDFDOCUMENTS_SUMBRUTTO' => 'Summe Artikel (brutto)',
|
||||
'D3_PDFDOCUMENTS_DISCOUNT' => 'Rabatt',
|
||||
'D3_PDFDOCUMENTS_SUMNETTO' => 'Summe Artikel (netto)',
|
||||
'D3_PDFDOCUMENTS_TAX' => 'zzgl. MwSt. %1$s %%',
|
||||
'D3_PDFDOCUMENTS_UNDEFINED_TAX' => 'zzgl. MwSt.',
|
||||
'D3_PDFDOCUMENTS_PROPORTIONAL_TAX' => 'zzgl. MwSt. (anteilig berechnet)',
|
||||
'D3_PDFDOCUMENTS_VOUCHERDISCOUNT' => 'Gutschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Versandkosten (netto)',
|
||||
'D3_PDFDOCUMENTS_DELIVERY' => 'Versandkosten',
|
||||
'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Aufschlag Zahlungsart (netto)',
|
||||
'D3_PDFDOCUMENTS_PAYMENT' => 'Aufschlag Zahlungsart',
|
||||
'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Geschenkverpackung (netto)',
|
||||
'D3_PDFDOCUMENTS_WRAPPING' => 'Geschenkverpackung',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Grußkarte (netto)',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD' => 'Grußkarte',
|
||||
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Gesamtsumme (brutto)',
|
||||
|
||||
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Ihre gewählte Zahlungsweise',
|
||||
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Zahlbar bis zum',
|
||||
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'Den Rechnungsbetrag haben wir dankend erhalten.',
|
||||
|
||||
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Geschäftsführer',
|
||||
'D3_PDFDOCUMENTS_COURT' => 'Amtsgericht',
|
||||
'D3_PDFDOCUMENTS_HRBNR' => 'HRB',
|
||||
'D3_PDFDOCUMENTS_USTID' => 'Ust.-ID',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT-Code',
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
84
Application/translations/de/pdfdocuments_translations.php
Normal file
84
Application/translations/de/pdfdocuments_translations.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$sLangName = "Deutsch";
|
||||
return [
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Vielen Dank für Ihren Einkauf!',
|
||||
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Ihr Team von %1$s.',
|
||||
|
||||
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'So erreichen Sie uns:',
|
||||
'D3_PDFDOCUMENTS_TELEFON' => 'Telefon',
|
||||
'D3_PDFDOCUMENTS_FAX' => 'Fax',
|
||||
'D3_PDFDOCUMENTS_EMAIL' => 'e-Mail',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNT' => 'Bankverbindung',
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNTNR' => 'IBAN',
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE_HEADER' => 'BIC',
|
||||
|
||||
'D3_PDFDOCUMENTS_ORDERBILLNR' => 'Rechnungs-Nr.',
|
||||
'D3_PDFDOCUMENTS_CUSTOMERNR' => 'Kundennummer',
|
||||
'D3_PDFDOCUMENTS_DATE' => 'Datum',
|
||||
'D3_PDFDOCUMENTS_DATE_FORMAT' => '%d.%m.%Y',
|
||||
'D3_PDFDOCUMENTS_USTIDNR' => 'Ust.-ID-Nr.',
|
||||
|
||||
'D3_PDFDOCUMENTS_DELIVERYADDRESS' => 'Lieferadresse',
|
||||
|
||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo',
|
||||
'D3_PDFDOCUMENTS_ORDERNR' => 'Bestellnr.',
|
||||
'D3_PDFDOCUMENTS_ORDER_FROM_AT' => 'Ihre Bestellung vom %1$s bei "%2$s"',
|
||||
|
||||
'D3_PDFDOCUMENTS_AMOUNT' => 'Menge',
|
||||
'D3_PDFDOCUMENTS_DESCRIPTION' => 'Beschreibung',
|
||||
'D3_PDFDOCUMENTS_USTPERCENTAGE' => 'Ust. %',
|
||||
'D3_PDFDOCUMENTS_UNITPRICE' => 'Einzelpreis',
|
||||
'D3_PDFDOCUMENTS_TOTALPRICE' => 'Gesamtpreis',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTNR' => 'Art.-Nr.',
|
||||
|
||||
'D3_PDFDOCUMENTS_SUMBRUTTO' => 'Summe Artikel (brutto)',
|
||||
'D3_PDFDOCUMENTS_DISCOUNT' => 'Rabatt',
|
||||
'D3_PDFDOCUMENTS_SUMNETTO' => 'Summe Artikel (netto)',
|
||||
'D3_PDFDOCUMENTS_TAX' => 'zzgl. MwSt. %1$s %%',
|
||||
'D3_PDFDOCUMENTS_UNDEFINED_TAX' => 'zzgl. MwSt.',
|
||||
'D3_PDFDOCUMENTS_PROPORTIONAL_TAX' => 'zzgl. MwSt. (anteilig berechnet)',
|
||||
'D3_PDFDOCUMENTS_VOUCHERDISCOUNT' => 'Gutschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Versandkosten (netto)',
|
||||
'D3_PDFDOCUMENTS_DELIVERY' => 'Versandkosten',
|
||||
'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Aufschlag Zahlungsart (netto)',
|
||||
'D3_PDFDOCUMENTS_PAYMENT' => 'Aufschlag Zahlungsart',
|
||||
'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Geschenkverpackung (netto)',
|
||||
'D3_PDFDOCUMENTS_WRAPPING' => 'Geschenkverpackung',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Grußkarte (netto)',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD' => 'Grußkarte',
|
||||
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Gesamtsumme (brutto)',
|
||||
|
||||
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Ihre gewählte Zahlungsweise',
|
||||
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Zahlbar bis zum %s.',
|
||||
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'Den Rechnungsbetrag haben wir dankend erhalten.',
|
||||
|
||||
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Geschäftsführer',
|
||||
'D3_PDFDOCUMENTS_COURT' => 'Amtsgericht',
|
||||
'D3_PDFDOCUMENTS_HRBNR' => 'HRB',
|
||||
'D3_PDFDOCUMENTS_USTID' => 'Ust.-ID',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT-Code',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTICLE_DATASHEET' => 'Artikel Datenblatt',
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
@ -1,76 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$sLangName = "English";
|
||||
$aLang = array(
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Many thanks for your purchase!',
|
||||
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Your team from %1$s',
|
||||
$aLang = include __DIR__."/pdfdocuments_translations.php";
|
||||
|
||||
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'You can contact us as follows',
|
||||
'D3_PDFDOCUMENTS_TELEFON' => 'Telephone',
|
||||
'D3_PDFDOCUMENTS_FAX' => 'Fax',
|
||||
'D3_PDFDOCUMENTS_EMAIL' => 'Email',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNT' => 'Bank Account',
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNTNR' => 'IBAN',
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE_HEADER' => 'BIC',
|
||||
|
||||
'D3_PDFDOCUMENTS_ORDERBILLNR' => 'Invoice No.',
|
||||
'D3_PDFDOCUMENTS_CUSTOMERNR' => 'Customer No.',
|
||||
'D3_PDFDOCUMENTS_DATE' => 'Date',
|
||||
'D3_PDFDOCUMENTS_DATE_FORMAT' => '%Y-%m-%d',
|
||||
'D3_PDFDOCUMENTS_USTIDNR' => 'VAT ID No.',
|
||||
|
||||
'D3_PDFDOCUMENTS_DELIVERYADDRESS' => 'Shipping Address',
|
||||
|
||||
'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_ORDERNR' => 'Order No.',
|
||||
'D3_PDFDOCUMENTS_ORDER_FROM_AT' => 'Your order from %1$s at "%2$s"',
|
||||
|
||||
'D3_PDFDOCUMENTS_AMOUNT' => 'Amount',
|
||||
'D3_PDFDOCUMENTS_DESCRIPTION' => 'Description',
|
||||
'D3_PDFDOCUMENTS_USTPERCENTAGE' => 'VAT %',
|
||||
'D3_PDFDOCUMENTS_UNITPRICE' => 'Unit Price',
|
||||
'D3_PDFDOCUMENTS_TOTALPRICE' => 'Total',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTNR' => 'Item No.',
|
||||
|
||||
'D3_PDFDOCUMENTS_SUMBRUTTO' => 'Total products (incl. tax)',
|
||||
'D3_PDFDOCUMENTS_DISCOUNT' => 'Discount',
|
||||
'D3_PDFDOCUMENTS_SUMNETTO' => 'Total products (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_TAX' => 'plus VAT %1$s %%',
|
||||
'D3_PDFDOCUMENTS_UNDEFINED_TAX' => 'plus VAT',
|
||||
'D3_PDFDOCUMENTS_PROPORTIONAL_TAX' => 'plus VAT (proportionally calculated)',
|
||||
'D3_PDFDOCUMENTS_VOUCHERDISCOUNT' => 'Coupon',
|
||||
'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Shipping costs (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_DELIVERY' => 'Shipping costs',
|
||||
'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Additional Charge Payment Method (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_PAYMENT' => 'Additional Charge Payment Method',
|
||||
'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Gift Wrapping (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_WRAPPING' => 'Gift Wrapping',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Greeting Card (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD' => 'Greeting Card',
|
||||
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Total sum (gross)',
|
||||
|
||||
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Your chosen payment method',
|
||||
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Billing till',
|
||||
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'We have received the invoice amount with thanks.',
|
||||
|
||||
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Managing director',
|
||||
'D3_PDFDOCUMENTS_COURT' => 'Local court',
|
||||
'D3_PDFDOCUMENTS_HRBNR' => 'HRB',
|
||||
'D3_PDFDOCUMENTS_USTID' => 'VAT ID',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT Code',
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
83
Application/translations/en/pdfdocuments_translations.php
Normal file
83
Application/translations/en/pdfdocuments_translations.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
return [
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'D3_PDFDOCUMENTS_THANKYOU_1' => 'Many thanks for your purchase!',
|
||||
'D3_PDFDOCUMENTS_THANKYOU_2' => 'Your team from %1$s.',
|
||||
|
||||
'D3_PDFDOCUMENTS_GET_IN_CONTACT' => 'You can contact us as follows',
|
||||
'D3_PDFDOCUMENTS_TELEFON' => 'Telephone',
|
||||
'D3_PDFDOCUMENTS_FAX' => 'Fax',
|
||||
'D3_PDFDOCUMENTS_EMAIL' => 'Email',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNT' => 'Bank Account',
|
||||
'D3_PDFDOCUMENTS_BANK_ACCOUNTNR' => 'IBAN',
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE_HEADER' => 'BIC',
|
||||
|
||||
'D3_PDFDOCUMENTS_ORDERBILLNR' => 'Invoice No.',
|
||||
'D3_PDFDOCUMENTS_CUSTOMERNR' => 'Customer No.',
|
||||
'D3_PDFDOCUMENTS_DATE' => 'Date',
|
||||
'D3_PDFDOCUMENTS_DATE_FORMAT' => '%Y-%m-%d',
|
||||
'D3_PDFDOCUMENTS_USTIDNR' => 'VAT ID No.',
|
||||
|
||||
'D3_PDFDOCUMENTS_DELIVERYADDRESS' => 'Shipping Address',
|
||||
|
||||
'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_ORDERNR' => 'Order No.',
|
||||
'D3_PDFDOCUMENTS_ORDER_FROM_AT' => 'Your order from %1$s at "%2$s"',
|
||||
|
||||
'D3_PDFDOCUMENTS_AMOUNT' => 'Amount',
|
||||
'D3_PDFDOCUMENTS_DESCRIPTION' => 'Description',
|
||||
'D3_PDFDOCUMENTS_USTPERCENTAGE' => 'VAT %',
|
||||
'D3_PDFDOCUMENTS_UNITPRICE' => 'Unit Price',
|
||||
'D3_PDFDOCUMENTS_TOTALPRICE' => 'Total',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTNR' => 'Item No.',
|
||||
|
||||
'D3_PDFDOCUMENTS_SUMBRUTTO' => 'Total products (incl. tax)',
|
||||
'D3_PDFDOCUMENTS_DISCOUNT' => 'Discount',
|
||||
'D3_PDFDOCUMENTS_SUMNETTO' => 'Total products (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_TAX' => 'plus VAT %1$s %%',
|
||||
'D3_PDFDOCUMENTS_UNDEFINED_TAX' => 'plus VAT',
|
||||
'D3_PDFDOCUMENTS_PROPORTIONAL_TAX' => 'plus VAT (proportionally calculated)',
|
||||
'D3_PDFDOCUMENTS_VOUCHERDISCOUNT' => 'Coupon',
|
||||
'D3_PDFDOCUMENTS_DELIVERY_NET' => 'Shipping costs (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_DELIVERY' => 'Shipping costs',
|
||||
'D3_PDFDOCUMENTS_PAYMENT_NET' => 'Additional Charge Payment Method (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_PAYMENT' => 'Additional Charge Payment Method',
|
||||
'D3_PDFDOCUMENTS_WRAPPING_NET' => 'Gift Wrapping (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_WRAPPING' => 'Gift Wrapping',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD_NET' => 'Greeting Card (excl. tax)',
|
||||
'D3_PDFDOCUMENTS_GIFTCARD' => 'Greeting Card',
|
||||
'D3_PDFDOCUMENTS_TOTALSUMBRUT' => 'Total sum (gross)',
|
||||
|
||||
'D3_PDFDOCUMENTS_USED_PAYMENTMETHOD' => 'Your chosen payment method',
|
||||
'D3_PDFDOCUMENTS_PAYABLEUNTIL' => 'Billing till %s.',
|
||||
'D3_PDFDOCUMENTS_RECEIVED_PAYMENT' => 'We have received the invoice amount with thanks.',
|
||||
|
||||
'D3_PDFDOCUMENTS_MANAGINGDIRECTOR' => 'Managing director',
|
||||
'D3_PDFDOCUMENTS_COURT' => 'Local court',
|
||||
'D3_PDFDOCUMENTS_HRBNR' => 'HRB',
|
||||
'D3_PDFDOCUMENTS_USTID' => 'VAT ID',
|
||||
|
||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT Code',
|
||||
|
||||
'D3_PDFDOCUMENTS_ARTICLE_DATASHEET' => 'Article data sheet',
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
@ -1,3 +0,0 @@
|
||||
[{$smarty.block.parent}]
|
||||
|
||||
[{include file="d3orderoverview_pdfform.tpl"}]
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
$sLangName = "Deutsch";
|
||||
$aLang = array(
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
|
||||
|
||||
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo',
|
||||
|
||||
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument',
|
||||
'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache',
|
||||
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen',
|
||||
);
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
$sLangName = "English";
|
||||
$aLang = array(
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
|
||||
|
||||
'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_PDF_TYPE' => 'Document',
|
||||
'D3_PDFDOCUMENTS_LANGUAGE' => 'Language',
|
||||
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document',
|
||||
);
|
18
Application/views/admin_smarty/de/pdfdocuments_lang.php
Normal file
18
Application/views/admin_smarty/de/pdfdocuments_lang.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$aLang = include __DIR__ . "/../../de/translations.php";
|
||||
// @codeCoverageIgnoreEnd
|
18
Application/views/admin_smarty/en/pdfdocuments_lang.php
Normal file
18
Application/views/admin_smarty/en/pdfdocuments_lang.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$aLang = include __DIR__ . "/../../en/translations.php";
|
||||
// @codeCoverageIgnoreEnd
|
18
Application/views/admin_twig/de/pdfdocuments_lang.php
Normal file
18
Application/views/admin_twig/de/pdfdocuments_lang.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$aLang = include __DIR__ . "/../../de/translations.php";
|
||||
// @codeCoverageIgnoreEnd
|
18
Application/views/admin_twig/en/pdfdocuments_lang.php
Normal file
18
Application/views/admin_twig/en/pdfdocuments_lang.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$aLang = include __DIR__ . "/../../en/translations.php";
|
||||
// @codeCoverageIgnoreEnd
|
59
Application/views/de/translations.php
Normal file
59
Application/views/de/translations.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$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;
|
||||
|
||||
return [
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'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 kann das Dokument im '.
|
||||
'SGML-Format ausgegeben werden. 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,
|
||||
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)',
|
||||
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp,
|
||||
|
||||
'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Rechnung',
|
||||
'SHOP_MODULE_invoicePaymentTerm' => 'Zahlungsziel (in Tagen)',
|
||||
|
||||
'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_'. 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',
|
||||
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein',
|
||||
'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo',
|
||||
|
||||
'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument',
|
||||
'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache',
|
||||
'D3_PDFDOCUMENTS_SGML_GENERATE' => 'Markup erstellen',
|
||||
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen',
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
59
Application/views/en/translations.php
Normal file
59
Application/views/en/translations.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
$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;
|
||||
|
||||
return [
|
||||
'charset' => 'utf-8',
|
||||
|
||||
'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 can exported '.
|
||||
'in SGML format. This makes it much easier to trace content errors.',
|
||||
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth of the shop - user name (optional)',
|
||||
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp,
|
||||
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth of the shop - password (optional)',
|
||||
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp,
|
||||
|
||||
'SHOP_MODULE_GROUP_'. Constants::OXID_MODULE_ID.'invoice' => 'Invoice',
|
||||
'SHOP_MODULE_invoicePaymentTerm' => 'Payment term (in days)',
|
||||
|
||||
'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_'. 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',
|
||||
'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice 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 markup',
|
||||
'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document',
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
@ -1,47 +0,0 @@
|
||||
[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="showLogo" value=$showLogo|default:true}]
|
||||
|
||||
[{capture append="pdfBlock_style"}]
|
||||
[{block name="pdfStyles"}]
|
||||
[{include file="d3pdfstyles.css"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_header"}]
|
||||
[{block name="pdfHeader"}]
|
||||
[{include file="d3pdfheader.tpl" showLogo=$showLogo}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_content"}]
|
||||
[{* include file="d3pdfrulers.tpl" pagePadding=$pagePadding *}]
|
||||
[{include file="d3pdffoldmarks.tpl" pagePadding=$pagePadding}]
|
||||
|
||||
[{block name="pdfAddressArea"}]
|
||||
[{include file="d3pdfaddressarea.tpl" addressfile="d3delnote_pdf_recipient.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfInformations"}]
|
||||
[{include file="d3pdfinformations.tpl" documentinformationfile="d3delnote_pdf_informations.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfSalutation"}]
|
||||
[{include file="d3delnote_pdf_salutation.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfArticleList"}]
|
||||
[{include file="d3pdfarticlelist.tpl" showPrices=false}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfConclusion"}]
|
||||
[{include file="d3delnote_pdf_conclusion.tpl"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_footer"}]
|
||||
[{block name="pdfFooter"}]
|
||||
[{include file="d3pdffooter.tpl" pagePadding=$pagePadding}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{include file="d3pdfbase.tpl" pagePadding=$pagePadding}]
|
@ -1 +0,0 @@
|
||||
[{include file="d3deliverynote_pdf.tpl" showLogo=false}]
|
@ -1,13 +0,0 @@
|
||||
[{assign var="backaddressfile" value=$backaddressfile|default:"d3pdfreturnaddress.tpl"}]
|
||||
[{assign var="addressfile" value=$addressfile|default:"d3pdfrecipientaddress.tpl"}]
|
||||
|
||||
<div class="addressarea">
|
||||
<div class="returnAddress">
|
||||
<div>
|
||||
[{include file=$backaddressfile}]
|
||||
</div>
|
||||
</div>
|
||||
<div class="recipientAddress">
|
||||
[{include file=$addressfile}]
|
||||
</div>
|
||||
</div>
|
@ -1,29 +0,0 @@
|
||||
[{assign var="pageset" value=$pageset|default:"new"}]
|
||||
[{assign var="orientation" value=$orientation|default:"P"}]
|
||||
[{assign var="format" value=$format|default:"A4"}]
|
||||
[{assign var="defaultPagePadding" value=","|explode:"45,15,25,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="pagePadding" value=$pagePadding|default:$defaultPagePadding}]
|
||||
|
||||
<style type="text/css">
|
||||
[{foreach from=$pdfBlock_style item="_block"}]
|
||||
[{$_block}]
|
||||
[{/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_header>
|
||||
[{foreach from=$pdfBlock_header item="_block"}]
|
||||
[{$_block}]
|
||||
[{/foreach}]
|
||||
</page_header>
|
||||
|
||||
<page_footer>
|
||||
[{foreach from=$pdfBlock_footer item="_block"}]
|
||||
[{$_block}]
|
||||
[{/foreach}]
|
||||
</page_footer>
|
||||
|
||||
[{foreach from=$pdfBlock_content item="_block"}]
|
||||
[{$_block}]
|
||||
[{/foreach}]
|
||||
</page>
|
@ -1,38 +0,0 @@
|
||||
[{assign var="defaultPagePadding" value=","|explode:"45,15,25,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="pagePadding" value=$pagePadding|default:$defaultPagePadding}]
|
||||
|
||||
[{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>
|
||||
</div>
|
||||
|
||||
[{/block}]
|
@ -1,13 +0,0 @@
|
||||
[{assign var="showLogo" value=$showLogo|default:true}]
|
||||
|
||||
[{block name="pdfHeader"}]
|
||||
<div class="header">
|
||||
[{if $showLogo}]
|
||||
[{* 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')}]">
|
||||
[{$viewConfig->setAdminMode($isAdmin)}]
|
||||
[{/if}]
|
||||
</div>
|
||||
[{/block}]
|
@ -1,51 +0,0 @@
|
||||
[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="showLogo" value=$showLogo|default:true}]
|
||||
|
||||
[{capture append="pdfBlock_style"}]
|
||||
[{block name="pdfStyles"}]
|
||||
[{include file="d3pdfstyles.css"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_header"}]
|
||||
[{block name="pdfHeader"}]
|
||||
[{include file="d3pdfheader.tpl" showLogo=$showLogo}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_content"}]
|
||||
[{* include file="d3pdfrulers.tpl" pagePadding=$pagePadding *}]
|
||||
[{include file="d3pdffoldmarks.tpl" pagePadding=$pagePadding}]
|
||||
|
||||
[{block name="pdfAddressArea"}]
|
||||
[{include file="d3pdfaddressarea.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfInformations"}]
|
||||
[{include file="d3pdfinformations.tpl" documentinformationfile="d3invoice_pdf_informations.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfDeliveryAddress"}]
|
||||
[{include file="d3pdfdeladdress.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfSalutation"}]
|
||||
[{include file="d3invoice_pdf_salutation.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfArticleList"}]
|
||||
[{include file="d3pdfarticlelist.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfConclusion"}]
|
||||
[{include file="d3invoice_pdf_conclusion.tpl"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture append="pdfBlock_footer"}]
|
||||
[{block name="pdfFooter"}]
|
||||
[{include file="d3pdffooter.tpl" pagePadding=$pagePadding}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{include file="d3pdfbase.tpl" pagePadding=$pagePadding}]
|
@ -1 +0,0 @@
|
||||
[{include file="d3invoice_pdf.tpl" showLogo=false}]
|
25
IntelliSenseHelper.php
Normal file
25
IntelliSenseHelper.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Modules\Application\Controller {
|
||||
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
||||
use OxidEsales\Eshop\Application\Controller\ArticleDetailsController;
|
||||
|
||||
class d3_overview_controller_pdfdocuments_parent extends OrderOverview
|
||||
{
|
||||
}
|
||||
|
||||
class ArticleDetailsController_pdfdocuments_parent extends ArticleDetailsController
|
||||
{}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Modules\Application\Controller;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\articleDataSheet;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
|
||||
class ArticleDetailsController_pdfdocuments extends ArticleDetailsController_pdfdocuments_parent
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
*/
|
||||
public function generateDataSheet(): void
|
||||
{
|
||||
$document = oxNew(articleDataSheet::class);
|
||||
$document->setArticle($this->getProduct());
|
||||
$document->downloadPdf();
|
||||
}
|
||||
}
|
@ -1,77 +1,193 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Modules\Application\Controller;
|
||||
|
||||
use Assert\Assert;
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
||||
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\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Modules\Application\Model\d3_Order_PdfDocuments;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use Doctrine\DBAL\Exception as DBALException;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||
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
|
||||
);
|
||||
}
|
||||
use OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator;
|
||||
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;
|
||||
|
||||
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
* @throws DatabaseConnectionException
|
||||
*/
|
||||
public function d3CanExport()
|
||||
{
|
||||
// We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
|
||||
$masterDb = DatabaseProvider::getMaster();
|
||||
$sOrderId = $this->getEditObjectId();
|
||||
protected ?string $generatorError = null;
|
||||
protected bool $doReload = false;
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->addTplParam('d3PdfDocumentGeneratorList', $this->d3getGeneratorList());
|
||||
|
||||
if ($this->doReload) {
|
||||
$formReload = <<<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("id", "generatorError");
|
||||
input.setAttribute("value", encodeURIComponent('$this->generatorError'));
|
||||
form.appendChild(input);
|
||||
form.submit();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
Registry::getUtils()->showMessageAndExit($formReload);
|
||||
} elseif ($generatorError = Registry::getRequest()->getRequestParameter('generatorError')) {
|
||||
Registry::getUtilsView()->addErrorToDisplay(urldecode($generatorError));
|
||||
$register = oxNew(JavaScriptRegistrator::class);
|
||||
$script = <<<JS
|
||||
top.basefrm.edit.document.getElementById('generatorError').remove();
|
||||
JS;
|
||||
$register->addSnippet($script);
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function d3PdfDocsIsDevMode(): bool
|
||||
{
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DBALDriverException
|
||||
*/
|
||||
public function d3CanExport(): bool
|
||||
{
|
||||
try {
|
||||
$sOrderId = $this->getEditObjectId();
|
||||
Assert::that($sOrderId)->string()->notSame('-1');
|
||||
$viewNameGenerator = Registry::get(TableViewNameGenerator::class);
|
||||
$sTable = $viewNameGenerator->getViewName("oxorderarticles");
|
||||
|
||||
$sQ = "select count(oxid) from {$sTable} where oxorderid = " . $masterDb->quote($sOrderId) . " and oxstorno = 0";
|
||||
return (bool) $masterDb->getOne($sQ);
|
||||
/** @var QueryBuilder $queryBuilder */
|
||||
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
||||
$queryBuilder
|
||||
->select('oxid')
|
||||
->from($sTable)
|
||||
->where(
|
||||
$queryBuilder->expr()->and(
|
||||
$queryBuilder->expr()->eq('oxorderid', $queryBuilder->createNamedParameter($sOrderId)),
|
||||
$queryBuilder->expr()->eq('oxstorno', $queryBuilder->createNamedParameter(0, ParameterType::INTEGER))
|
||||
)
|
||||
);
|
||||
|
||||
return (bool) $queryBuilder->execute()->fetchOne();
|
||||
} catch (NotFoundExceptionInterface|ContainerExceptionInterface|DBALException|InvalidArgumentException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws noBaseObjectSetException
|
||||
* @throws noPdfHandlerFoundException
|
||||
* @throws pdfGeneratorExceptionAbstract
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function d3CreatePDF()
|
||||
public function d3CreatePDF(): void
|
||||
{
|
||||
try {
|
||||
$oldErrorHandlder = set_error_handler(
|
||||
[$this, 'exception_error_handler'],
|
||||
E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
|
||||
);
|
||||
$soxId = $this->getEditObjectId();
|
||||
if ($soxId != "-1" && isset($soxId)) {
|
||||
/** @var d3_Order_PdfDocuments $oOrder */
|
||||
$oOrder = oxNew(Order::class);
|
||||
if ($oOrder->load($soxId)) {
|
||||
$generator = oxNew( orderOverviewPdfGenerator::class );
|
||||
$generator->generatePdf($oOrder, Registry::getRequest()->getRequestEscapedParameter("pdflanguage"));
|
||||
}
|
||||
$language = Registry::getRequest()->getRequestEscapedParameter("pdflanguage");
|
||||
Assert::that($soxId)->string()->notSame('-1');
|
||||
Assert::that($language)->integerish();
|
||||
$oOrder = $this->d3PdfGetOrder();
|
||||
Assert::that($oOrder->load($soxId))->true();
|
||||
$generator = $this->d3PdfGetGeneratorController();
|
||||
$generator->generatePdf($oOrder, $language);
|
||||
} catch (Exception $exception) {
|
||||
$this->doReload = true;
|
||||
Registry::getLogger()->error($exception->getMessage(), [ 'exception' => $exception ]);
|
||||
$this->generatorError = 'PDF documents: ' . $exception->getMessage();
|
||||
} finally {
|
||||
set_error_handler($oldErrorHandlder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return registryOrderoverview
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function d3getGeneratorList()
|
||||
public function d3PdfGetOrder(): Order
|
||||
{
|
||||
return oxNew(registryOrderoverview::class);
|
||||
return oxNew(Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function d3PdfGetGeneratorController(): orderOverviewPdfGenerator
|
||||
{
|
||||
return oxNew(orderOverviewPdfGenerator::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function d3getGeneratorList(): ?registryOrderoverview
|
||||
{
|
||||
try {
|
||||
return ContainerFactory::getInstance()->getContainer()->get( registryOrderoverviewInterface::class );
|
||||
} catch (Exception $exception) {
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception->getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function exception_error_handler(int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): void
|
||||
{
|
||||
if (!(error_reporting() & $errno)) {
|
||||
// This error code is not included in error_reporting
|
||||
return;
|
||||
}
|
||||
|
||||
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
}
|
||||
}
|
27
README.en.md
27
README.en.md
@ -1,31 +1,36 @@
|
||||
> [german version](README.md)
|
||||

|
||||
[](https://packagist.org/packages/d3/pdfdocuments)
|
||||

|
||||
|
||||
[](README.md)
|
||||
[](README.en.md)
|
||||
|
||||
# PDF Documents
|
||||
|
||||

|
||||
|
||||
PDF document generator for OXID eShop
|
||||
|
||||
Create a wide variety of static or dynamic PDF documents at the touch of a button. The document content is created from Smarty templates.
|
||||
Create a wide variety of static or dynamic PDF documents at the touch of a button. The document content is created from templates (Smarty or Twig).
|
||||
|
||||
At the orders of your OXID shop you have the option of creating an invoice and delivery note.
|
||||
|
||||
The module can be easily extended to adapt existing documents or add new ones. Even completely different document types (e.g. article data sheets) are possible.
|
||||
The module can be easily extended to adapt existing documents or add new ones. Even completely different document types (e.g. article data sheets or pick lists) are possible.
|
||||
|
||||
## System requirements:
|
||||
|
||||
- installed OXID eShop version from 6.1
|
||||
- PHP version for which installation packages are available (PHP 7 + 8)
|
||||
- installed OXID eShop version 7.x
|
||||
- PHP version for which installation packages are available (PHP 8)
|
||||
- Installation via Composer
|
||||
|
||||
## Compatibility:
|
||||
|
||||
The module contains the same functionality as the 'OXID Invoice PDF' module. Basically, both modules can be installed in parallel in the shop, if required.
|
||||
|
||||
If the `OXID Invoice PDF` module is to be completely replaced by the `D3 PDF Documents` module (e.g. because third modules also use its function), we provide [a customization](https://packagist.org/packages/d3/pdfdocuments_compat) which is installed additionally.
|
||||
The module contains the same functionality as the former 'OXID Invoice PDF' module.
|
||||
|
||||
## Installation:
|
||||
|
||||
```bash
|
||||
composer require d3/pdfdocuments:^1.0 --update-no-dev
|
||||
composer require d3/pdfdocuments:^2.0 --update-no-dev
|
||||
```
|
||||
|
||||
Detailed installation instructions can be found [online](https://docs.oxidmodule.com/PDF-Dokumente/) and in the docs directory of this package. The module manual is also available there.
|
||||
@ -38,7 +43,9 @@ Detailed installation instructions can be found [online](https://docs.oxidmodule
|
||||
|
||||
## Credits:
|
||||
|
||||
- PDF logo made by Dimitriy Morilubov from www.flaticon.com
|
||||
- PDF icon made by Dimitriy Morilubov by www.flaticon.com
|
||||
- example company logo by https://www.logologo.com/
|
||||
- background image of the article data sheet [designed by Harryarts / Freepik](http://www.freepik.com)
|
||||
|
||||
## License
|
||||
|
||||
|
29
README.md
29
README.md
@ -1,31 +1,36 @@
|
||||
> [english version](README.en.md)
|
||||

|
||||
[](https://packagist.org/packages/d3/pdfdocuments)
|
||||

|
||||
|
||||
[](README.md)
|
||||
[](README.en.md)
|
||||
|
||||
# PDF-Dokumente
|
||||
|
||||
PDF-Dokumentgenerator für OXID eShop
|
||||

|
||||
|
||||
Erstellen Sie unterschiedlichste statische oder dynamische PDF-Dokument auf Kopfdruck. Der Dokumentinhalt wird aus Smartytemplates erstellt.
|
||||
**PDF-Dokumentgenerator für OXID eShop**
|
||||
|
||||
Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Knopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt.
|
||||
|
||||
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 oder Picklisten) sind einfach möglich.
|
||||
|
||||
## Systemanforderungen:
|
||||
|
||||
- installierter OXID eShop in Version ab 6.1
|
||||
- PHP-Version, für die Installationspakete verfügbar sind (PHP 7 + 8)
|
||||
- installierter OXID eShop in Version 7.x
|
||||
- PHP-Version, für die Installationspakete verfügbar sind (PHP 8)
|
||||
- Installation via Composer
|
||||
|
||||
## Kompatibilität:
|
||||
|
||||
Das Modul enthält die selbe Funktionalität wie das `OXID Invoice-PDF`-Modul. Grundsätzlich können beide Module parallel im Shop installiert werden, wenn dies erforderlich ist.
|
||||
|
||||
Soll das `OXID Invoice-PDF`-Modul komplett vom `PDF Dokumente` Modul ersetzt werden (weil z.B. dritte Module ebenfalls dessen Funktion verwenden), stellen wir [eine Anpassung](https://packagist.org/packages/d3/pdfdocuments_compat) zur Verfügung, die zusätzlich installiert wird.
|
||||
Das Modul enthält die selbe Funktionalität wie das ehemalige `OXID Invoice-PDF`-Modul.
|
||||
|
||||
## Installation:
|
||||
|
||||
```bash
|
||||
composer require d3/pdfdocuments:^1.0 --update-no-dev
|
||||
composer require d3/pdfdocuments:^2.0 --update-no-dev
|
||||
```
|
||||
|
||||
Eine detaillierte Installationsanleitung finden Sie [online](https://docs.oxidmodule.com/PDF-Dokumente/) und im docs-Verzeichnis dieses Pakets. Dort ist ebenfalls das Modulhandbuch hinterlegt.
|
||||
@ -38,7 +43,9 @@ Eine detaillierte Installationsanleitung finden Sie [online](https://docs.oxidmo
|
||||
|
||||
## Danksagung:
|
||||
|
||||
- PDF-Logo erstellt von Dimitriy Morilubov von www.flaticon.com
|
||||
- PDF-Icon erstellt von Dimitriy Morilubov von www.flaticon.com
|
||||
- Beispielfirmenlogo von https://www.logologo.com/
|
||||
- Hintergrundgrafik des Artikeldatenblatts [designed by Harryarts / Freepik](http://www.freepik.com)
|
||||
|
||||
## Lizenz
|
||||
|
||||
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Controller;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
use Twig\Error\Error;
|
||||
|
||||
class orderOverviewPdfGeneratorTest extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator::generatePdf
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGeneratePdf(): void
|
||||
{
|
||||
$document = $this->getMockBuilder(invoicePdf::class)
|
||||
->onlyMethods(['downloadPdf'])
|
||||
->getMock();
|
||||
$document->expects($this->once())->method('downloadPdf');
|
||||
|
||||
$sut = $this->getMockBuilder(orderOverviewPdfGenerator::class)
|
||||
->onlyMethods(['getPdfClass'])
|
||||
->getMock();
|
||||
$sut->expects($this->once())->method('getPdfClass')->willReturn($document);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'generatePdf',
|
||||
[oxNew(Order::class)]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator::getPdfClass
|
||||
* @throws ReflectionException
|
||||
* @dataProvider getPdfClassDataProvider
|
||||
*/
|
||||
public function testGetPdfClass(array $generatorList, string $request, bool $expectException): void
|
||||
{
|
||||
$_GET['pdftype'] = $request;
|
||||
|
||||
$orderOverviewRegistry = $this->getMockBuilder(registryOrderoverview::class)
|
||||
->onlyMethods(['getList'])
|
||||
->getMock();
|
||||
$orderOverviewRegistry->method('getList')->willReturn($generatorList);
|
||||
|
||||
$this->addServiceMocks([
|
||||
registryOrderoverviewInterface::class => $orderOverviewRegistry,
|
||||
]);
|
||||
|
||||
$sut = oxNew(orderOverviewPdfGenerator::class);
|
||||
|
||||
if ($expectException) {
|
||||
$this->expectException(noPdfHandlerFoundException::class);
|
||||
}
|
||||
|
||||
$this->assertInstanceOf(
|
||||
pdfdocumentsOrderInterface::class,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPdfClass',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPdfClassDataProvider(): Generator
|
||||
{
|
||||
yield 'no generator set' => [[], 'foo', true];
|
||||
yield 'unknown generator set' => [[new invoicePdf()], 'foo', true];
|
||||
yield 'valid generator set' => [[new invoicePdf()], 'invoice', false];
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric as pdfdocumentsGenericSut;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Generator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
|
||||
abstract class pdfDocumentsGeneric extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
protected string $sutClassName;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::setDevelopmentMode
|
||||
*/
|
||||
public function testSetDevelopmentMode(): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertFalse($this->getValue($sut, 'devMode'));
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'setDevelopmentMode',
|
||||
[true]
|
||||
);
|
||||
|
||||
$this->assertTrue($this->getValue($sut, 'devMode'));
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'setDevelopmentMode',
|
||||
[false]
|
||||
);
|
||||
|
||||
$this->assertFalse($this->getValue($sut, 'devMode'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::genPdf
|
||||
*/
|
||||
public function testGenPdf(): void
|
||||
{
|
||||
$html = 'htmlFixture';
|
||||
|
||||
$html2Pdf = $this->getMockBuilder(Html2Pdf::class)
|
||||
->onlyMethods(['writeHTML'])
|
||||
->getMock();
|
||||
$html2Pdf->method('writeHTML')->with($this->identicalTo($html));
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getHtml2Pdf', 'getHTMLContent', 'output'])
|
||||
->getMock();
|
||||
$sut->method('getHtml2Pdf')->willReturn($html2Pdf);
|
||||
$sut->method('getHTMLContent')->willReturn($html);
|
||||
$sut->method('output')->with(
|
||||
$this->identicalTo($html2Pdf),
|
||||
$this->identicalTo('fileNameFixture'),
|
||||
$this->identicalTo(pdfdocumentsGenericSut::PDF_DESTINATION_FILEANDDOWNLOAD),
|
||||
$this->identicalTo($html),
|
||||
)->willReturn('expectedReturn');
|
||||
|
||||
$this->assertSame(
|
||||
'expectedReturn',
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'genPdf',
|
||||
[ 'fileNameFixture', 10, pdfdocumentsGenericSut::PDF_DESTINATION_FILEANDDOWNLOAD]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::getHtml2Pdf
|
||||
*/
|
||||
public function testGetHtml2Pdf(): void
|
||||
{
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getPdfProperties'])
|
||||
->getMock();
|
||||
$sut->expects($this->once())->method('getPdfProperties');
|
||||
|
||||
$this->assertInstanceOf(
|
||||
Html2Pdf::class,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getHtml2Pdf'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::getTemplateEngineVars
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetTemplateEngineVars(): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$vars = $this->callMethod(
|
||||
$sut,
|
||||
'getTemplateEngineVars',
|
||||
[0]
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('config', $vars);
|
||||
$this->assertArrayHasKey('oViewConf', $vars);
|
||||
$this->assertArrayHasKey('shop', $vars);
|
||||
$this->assertArrayHasKey('lang', $vars);
|
||||
$this->assertArrayHasKey('document', $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\deliverynotePdf::sanitizeFileName
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\deliverynotePdf::beautifyFilename
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @dataProvider sanitizeFileNameDataProvider
|
||||
*/
|
||||
public function testSanitizeFileName($filename, $expected): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'sanitizeFileName',
|
||||
[$filename]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator
|
||||
*/
|
||||
public function sanitizeFileNameDataProvider(): Generator
|
||||
{
|
||||
yield 'file system reserved' => ["ab<>cd\\ef*ghi.ext", 'ab-cd-ef-ghi.ext'];
|
||||
yield 'control characters' => [".abc\x00def\x01ghi.ext", 'abc-def-ghi.ext'];
|
||||
yield 'non-printing characters' => ["..abc\x7Fdef\xA0ghi.ext", 'abc-def-ghi.ext'];
|
||||
yield 'URI reserved' => ['abc#def@&ghi.ext', 'abc-def-ghi.ext'];
|
||||
yield 'URL unsafe characters' => ["abc{def~ghi.ext", 'abc-def-ghi.ext'];
|
||||
yield 'umlauts' => ["abücdßefÄgh.ext", 'abucdssefagh.ext'];
|
||||
yield 'accents' => ["abçcdïeféghùijôkl.ext", 'abccdiefeghuijokl.ext'];
|
||||
yield 'currency signs' => ['ab€cd£ef$gh?ij¢kl¥m.ext', 'abeurcd-ef-gh-ij-kl-m.ext'];
|
||||
yield 'cyrillic' => ['Тестовый текст.ext', 'testovyj-tekst.ext'];
|
||||
yield 'arabic' => ['نص اختباري.ext', 'ns-akhtbary.ext'];
|
||||
yield 'long string' => [str_repeat("a", 300).".ext", str_repeat('a', 251).'.ext'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \D3\ModCfg\Application\Model\d3filesystem::beautifyFilename
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @dataProvider beautifyFilenameTestDataProvider
|
||||
*/
|
||||
public function beautifyFilenameTest(string $fileName, string $expected): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'beautifyFilename',
|
||||
[$fileName]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator
|
||||
*/
|
||||
public function beautifyFilenameTestDataProvider(): Generator
|
||||
{
|
||||
yield 'spaces' => ['file name.zip', 'file-name.zip'];
|
||||
yield 'underscores' => ['file___name.zip', 'file-name.zip'];
|
||||
yield 'dashes' => ['file---name.zip', 'file-name.zip'];
|
||||
yield 'dot separated dashes' => ['file--.--.-.--name.zip', 'file.name.zip'];
|
||||
yield 'dotted' => [' file...name..zip ', 'file.name.zip'];
|
||||
yield 'mixed cases' => ['fIleNaMe..zIp', 'filename.zip'];
|
||||
yield 'trimmed' => ['.file-name.-', 'file-name'];
|
||||
yield 'single underscore' => ['file_name', 'file_name'];
|
||||
yield 'empty' => ['', ''];
|
||||
}
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting;
|
||||
use ReflectionException;
|
||||
|
||||
abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getOrder
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetUnsetOrder(): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getOrder'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getOrder
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetUnloadedOrder(): void
|
||||
{
|
||||
/** @var deliverynotePdf $sut */
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$sut->setOrder(oxNew(Order::class));
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getOrder'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getOrder
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::setOrder
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetLoadedOrder(): void
|
||||
{
|
||||
/** @var deliverynotePdf $sut */
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['isLoaded'])
|
||||
->getMock();
|
||||
$order->method('isLoaded')->willReturn(true);
|
||||
|
||||
$sut->setOrder($order);
|
||||
|
||||
$this->assertSame(
|
||||
$order,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getOrder'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getTemplateEngineVars
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetTemplateEngineVars(): void
|
||||
{
|
||||
$order = oxNew(Order::class);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
|
||||
$vars = $this->callMethod(
|
||||
$sut,
|
||||
'getTemplateEngineVars',
|
||||
[0]
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey('order', $vars);
|
||||
$this->assertArrayHasKey('user', $vars);
|
||||
$this->assertArrayHasKey('payment', $vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getFilename
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicePdf::getFilename
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf::getFilename
|
||||
* @dataProvider getFileNameDataProvider
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetFileName(mixed $predefinedFileName, string $expected): void
|
||||
{
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['getFieldData'])
|
||||
->getMock();
|
||||
$order->method('getFieldData')->willReturnMap([
|
||||
['oxbilllname', 'billLNameFixture'],
|
||||
['oxordernr', 'orderNumberFixture'],
|
||||
]);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
|
||||
if ($predefinedFileName) {
|
||||
$this->setValue($sut, 'filename', $predefinedFileName);
|
||||
}
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getFileName'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
abstract public static function getFileNameDataProvider(): Generator;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
||||
* @throws ReflectionException
|
||||
* @dataProvider getPaymentTermDataProvider
|
||||
*/
|
||||
public function testGetPaymentTerm(bool $settingExist, $settingValue, int $expected): void
|
||||
{
|
||||
$setting = $this->getMockBuilder(Setting::class)
|
||||
->onlyMethods(['getValue'])
|
||||
->getMock();
|
||||
$setting->method('getValue')->willReturn($settingValue);
|
||||
|
||||
$configuration = $this->getMockBuilder(ModuleConfiguration::class)
|
||||
->onlyMethods(['hasModuleSetting', 'getModuleSetting'])
|
||||
->getMock();
|
||||
$configuration->method('hasModuleSetting')->willReturn($settingExist);
|
||||
$configuration->method('getModuleSetting')->willReturn($setting);
|
||||
|
||||
$configurationBridge = $this->getMockBuilder(ModuleConfigurationDaoBridge::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['get'])
|
||||
->getMock();
|
||||
$configurationBridge->method('get')->willReturn($configuration);
|
||||
|
||||
$this->addServiceMocks([
|
||||
ModuleConfigurationDaoBridgeInterface::class => $configurationBridge,
|
||||
]);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPaymentTerm'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPaymentTermDataProvider(): Generator
|
||||
{
|
||||
yield 'setting exists' => [true, 10, 10];
|
||||
yield 'setting value to low' => [true, -1, 0];
|
||||
yield 'setting does not exist' => [false, null, 7];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPayableUntilDate
|
||||
* @throws ReflectionException
|
||||
* @dataProvider getPayableUntilDateDataProvider
|
||||
*/
|
||||
public function testGetPayableUntilDate($billdate, $expected): void
|
||||
{
|
||||
$order = oxNew(Order::class);
|
||||
$order->assign(['oxbilldate' => $billdate]);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder', 'getPaymentTerm'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
$sut->method('getPaymentTerm')->willReturn(10);
|
||||
|
||||
$return = $this->callMethod(
|
||||
$sut,
|
||||
'getPayableUntilDate'
|
||||
);
|
||||
|
||||
if (is_int($expected)) {
|
||||
$this->assertSame($expected, $return);
|
||||
} else {
|
||||
$this->assertGreaterThan(time(), $return);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPayableUntilDateDataProvider(): Generator
|
||||
{
|
||||
yield 'date set' => ['2020-01-01', 1578697200];
|
||||
yield 'zero date set' => ['0000-00-00', null]; // expected greater than now
|
||||
yield 'date is null' => [null, null]; // expected greater than now
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Documents;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
use D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses\pdfDocumentsOrder;
|
||||
use Generator;
|
||||
|
||||
class deliveryNotePdfTest extends pdfDocumentsOrder
|
||||
{
|
||||
protected string $sutClassName = deliveryNotePdf::class;
|
||||
|
||||
public static function getFileNameDataProvider(): Generator
|
||||
{
|
||||
yield 'predefined' => ['predefinedFileName', 'predefinedfilename.pdf'];
|
||||
yield 'undefined' => [null, 'delnote_ordernumberfixture_billlnamefixture.pdf'];
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Documents;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
|
||||
use Generator;
|
||||
|
||||
class invoicePdfNoLogoTest extends invoicePdfTest
|
||||
{
|
||||
protected string $sutClassName = invoicewithoutlogoPdf::class;
|
||||
|
||||
public static function getFileNameDataProvider(): Generator
|
||||
{
|
||||
yield 'predefined' => ['predefinedFileName', 'predefinedfilename.pdf'];
|
||||
yield 'undefined' => [null, 'invoice-nl_ordernumberfixture_billlnamefixture.pdf'];
|
||||
}
|
||||
}
|
175
Tests/Unit/Application/Model/Documents/invoicePdfTest.php
Normal file
175
Tests/Unit/Application/Model/Documents/invoicePdfTest.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Documents;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses\pdfDocumentsOrder;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use ReflectionException;
|
||||
|
||||
class invoicePdfTest extends pdfDocumentsOrder
|
||||
{
|
||||
protected string $sutClassName = invoicePdf::class;
|
||||
|
||||
public static function getFileNameDataProvider(): Generator
|
||||
{
|
||||
yield 'predefined' => ['predefinedFileName', 'predefinedfilename.pdf'];
|
||||
yield 'undefined' => [null, 'invoice_ordernumberfixture_billlnamefixture.pdf'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicePdf::runPreAction
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf::runPreAction
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testPreAction(): void
|
||||
{
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['setInvoiceNumber', 'setInvoiceDate', 'saveOrderOnChanges'])
|
||||
->getMock();
|
||||
$sut->expects($this->once())->method('setInvoiceNumber');
|
||||
$sut->expects($this->once())->method('setInvoiceDate');
|
||||
$sut->expects($this->once())->method('saveOrderOnChanges');
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'runPreAction',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicePdf::setInvoiceNumber
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf::setInvoiceNumber
|
||||
* @throws ReflectionException
|
||||
* @dataProvider setInvoiceNumberDataProvider
|
||||
*/
|
||||
public function testSetInvoiceNumber(?string $setBillNo, InvocationOrder $expectNewBillNo, bool $changedOrder): void
|
||||
{
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['getFieldData', 'assign', 'getNextBillNum'])
|
||||
->getMock();
|
||||
$order->method('getFieldData')->willReturnMap([
|
||||
['oxbillnr', $setBillNo],
|
||||
]);
|
||||
$order->expects($expectNewBillNo)->method('assign');
|
||||
$order->method('getNextBillNum')->willReturn(1234);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'setInvoiceNumber',
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
$changedOrder,
|
||||
$this->getValue(
|
||||
$sut,
|
||||
'orderIsChanged',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setInvoiceNumberDataProvider(): Generator
|
||||
{
|
||||
yield 'has bill no' => ['4567', self::never(), false];
|
||||
yield 'has not bill no' => [null, self::atLeastOnce(), true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicePdf::setInvoiceDate
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf::setInvoiceDate
|
||||
* @throws ReflectionException
|
||||
* @dataProvider setInvoiceDateDataProvider
|
||||
*/
|
||||
public function testSetInvoiceDate(?string $setBillDate, InvocationOrder $expectNewBillNo, bool $changedOrder): void
|
||||
{
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['getFieldData', 'assign'])
|
||||
->getMock();
|
||||
$order->method('getFieldData')->willReturnMap([
|
||||
['oxbilldate', $setBillDate],
|
||||
]);
|
||||
$order->expects($expectNewBillNo)->method('assign');
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'setInvoiceDate',
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
$changedOrder,
|
||||
$this->getValue(
|
||||
$sut,
|
||||
'orderIsChanged',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setInvoiceDateDataProvider(): Generator
|
||||
{
|
||||
yield 'has bill no' => ['2020-01-01', self::never(), false];
|
||||
yield 'has not bill no' => ['0000-00-00', self::atLeastOnce(), true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicePdf::saveOrderOnChanges
|
||||
* @covers \D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf::saveOrderOnChanges
|
||||
* @throws ReflectionException
|
||||
* @dataProvider saveOrderOnChangesDataProvider
|
||||
*/
|
||||
public function testSaveOrderOnChanges(InvocationOrder $saveInvocation, bool $orderIsChanged): void
|
||||
{
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['save'])
|
||||
->getMock();
|
||||
$order->expects($saveInvocation)->method('save');
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getOrder'])
|
||||
->getMock();
|
||||
$sut->method('getOrder')->willReturn($order);
|
||||
|
||||
$this->setValue(
|
||||
$sut,
|
||||
'orderIsChanged',
|
||||
$orderIsChanged,
|
||||
);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'saveOrderOnChanges',
|
||||
);
|
||||
}
|
||||
|
||||
public static function saveOrderOnChangesDataProvider(): Generator
|
||||
{
|
||||
yield 'is changed' => [self::once(), true];
|
||||
yield 'not changed' => [self::never(), false];
|
||||
}
|
||||
}
|
566
Tests/Unit/Application/Model/Documents/nonOrderDocumentTest.php
Normal file
566
Tests/Unit/Application/Model/Documents/nonOrderDocumentTest.php
Normal file
@ -0,0 +1,566 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Documents;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric as pdfdocumentsGenericSut;
|
||||
use D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses\pdfDocumentsGeneric;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\nonOrderDocument;
|
||||
use Generator;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use OxidEsales\Eshop\Core\Config;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Spipu\Html2Pdf\MyPdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
|
||||
class nonOrderDocumentTest extends pdfDocumentsGeneric
|
||||
{
|
||||
protected string $sutClassName = nonOrderDocument::class;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::downloadPdf
|
||||
*/
|
||||
public function testDownloadPdf(): void
|
||||
{
|
||||
$utils = $this->getMockBuilder(Utils::class)
|
||||
->onlyMethods(['showMessageAndExit'])
|
||||
->getMock();
|
||||
$utils->expects($this->once())->method('showMessageAndExit');
|
||||
Registry::set(Utils::class, $utils);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['runPreAction', 'genPdf', 'runPostAction'])
|
||||
->getMock();
|
||||
$sut->expects($this->atLeastOnce())->method('runPreAction');
|
||||
$sut->expects($this->atLeastOnce())->method('genPdf')->with(
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
pdfdocumentsGenericSut::PDF_DESTINATION_DOWNLOAD
|
||||
);
|
||||
$sut->expects($this->atLeastOnce())->method('runPostAction');
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'downloadPdf',
|
||||
[10]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::savePdfFile
|
||||
*/
|
||||
public function testSavePdfFile(): void
|
||||
{
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['runPreAction', 'genPdf', 'runPostAction'])
|
||||
->getMock();
|
||||
$sut->expects($this->atLeastOnce())->method('runPreAction');
|
||||
$sut->expects($this->atLeastOnce())->method('genPdf')->with(
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
pdfdocumentsGenericSut::PDF_DESTINATION_FILE
|
||||
);
|
||||
$sut->expects($this->atLeastOnce())->method('runPostAction');
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'savePdfFile',
|
||||
[10]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::getPdfContent
|
||||
* @dataProvider getPdfContentDataProvider
|
||||
*/
|
||||
public function testGetPdfContent(bool $throwException, ?string $expected): void
|
||||
{
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['runPreAction', 'genPdf', 'runPostAction'])
|
||||
->getMock();
|
||||
$sut->expects($this->atLeastOnce())->method('runPreAction');
|
||||
$sut->expects($this->atLeastOnce())->method('genPdf')->with(
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
pdfdocumentsGenericSut::PDF_DESTINATION_STRING
|
||||
)->willReturn('pdfContentFixture');
|
||||
if ($throwException) {
|
||||
$sut->expects($this->atLeastOnce())->method('runPostAction')
|
||||
->willThrowException(new InvalidArgumentException('messageFixture', 200));
|
||||
} else {
|
||||
$sut->expects($this->atLeastOnce())->method('runPostAction');
|
||||
}
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPdfContent',
|
||||
[10]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPdfContentDataProvider(): Generator
|
||||
{
|
||||
yield 'no exception' => [false, 'pdfContentFixture'];
|
||||
yield 'exception' => [true, null];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::getHTMLContent
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetHTMLContent(): void
|
||||
{
|
||||
$templateRender = $this->getMockBuilder(TemplateRenderer::class)
|
||||
->onlyMethods(['renderTemplate'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$templateRender->method('renderTemplate')->willReturn('htmlContentFixture');
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['getTemplateRenderer', 'addBasicAuth'])
|
||||
->getMock();
|
||||
$sut->method('getTemplateRenderer')->willReturn($templateRender);
|
||||
$sut->method('addBasicAuth')->willReturnArgument(0);
|
||||
|
||||
$this->assertSame(
|
||||
'htmlContentFixture',
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getHTMLContent',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::addBasicAuth
|
||||
* @throws ReflectionException
|
||||
* @dataProvider addBasicAuthDataProvider
|
||||
*/
|
||||
public function testAddBasicAuth(string $credential, string $expected): void
|
||||
{
|
||||
$source = '<a href="https://www.test.dev/image.jpg">image</a>';
|
||||
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->onlyMethods(['getString'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$settingService->method('getString')->willReturn(new UnicodeString($credential));
|
||||
|
||||
$config = $this->getMockBuilder(Config::class)
|
||||
->onlyMethods(['getShopCurrentUrl'])
|
||||
->getMock();
|
||||
$config->method('getShopCurrentUrl')->willReturn('https://www.test.dev/index.php');
|
||||
|
||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
||||
$currentConfig = Registry::getConfig();
|
||||
Registry::set(Config::class, $config);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
try {
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'addBasicAuth',
|
||||
[ $source ]
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
Registry::set(Config::class, $currentConfig);
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function addBasicAuthDataProvider(): Generator
|
||||
{
|
||||
yield 'no credential' => ['', '<a href="https://www.test.dev/image.jpg">image</a>'];
|
||||
yield 'credential' => ['crd', '<a href="https://crd:crd@www.test.dev/image.jpg">image</a>'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::setFilename
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::getFilename
|
||||
* @throws ReflectionException
|
||||
* @dataProvider setFilenameDataProvider
|
||||
*/
|
||||
public function testGetFileName(?string $setFileName, InvocationOrder $getTypeInvocation, string $expected): void
|
||||
{
|
||||
/** @var MockObject|nonOrderDocument $sut */
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['sanitizeFileName', 'addFilenameExtension', 'getTypeForFilename'])
|
||||
->getMock();
|
||||
$sut->expects($this->once())->method('sanitizeFileName')->willReturnArgument(0);
|
||||
$sut->expects($this->once())->method('addFilenameExtension')->willReturnArgument(0);
|
||||
$sut->expects($getTypeInvocation)->method('getTypeForFilename')->willReturn('docType');
|
||||
|
||||
if ($setFileName) {
|
||||
$sut->setFileName($setFileName);
|
||||
}
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getFileName'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function setFilenameDataProvider(): Generator
|
||||
{
|
||||
yield 'no set filename' => [null, self::once(), 'docType'];
|
||||
yield 'set filename' => ['document', self::never(), 'document'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::addFilenameExtension
|
||||
* @throws ReflectionException
|
||||
* @dataProvider addFilenameExtensionDataProvider
|
||||
*/
|
||||
public function testAddFilenameExtension(string $filename, string $expected): void
|
||||
{
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'addFilenameExtension',
|
||||
[$filename]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function addFilenameExtensionDataProvider(): Generator
|
||||
{
|
||||
yield 'no extension' => ['document', 'document.pdf'];
|
||||
yield 'with extension' => ['document.pdf', 'document.pdf'];
|
||||
yield 'with different extensions' => ['document.txt', 'document.txt.pdf'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::output
|
||||
* @throws ReflectionException
|
||||
* @dataProvider outputDataProvider
|
||||
*/
|
||||
public function testOutput(bool $dev, InvocationOrder $outputInvocation, InvocationOrder $devInvocation): void
|
||||
{
|
||||
$pdf = $this->getMockBuilder(Html2Pdf::class)
|
||||
->onlyMethods(['output'])
|
||||
->getMock();
|
||||
$pdf->expects($outputInvocation)->method('output');
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['outputDev'])
|
||||
->getMock();
|
||||
$sut->expects($devInvocation)->method('outputDev');
|
||||
|
||||
$this->setValue($sut, 'devMode', $dev);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'output',
|
||||
[$pdf, 'fileNameFixture', 'targetFixture', 'htmlFixture']
|
||||
);
|
||||
}
|
||||
|
||||
public static function outputDataProvider(): Generator
|
||||
{
|
||||
yield 'is dev' => [true, self::never(), self::once()];
|
||||
yield 'is prod' => [false, self::once(), self::never()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev
|
||||
* @throws ReflectionException
|
||||
* @dataProvider outputDevDataProvider
|
||||
*/
|
||||
public function testOutputDev(
|
||||
string $target,
|
||||
InvocationOrder $stdout,
|
||||
InvocationOrder $download,
|
||||
InvocationOrder $file,
|
||||
InvocationOrder $error,
|
||||
?string $expectedReturn
|
||||
): void {
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($error)->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['outputDev_stdout', 'outputDev_download', 'outputDev_saveLocal'])
|
||||
->getMock();
|
||||
$sut->expects($stdout)->method('outputDev_stdout');
|
||||
$sut->expects($download)->method('outputDev_download');
|
||||
$sut->expects($file)->method('outputDev_saveLocal');
|
||||
|
||||
$this->assertSame(
|
||||
$expectedReturn,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev',
|
||||
[$pdf, 'fileNameFixture', $target, 'htmlFixture']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function outputDevDataProvider(): Generator
|
||||
{
|
||||
yield 'stdout' => [pdfdocumentsGenericSut::PDF_DESTINATION_STDOUT, self::once(), self::never(), self::never(), self::never(), null];
|
||||
yield 'download' => [pdfdocumentsGenericSut::PDF_DESTINATION_DOWNLOAD, self::never(), self::once(), self::never(), self::never(), null];
|
||||
yield 'file' => [pdfdocumentsGenericSut::PDF_DESTINATION_FILE, self::never(), self::never(), self::once(), self::never(), null];
|
||||
yield 'string' => [pdfdocumentsGenericSut::PDF_DESTINATION_STRING, self::never(), self::never(), self::never(), self::never(), 'htmlFixture'];
|
||||
yield 'other' => ['unknown', self::never(), self::never(), self::never(), self::once(), null];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_stdout
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testOutputDev_stdout_formerOutput(): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->once())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
ob_start();
|
||||
echo 'formerOutput';
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_stdout',
|
||||
[$pdf, 'fileNameFixture', 'htmlFixture']
|
||||
);
|
||||
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_stdout
|
||||
* @throws ReflectionException
|
||||
* @dataProvider outputDev_stdout_noFormerOutputDataProvider
|
||||
*/
|
||||
public function testOutputDev_stdout_noFormerOutput(bool $isCli): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->never())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
ob_start();
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['isCli', 'headersSent'])
|
||||
->getMock();
|
||||
$sut->method('isCli')->willReturn($isCli);
|
||||
$sut->method('headersSent')->willReturn(false);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_stdout',
|
||||
[$pdf, 'fileNameFixture', 'htmlFixture']
|
||||
);
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertSame(
|
||||
$output,
|
||||
'htmlFixture'
|
||||
);
|
||||
}
|
||||
|
||||
public static function outputDev_stdout_noFormerOutputDataProvider(): Generator
|
||||
{
|
||||
yield 'is cli' => [true];
|
||||
yield 'is not cli' => [false];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_download
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testOutputDev_download_formerOutput(): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->once())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
ob_start();
|
||||
echo 'formerOutput';
|
||||
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['headersSent'])
|
||||
->getMock();
|
||||
$sut->method('headersSent')->willReturn(false);
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_download',
|
||||
[$pdf, 'fileNameFixture', 'htmlFixture']
|
||||
);
|
||||
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_download
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testOutputDev_download_noFormerOutput(): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->never())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
ob_start();
|
||||
$sut = $this->getMockBuilder($this->sutClassName)
|
||||
->onlyMethods(['headersSent'])
|
||||
->getMock();
|
||||
$sut->method('headersSent')->willReturn(false);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_download',
|
||||
[$pdf, 'fileNameFixture', 'htmlFixture']
|
||||
)
|
||||
);
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertSame(
|
||||
$output,
|
||||
'htmlFixture'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_saveLocal
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testOutputDev_saveLocal_passed(): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->never())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$root = vfsStream::setup('exampleDir');
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_saveLocal',
|
||||
[$pdf, $root->url().'/fileNameFixture.pdf', 'htmlFixture']
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertFileExists(
|
||||
$root->url().'/fileNameFixture.pdf'
|
||||
);
|
||||
$this->assertSame(
|
||||
strlen('htmlFixture'),
|
||||
$root->getChild('fileNameFixture.pdf')->size()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric::outputDev_saveLocal
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testOutputDev_saveLocal_unableToWrite(): void
|
||||
{
|
||||
$myPdf = $this->getMockBuilder(MyPdf::class)
|
||||
->onlyMethods(['Error'])
|
||||
->getMock();
|
||||
$myPdf->expects($this->once())->method('Error');
|
||||
|
||||
$pdf = oxNew(Html2Pdf::class);
|
||||
$this->setValue($pdf, 'pdf', $myPdf);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$root = vfsStream::setup('exampleDir');
|
||||
$root->chmod(0000);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'outputDev_saveLocal',
|
||||
[$pdf, $root->url().'/fileNameFixture.pdf', 'htmlFixture']
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertFileDoesNotExist(
|
||||
$root->url().'/fileNameFixture.pdf'
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
|
||||
class NoPdfHandlerFoundExceptionTest extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
|
||||
/**
|
||||
* @covers \D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException::__construct
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$fixture = 'requestIdFixture';
|
||||
|
||||
$sut = $this->getMockBuilder(noPdfHandlerFoundException::class)
|
||||
->setConstructorArgs([$fixture])
|
||||
->getMock();
|
||||
|
||||
$this->assertStringContainsString(
|
||||
$fixture,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getMessage'
|
||||
)
|
||||
);
|
||||
|
||||
$sut = $this->getMockBuilder(noPdfHandlerFoundException::class)
|
||||
->setConstructorArgs([$fixture, 'custom message'])
|
||||
->getMock();
|
||||
|
||||
$this->assertStringContainsString(
|
||||
$fixture,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getMessage'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
|
||||
class wrongPdfGeneratorInterfaceTest extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
|
||||
/**
|
||||
* @covers \D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface::__construct
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$fixture = 'requestIdFixture';
|
||||
|
||||
$sut = $this->getMockBuilder(wrongPdfGeneratorInterface::class)
|
||||
->setConstructorArgs([$fixture])
|
||||
->getMock();
|
||||
|
||||
$this->assertStringEndsWith(
|
||||
$fixture,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getMessage'
|
||||
)
|
||||
);
|
||||
|
||||
$sut = $this->getMockBuilder(wrongPdfGeneratorInterface::class)
|
||||
->setConstructorArgs([$fixture, 'custom message'])
|
||||
->getMock();
|
||||
|
||||
$this->assertStringEndsWith(
|
||||
$fixture,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getMessage'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
195
Tests/Unit/Application/Model/Registries/registryAbstract.php
Normal file
195
Tests/Unit/Application/Model/Registries/registryAbstract.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\nonOrderDocument;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Exception;
|
||||
use Generator;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
|
||||
abstract class registryAbstract extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::addGenerator
|
||||
* @dataProvider addGeneratorDataProvider
|
||||
*/
|
||||
public function testAddGenerator(bool $exist, InvocationOrder $addInvocation, bool $expectException): void
|
||||
{
|
||||
$sut = $this->getMockBuilder(registryOrderoverview::class)
|
||||
->onlyMethods(['hasGenerator', 'addItem'])
|
||||
->getMock();
|
||||
$sut->method('hasGenerator')->willReturn($exist);
|
||||
$sut->expects($addInvocation)->method('addItem');
|
||||
|
||||
if ($expectException) {
|
||||
$this->expectException(Exception::class);
|
||||
}
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'addGenerator',
|
||||
[orderDocument::class]
|
||||
);
|
||||
}
|
||||
|
||||
public static function addGeneratorDataProvider(): Generator
|
||||
{
|
||||
yield 'not added' => [false, self::once(), false];
|
||||
yield 'already added' => [true, self::never(), true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::addItem
|
||||
* @dataProvider addItemDataProvider
|
||||
*/
|
||||
public function testAddItem(string $fqcn, bool $expectException): void
|
||||
{
|
||||
$sut = $this->getMockBuilder(registryOrderoverview::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['addGenerator'])
|
||||
->getMock();
|
||||
|
||||
$this->assertArrayNotHasKey($fqcn, $this->getValue($sut, 'registry'));
|
||||
|
||||
if ($expectException) {
|
||||
$this->expectException(Exception::class);
|
||||
}
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'addItem',
|
||||
[oxNew($fqcn)]
|
||||
);
|
||||
|
||||
if ($expectException) {
|
||||
$this->assertArrayNotHasKey($fqcn, $this->getValue($sut, 'registry'));
|
||||
} else {
|
||||
$this->assertArrayHasKey($fqcn, $this->getValue($sut, 'registry'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function addItemDataProvider(): Generator
|
||||
{
|
||||
yield 'right interface passed' => [orderDocument::class, false];
|
||||
yield 'wrong interface' => [nonOrderDocument::class, true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::removeGenerator
|
||||
* @dataProvider removeGeneratorDataProvider
|
||||
*/
|
||||
public function testRemoveGenerator(bool $exist, bool $removed): void
|
||||
{
|
||||
$sut = $this->getMockBuilder(registryOrderoverview::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['hasGenerator'])
|
||||
->getMock();
|
||||
$sut->method('hasGenerator')->willReturn($exist);
|
||||
|
||||
$this->setValue(
|
||||
$sut,
|
||||
'registry',
|
||||
array_merge(
|
||||
$this->getValue(
|
||||
$sut,
|
||||
'registry',
|
||||
),
|
||||
[orderDocument::class => oxNew(orderDocument::class)]
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertArrayHasKey(orderDocument::class, $this->getValue($sut, 'registry'));
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'removeGenerator',
|
||||
[orderDocument::class]
|
||||
);
|
||||
|
||||
if ($removed) {
|
||||
$this->assertArrayNotHasKey(orderDocument::class, $this->getValue($sut, 'registry'));
|
||||
} else {
|
||||
$this->assertArrayHasKey(orderDocument::class, $this->getValue($sut, 'registry'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeGeneratorDataProvider(): Generator
|
||||
{
|
||||
yield 'generator exists' => [true, true];
|
||||
yield 'generator does not exist' => [false, false];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::hasGenerator
|
||||
*/
|
||||
public function testHasGenerator(): void
|
||||
{
|
||||
$sut = oxNew(registryOrderoverview::class);
|
||||
|
||||
$this->assertFalse($sut->hasGenerator(orderDocument::class));
|
||||
$sut->addGenerator(orderDocument::class);
|
||||
$this->assertTrue($sut->hasGenerator(orderDocument::class));
|
||||
$sut->removeGenerator(orderDocument::class);
|
||||
$this->assertFalse($sut->hasGenerator(orderDocument::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::getList
|
||||
*/
|
||||
public function testGetList(): void
|
||||
{
|
||||
$sut = oxNew(registryOrderoverview::class);
|
||||
$list = $sut->getList();
|
||||
|
||||
$this->assertIsIterable($list);
|
||||
$startCount = count($list);
|
||||
|
||||
$sut->addGenerator(orderDocument::class);
|
||||
$this->assertCount($startCount + 1, $sut->getList());
|
||||
|
||||
$sut->removeGenerator(orderDocument::class);
|
||||
$this->assertCount($startCount, $sut->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryAbstract::clearList
|
||||
*/
|
||||
public function testClearList(): void
|
||||
{
|
||||
$sut = oxNew(registryOrderoverview::class);
|
||||
$sut->addGenerator(orderDocument::class);
|
||||
$sut->clearList();
|
||||
$this->assertCount(0, $sut->getList());
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\nonOrderDocument;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Exception;
|
||||
use Generator;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionException;
|
||||
|
||||
class registryOrderOverviewTest extends registryAbstract
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrderoverview::__construct
|
||||
* @dataProvider constructDataProvider
|
||||
*/
|
||||
public function testConstructor(bool $inv, bool $deln, bool $invNL, bool $delnNL, int $expectedCount): void
|
||||
{
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->onlyMethods(['getBoolean'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$settingService->method('getBoolean')->willReturnMap([
|
||||
['d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID, $inv],
|
||||
['d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID, $deln],
|
||||
['d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID, $invNL],
|
||||
['d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID, $delnNL],
|
||||
]);
|
||||
|
||||
try {
|
||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
||||
|
||||
$sut = $this->getMockBuilder(registryOrderoverview::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['addGenerator'])
|
||||
->getMock();
|
||||
$sut->expects($this->exactly($expectedCount))->method('addGenerator');
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'__construct'
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function constructDataProvider(): Generator
|
||||
{
|
||||
yield 'nothing' => [false, false, false, false, 0];
|
||||
yield 'invoice only' => [true, false, false, false, 1];
|
||||
yield 'invoice + delnote' => [true, true, false, false, 2];
|
||||
yield 'invoice + NoLogo + delnote' => [true, true, true, false, 3];
|
||||
yield 'invoice + NoLogo + delnote + NoLogo' => [true, true, true, true, 4];
|
||||
yield 'invNoLogo + delnote + NoLogo' => [false, true, true, true, 3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrderoverview::getGenerator
|
||||
*/
|
||||
public function testGetGenerator(): void
|
||||
{
|
||||
$sut = oxNew(registryOrderoverview::class);
|
||||
$sut->addGenerator(orderDocument::class);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
orderDocument::class,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getGenerator',
|
||||
[orderDocument::class]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrdermanagerActions;
|
||||
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
||||
use Generator;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use ReflectionException;
|
||||
|
||||
class registryOrdermanagerActionsTest extends registryAbstract
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrdermanagerActions::__construct
|
||||
* @dataProvider constructDataProvider
|
||||
*/
|
||||
public function testConstructor(bool $inv, bool $deln, bool $invNL, bool $delnNL, int $expectedCount): void
|
||||
{
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->onlyMethods(['getBoolean'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$settingService->method('getBoolean')->willReturnMap([
|
||||
['d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID, $inv],
|
||||
['d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID, $deln],
|
||||
['d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID, $invNL],
|
||||
['d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID, $delnNL],
|
||||
]);
|
||||
|
||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
||||
|
||||
try {
|
||||
$sut = $this->getMockBuilder(registryOrdermanagerActions::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['addGenerator'])
|
||||
->getMock();
|
||||
$sut->expects($this->exactly($expectedCount))->method('addGenerator');
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'__construct'
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function constructDataProvider(): Generator
|
||||
{
|
||||
yield 'nothing' => [false, false, false, false, 0];
|
||||
yield 'invoice only' => [true, false, false, false, 1];
|
||||
yield 'invoice + delnote' => [true, true, false, false, 2];
|
||||
yield 'invoice + NoLogo + delnote' => [true, true, true, false, 3];
|
||||
yield 'invoice + NoLogo + delnote + NoLogo' => [true, true, true, true, 4];
|
||||
yield 'invNoLogo + delnote + NoLogo' => [false, true, true, true, 3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrdermanagerActions::getGenerator
|
||||
*/
|
||||
public function testGetGenerator(): void
|
||||
{
|
||||
$sut = oxNew(registryOrdermanagerActions::class);
|
||||
$sut->addGenerator(orderDocument::class);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
orderDocument::class,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getGenerator',
|
||||
[orderDocument::class]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
39
Tests/Unit/Helpers/nonOrderDocument.php
Normal file
39
Tests/Unit/Helpers/nonOrderDocument.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Helpers;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
|
||||
class nonOrderDocument extends pdfDocumentsGeneric
|
||||
{
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'requestId';
|
||||
}
|
||||
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return 'titleIdent';
|
||||
}
|
||||
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return 'template';
|
||||
}
|
||||
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'nonOrderDocument';
|
||||
}
|
||||
}
|
91
Tests/Unit/Helpers/orderDocument.php
Normal file
91
Tests/Unit/Helpers/orderDocument.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Helpers;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
|
||||
class orderDocument implements pdfdocumentsOrderInterface
|
||||
{
|
||||
public function getRequestId(): string
|
||||
{
|
||||
return 'requestId';
|
||||
}
|
||||
|
||||
public function getTitleIdent(): string
|
||||
{
|
||||
return 'titleIdent';
|
||||
}
|
||||
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return 'template';
|
||||
}
|
||||
|
||||
public function getHTMLContent(): string
|
||||
{
|
||||
return "HtmlContent";
|
||||
}
|
||||
|
||||
public function downloadPdf(int $language = 0): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getPdfContent(int $language = 0): ?string
|
||||
{
|
||||
return "pdfContent";
|
||||
}
|
||||
|
||||
public function savePdfFile(string $path, int $language = 0): void
|
||||
{
|
||||
}
|
||||
|
||||
public function genPdf(string $filename, int $language = 0, string $target = 'I'): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getFilename(): string
|
||||
{
|
||||
return 'filename';
|
||||
}
|
||||
|
||||
public function addFilenameExtension(string $filename): string
|
||||
{
|
||||
return 'filenameExtension';
|
||||
}
|
||||
|
||||
public function setDevelopmentMode(bool $devMode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setOrder(Order $order): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getOrder(): Order
|
||||
{
|
||||
return oxNew(Order::class);
|
||||
}
|
||||
|
||||
public function getTypeForFilename(): string
|
||||
{
|
||||
return 'typeForFilename';
|
||||
}
|
||||
}
|
@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Modules\Application\Controller;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\ForwardCompatibility\Result;
|
||||
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
use Twig\Error\Error;
|
||||
|
||||
class d3_overview_controller_pdfdocumentsTest extends TestCase
|
||||
{
|
||||
use CanAccessRestricted;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::render
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testRenderReload(): void
|
||||
{
|
||||
$utils = $this->getMockBuilder(Utils::class)
|
||||
->onlyMethods(['showMessageAndExit'])
|
||||
->getMock();
|
||||
$utils->expects($this->once())->method('showMessageAndExit');
|
||||
|
||||
Registry::set(Utils::class, $utils);
|
||||
|
||||
$sut = oxNew(d3_overview_controller_pdfdocuments::class);
|
||||
|
||||
$this->setValue($sut, 'doReload', true);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'render'
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::render
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testRenderDisplayError(): void
|
||||
{
|
||||
$utilsview = $this->getMockBuilder(UtilsView::class)
|
||||
->onlyMethods(['addErrorToDisplay'])
|
||||
->getMock();
|
||||
$utilsview->expects($this->once())->method('addErrorToDisplay');
|
||||
|
||||
Registry::set(UtilsView::class, $utilsview);
|
||||
|
||||
$sut = oxNew(d3_overview_controller_pdfdocuments::class);
|
||||
|
||||
$this->setValue($sut, 'doReload', false);
|
||||
$_GET['generatorError'] = 'errorMessageFixture';
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'render'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3PdfDocsIsDevMode
|
||||
* @throws ReflectionException
|
||||
* @dataProvider d3PdfDocsIsDevModeDataProvider
|
||||
*/
|
||||
public function testPdfDocsIsDevMode(bool $devMode): void
|
||||
{
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->onlyMethods(['getBoolean'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$settingService->method('getBoolean')->willReturn($devMode);
|
||||
|
||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
||||
|
||||
$sut = oxNew(d3_overview_controller_pdfdocuments::class);
|
||||
|
||||
try {
|
||||
$this->assertSame(
|
||||
$devMode,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'd3PdfDocsIsDevMode'
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function d3PdfDocsIsDevModeDataProvider(): Generator
|
||||
{
|
||||
yield 'is dev' => [true];
|
||||
yield 'is prod' => [false];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3CanExport
|
||||
* @dataProvider d3CanExportDataProvider
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testCanExport(bool $throwException, bool $expectedReturn): void
|
||||
{
|
||||
$result = $this->getMockBuilder(Result::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['fetchOne'])
|
||||
->getMock();
|
||||
$result->method('fetchOne')->willReturn('oxid');
|
||||
|
||||
$expressionBuilder = $this->getMockBuilder(ExpressionBuilder::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$queryBuilder = $this->getMockBuilder(QueryBuilder::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['execute', 'expr'])
|
||||
->getMock();
|
||||
if ($throwException) {
|
||||
$queryBuilder->method('execute')->willThrowException(new Exception());
|
||||
} else {
|
||||
$queryBuilder->method('execute')->willReturn($result);
|
||||
}
|
||||
$queryBuilder->method('expr')->willReturn($expressionBuilder);
|
||||
|
||||
$qbFactory = $this->getMockBuilder(QueryBuilderFactory::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['create'])
|
||||
->getMock();
|
||||
$qbFactory->method('create')->willReturn($queryBuilder);
|
||||
|
||||
$this->addServiceMocks([
|
||||
QueryBuilderFactoryInterface::class => $qbFactory,
|
||||
]);
|
||||
|
||||
$sut = $this->getMockBuilder(d3_overview_controller_pdfdocuments::class)
|
||||
->onlyMethods(['getEditObjectId'])
|
||||
->getMock();
|
||||
$sut->method('getEditObjectId')->willReturn('oxid');
|
||||
|
||||
try {
|
||||
$this->assertSame(
|
||||
$expectedReturn,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'd3CanExport'
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function d3CanExportDataProvider(): Generator
|
||||
{
|
||||
yield 'throw exception' => [true, false];
|
||||
yield 'doesnt throw exception' => [false, true];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3CreatePDF
|
||||
* @throws ReflectionException
|
||||
* @dataProvider createPdfDataProvider
|
||||
*/
|
||||
public function testCreatePdf(?string $objectid, bool $loadable, ?string $language, InvocationOrder $generate, bool $throwException): void
|
||||
{
|
||||
$order = $this->getMockBuilder(Order::class)
|
||||
->onlyMethods(['load'])
|
||||
->getMock();
|
||||
$order->method('load')->willReturn($loadable);
|
||||
|
||||
$generatorController = $this->getMockBuilder(orderOverviewPdfGenerator::class)
|
||||
->onlyMethods(['generatePdf'])
|
||||
->getMock();
|
||||
if ($throwException) {
|
||||
$generatorController->expects($generate)->method('generatePdf')->willThrowException(new \Exception());
|
||||
} else {
|
||||
$generatorController->expects($generate)->method('generatePdf');
|
||||
}
|
||||
|
||||
$sut = $this->getMockBuilder(d3_overview_controller_pdfdocuments::class)
|
||||
->onlyMethods(['getEditObjectId', 'd3PdfGetOrder', 'd3PdfGetGeneratorController'])
|
||||
->getMock();
|
||||
$sut->method('getEditObjectId')->willReturn($objectid);
|
||||
$sut->method('d3PdfGetOrder')->willReturn($order);
|
||||
$sut->method('d3PdfGetGeneratorController')->willReturn($generatorController);
|
||||
|
||||
$_GET['pdflanguage'] = $language;
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'd3CreatePdf'
|
||||
);
|
||||
|
||||
if ($throwException) {
|
||||
$this->assertTrue($this->getValue($sut, 'doReload'));
|
||||
$this->getValue($sut, 'generatorError');
|
||||
$this->assertStringContainsString('PDF documents', $this->getValue($sut, 'generatorError'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function createPdfDataProvider(): Generator
|
||||
{
|
||||
yield 'no edit object id' => [null, true, '1', self::never(), false];
|
||||
yield 'unloadable order' => ['objectid', false, '1', self::never(), false];
|
||||
yield 'no language defined' => ['objectid', false, null, self::never(), false];
|
||||
yield 'can generate' => ['objectid', true, '1', self::once(), false];
|
||||
yield 'generate exception' => ['objectid', true, '1', self::once(), true];
|
||||
}
|
||||
}
|
40
Tests/phpunit.xml
Normal file
40
Tests/phpunit.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="true"
|
||||
bootstrap="../../../../source/bootstrap.php"
|
||||
colors="true"
|
||||
backupStaticAttributes="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="false"
|
||||
convertWarningsToExceptions="false"
|
||||
forceCoversAnnotation="false"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>Unit/</directory>
|
||||
</testsuite>
|
||||
<!-- <testsuite name="Integration">-->
|
||||
<!-- <directory>integration/</directory>-->
|
||||
<!-- </testsuite>-->
|
||||
</testsuites>
|
||||
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>../.php-cs-fixer.php</file>
|
||||
<file>../IntelliSenseHelper.php</file>
|
||||
<file>../rector.php</file>
|
||||
<directory>../Tests/</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
<php>
|
||||
<const name="OXID_PHP_UNIT" value="true"/>
|
||||
</php>
|
||||
</phpunit>
|
BIN
assets/out/img/ads_bg.jpg
Normal file
BIN
assets/out/img/ads_bg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 199 KiB |
BIN
assets/out/img/clogo.jpg
Normal file
BIN
assets/out/img/clogo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
57
assets/picture.svg
Normal file
57
assets/picture.svg
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="201px" height="124px" viewBox="0 0 201 124" enable-background="new 0 0 201 124" xml:space="preserve">
|
||||
<g>
|
||||
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="47.0591" y1="67.5117" x2="47.0591" y2="54.6143">
|
||||
<stop offset="0.0056" style="stop-color:#3266A9"/>
|
||||
<stop offset="1" style="stop-color:#0099FF"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_1_)" d="M50.282,55.502c-0.784-0.592-2.104-0.888-3.961-0.888h-1.376l-2.283,12.898h1.779
|
||||
c3.76,0,6.032-2.245,6.815-6.733c0.134-0.871,0.202-1.642,0.202-2.313C51.457,57.081,51.064,56.093,50.282,55.502z"/>
|
||||
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="65.9609" y1="49.104" x2="65.9609" y2="36.9434">
|
||||
<stop offset="0.0056" style="stop-color:#3266A9"/>
|
||||
<stop offset="1" style="stop-color:#0099FF"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_2_)" d="M65.72,40.482c1.074,0,1.611,0.381,1.611,1.143c0,0.701-0.321,1.201-0.962,1.5
|
||||
c-0.209,0.119-0.366,0.194-0.471,0.224c-0.065,0.019-0.158,0.037-0.271,0.056c1.98,1.621,3.702,3.544,5.097,5.699
|
||||
c0.117-0.321,0.21-0.658,0.277-1.013l0.09-1.008c0-1.223-0.568-2.081-1.701-2.574c0.776-0.402,1.376-0.94,1.801-1.611
|
||||
c0.425-0.672,0.638-1.418,0.638-2.239c0-0.642-0.198-1.265-0.593-1.868c-0.396-0.605-0.98-1.049-1.757-1.333
|
||||
c-0.433-0.193-0.876-0.328-1.332-0.402c-0.456-0.075-1.003-0.113-1.645-0.113c-0.82,0-1.663,0.124-2.529,0.37
|
||||
c-0.865,0.246-1.6,0.563-2.204,0.952s-1.13,0.907-1.578,1.557c-0.036,0.052-0.066,0.109-0.101,0.163
|
||||
c1.196,0.534,2.341,1.163,3.426,1.874C63.947,40.943,64.68,40.482,65.72,40.482z"/>
|
||||
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="50.0576" y1="87.0566" x2="50.0576" y2="37.8525">
|
||||
<stop offset="0.0056" style="stop-color:#3266A9"/>
|
||||
<stop offset="1" style="stop-color:#0099FF"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_3_)" d="M70.725,49.104c-0.433,1.189-1.208,2.147-2.331,2.871c-1.425,0.918-3.182,1.377-5.271,1.377
|
||||
c-1.179,0-2.175-0.176-2.988-0.525c-0.813-0.35-1.444-0.864-1.891-1.543c-0.448-0.678-0.671-1.481-0.671-2.405l0.022-0.694
|
||||
l0.156-0.693h4.367l-0.028,0.179v0.179v0.246c0,1.164,0.628,1.746,1.884,1.746c0.635,0,1.201-0.217,1.696-0.649
|
||||
c0.495-0.434,0.742-0.94,0.742-1.522c0-0.522-0.194-0.887-0.582-1.097c-0.329-0.208-1.007-0.313-2.036-0.313l0.47-2.754
|
||||
l1.141-0.067c0.083-0.011,0.154-0.022,0.221-0.033c-0.674-0.551-1.378-1.067-2.11-1.546c-0.044,0.096-0.087,0.195-0.125,0.302
|
||||
h-4.185c0.192-0.837,0.49-1.56,0.884-2.175c-3.064-1.372-6.46-2.133-10.034-2.133c-13.588,0-24.603,11.014-24.603,24.601
|
||||
c0,13.59,11.015,24.604,24.603,24.604S74.66,76.043,74.66,62.453C74.66,57.532,73.214,52.949,70.725,49.104z M59.413,59.233
|
||||
l-0.168,1.275c-0.538,2.953-1.511,5.404-2.921,7.35c-1.298,1.835-3.016,3.179-5.153,4.028c-2.138,0.851-4.494,1.274-7.067,1.274
|
||||
H33.731l4.264-24.198h10.441c1.141,0,2.204,0.073,3.189,0.218c0.984,0.146,1.868,0.364,2.651,0.655
|
||||
c1.611,0.537,2.887,1.471,3.827,2.802c0.94,1.332,1.41,2.992,1.41,4.984L59.413,59.233z"/>
|
||||
</g>
|
||||
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="107.3027" y1="105.8555" x2="93.0727" y2="16.0106">
|
||||
<stop offset="0" style="stop-color:#B2B2B2;stop-opacity:0"/>
|
||||
<stop offset="0.2" style="stop-color:#B2B2B2"/>
|
||||
<stop offset="0.8" style="stop-color:#B2B2B2"/>
|
||||
<stop offset="1" style="stop-color:#B2B2B2;stop-opacity:0"/>
|
||||
</linearGradient>
|
||||
<rect x="99.875" y="14.933" fill="url(#SVGID_4_)" width="0.625" height="92"/>
|
||||
<script xmlns=""></script>
|
||||
<path d="M126.531,43.25c0-3.446,2.801-6.25,6.25-6.25h15.624v12.5c0,1.729,1.398,3.125,3.126,3.125h12.5v14.063h-20.313
|
||||
c-3.448,0-6.25,2.801-6.25,6.25V87h-4.688c-3.449,0-6.25-2.801-6.25-6.248V43.25z M164.031,49.5h-12.5V37L164.031,49.5z
|
||||
M143.719,71.375h3.125c3.018,0,5.469,2.451,5.469,5.469s-2.451,5.471-5.469,5.471h-1.563v3.123c0,0.861-0.702,1.563-1.563,1.563
|
||||
c-0.861,0-1.563-0.701-1.563-1.563v-4.686v-7.814C142.156,72.076,142.857,71.375,143.719,71.375z M146.844,79.188
|
||||
c1.3,0,2.343-1.043,2.343-2.344c0-1.299-1.043-2.344-2.343-2.344h-1.563v4.688H146.844z M156.218,71.375h3.125
|
||||
c2.589,0,4.688,2.102,4.688,4.688v6.252c0,2.586-2.1,4.686-4.688,4.686h-3.125c-0.86,0-1.562-0.701-1.562-1.563v-12.5
|
||||
C154.656,72.076,155.357,71.375,156.218,71.375z M159.343,83.875c0.861,0,1.563-0.703,1.563-1.561v-6.252
|
||||
c0-0.861-0.702-1.563-1.563-1.563h-1.563v9.375H159.343z M167.155,72.938c0-0.861,0.703-1.563,1.563-1.563h4.688
|
||||
c0.861,0,1.563,0.701,1.563,1.563s-0.701,1.563-1.563,1.563h-3.124v3.125h3.124c0.861,0,1.563,0.703,1.563,1.563
|
||||
s-0.701,1.564-1.563,1.564h-3.124v4.686c0,0.861-0.703,1.563-1.563,1.563c-0.859,0-1.563-0.701-1.563-1.563v-6.25V72.938z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 4.8 KiB |
@ -7,13 +7,18 @@
|
||||
"modules",
|
||||
"eShop",
|
||||
"d3",
|
||||
"PDF"
|
||||
"PDF",
|
||||
"documents",
|
||||
"invoice",
|
||||
"delivery note",
|
||||
"d3dependencycheck",
|
||||
"id_d3PdfDocuments"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "D3 Data Development (Inh. Thomas Dartsch)",
|
||||
"email": "info@shopmodule.com",
|
||||
"homepage": "http://www.d3data.de",
|
||||
"homepage": "https://www.d3data.de",
|
||||
"role": "Owner"
|
||||
}
|
||||
],
|
||||
@ -21,24 +26,37 @@
|
||||
"license": [
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"extra": {
|
||||
"oxideshop": {
|
||||
"blacklist-filter": [
|
||||
"composer.json",
|
||||
"docs/**/*.*"
|
||||
],
|
||||
"target-directory": "d3/pdfdocuments"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0 || ^8.0",
|
||||
"oxid-esales/oxideshop-ce": "6.3 - 6.14",
|
||||
"spipu/html2pdf": "^5.2",
|
||||
"d3/modcfg": "^5.3.6.000 || ^6"
|
||||
"php": "^8.0",
|
||||
"oxid-esales/oxideshop-ce": "7.0 - 7.2",
|
||||
"spipu/html2pdf": "~5.3.2",
|
||||
"beberlei/assert": "^3.3.2",
|
||||
"symfony/string": "^6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "^9.6",
|
||||
"d3/testingtools": "^1.3.0.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.9",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"boxblinkracer/phpunuhi": "^1.12",
|
||||
"mikey179/vfsstream": "^1.6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"D3\\PdfDocuments\\": "../../../source/modules/d3/pdfdocuments"
|
||||
"D3\\PdfDocuments\\": ""
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/pdfdocuments/.php-cs-fixer.php",
|
||||
|
||||
"phpstan": "./vendor/bin/phpstan --configuration=vendor/d3/pdfdocuments/phpstan.neon analyse",
|
||||
"phpstan-report": "./vendor/bin/phpstan --configuration=vendor/d3/pdfdocuments/phpstan.neon analyse --error-format=json > vendor/d3/pdfdocuments/Tests/phpstan.report.json",
|
||||
|
||||
"phpunit": "XDEBUG_MODE=off ./vendor/bin/phpunit --config=vendor/d3/pdfdocuments/Tests/",
|
||||
"phpunit-line-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/pdfdocuments/Tests/ --coverage-html=vendor/d3/pdfdocuments/Tests/result/coverage",
|
||||
"phpunit-path-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --config=vendor/d3/pdfdocuments/Tests/ --coverage-html=vendor/d3/pdfdocuments/Tests/result/coverage --path-coverage",
|
||||
|
||||
"phpunuhi-validate": "./vendor/bin/phpunuhi validate --configuration=vendor/d3/pdfdocuments/phpunuhi.xml",
|
||||
"phpunuhi-status": "./vendor/bin/phpunuhi status --configuration=vendor/d3/pdfdocuments/phpunuhi.xml"
|
||||
}
|
||||
}
|
||||
|
29
development.md
Normal file
29
development.md
Normal file
@ -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.
|
@ -2,22 +2,61 @@
|
||||
title: Changelog
|
||||
---
|
||||
|
||||
## 1.0.3.1 - (2023-05-09)
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.2.0...rel_2.x)
|
||||
|
||||
## [2.0.2.0](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.1...2.0.2.0) - 2025-01-21
|
||||
### Added
|
||||
- installierbar in OXID 7.2
|
||||
### Fixed
|
||||
- fix multiple documents at once
|
||||
- Syntaxfehler in Twig Templates
|
||||
- Wiederverwendung von Captures in unterschiedlichen Templates der selben Rendererinstanz in Smarty behoben
|
||||
### Changed
|
||||
- Template Renderer Verwendung
|
||||
|
||||
---
|
||||
## [2.0.1.1](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.0...2.0.1.1) - 2024-10-04
|
||||
### Fixed
|
||||
- Syntax der Steuerangaben in Twig-Templates
|
||||
|
||||
## 1.0.3.0 - (2023-01-04)
|
||||
## [2.0.1.0](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.0.0...2.0.1.0) - 2024-10-01
|
||||
### Added
|
||||
- Entwicklungshandbuch
|
||||
- Überladungsblock für Unternehmenslogo
|
||||
### Fixed
|
||||
- CSS wird nicht als Referenz sondern inline eingebunden
|
||||
- Entwicklermodus kann konfiguriert werden
|
||||
- Smarty Templates
|
||||
### Removed
|
||||
- Modul Connector Bedingung
|
||||
|
||||
## [2.0.0.0](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.4.0...2.0.0.0) - 2024-09-12
|
||||
### Added
|
||||
- installierbar in OXID 7.0 && 7.1 (CE 7.0.x - 7.1.x)
|
||||
- Support für Smarty- und Twig-Templates
|
||||
### Removed
|
||||
- Support für OXID < 7.0
|
||||
|
||||
## [1.0.4.0](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.3.1...1.0.4.0) - 2023-12-22
|
||||
### Added
|
||||
- installierbar in OXID 6.5.2 + 6.5.3 (CE 6.14)
|
||||
- Modullogo
|
||||
|
||||
### Changed
|
||||
- behandelt fehlende Bestellung bei auf Bestellungen basierenden Dokumenten
|
||||
|
||||
## [1.0.3.1](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.3.0...1.0.3.1) - 2023-05-09
|
||||
### Fixed
|
||||
- kann mehrere Dokumente auf einmal generieren
|
||||
|
||||
## [1.0.3.0](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.2.0...1.0.3.0) - 2023-01-04
|
||||
### Added
|
||||
- installierbar in OXID 6.4 und 6.5
|
||||
|
||||
---
|
||||
|
||||
## 1.0.2.0 - (2021-04-30)
|
||||
|
||||
## [1.0.2.0](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.1.0...1.0.2.0) - 2021-04-30
|
||||
### Added
|
||||
- installierbar in OXID 6.2.4 und 6.3.0
|
||||
- Dateinamen werden auf Gültigkeit hin korrigiert
|
||||
@ -25,17 +64,11 @@ title: Changelog
|
||||
### Fixed
|
||||
- Setzen der Rechnungsnummer setzt den "neue Bestellung"-Status nicht zurück
|
||||
|
||||
---
|
||||
|
||||
## 1.0.1.0 - (2020-08-20)
|
||||
|
||||
## [1.0.1.0](https://git.d3data.de/D3Public/pdfdokumente/compare/1.0.0.0...1.0.1.0) - 2020-08-20
|
||||
### Changed
|
||||
- Dokumentid für "Rechnung ohne Logo" angepasst
|
||||
|
||||
---
|
||||
|
||||
## 1.0.0.0 - (2020-08-13)
|
||||
|
||||
## [1.0.1.0](https://git.d3data.de/D3Public/pdfdokumente/tag/1.0.0.0) - 2020-08-13
|
||||
#### Added
|
||||
- Framework zur Erstellung unterschiedlichster PDF Dokumente
|
||||
- ermöglicht Generierung von Rechnungen und Lieferscheinen für Bestellungen aus dem Adminbereich
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "<i class='fab fa-d3 d3fa-color-blue'></i> PDF Dokumente",
|
||||
"moduleversion": "1.0.3.1",
|
||||
"moduleversion": "2.0.2.0",
|
||||
"titledesc": "für den Oxid eShop",
|
||||
"author": "D³ Data Development",
|
||||
"moduledate": "09.05.2023",
|
||||
"moduledate": "21.01.2025",
|
||||
"editors": "",
|
||||
"tagline": "",
|
||||
"image": "",
|
||||
|
@ -3,17 +3,15 @@ title: Systemanforderungen
|
||||
---
|
||||
|
||||
* PHP Version
|
||||
* 7.0.x bis 8.x
|
||||
* 8.x
|
||||
* Shopversionen / -editionen
|
||||
* OXID eShop Community Edition (CE), Professional Edition (PE) oder Enterprise Edition (EE) in Compilation Version
|
||||
* 6.1.x
|
||||
* 6.2.x
|
||||
* 6.3.x
|
||||
* 6.4.x
|
||||
* 6.5.x
|
||||
* 7.0.x
|
||||
* 7.1.x
|
||||
* 7.2.x
|
||||
* Themes
|
||||
* Diese Modul bindet sich nicht in Frontendthemes ein und ist daher davon unabhängig
|
||||
* (D3) Modul-Connector ([kostenfrei bei D3 erhältlich](https://www.oxidmodule.com/connector/)) ab Version 5.3.6.0
|
||||
* Template-Engine
|
||||
* Smarty
|
||||
* Twig
|
||||
* Installation via [Composer](https://getcomposer.org)
|
||||
|
@ -2,4 +2,4 @@
|
||||
title: Kompatibilität mit anderen Modulen
|
||||
---
|
||||
|
||||
Das PDF Dokumente-Modul integriert sich auch in die Erweiterung "Auftragsmanager" von (D3) Data Development, sofern dieses im Shop installiert wurde. Diese Integration wurde für die Version 4.0.0.0 des "Auftragsmanager"-Moduls entwickelt.
|
||||
Das PDF Dokumente-Modul integriert sich auch in die Erweiterung "Auftragsmanager" von (D3) Data Development, sofern dieses im Shop installiert wurde. Diese Integration wurde für die Version 6.0.0.0 des "Auftragsmanager"-Moduls entwickelt.
|
||||
|
@ -2,8 +2,7 @@
|
||||
title: Dateien löschen
|
||||
---
|
||||
|
||||
Löschen Sie den Ordner `{$modulefolder}` und seine enthaltenen Elemente aus dem Verzeichnis `source/modules/d3` Ihres Shops.
|
||||
Bestätigen Sie anschließend im Shopadmin unter [ Erweiterungen ] -> [ Module ] -> [ Installierte Shop-Module ] die Nachricht:
|
||||
Sofern nötig, bestätigen Sie im Shopadmin unter [ Erweiterungen ] -> [ Module ] -> [ Installierte Shop-Module ] die Nachricht:
|
||||
|
||||
> Es gibt registrierte Erweiterungen im eShop, deren Verzeichnis nicht vorhanden ist.
|
||||
> Möchten Sie alle Modulinformationen einschließlich Konfigurationseinstellungen und Blockinformationen für Templates löschen?
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: Funktionen
|
||||
---
|
||||
|
||||
Erstellen Sie unterschiedlichste statische oder dynamische PDF-Dokument auf Kopfdruck. Der Dokumentinhalt wird aus Smartytemplates erstellt.
|
||||
Erstellen Sie unterschiedlichste statische oder dynamische PDF-Dokument auf Kopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt.
|
||||
|
||||
An den Bestellungen Ihres OXID-Shops steht Ihnen die Erstellung von Rechnung und Lieferschein zur Verfügung.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: Anpassungen an bestehenden Dokumenten
|
||||
---
|
||||
|
||||
Die Dokumente werden aus Smartytemplates erstellt, die Sie im `Application/views/tpl/documents` finden.
|
||||
Die Dokumente werden aus Templates (Smarty bzw. Twig) erstellt, die Sie im Ordner `views/smarty/documents` bzw. `views/twig/documents` finden.
|
||||
|
||||
Für Änderungen einzelner Dokumentbereiche können Sie die darin notierten Templateblöcke in einem eigenen Modul überladen und deren Inhalt so verändern oder ergänzen. So müssen Sie das Originalmodul nicht verändern.
|
||||
|
||||
|
@ -14,9 +14,9 @@ Layouts können mit inline CSS-Styles definiert werden. Die Einbindung externer
|
||||
|
||||
Beachten Sie bitte, dass auch nur ein CSS-Subset unterstützt wird. Mit etwas CSS-Kreativität sollten sich die üblichen Formatierungen dennoch deutlich einfacher umsetzen lassen, als dies direkt in PHP-Programmierung möglich wäre.
|
||||
|
||||
## Smarty
|
||||
## Templates
|
||||
|
||||
Innerhalb der Templates steht Ihnen die komplette Smarty-Funktionalität zur Verfügung.
|
||||
Innerhalb der Templates steht Ihnen die komplette Twig- bzw. Smarty-Funktionalität zur Verfügung.
|
||||
|
||||
## Debug
|
||||
|
||||
|
164
metadata.php
164
metadata.php
@ -1,90 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* See LICENSE file for license details.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
|
||||
* @link http://www.oxidmodule.com
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Constants as Constants;
|
||||
use D3\PdfDocuments\Modules\Application\Controller\ArticleDetailsController_pdfdocuments;
|
||||
use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
||||
use OxidEsales\Eshop\Application\Controller\ArticleDetailsController;
|
||||
|
||||
/**
|
||||
* Metadata version
|
||||
*/
|
||||
// @codeCoverageIgnoreStart
|
||||
$sMetadataVersion = '2.1';
|
||||
|
||||
$logo = '<img src="https://logos.oxidmodule.com/d3logo.svg" alt="(D3)" style="height:1em;width:1em">';
|
||||
|
||||
$sModuleId = 'd3PdfDocuments';
|
||||
/**
|
||||
* Module information
|
||||
*/
|
||||
$aModule = [
|
||||
'id' => $sModuleId,
|
||||
'id' => Constants::OXID_MODULE_ID,
|
||||
'title' => [
|
||||
'de' => $logo.' PDF-Dokumente',
|
||||
'en' => $logo.' PDF documents',
|
||||
'de' => '(D3) PDF-Dokumente',
|
||||
'en' => '(D3) PDF documents',
|
||||
],
|
||||
'version' => '1.0.3.1',
|
||||
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
|
||||
'version' => '2.0.2.0',
|
||||
'author' => 'D3 Data Development (Inh.: Thomas Dartsch)',
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'http://www.oxidmodule.com/',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
'extend' => [
|
||||
OrderOverview::class => d3_overview_controller_pdfdocuments::class
|
||||
ArticleDetailsController::class => ArticleDetailsController_pdfdocuments::class,
|
||||
OrderOverview::class => d3_overview_controller_pdfdocuments::class,
|
||||
],
|
||||
'controllers' => [],
|
||||
'thumbnail' => 'logo.png',
|
||||
'thumbnail' => 'picture.svg',
|
||||
'templates' => [
|
||||
'd3orderoverview_pdfform.tpl' => 'd3/pdfdocuments/Application/views/tpl/admin/orderoverview_pdfform.tpl',
|
||||
//Admin
|
||||
'@' . Constants::OXID_MODULE_ID . '/admin/d3orderoverview_pdfform.tpl' => 'views/smarty/admin/orderoverview_pdfform.tpl',
|
||||
|
||||
'd3deliverynote_pdf.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/deliverynote.tpl',
|
||||
'd3deliverynoteNoLogo_pdf.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/deliverynoteNoLogo.tpl',
|
||||
'd3delnote_pdf_informations.tpl'=> 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/inc/informations.tpl',
|
||||
'd3delnote_pdf_recipient.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/inc/recipientAddress.tpl',
|
||||
'd3delnote_pdf_salutation.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/inc/salutation.tpl',
|
||||
'd3delnote_pdf_conclusion.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/deliverynote/inc/conclusion.tpl',
|
||||
// Frontend - Flow - Deliverynote
|
||||
'@' . 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',
|
||||
|
||||
'd3invoice_pdf.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/invoice.tpl',
|
||||
'd3invoiceNoLogo_pdf.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/invoiceNoLogo.tpl',
|
||||
'd3invoice_pdf_informations.tpl'=> 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/informations.tpl',
|
||||
'd3invoice_pdf_salutation.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/salutation.tpl',
|
||||
'd3invoice_pdf_conclusion.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/conclusion.tpl',
|
||||
'd3invoice_pdf_payinfo.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/invoice/inc/payinfo.tpl',
|
||||
// Frontend - Flow - Invoice
|
||||
'@' . 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',
|
||||
|
||||
'd3pdfbase.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/base.tpl',
|
||||
'd3pdfheader.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/header.tpl',
|
||||
'd3pdffooter.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/footer.tpl',
|
||||
'd3pdfreturnaddress.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/page/returnaddress.tpl',
|
||||
// Frontend - Flow - Inc - Page
|
||||
'@' . 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',
|
||||
|
||||
'd3pdfaddressarea.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/addressarea.tpl',
|
||||
'd3pdfrecipientaddress.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/recipientAddress.tpl',
|
||||
'd3pdfinformations.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/informations.tpl',
|
||||
'd3pdfdeladdress.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/deliveryaddress.tpl',
|
||||
'd3pdfarticlelist.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/articlelist.tpl',
|
||||
'd3pdfarticlecostsummary.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/articlecostssummary.tpl',
|
||||
'd3pdffoldmarks.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/elements/foldmarks.tpl',
|
||||
// Frontend - Flow - Inc - Elements
|
||||
'@' . 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',
|
||||
|
||||
'd3pdfstyles.css' => 'd3/pdfdocuments/out/src/css/pdfStyling.css',
|
||||
// Frontend - Flow - Inc - Helper
|
||||
'@' . Constants::OXID_MODULE_ID . '/documents/inc/helper/rulers.tpl' => 'views/smarty/documents/inc/helper/rulers.tpl',
|
||||
|
||||
'd3pdfrulers.tpl' => 'd3/pdfdocuments/Application/views/tpl/documents/inc/helper/rulers.tpl',
|
||||
// Frontend - Flow - Inc - Styles
|
||||
'@' . Constants::OXID_MODULE_ID . '/assets/d3pdfstyles.css.tpl' => 'views/smarty/assets/pdfStyling.css.tpl',
|
||||
],
|
||||
'events' => [],
|
||||
'blocks' => [
|
||||
[
|
||||
'template' => 'order_overview.tpl',
|
||||
'block' => 'admin_order_overview_export',
|
||||
'file' => 'Application/views/admin/blocks/order_overview.tpl'
|
||||
]
|
||||
'file' => 'views/smarty/blocks/order_overview.tpl',
|
||||
],
|
||||
],
|
||||
'settings' => [
|
||||
[
|
||||
'group' => $sModuleId.'main',
|
||||
'name' => $sModuleId.'bDev',
|
||||
'group' => Constants::OXID_MODULE_ID.'main',
|
||||
'name' => Constants::OXID_MODULE_ID.'bDev',
|
||||
'type' => 'bool',
|
||||
'value' => false
|
||||
]
|
||||
]
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'main',
|
||||
'name' => Constants::OXID_MODULE_ID.'basicAuthUserName',
|
||||
'type' => 'str',
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'main',
|
||||
'name' => Constants::OXID_MODULE_ID.'basicAuthPassword',
|
||||
'type' => 'password',
|
||||
],
|
||||
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'invoice',
|
||||
'name' => 'invoicePaymentTerm',
|
||||
'type' => 'num',
|
||||
'value' => 7,
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'contents',
|
||||
'name' => Constants::OXID_MODULE_ID.'LogoUrl',
|
||||
'type' => 'str'
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'contents',
|
||||
'name' => Constants::OXID_MODULE_ID.'BackgroundUrl',
|
||||
'type' => 'str'
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'documents',
|
||||
'name' => Constants::OXID_MODULE_ID.'DocInvoice',
|
||||
'type' => 'bool',
|
||||
'value' => true
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'documents',
|
||||
'name' => Constants::OXID_MODULE_ID.'DocInvoiceNoLogo',
|
||||
'type' => 'bool',
|
||||
'value' => true
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'documents',
|
||||
'name' => Constants::OXID_MODULE_ID.'DocDeliveryNote',
|
||||
'type' => 'bool',
|
||||
'value' => true
|
||||
],
|
||||
[
|
||||
'group' => Constants::OXID_MODULE_ID.'documents',
|
||||
'name' => Constants::OXID_MODULE_ID.'DocDeliveryNoteNoLogo',
|
||||
'type' => 'bool',
|
||||
'value' => true
|
||||
],
|
||||
],
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
26
phpunuhi.xml
Normal file
26
phpunuhi.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<phpunuhi
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../boxblinkracer/phpunuhi/config.xsd"
|
||||
bootstrap="../../autoload.php">
|
||||
>
|
||||
<translations>
|
||||
<set name="Frontend">
|
||||
<format>
|
||||
<php/>
|
||||
</format>
|
||||
<locales>
|
||||
<locale name="de">./Application/translations/de/pdfdocuments_translations.php</locale>
|
||||
<locale name="en">./Application/translations/en/pdfdocuments_translations.php</locale>
|
||||
</locales>
|
||||
</set>
|
||||
<set name="Backend">
|
||||
<format>
|
||||
<php/>
|
||||
</format>
|
||||
<locales>
|
||||
<locale name="de">./Application/views/de/translations.php</locale>
|
||||
<locale name="en">./Application/views/en/translations.php</locale>
|
||||
</locales>
|
||||
</set>
|
||||
</translations>
|
||||
</phpunuhi>
|
10
services.yaml
Normal file
10
services.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: false
|
||||
public: true
|
||||
|
||||
D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface:
|
||||
factory: 'oxNew'
|
||||
shared: true
|
||||
arguments:
|
||||
- D3\PdfDocuments\Application\Model\Registries\registryOrderoverview
|
@ -1,10 +1,13 @@
|
||||
[{if $edit && $oView->d3CanExport()}]
|
||||
<br>
|
||||
[{assign var="devmode" value=$oView->d3PdfDocsIsDevMode()}]
|
||||
|
||||
<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,12 +17,13 @@
|
||||
</td>
|
||||
<td style="vertical-align: top; text-align: right" class="edittext">
|
||||
<label for="pdftype">[{oxmultilang ident="D3_PDFDOCUMENTS_PDF_TYPE" suffix="COLON"}]</label>:
|
||||
<select id="pdftype" name="pdftype" class="editinput" style="width:80px;">
|
||||
<select id="pdftype" name="pdftype" class="editinput" style="min-width:150px;">
|
||||
[{block name="d3_pdfdocuments_order_overview_pdfTypeOptions"}]
|
||||
[{assign var="generatorList" value=$oView->d3getGeneratorList()}]
|
||||
[{foreach from=$generatorList->getList() item="generator"}]
|
||||
[{if $d3PdfDocumentGeneratorList}]
|
||||
[{foreach from=$d3PdfDocumentGeneratorList->getList() item="generator"}]
|
||||
<option value="[{$generator->getRequestId()}]">[{oxmultilang ident=$generator->getTitleIdent()}]</option>
|
||||
[{/foreach}]
|
||||
[{/if}]
|
||||
[{/block}]
|
||||
</select>
|
||||
</td>
|
||||
@ -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="min-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>
|
3
views/smarty/blocks/order_overview.tpl
Normal file
3
views/smarty/blocks/order_overview.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
[{$smarty.block.parent}]
|
||||
|
||||
[{include file="@d3PdfDocuments/admin/d3orderoverview_pdfform.tpl"}]
|
46
views/smarty/documents/deliverynote/deliverynote.tpl
Normal file
46
views/smarty/documents/deliverynote/deliverynote.tpl
Normal file
@ -0,0 +1,46 @@
|
||||
[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="showLogo" value=$showLogo|default:true}]
|
||||
|
||||
[{capture assign="pdfBlock_style"}]
|
||||
[{block name="pdfStyles"}]
|
||||
[{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture assign="pdfBlock_header"}]
|
||||
[{block name="pdfHeader"}]
|
||||
[{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture assign="pdfBlock_content"}]
|
||||
[{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}]
|
||||
|
||||
[{block name="pdfAddressArea"}]
|
||||
[{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.tpl" documentinformationfile="@d3PdfDocuments/documents/deliverynote/informations.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfSalutation"}]
|
||||
[{include file="@d3PdfDocuments/documents/deliverynote/salutation.tpl"}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfArticleList"}]
|
||||
[{include file="@d3PdfDocuments/documents/inc/elements/articlelist.tpl" showPrices=false}]
|
||||
[{/block}]
|
||||
|
||||
[{block name="pdfConclusion"}]
|
||||
[{include file="@d3PdfDocuments/documents/deliverynote/conclusion.tpl"}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{capture assign="pdfBlock_footer"}]
|
||||
[{block name="pdfFooter"}]
|
||||
[{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}]
|
||||
[{/block}]
|
||||
[{/capture}]
|
||||
|
||||
[{include file="@d3PdfDocuments/documents/inc/page/base.tpl" pagePadding=$pagePadding}]
|
@ -0,0 +1 @@
|
||||
[{include file="@d3PdfDocuments/documents/deliverynote/deliverynote.tpl" showLogo=false}]
|
13
views/smarty/documents/inc/elements/addressarea.tpl
Normal file
13
views/smarty/documents/inc/elements/addressarea.tpl
Normal file
@ -0,0 +1,13 @@
|
||||
[{assign var="backaddressfile" value=$backaddressfile|default:"@d3PdfDocuments/documents/inc/page/returnaddress.tpl"}]
|
||||
[{assign var="addressfile" value=$addressfile|default:"@d3PdfDocuments/documents/inc/elements/recipientAddress.tpl"}]
|
||||
|
||||
<div class="addressarea">
|
||||
<div class="returnAddress">
|
||||
<div>
|
||||
[{include file=$backaddressfile}]
|
||||
</div>
|
||||
</div>
|
||||
<div class="recipientAddress">
|
||||
[{include file=$addressfile}]
|
||||
</div>
|
||||
</div>
|
@ -54,7 +54,7 @@
|
||||
<nobreak>
|
||||
<table class="article_costs_table">
|
||||
[{block name="d3_article_costs_summary"}]
|
||||
[{include file="d3pdfarticlecostsummary.tpl"}]
|
||||
[{include file="@d3PdfDocuments/documents/inc/elements/articlecostssummary.tpl"}]
|
||||
[{/block}]
|
||||
</table>
|
||||
</nobreak>
|
@ -1,7 +1,7 @@
|
||||
[{assign var="defaultPagePadding" value=","|explode:"45,15,25,25"}] [{* top, right, bottom, left *}]
|
||||
[{assign var="pagePadding" value=$pagePadding|default:$defaultPagePadding}]
|
||||
|
||||
<style type="text/css">
|
||||
<style>
|
||||
.marks {
|
||||
position: absolute;
|
||||
left: [{math equation="left - padding" left=5 padding=$pagePadding.3}]mm ;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user