pdfdokumente/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php

84 lines
3.1 KiB
PHP
Raw Permalink Normal View History

2020-05-19 16:06:32 +02:00
<?php
2020-05-30 00:52:41 +02:00
/**
2020-07-04 23:25:24 +02:00
* See LICENSE file for license details.
2020-05-30 00:52:41 +02:00
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
2020-07-04 23:25:24 +02:00
* @author D3 Data Development - Max Buhe <support@shopmodule.com>
* @link http://www.oxidmodule.com
2020-05-30 00:52:41 +02:00
*/
namespace D3\PdfDocuments\Modules\Application\Controller;
2020-05-19 16:06:32 +02:00
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
2020-07-03 20:04:21 +02:00
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
2020-05-30 00:52:41 +02:00
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
2020-05-30 01:02:50 +02:00
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
2024-12-10 10:27:53 +01:00
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\QueryBuilder;
2020-05-20 11:51:48 +02:00
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\DatabaseProvider;
2020-07-03 20:04:21 +02:00
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
2020-05-20 11:51:48 +02:00
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\TableViewNameGenerator;
2024-12-10 10:27:53 +01:00
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
2020-05-20 11:51:48 +02:00
2020-05-19 16:06:32 +02:00
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
{
2024-12-10 10:27:53 +01:00
/**
2020-07-03 20:04:21 +02:00
* @return bool
2024-12-10 10:27:53 +01:00
* @throws Exception
2020-07-03 20:04:21 +02:00
*/
2024-12-10 10:27:53 +01:00
public function d3CanExport(): bool
2020-07-03 20:04:21 +02:00
{
2024-12-10 10:27:53 +01:00
try {
$sOrderId = $this->getEditObjectId();
$viewNameGenerator = Registry::get( TableViewNameGenerator::class );
$sTable = $viewNameGenerator->getViewName( "oxorderarticles" );
2020-05-19 16:06:32 +02:00
2024-12-10 10:27:53 +01:00
/** @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 ) )
)
);
2020-05-19 16:06:32 +02:00
2024-12-10 10:27:53 +01:00
return $queryBuilder->execute()->fetchOne();
} catch (NotFoundExceptionInterface|ContainerExceptionInterface|DBALException) {
return false;
}
2020-05-19 16:06:32 +02:00
}
2020-05-30 00:52:41 +02:00
/**
2020-07-03 20:04:21 +02:00
* @throws noPdfHandlerFoundException
* @throws pdfGeneratorExceptionAbstract
2020-05-30 00:52:41 +02:00
*/
2024-12-10 10:27:53 +01:00
public function d3CreatePDF(): void
2020-07-03 20:04:21 +02:00
{
$soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) {
/** @var Order $oOrder */
2020-07-03 20:04:21 +02:00
$oOrder = oxNew(Order::class);
if ($oOrder->load($soxId)) {
$generator = oxNew( orderOverviewPdfGenerator::class );
$generator->generatePdf($oOrder, Registry::getRequest()->getRequestEscapedParameter("pdflanguage"));
}
}
}
2024-12-10 10:27:53 +01:00
public function d3getGeneratorList(): registryOrderoverview
2020-07-03 20:04:21 +02:00
{
return oxNew(registryOrderoverview::class);
}
2020-05-19 16:06:32 +02:00
}