Compare commits
4 Commits
dev_2.x
...
dev_2.x_da
Author | SHA1 | Date | |
---|---|---|---|
3a0db1dfb6 | |||
b6fc417016 | |||
5e1195aa40 | |||
ea2dc48b89 |
@ -27,29 +27,27 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServ
|
|||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class orderOverviewPdfGenerator
|
class orderOverviewPdfGenerator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws noPdfHandlerFoundException
|
||||||
|
*/
|
||||||
public function generatePdf(Order $order, int $iSelLang = 0): void
|
public function generatePdf(Order $order, int $iSelLang = 0): void
|
||||||
{
|
{
|
||||||
try {
|
$Pdf = $this->getPdfClass();
|
||||||
$Pdf = $this->getPdfClass();
|
|
||||||
|
|
||||||
/** @var ModuleSettingService $settingsService */
|
/** @var ModuleSettingService $settingsService */
|
||||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||||
|
|
||||||
$Pdf->setDevelopmentMode(
|
$Pdf->setDevelopmentMode(
|
||||||
$settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID) &&
|
$settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID) &&
|
||||||
Registry::getRequest()->getRequestEscapedParameter('devmode')
|
Registry::getRequest()->getRequestEscapedParameter('devmode')
|
||||||
);
|
);
|
||||||
$Pdf->setOrder($order);
|
$Pdf->setOrder($order);
|
||||||
$Pdf->downloadPdf($iSelLang);
|
$Pdf->downloadPdf($iSelLang);
|
||||||
// @codeCoverageIgnoreStart
|
|
||||||
} catch (Throwable $exception) {
|
|
||||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
|
||||||
}
|
|
||||||
// @codeCoverageIgnoreEnd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,8 +23,6 @@ use OxidEsales\Eshop\Core\Base;
|
|||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\UtilsView;
|
use OxidEsales\Eshop\Core\UtilsView;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleConfigurationNotFoundException;
|
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||||
@ -74,8 +72,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws Html2PdfException
|
* @throws Html2PdfException
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function genPdf(string $filename, int $language = 0, string $target = self::PDF_DESTINATION_STDOUT): ?string
|
public function genPdf(string $filename, int $language = 0, string $target = self::PDF_DESTINATION_STDOUT): ?string
|
||||||
@ -102,8 +98,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws Html2PdfException
|
* @throws Html2PdfException
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function downloadPdf(int $language = 0): void
|
public function downloadPdf(int $language = 0): void
|
||||||
@ -125,8 +119,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws Html2PdfException
|
* @throws Html2PdfException
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function savePdfFile(string $path, int $language = 0): void
|
public function savePdfFile(string $path, int $language = 0): void
|
||||||
@ -151,8 +143,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws Html2PdfException
|
* @throws Html2PdfException
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getPdfContent(int $language = 0): ?string
|
public function getPdfContent(int $language = 0): ?string
|
||||||
@ -189,8 +179,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getHTMLContent(int $language = 0): string
|
public function getHTMLContent(int $language = 0): string
|
||||||
@ -215,12 +203,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $content
|
|
||||||
* @return string
|
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
*/
|
*/
|
||||||
protected function addBasicAuth(string $content): string
|
protected function addBasicAuth(string $content): string
|
||||||
{
|
{
|
||||||
|
@ -23,9 +23,11 @@ use OxidEsales\Eshop\Application\Model\Order;
|
|||||||
use OxidEsales\Eshop\Application\Model\Payment;
|
use OxidEsales\Eshop\Application\Model\Payment;
|
||||||
use OxidEsales\Eshop\Application\Model\User;
|
use OxidEsales\Eshop\Application\Model\User;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||||
use Throwable;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
||||||
{
|
{
|
||||||
@ -103,18 +105,31 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ModuleSettingNotFountException
|
||||||
|
*/
|
||||||
public function getPaymentTerm(): int
|
public function getPaymentTerm(): int
|
||||||
{
|
{
|
||||||
try {
|
/** @var ModuleConfigurationDaoBridge $configurationBridge */
|
||||||
/** @var ModuleSettingService $settingService */
|
$configurationBridge = ContainerFactory::getInstance()->getContainer()
|
||||||
$settingService = ContainerFactory::getInstance()->getContainer()
|
->get(ModuleConfigurationDaoBridgeInterface::class);
|
||||||
->get(ModuleSettingServiceInterface::class);
|
$configuration = $configurationBridge->get(Constants::OXID_MODULE_ID);
|
||||||
return $settingService->getInteger('invoicePaymentTerm', Constants::OXID_MODULE_ID);
|
|
||||||
} catch (Throwable) {
|
return max(
|
||||||
return 7;
|
$configuration->hasModuleSetting('invoicePaymentTerm') ?
|
||||||
}
|
(int)$configuration->getModuleSetting('invoicePaymentTerm')->getValue() :
|
||||||
|
7,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws ModuleSettingNotFountException
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
public function getPayableUntilDate(): false|int
|
public function getPayableUntilDate(): false|int
|
||||||
{
|
{
|
||||||
$startDate = $this->getOrder()->getFieldData('oxbilldate');
|
$startDate = $this->getOrder()->getFieldData('oxbilldate');
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,6 @@ use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
|||||||
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
|
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleConfigurationNotFoundException;
|
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@ -21,8 +19,6 @@ trait registryTrait
|
|||||||
/**
|
/**
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ModuleConfigurationNotFoundException
|
|
||||||
* @throws ModuleSettingNotFountException
|
|
||||||
* @throws wrongPdfGeneratorInterface
|
* @throws wrongPdfGeneratorInterface
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -78,5 +78,7 @@ return [
|
|||||||
'D3_PDFDOCUMENTS_USTID' => 'Ust.-ID',
|
'D3_PDFDOCUMENTS_USTID' => 'Ust.-ID',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT-Code',
|
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT-Code',
|
||||||
|
|
||||||
|
'D3_PDFDOCUMENTS_ARTICLE_DATASHEET' => 'Artikel Datenblatt',
|
||||||
];
|
];
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
@ -77,5 +77,7 @@ return [
|
|||||||
'D3_PDFDOCUMENTS_USTID' => 'VAT ID',
|
'D3_PDFDOCUMENTS_USTID' => 'VAT ID',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT Code',
|
'D3_PDFDOCUMENTS_BANK_BANKCODE' => 'BIC/SWIFT Code',
|
||||||
|
|
||||||
|
'D3_PDFDOCUMENTS_ARTICLE_DATASHEET' => 'Article data sheet',
|
||||||
];
|
];
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
@ -14,8 +14,12 @@
|
|||||||
namespace D3\PdfDocuments\Modules\Application\Controller {
|
namespace D3\PdfDocuments\Modules\Application\Controller {
|
||||||
|
|
||||||
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
||||||
|
use OxidEsales\Eshop\Application\Controller\ArticleDetailsController;
|
||||||
|
|
||||||
class d3_overview_controller_pdfdocuments_parent extends OrderOverview
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -17,10 +17,12 @@ use Assert\Assert;
|
|||||||
use Assert\InvalidArgumentException;
|
use Assert\InvalidArgumentException;
|
||||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||||
use D3\PdfDocuments\Application\Model\Constants;
|
use D3\PdfDocuments\Application\Model\Constants;
|
||||||
|
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||||
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
|
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
|
use Exception;
|
||||||
use Doctrine\DBAL\Exception as DBALException;
|
use Doctrine\DBAL\Exception as DBALException;
|
||||||
use Doctrine\DBAL\ParameterType;
|
use Doctrine\DBAL\ParameterType;
|
||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
@ -34,16 +36,12 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServ
|
|||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
|
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
|
||||||
{
|
{
|
||||||
protected ?string $generatorError = null;
|
protected ?string $generatorError = null;
|
||||||
protected bool $doReload = false;
|
protected bool $doReload = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$this->addTplParam('d3PdfDocumentGeneratorList', $this->d3getGeneratorList());
|
$this->addTplParam('d3PdfDocumentGeneratorList', $this->d3getGeneratorList());
|
||||||
@ -78,17 +76,15 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
|||||||
return parent::render();
|
return parent::render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
public function d3PdfDocsIsDevMode(): bool
|
public function d3PdfDocsIsDevMode(): bool
|
||||||
{
|
{
|
||||||
try {
|
/** @var ModuleSettingService $settingsService */
|
||||||
/** @var ModuleSettingService $settingsService */
|
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID);
|
||||||
return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID);
|
|
||||||
} catch (Throwable $exception) {
|
|
||||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,6 +116,11 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws noPdfHandlerFoundException
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
public function d3CreatePDF(): void
|
public function d3CreatePDF(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -135,7 +136,7 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
|||||||
Assert::that($oOrder->load($soxId))->true();
|
Assert::that($oOrder->load($soxId))->true();
|
||||||
$generator = $this->d3PdfGetGeneratorController();
|
$generator = $this->d3PdfGetGeneratorController();
|
||||||
$generator->generatePdf($oOrder, $language);
|
$generator->generatePdf($oOrder, $language);
|
||||||
} catch (Throwable $exception) {
|
} catch (Exception $exception) {
|
||||||
$this->doReload = true;
|
$this->doReload = true;
|
||||||
Registry::getLogger()->error($exception->getMessage(), [ 'exception' => $exception ]);
|
Registry::getLogger()->error($exception->getMessage(), [ 'exception' => $exception ]);
|
||||||
$this->generatorError = 'PDF documents: ' . $exception->getMessage();
|
$this->generatorError = 'PDF documents: ' . $exception->getMessage();
|
||||||
@ -161,13 +162,15 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function d3getGeneratorList(): ?registryOrderoverview
|
public function d3getGeneratorList(): ?registryOrderoverview
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return ContainerFactory::getInstance()->getContainer()->get( registryOrderoverviewInterface::class );
|
return ContainerFactory::getInstance()->getContainer()->get( registryOrderoverviewInterface::class );
|
||||||
} catch (Throwable $exception) {
|
} catch (Exception $exception) {
|
||||||
Registry::getUtilsView()->addErrorToDisplay($exception->getMessage());
|
Registry::getUtilsView()->addErrorToDisplay($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +43,9 @@ Detailed installation instructions can be found [online](https://docs.oxidmodule
|
|||||||
|
|
||||||
## Credits:
|
## Credits:
|
||||||
|
|
||||||
- PDF logo made by Dimitriy Morilubov by www.flaticon.com
|
- PDF icon made by Dimitriy Morilubov by www.flaticon.com
|
||||||
- example company logo by https://www.logologo.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
|
## License
|
||||||
|
|
||||||
|
@ -43,8 +43,9 @@ Eine detaillierte Installationsanleitung finden Sie [online](https://docs.oxidmo
|
|||||||
|
|
||||||
## Danksagung:
|
## 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/
|
- Beispielfirmenlogo von https://www.logologo.com/
|
||||||
|
- Hintergrundgrafik des Artikeldatenblatts [designed by Harryarts / Freepik](http://www.freepik.com)
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
|
@ -13,17 +13,37 @@
|
|||||||
|
|
||||||
namespace D3\PdfDocuments\Tests\Unit\Application\Controller;
|
namespace D3\PdfDocuments\Tests\Unit\Application\Controller;
|
||||||
|
|
||||||
|
use Assert\InvalidArgumentException;
|
||||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
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\Documents\invoicePdf;
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
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\Interfaces\pdfdocumentsOrderInterface;
|
||||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||||
use D3\TestingTools\Development\CanAccessRestricted;
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use Generator;
|
use Generator;
|
||||||
use OxidEsales\Eshop\Application\Model\Order;
|
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 PHPUnit\Framework\TestCase;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||||
|
use Spipu\Html2Pdf\Html2Pdf;
|
||||||
|
use Symfony\Component\String\UnicodeString;
|
||||||
|
use Twig\Error\Error;
|
||||||
|
|
||||||
class orderOverviewPdfGeneratorTest extends TestCase
|
class orderOverviewPdfGeneratorTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -15,12 +15,12 @@ namespace D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses;
|
|||||||
|
|
||||||
use Assert\InvalidArgumentException;
|
use Assert\InvalidArgumentException;
|
||||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||||
use Exception;
|
|
||||||
use Generator;
|
use Generator;
|
||||||
use OxidEsales\Eshop\Application\Model\Order;
|
use OxidEsales\Eshop\Application\Model\Order;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
||||||
@ -155,64 +155,47 @@ abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
|||||||
* @test
|
* @test
|
||||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
* @dataProvider getPaymentTermDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGetPaymentTerm(): void
|
public function testGetPaymentTerm(bool $settingExist, $settingValue, int $expected): void
|
||||||
{
|
{
|
||||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
$setting = $this->getMockBuilder(Setting::class)
|
||||||
->disableOriginalConstructor()
|
->onlyMethods(['getValue'])
|
||||||
->onlyMethods(['getInteger'])
|
|
||||||
->getMock();
|
->getMock();
|
||||||
$settingService->method('getInteger')->willReturn(10);
|
$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([
|
$this->addServiceMocks([
|
||||||
ModuleSettingServiceInterface::class => $settingService,
|
ModuleConfigurationDaoBridgeInterface::class => $configurationBridge,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sut = oxNew($this->sutClassName);
|
$sut = oxNew($this->sutClassName);
|
||||||
|
|
||||||
try {
|
$this->assertSame(
|
||||||
$this->assertSame(
|
$expected,
|
||||||
10,
|
$this->callMethod(
|
||||||
$this->callMethod(
|
$sut,
|
||||||
$sut,
|
'getPaymentTerm'
|
||||||
'getPaymentTerm'
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
ContainerFactory::resetContainer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function getPaymentTermDataProvider(): Generator
|
||||||
* @test
|
|
||||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function testGetPaymentTermUnknownSetting(): void
|
|
||||||
{
|
{
|
||||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
yield 'setting exists' => [true, 10, 10];
|
||||||
->disableOriginalConstructor()
|
yield 'setting value to low' => [true, -1, 0];
|
||||||
->onlyMethods(['getInteger'])
|
yield 'setting does not exist' => [false, null, 7];
|
||||||
->getMock();
|
|
||||||
$settingService->method('getInteger')->willThrowException(new Exception());
|
|
||||||
|
|
||||||
$this->addServiceMocks([
|
|
||||||
ModuleSettingServiceInterface::class => $settingService,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$sut = oxNew($this->sutClassName);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->assertSame(
|
|
||||||
7,
|
|
||||||
$this->callMethod(
|
|
||||||
$sut,
|
|
||||||
'getPaymentTerm'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
ContainerFactory::resetContainer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ use org\bovigo\vfs\vfsStream;
|
|||||||
use OxidEsales\Eshop\Core\Config;
|
use OxidEsales\Eshop\Core\Config;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\Utils;
|
use OxidEsales\Eshop\Core\Utils;
|
||||||
|
use OxidEsales\Eshop\Core\UtilsView;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Exceptions;
|
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Exceptions;
|
||||||
|
|
||||||
|
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||||
use D3\TestingTools\Development\CanAccessRestricted;
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
@ -14,13 +14,19 @@
|
|||||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
||||||
|
|
||||||
use D3\PdfDocuments\Application\Model\Constants;
|
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\Exceptions\wrongPdfGeneratorInterface;
|
||||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||||
|
use D3\PdfDocuments\Tests\Unit\Helpers\nonOrderDocument;
|
||||||
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
||||||
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
|
use Exception;
|
||||||
use Generator;
|
use Generator;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
|
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
class registryOrderOverviewTest extends registryAbstract
|
class registryOrderOverviewTest extends registryAbstract
|
||||||
|
@ -70,8 +70,9 @@ class orderDocument implements pdfdocumentsOrderInterface
|
|||||||
return 'filenameExtension';
|
return 'filenameExtension';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDevelopmentMode(bool $devMode): void
|
public function setDevelopmentMode(bool $devMode)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOrder(Order $order): void
|
public function setOrder(Order $order): void
|
||||||
|
@ -13,7 +13,16 @@
|
|||||||
|
|
||||||
namespace D3\PdfDocuments\Tests\Unit\Modules\Application\Controller;
|
namespace D3\PdfDocuments\Tests\Unit\Modules\Application\Controller;
|
||||||
|
|
||||||
|
use Assert\InvalidArgumentException;
|
||||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
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\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
|
||||||
use D3\TestingTools\Development\CanAccessRestricted;
|
use D3\TestingTools\Development\CanAccessRestricted;
|
||||||
use Doctrine\DBAL\Exception;
|
use Doctrine\DBAL\Exception;
|
||||||
@ -22,6 +31,8 @@ use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
|
|||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Generator;
|
use Generator;
|
||||||
use OxidEsales\Eshop\Application\Model\Order;
|
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\Registry;
|
||||||
use OxidEsales\Eshop\Core\Utils;
|
use OxidEsales\Eshop\Core\Utils;
|
||||||
use OxidEsales\Eshop\Core\UtilsView;
|
use OxidEsales\Eshop\Core\UtilsView;
|
||||||
@ -30,9 +41,19 @@ use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactory;
|
|||||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
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\MockObject\Rule\InvocationOrder;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
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
|
class d3_overview_controller_pdfdocumentsTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -123,35 +144,6 @@ class d3_overview_controller_pdfdocumentsTest extends TestCase
|
|||||||
yield 'is prod' => [false];
|
yield 'is prod' => [false];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3PdfDocsIsDevMode
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function testPdfDocsIsDevModeUnknownSetting(): void
|
|
||||||
{
|
|
||||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
|
||||||
->onlyMethods(['getBoolean'])
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$settingService->method('getBoolean')->willThrowException(new Exception());
|
|
||||||
|
|
||||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
|
||||||
|
|
||||||
$sut = oxNew(d3_overview_controller_pdfdocuments::class);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->assertFalse(
|
|
||||||
$this->callMethod(
|
|
||||||
$sut,
|
|
||||||
'd3PdfDocsIsDevMode'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
ContainerFactory::resetContainer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3CanExport
|
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3CanExport
|
||||||
|
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 |
@ -12,8 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use D3\PdfDocuments\Application\Model\Constants as Constants;
|
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 D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
|
||||||
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
|
||||||
|
use OxidEsales\Eshop\Application\Controller\ArticleDetailsController;
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
$sMetadataVersion = '2.1';
|
$sMetadataVersion = '2.1';
|
||||||
@ -29,6 +31,7 @@ $aModule = [
|
|||||||
'email' => 'support@shopmodule.com',
|
'email' => 'support@shopmodule.com',
|
||||||
'url' => 'https://www.oxidmodule.com/',
|
'url' => 'https://www.oxidmodule.com/',
|
||||||
'extend' => [
|
'extend' => [
|
||||||
|
ArticleDetailsController::class => ArticleDetailsController_pdfdocuments::class,
|
||||||
OrderOverview::class => d3_overview_controller_pdfdocuments::class,
|
OrderOverview::class => d3_overview_controller_pdfdocuments::class,
|
||||||
],
|
],
|
||||||
'controllers' => [],
|
'controllers' => [],
|
||||||
|
205
views/twig/documents/article/datasheet.html.twig
Normal file
205
views/twig/documents/article/datasheet.html.twig
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
{% set pagePadding = "45,15,25,25"|split(",") %} {# top, right, bottom, left #}
|
||||||
|
{#{% set hideHeader = 2..100 %}#}
|
||||||
|
{#{% set hideFooter = 1..100 %}#}
|
||||||
|
{% set bgImage = oViewConf.getModulePath('d3PdfDocuments', 'out/img/ads_bg.jpg') %}
|
||||||
|
|
||||||
|
{% set showLogo = showLogo|default(1) %}
|
||||||
|
|
||||||
|
{% set pdfBlock_style %}
|
||||||
|
{% block pdfStyles %}
|
||||||
|
{% include "@d3PdfDocuments/assets/pdfStyling.css.twig" %}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
padding-left: 5mm;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.header {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
div.header img {
|
||||||
|
height: 20mm; {# smaller logo from page 2 #}
|
||||||
|
}
|
||||||
|
div.header-1 img {
|
||||||
|
height: inherit; {# default logo size on page 1 #}
|
||||||
|
}
|
||||||
|
div.header .address {
|
||||||
|
position: absolute; font-size: 3mm; top: 42mm; left: 155mm; text-align: center
|
||||||
|
}
|
||||||
|
div.header-2 .address {
|
||||||
|
font-size: 2.5mm; top: 33mm; left: 165mm
|
||||||
|
}
|
||||||
|
{% endblock %}
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
|
{% set pdfBlock_header %}
|
||||||
|
{% block pdfHeader %}
|
||||||
|
{# {% include "@d3PdfDocuments/documents/inc/page/header.html.twig" with {showLogo: showLogo} %}#}
|
||||||
|
|
||||||
|
{% set article = document.getArticle() %}
|
||||||
|
<div style="position: relative; left: 25mm; top: 7mm; color: #FFF">
|
||||||
|
<h3>{{ article.getFieldData('oxtitle') }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="header header-[[page_cu]]">
|
||||||
|
{% if showLogo %}
|
||||||
|
{% block pdfHeaderLogo %}
|
||||||
|
{% set logoUrl = config.getConfigParam('d3PdfDocumentsLogoUrl') | default( oViewConf.getModulePath('d3PdfDocuments', 'out/img/clogo.jpg') ) %}
|
||||||
|
<img class="logo" alt="Logo" src="{{ logoUrl }}">
|
||||||
|
{% endblock %}
|
||||||
|
{% endif %}
|
||||||
|
<div class="address">
|
||||||
|
{{ shop.getFieldData('oxname') }}<br>
|
||||||
|
{{ shop.getFieldData('oxstreet') }}<br>
|
||||||
|
{{ shop.getFieldData('oxzip') }} {{ shop.getFieldData('oxcity') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
|
{% set pdfBlock_content %}
|
||||||
|
{# {% include "@d3PdfDocuments/documents/inc/helper/rulers.html.twig" with {pagePadding: pagePadding} %}#}
|
||||||
|
{% include "@d3PdfDocuments/documents/inc/elements/foldmarks.html.twig" with {pagePadding: pagePadding} %}
|
||||||
|
|
||||||
|
{% set article = document.getArticle() %}
|
||||||
|
<div style="position: relative; top: 0;">
|
||||||
|
{# <h3>{{ article.getFieldData('oxtitle') }}</h3>#}
|
||||||
|
<nobreak>
|
||||||
|
<p>
|
||||||
|
<div class="desc">
|
||||||
|
{{ translate({ ident: "ARTNUM", suffix: "COLON" }) }}
|
||||||
|
</div>
|
||||||
|
<div class="value">
|
||||||
|
{{ article.getFieldData('oxartnum') }}
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
</nobreak>
|
||||||
|
<nobreak>
|
||||||
|
<p>
|
||||||
|
<div class="desc">
|
||||||
|
{{ translate({ ident: "MANUFACTURER", suffix: "COLON" }) }}
|
||||||
|
</div>
|
||||||
|
<div class="value">
|
||||||
|
{{ article.getManufacturer().getTitle() }}
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
</nobreak>
|
||||||
|
<nobreak>
|
||||||
|
<p>
|
||||||
|
<div class="desc">
|
||||||
|
Link zum Shop:
|
||||||
|
</div>
|
||||||
|
<div class="value">
|
||||||
|
<a href="{{ utilsUrl.prepareUrlForNoSession(article.getLink()) }}">
|
||||||
|
{{ utilsUrl.prepareUrlForNoSession(article.getLink()) }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
</nobreak>
|
||||||
|
<qrcode value="{{ utilsUrl.prepareUrlForNoSession(article.getLink()) }}" style="position: absolute; top: 11mm; left: 133mm; width: 30mm; background-color: white; color: black;"></qrcode>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<p>{{ article.getFieldData('oxshortdesc') }}</p>
|
||||||
|
<p style="text-align: center">
|
||||||
|
<img alt="{{ article.getFieldData('oxtitle') }}" style="width: 50%" src="{{ article.getThumbnailUrl() }}">
|
||||||
|
</p>
|
||||||
|
<p>{{ article.getLongDescription() }}</p>
|
||||||
|
<p>
|
||||||
|
{% set attributes = article.getAttributes() %}
|
||||||
|
{% if attributes %}
|
||||||
|
<h4 class="desc">Eigenschaften:</h4>
|
||||||
|
<div class="value">
|
||||||
|
<table>
|
||||||
|
{% for oAttr in attributes %}
|
||||||
|
<tr>
|
||||||
|
<td id="attrTitle_{{ loop.index }}">{{ oAttr.getFieldData('oxtitle') }}:</td>
|
||||||
|
<td id="attrValue_{{ loop.index }}">{{ oAttr.getFieldData('oxvalue') }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
<nobreak>
|
||||||
|
<div class="desc">
|
||||||
|
Preis:
|
||||||
|
</div>
|
||||||
|
<div class="value">
|
||||||
|
{% if article.getPrice() %}
|
||||||
|
{% set sFrom = "" %}
|
||||||
|
{% set oPrice = article.getPrice() %}
|
||||||
|
{% if article.isParentNotBuyable() %}
|
||||||
|
{% set oPrice = article.getVarMinPrice() %}
|
||||||
|
{% if article.isRangePrice() %}
|
||||||
|
{% set sFrom = "PRICE_FROM"|translate %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<span {% if article.getTPrice() %} class="text-danger"{% endif %}>
|
||||||
|
<span class="price-from">{{ sFrom }}</span>
|
||||||
|
<span class="price">{{ format_price(oPrice, { currency: currency }) }}</span>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% hasrights { ident: "SHOWARTICLEPRICE" } %}
|
||||||
|
{% set oUnitPrice = article.getUnitPrice() %}
|
||||||
|
{% if oUnitPrice %}
|
||||||
|
<div class="ppu" aria-label="{{ translate({ ident: "WEIGHT" }) }}">
|
||||||
|
{{ format_price(oUnitPrice, { currency: currency }) }}/{{ article.getUnitName() }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endhasrights %}
|
||||||
|
</div>
|
||||||
|
</nobreak>
|
||||||
|
<nobreak>
|
||||||
|
<h4 class="desc">Verfügbarkeit:</h4>
|
||||||
|
<div class="value">
|
||||||
|
{% if article.getStockStatus() == -1 %}
|
||||||
|
<span class="text-danger">?</span>
|
||||||
|
{% if article.oxarticles__oxnostocktext.value %}
|
||||||
|
{{ article.oxarticles__oxnostocktext.value }}
|
||||||
|
{% elseif oViewConf.getStockOffDefaultMessage() %}
|
||||||
|
{{ translate({ ident: "MESSAGE_NOT_ON_STOCK" }) }}
|
||||||
|
{% endif %}
|
||||||
|
{% if article.getDeliveryDate() %}
|
||||||
|
{{ translate({ ident: "AVAILABLE_ON" }) }} {{ article.getDeliveryDate() }}
|
||||||
|
{% endif %}
|
||||||
|
{% elseif article.getStockStatus() == 1 %}
|
||||||
|
<span class="text-warning">?</span> {{ translate({ ident: "LOW_STOCK" }) }}
|
||||||
|
{% elseif article.getStockStatus() == 0 %}
|
||||||
|
<div style="width: 5mm; height: 5mm; background-color: darkgreen; float: left"></div>
|
||||||
|
{% if article.oxarticles__oxstocktext.value %}
|
||||||
|
{{ article.oxarticles__oxstocktext.value }}
|
||||||
|
{% elseif oViewConf.getStockOnDefaultMessage() %}
|
||||||
|
{{ translate({ ident: "READY_FOR_SHIPPING" }) }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</nobreak>
|
||||||
|
<nobreak>
|
||||||
|
<p>
|
||||||
|
<h4 class="desc">Galerie</h4>
|
||||||
|
{% for picture in article.getPictureGallery().Pics %}
|
||||||
|
<span style="width: 25%; border: 1px solid silver">
|
||||||
|
<img style="width: 100%" src="{{ picture }}" alt="{{ article.getFieldData('oxtitle') }}">
|
||||||
|
</span>
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
</nobreak>
|
||||||
|
<p>
|
||||||
|
Vielen Dank für Ihr Interesse an unserem Sortiment.<br>
|
||||||
|
Kontaktieren Sie uns gern telefonisch oder nutzen Sie unsere Online-Shop unter <a href="{{ oViewConf.getShopUrl() }}">{{ oViewConf.getShopUrl() }}</a>.
|
||||||
|
</p>
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
|
{% set pdfBlock_footer %}
|
||||||
|
{% block pdfFooter %}
|
||||||
|
<p style="position: absolute; bottom: 5mm; text-align: right; margin-right: 5mm; color: #FFF; font-size: 2.5mm">Stand: {{ "now"|date("d.m.Y H:i:s") }}</p>
|
||||||
|
{% endblock %}
|
||||||
|
{% endset %}
|
||||||
|
|
||||||
|
{% include "@d3PdfDocuments/documents/inc/page/base.html.twig" with {pagePadding: pagePadding} %}
|
Reference in New Issue
Block a user