diff --git a/Classes/Service/PdfService.php b/Classes/Service/PdfService.php index c7905a0..d7ced68 100644 --- a/Classes/Service/PdfService.php +++ b/Classes/Service/PdfService.php @@ -14,15 +14,21 @@ use Extcode\Cart\Domain\Model\Order\Item as OrderItem; use Extcode\CartPdf\Domain\Model\Dto\PdfDemand; use TYPO3\CMS\Core\Http\ApplicationType; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\View\ViewFactoryData; +use TYPO3\CMS\Core\View\ViewFactoryInterface; +use TYPO3\CMS\Core\View\ViewInterface; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; readonly class PdfService implements DocumentRenderServiceInterface { private array $configuration; + private array $viewSettings; public function __construct( private readonly ConfigurationManager $configurationManager, + private ViewFactoryInterface $viewFactory, ) { if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) { $pageId = (int)($GLOBALS['TYPO3_REQUEST']->getQueryParams()['id'] ?? 1); @@ -40,12 +46,57 @@ public function __construct( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'CartPdf' ); + + $viewSettings = $this->configuration['view'] ?? []; + $this->viewSettings = is_array($viewSettings) ? $viewSettings : []; + } + + public function getStandaloneView(string $format = 'html'): ViewInterface + { + return $this->viewFactory->create(new ViewFactoryData( + $this->viewSettings['templateRootPaths'] ?? [], + $this->viewSettings['partialRootPaths'] ?? [], + $this->viewSettings['layoutRootPaths'] ?? [], + null, + $GLOBALS['TYPO3_REQUEST'] ?? null, + $format, + )); + } + + public function renderStandaloneView( + string $templatePath, + string $type, + array $config, + array $assignToView = [], + ): string { + $view = $this->getStandaloneView(); + + if (!empty($config['file'])) { + $file = GeneralUtility::getFileAbsFileName($config['file']); + $view->assign('file', $file); + $view->assign('file_base64', base64_encode(file_get_contents($file))); + $view->assign('file_mimetype', mime_content_type($file)); + + if (!empty($config['width'])) { + $view->assign('width', $config['width']); + } + + if (!empty($config['height'])) { + $view->assign('height', $config['height']); + } + } + + $view->assignMultiple($assignToView); + + $content = (string)$view->render($templatePath . ucfirst($type)); + return trim(preg_replace('~[\\n]+~', '', $content)); } public function renderDocument(OrderItem $orderItem, string $pdfType): string { $pdfType .= 'Pdf'; - $pdfSettings = $this->configuration[$pdfType]; + $pdfSettings = $this->configuration[$pdfType] ?? []; + $pdfSettings = is_array($pdfSettings) ? $pdfSettings : []; $pdfDemand = PdfDemand::createFromSettings($pdfSettings); $pdf = TcpdfWrapper::createWithTypeAndSettings( @@ -53,14 +104,48 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string $this->configuration, ); + foreach ($pdfSettings['header']['html'] ?? [] as $partName => $partConfig) { + $assignToView = []; + if ($partName === 'page') { + $assignToView['numPage'] = $pdf->getAliasNumPage(); + $assignToView['numPages'] = $pdf->getAliasNbPages(); + } + + $content = $this->renderStandaloneView( + $pdfSettings['header']['html'][$partName]['templatePath'], + $partName, + $partConfig, + $assignToView, + ); + + $pdf->addHeaderPart($content, $partConfig); + } + + foreach ($pdfSettings['footer']['html'] ?? [] as $partName => $partConfig) { + $assignToView = []; + if ($partName === 'page') { + $assignToView['numPage'] = $pdf->getAliasNumPage(); + $assignToView['numPages'] = $pdf->getAliasNbPages(); + } + + $content = $this->renderStandaloneView( + $pdfSettings['footer']['html'][$partName]['templatePath'], + $partName, + $partConfig, + $assignToView, + ); + + $pdf->addFooterPart($content, $partConfig); + } + if (empty($pdfSettings['header'])) { $pdf->setPrintHeader(false); } else { if (!empty($pdfSettings['header']['margin'])) { $pdf->setHeaderMargin((int)$pdfSettings['header']['margin']); - $pdf->SetMargins(PDF_MARGIN_LEFT, (float)$pdfSettings['header']['margin'], PDF_MARGIN_RIGHT); + $pdf->setMargins(PDF_MARGIN_LEFT, (float)$pdfSettings['header']['margin'], PDF_MARGIN_RIGHT); } else { - $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); } } @@ -95,7 +180,7 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string $fontSize = $pdfSettings['fontSize']; } - $pdf->SetFont($font, $fontStyle, $fontSize); + $pdf->setFont($font, $fontStyle, $fontSize); $colorArray = [0, 0, 0]; @@ -110,7 +195,8 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string foreach ($pdfSettings['letterhead']['html'] as $partName => $partConfig) { $templatePath = '/' . ucfirst($pdfType) . '/Letterhead/'; $assignToView = ['orderItem' => $orderItem]; - $pdf->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $content = $this->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $pdf->writeHtmlCellWithConfig($content, $partConfig); } } @@ -118,7 +204,8 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string foreach ($pdfSettings['body']['before']['html'] as $partName => $partConfig) { $templatePath = '/' . ucfirst($pdfType) . '/Body/Before/'; $assignToView = ['orderItem' => $orderItem]; - $pdf->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $content = $this->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $pdf->writeHtmlCellWithConfig($content, $partConfig); } } @@ -128,7 +215,8 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string foreach ($pdfSettings['body']['after']['html'] as $partName => $partConfig) { $templatePath = '/' . ucfirst($pdfType) . '/Body/After/'; $assignToView = ['orderItem' => $orderItem]; - $pdf->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $content = $this->renderStandaloneView($templatePath, $partName, $partConfig, $assignToView); + $pdf->writeHtmlCellWithConfig($content, $partConfig); } } @@ -138,15 +226,15 @@ public function renderDocument(OrderItem $orderItem, string $pdfType): string private function renderMarker(TcpdfWrapper $pdf, PdfDemand $pdfDemand): void { if ($pdfDemand->getFoldMarksEnabled()) { - $pdf->SetLineWidth(0.1); + $pdf->setLineWidth(0.1); $pdf->Line(6.0, 105.0, 8.0, 105.0); $pdf->Line(6.0, 148.5, 10.0, 148.5); $pdf->Line(6.0, 210.0, 8.0, 210.0); - $pdf->SetLineWidth(0.2); + $pdf->setLineWidth(0.2); } if ($pdfDemand->getAddressFieldMarksEnabled()) { - $pdf->SetLineWidth(0.1); + $pdf->setLineWidth(0.1); $pdf->Line(20.0, 45.0, 21.0, 45.0); $pdf->Line(20.0, 45.0, 20.0, 46.0); @@ -159,7 +247,7 @@ private function renderMarker(TcpdfWrapper $pdf, PdfDemand $pdfDemand): void $pdf->Line(105.0, 90.0, 104.0, 90.0); $pdf->Line(105.0, 90.0, 105.0, 89.0); - $pdf->SetLineWidth(0.2); + $pdf->setLineWidth(0.2); } } @@ -172,34 +260,34 @@ private function renderCart(TcpdfWrapper $pdf, OrderItem $orderItem, string $pdf $config['spacingY'] = 5; } - $headerOut = $this->renderCartHeader($pdf, $orderItem, $pdfType); - $bodyOut = $this->renderCartBody($pdf, $orderItem, $pdfType); - $footerOut = $this->renderCartFooter($pdf, $orderItem, $pdfType); + $headerOut = $this->renderCartHeader($orderItem, $pdfType); + $bodyOut = $this->renderCartBody($orderItem, $pdfType); + $footerOut = $this->renderCartFooter($orderItem, $pdfType); $content = '' . $headerOut . $bodyOut . $footerOut . '
'; $pdf->writeHtmlCellWithConfig($content, $config); } - private function renderCartHeader(TcpdfWrapper $pdf, OrderItem $orderItem, string $pdfType): string + private function renderCartHeader(OrderItem $orderItem, string $pdfType): string { - $view = $pdf->getStandaloneView('/' . ucfirst($pdfType) . '/Order/', 'Header'); + $view = $this->getStandaloneView(); $view->assign('orderItem', $orderItem); - $header = $view->render(); + $header = $view->render('/' . ucfirst($pdfType) . '/Order/Header'); return trim(preg_replace('~[\\n]+~', '', $header)); } - private function renderCartBody(TcpdfWrapper $pdf, OrderItem $orderItem, string $pdfType): string + private function renderCartBody(OrderItem $orderItem, string $pdfType): string { - $view = $pdf->getStandaloneView('/' . ucfirst($pdfType) . '/Order/', 'Product'); + $view = $this->getStandaloneView(); $view->assign('orderItem', $orderItem); $bodyOut = ''; foreach ($orderItem->getProducts() as $product) { $view->assign('product', $product); - $product = $view->render(); + $product = $view->render('/' . ucfirst($pdfType) . '/Order/Product'); $bodyOut .= trim(preg_replace('~[\\n]+~', '', $product)); } @@ -207,12 +295,12 @@ private function renderCartBody(TcpdfWrapper $pdf, OrderItem $orderItem, string return $bodyOut; } - private function renderCartFooter(TcpdfWrapper $pdf, OrderItem $orderItem, string $pdfType): string + private function renderCartFooter(OrderItem $orderItem, string $pdfType): string { - $view = $pdf->getStandaloneView('/' . ucfirst($pdfType) . '/Order/', 'Footer'); + $view = $this->getStandaloneView(); $view->assign('orderSettings', $this->configuration[$pdfType]['body']['order']); $view->assign('orderItem', $orderItem); - $footer = $view->render(); + $footer = $view->render('/' . ucfirst($pdfType) . '/Order/Footer'); return trim(preg_replace('~[\\n]+~', '', $footer)); } diff --git a/Classes/Service/TcpdfWrapper.php b/Classes/Service/TcpdfWrapper.php index df0d29b..34dfb7a 100644 --- a/Classes/Service/TcpdfWrapper.php +++ b/Classes/Service/TcpdfWrapper.php @@ -12,20 +12,18 @@ */ use TCPDF; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Fluid\View\StandaloneView; class TcpdfWrapper extends TCPDF { private readonly array $pdfSettings; - private readonly array $viewSettings; + private array $headerParts = []; + private array $footerParts = []; public function __construct( private readonly string $pdfType, array $settings, ) { $this->pdfSettings = $settings[$this->pdfType]; - $this->viewSettings = $settings['view']; parent::__construct(); } @@ -40,29 +38,33 @@ public static function createWithTypeAndSettings( ); } + public function addHeaderPart($content, array $config): void + { + $this->headerParts[] = ['content' => $content, 'config' => $config]; + } + + public function addFooterPart($content, array $config): void + { + $this->footerParts[] = ['content' => $content, 'config' => $config]; + } + public function getCartPdfType(): string { return $this->pdfType; } - public function header(): void + public function Header(): void { if (empty($this->pdfSettings['header'] ?? [])) { return; } if (!empty($this->pdfSettings['fontSize'])) { - $this->SetFontSize($this->pdfSettings['fontSize']); + $this->setFontSize($this->pdfSettings['fontSize']); } - if (!empty($this->pdfSettings['header']['html'])) { - foreach ($this->pdfSettings['header']['html'] as $partName => $partConfig) { - $this->renderStandaloneView( - $this->pdfSettings['header']['html'][$partName]['templatePath'], - $partName, - $partConfig - ); - } + foreach ($this->headerParts as $headerPart) { + $this->writeHtmlCellWithConfig($headerPart['content'], $headerPart['config']); } if (!empty($this->pdfSettings['header']['line'])) { @@ -78,24 +80,18 @@ public function header(): void } } - public function footer(): void + public function Footer(): void { if (empty($this->pdfSettings['footer'] ?? [])) { return; } if (!empty($this->pdfSettings['fontSize'])) { - $this->SetFontSize($this->pdfSettings['fontSize']); + $this->setFontSize($this->pdfSettings['fontSize']); } - if (!empty($this->pdfSettings['footer']['html'])) { - foreach ($this->pdfSettings['footer']['html'] as $partName => $partConfig) { - $this->renderStandaloneView( - $this->pdfSettings['footer']['html'][$partName]['templatePath'], - $partName, - $partConfig - ); - } + foreach ($this->footerParts as $footerPart) { + $this->writeHtmlCellWithConfig($footerPart['content'], $footerPart['config']); } if (!empty($this->pdfSettings['footer']['line'])) { @@ -111,42 +107,6 @@ public function footer(): void } } - public function renderStandaloneView( - string $templatePath, - string $type, - array $config, - array $assignToView = [] - ): void { - $view = $this->getStandaloneView($templatePath, ucfirst($type)); - - if (!empty($config['file'])) { - $file = GeneralUtility::getFileAbsFileName($config['file']); - $view->assign('file', $file); - $view->assign('file_base64', base64_encode(file_get_contents($file))); - $view->assign('file_mimetype', mime_content_type($file)); - - if (!empty($config['width'])) { - $view->assign('width', $config['width']); - } - - if (!empty($config['height'])) { - $view->assign('height', $config['height']); - } - } - - if ($type === 'page') { - $view->assign('numPage', $this->getAliasNumPage()); - $view->assign('numPages', $this->getAliasNbPages()); - } - - $view->assignMultiple($assignToView); - - $content = (string)$view->render(); - $content = trim(preg_replace('~[\\n]+~', '', $content)); - - $this->writeHtmlCellWithConfig($content, $config); - } - public function writeHtmlCellWithConfig(string $content, array $config): void { $width = (float)($config['width'] ?? 0.0); @@ -167,9 +127,9 @@ public function writeHtmlCellWithConfig(string $content, array $config): void } $oldFontSize = null; - if (empty($config['fontSize']) && is_numeric($config['fontSize'])) { + if (isset($config['fontSize']) && is_numeric($config['fontSize'])) { $oldFontSize = $this->getFontSizePt(); - $this->SetFontSize((float)$config['fontSize']); + $this->setFontSize((float)$config['fontSize']); } if (isset($config['spacingY']) && is_numeric($config['spacingY'])) { @@ -191,40 +151,7 @@ public function writeHtmlCellWithConfig(string $content, array $config): void ); if (is_null($oldFontSize) === false) { - $this->SetFontSize($oldFontSize); - } - } - - public function getStandaloneView( - string $templatePath, - string $templateFileName = 'Default', - string $format = 'html' - ): StandaloneView { - $templatePathAndFileName = $templatePath . $templateFileName . '.' . $format; - - /** @var StandaloneView $view */ - $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->setFormat($format); - - if (!empty($this->viewSettings)) { - $view->setLayoutRootPaths($this->viewSettings['layoutRootPaths']); - $view->setPartialRootPaths($this->viewSettings['partialRootPaths']); - - if ($this->viewSettings['templateRootPaths']) { - foreach ($this->viewSettings['templateRootPaths'] as $pathNameKey => $pathNameValue) { - $templateRootPath = GeneralUtility::getFileAbsFileName( - $pathNameValue - ); - - $completePath = $templateRootPath . $templatePathAndFileName; - - if (file_exists($completePath)) { - $view->setTemplatePathAndFilename($completePath); - } - } - } + $this->setFontSize($oldFontSize); } - - return $view; } } diff --git a/Configuration/Sets/CartPdf/config.yaml b/Configuration/Sets/CartPdf/config.yaml new file mode 100644 index 0000000..be7e0aa --- /dev/null +++ b/Configuration/Sets/CartPdf/config.yaml @@ -0,0 +1,2 @@ +name: extcode/cart-pdf +label: Shopping Cart - Cart Pdf diff --git a/Configuration/Sets/CartPdf/constants.typoscript b/Configuration/Sets/CartPdf/constants.typoscript new file mode 100644 index 0000000..816a581 --- /dev/null +++ b/Configuration/Sets/CartPdf/constants.typoscript @@ -0,0 +1,15 @@ +plugin.tx_cartpdf { + view { + templateRootPath = EXT:cart_pdf/Resources/Private/Templates/ + partialRootPath = EXT:cart_pdf/Resources/Private/Partials/ + layoutRootPath = EXT:cart_pdf/Resources/Private/Layouts/ + } +} + +module.tx_cartpdf { + view { + templateRootPath = EXT:cart_pdf/Resources/Private/Templates/ + partialRootPath = EXT:cart_pdf/Resources/Private/Partials/ + layoutRootPath = EXT:cart_pdf/Resources/Private/Layouts/ + } +} diff --git a/Configuration/Sets/CartPdf/setup.typoscript b/Configuration/Sets/CartPdf/setup.typoscript new file mode 100644 index 0000000..1dd3dec --- /dev/null +++ b/Configuration/Sets/CartPdf/setup.typoscript @@ -0,0 +1,28 @@ +plugin.tx_cartpdf { + view { + templateRootPaths { + 0 = {$plugin.tx_cartpdf.view.templateRootPath} + } + partialRootPaths { + 0 = {$plugin.tx_cartpdf.view.partialRootPath} + } + layoutRootPaths { + 0 = {$plugin.tx_cartpdf.view.layoutRootPath} + } + } +} + +module.tx_cartpdf { + view { + templateRootPaths { + 0 = {$module.tx_cartpdf.view.templateRootPath} + } + partialRootPaths { + 0 = {$module.tx_cartpdf.view.partialRootPath} + } + layoutRootPaths { + 0 = {$module.tx_cartpdf.view.layoutRootPath} + } + } +} + diff --git a/Configuration/Sets/DeliveryPdf/config.yaml b/Configuration/Sets/DeliveryPdf/config.yaml new file mode 100644 index 0000000..0397bcf --- /dev/null +++ b/Configuration/Sets/DeliveryPdf/config.yaml @@ -0,0 +1,4 @@ +name: extcode/cart-pdf-delivery-pdf +label: Shopping Cart - Cart Pdf - Delivery PDF +dependencies: + - extcode/cart-pdf diff --git a/Configuration/Sets/DeliveryPdf/constants.typoscript b/Configuration/Sets/DeliveryPdf/constants.typoscript new file mode 100644 index 0000000..eb12695 --- /dev/null +++ b/Configuration/Sets/DeliveryPdf/constants.typoscript @@ -0,0 +1,6 @@ +plugin.tx_cartpdf { + deliveryPdf { + storageRepository = 1 + storageFolder = tx_cart/delivery_pdf + } +} diff --git a/Configuration/Sets/DeliveryPdf/setup.typoscript b/Configuration/Sets/DeliveryPdf/setup.typoscript new file mode 100644 index 0000000..e01722a --- /dev/null +++ b/Configuration/Sets/DeliveryPdf/setup.typoscript @@ -0,0 +1,152 @@ +plugin.tx_cartpdf { + invoicePdf { + storageRepository = {$plugin.tx_cartpdf.invoicePdf.storageRepository} + storageFolder = {$plugin.tx_cartpdf.invoicePdf.storageFolder} + + debug = 0 + + # font = Helvetica + # fontStyle = + fontSize = 10 + + # drawColor = 0,0,0 + + enableFoldMarks = 1 + enableAddressFieldMarks = 1 + + header { + margin = 30mm + html { + logo { + width = 50 + positionX = 10 + positionY = 5 + templatePath = /InvoicePdf/Header/ + file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png + } + + content { + width = 120 + positionX = 80 + positionY = 5 + templatePath = /InvoicePdf/Header/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 24 + x2 = 200 + y2 = 24 + style { + width = 0.5 + } + } + } + } + + footer { + margin = 40mm + + html { + content { + width = 190 + height = 35 + positionX = 15 + positionY = 265 + templatePath = /InvoicePdf/Footer/ + fontSize = 8 + } + + page { + width = 100 + height = 10 + positionX = 115 + positionY = 290 + templatePath = /InvoicePdf/Footer/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 262 + x2 = 200 + y2 = 262 + style { + width = 0.5 + } + } + } + } + + letterhead { + html { + envelopeAddress { + width = 83 + height = 10 + positionX = 21 + positionY = 46 + fontSize = 6 + } + + invoiceAddress { + width = 83 + height = 33 + positionX = 21 + positionY = 56 + } + + date { + width = 60 + height = 5 + positionX = 130 + positionY = 84 + align = R + } + } + } + + body { + before { + html { + overview { + width = 170 + positionX = 20 + positionY = 100 + fontSize = 12 + } + } + } + + order { + width=170 + positionX=20 + spacingY = 10 + fontSize=8 + + summary < plugin.tx_cart.settings.showCartAction.summary + } + + after { + html { + greetings { + width = 170 + height = 20 + positionX = 20 + spacingY = 20 + } + } + } + } + } +} + +module.tx_cartpdf { + invoicePdf < plugin.tx_cartpdf.invoicePdf +} diff --git a/Configuration/Sets/InvoicePdf/config.yaml b/Configuration/Sets/InvoicePdf/config.yaml new file mode 100644 index 0000000..c277edc --- /dev/null +++ b/Configuration/Sets/InvoicePdf/config.yaml @@ -0,0 +1,4 @@ +name: extcode/cart-pdf-invoice-pdf +label: Shopping Cart - Cart Pdf - Invoice PDF +dependencies: + - extcode/cart-pdf diff --git a/Configuration/Sets/InvoicePdf/constants.typoscript b/Configuration/Sets/InvoicePdf/constants.typoscript new file mode 100644 index 0000000..181dbd6 --- /dev/null +++ b/Configuration/Sets/InvoicePdf/constants.typoscript @@ -0,0 +1,6 @@ +plugin.tx_cartpdf { + invoicePdf { + storageRepository = 1 + storageFolder = tx_cart/invoice_pdf + } +} diff --git a/Configuration/Sets/InvoicePdf/setup.typoscript b/Configuration/Sets/InvoicePdf/setup.typoscript new file mode 100644 index 0000000..d0eaef6 --- /dev/null +++ b/Configuration/Sets/InvoicePdf/setup.typoscript @@ -0,0 +1,152 @@ +plugin.tx_cartpdf { + invoicePdf { + storageRepository = {$plugin.tx_cartpdf.invoicePdf.storageRepository} + storageFolder = {$plugin.tx_cartpdf.invoicePdf.storageFolder} + + debug = 0 + + # font = Helvetica + # fontStyle = + fontSize = 10 + + # drawColor = 0,0,0 + + enableFoldMarks = 1 + enableAddressFieldMarks = 1 + + header { + margin = 30mm + html { + logo { + width = 50 + positionX = 10 + positionY = 5 + templatePath = /InvoicePdf/Header/ + file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png + } + + content { + width = 120 + positionX = 80 + positionY = 5 + templatePath = /InvoicePdf/Header/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 24 + x2 = 200 + y2 = 24 + style { + width = 0.5 + } + } + } + } + + footer { + margin = 40mm + + html { + content { + width = 190 + height = 35 + positionX = 15 + positionY = 265 + templatePath = /InvoicePdf/Footer/ + fontSize = 8 + } + + page { + width = 100 + height = 10 + positionX = 115 + positionY = 290 + templatePath = /InvoicePdf/Footer/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 262 + x2 = 200 + y2 = 262 + style { + width = 0.5 + } + } + } + } + + letterhead { + html { + envelopeAddress { + width = 83 + height = 10 + positionX = 21 + positionY = 46 + fontSize = 6 + } + + invoiceAddress { + width = 83 + height = 33 + positionX = 21 + positionY = 56 + } + + date { + width = 60 + height = 5 + positionX = 130 + positionY = 84 + align = R + } + } + } + + body { + before { + html { + overview { + width = 170 + positionX = 20 + positionY = 100 + fontSize = 12 + } + } + } + + order { + width=170 + positionX=20 + spacingY = 10 + fontSize=8 + + summary < plugin.tx_cart.settings.showCartAction.summary + } + + after { + html { + greetings { + width = 170 + height = 20 + positionX = 20 + spacingY = 20 + } + } + } + } + } +} + +module.tx_cartpdf { + invoicePdf < plugin.tx_cartpdf.invoicePdf +} \ No newline at end of file diff --git a/Configuration/Sets/OrderPdf/config.yaml b/Configuration/Sets/OrderPdf/config.yaml new file mode 100644 index 0000000..e121d7d --- /dev/null +++ b/Configuration/Sets/OrderPdf/config.yaml @@ -0,0 +1,4 @@ +name: extcode/cart-pdf-order-pdf +label: Shopping Cart - Cart Pdf - Order PDF +dependencies: + - extcode/cart-pdf diff --git a/Configuration/Sets/OrderPdf/constants.typoscript b/Configuration/Sets/OrderPdf/constants.typoscript new file mode 100644 index 0000000..9606ec1 --- /dev/null +++ b/Configuration/Sets/OrderPdf/constants.typoscript @@ -0,0 +1,6 @@ +plugin.tx_cartpdf { + orderPdf { + storageRepository = 1 + storageFolder = tx_cart/order_pdf + } +} diff --git a/Configuration/Sets/OrderPdf/setup.typoscript b/Configuration/Sets/OrderPdf/setup.typoscript new file mode 100644 index 0000000..62f2be0 --- /dev/null +++ b/Configuration/Sets/OrderPdf/setup.typoscript @@ -0,0 +1,152 @@ +plugin.tx_cartpdf { + orderPdf { + storageRepository = {$plugin.tx_cartpdf.orderPdf.storageRepository} + storageFolder = {$plugin.tx_cartpdf.orderPdf.storageFolder} + + debug = 0 + + # font = Helvetica + # fontStyle = + fontSize = 10 + + # drawColor = 0,0,0 + + enableFoldMarks = 1 + enableAddressFieldMarks = 1 + + header { + margin = 30mm + html { + logo { + width = 50 + positionX = 10 + positionY = 5 + templatePath = /OrderPdf/Header/ + file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png + } + + content { + width = 120 + positionX = 80 + positionY = 5 + templatePath = /OrderPdf/Header/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 24 + x2 = 200 + y2 = 24 + style { + width = 0.5 + } + } + } + } + + footer { + margin = 40mm + + html { + content { + width = 190 + height = 35 + positionX = 15 + positionY = 265 + templatePath = /OrderPdf/Footer/ + fontSize = 8 + } + + page { + width = 100 + height = 10 + positionX = 115 + positionY = 290 + templatePath = /OrderPdf/Footer/ + fontSize = 8 + align = R + } + } + + line { + 1 { + x1 = 10 + y1 = 262 + x2 = 200 + y2 = 262 + style { + width = 0.5 + } + } + } + } + + letterhead { + html { + envelopeAddress { + width = 83 + height = 10 + positionX = 21 + positionY = 46 + fontSize = 6 + } + + invoiceAddress { + width = 83 + height = 33 + positionX = 21 + positionY = 56 + } + + date { + width = 60 + height = 5 + positionX = 130 + positionY = 84 + align = R + } + } + } + + body { + before { + html { + overview { + width = 170 + positionX = 20 + positionY = 100 + fontSize = 12 + } + } + } + + order { + width=170 + positionX=20 + spacingY = 10 + fontSize=8 + + summary < plugin.tx_cart.settings.showCartAction.summary + } + + after { + html { + greetings { + width = 170 + height = 20 + positionX = 20 + spacingY = 20 + } + } + } + } + } +} + +module.tx_cartpdf { + orderPdf < plugin.tx_cartpdf.orderPdf +} \ No newline at end of file diff --git a/Configuration/TypoScript/DeliveryPdf/constants.typoscript b/Configuration/TypoScript/DeliveryPdf/constants.typoscript index eb12695..4fed724 100644 --- a/Configuration/TypoScript/DeliveryPdf/constants.typoscript +++ b/Configuration/TypoScript/DeliveryPdf/constants.typoscript @@ -1,6 +1 @@ -plugin.tx_cartpdf { - deliveryPdf { - storageRepository = 1 - storageFolder = tx_cart/delivery_pdf - } -} +@import 'EXT:cart_pdf/Configuration/Sets/DeliveryPdf/constants.typoscript' diff --git a/Configuration/TypoScript/DeliveryPdf/setup.typoscript b/Configuration/TypoScript/DeliveryPdf/setup.typoscript index e983104..1b6c38d 100644 --- a/Configuration/TypoScript/DeliveryPdf/setup.typoscript +++ b/Configuration/TypoScript/DeliveryPdf/setup.typoscript @@ -1,152 +1 @@ -plugin.tx_cartpdf { - deliveryPdf { - storageRepository = {$plugin.tx_cartpdf.deliveryPdf.storageRepository} - storageFolder = {$plugin.tx_cartpdf.deliveryPdf.storageFolder} - - debug = 0 - - # font = Helvetica - # fontStyle = - fontSize = 10 - - # drawColor = 0,0,0 - - enableFoldMarks = 1 - enableAddressFieldMarks = 1 - - header { - margin = 30mm - html { - logo { - width = 50 - positionX = 10 - positionY = 5 - templatePath = /DeliveryPdf/Header/ - file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png - } - - content { - width = 120 - positionX = 80 - positionY = 5 - templatePath = /DeliveryPdf/Header/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 24 - x2 = 200 - y2 = 24 - style { - width = 0.5 - } - } - } - } - - footer { - margin = 40mm - - html { - content { - width = 190 - height = 35 - positionX = 15 - positionY = 265 - templatePath = /DeliveryPdf/Footer/ - fontSize = 8 - } - - page { - width = 100 - height = 10 - positionX = 115 - positionY = 290 - templatePath = /DeliveryPdf/Footer/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 262 - x2 = 200 - y2 = 262 - style { - width = 0.5 - } - } - } - } - - letterhead { - html { - envelopeAddress { - width = 83 - height = 10 - positionX = 21 - positionY = 46 - fontSize = 6 - } - - invoiceAddress { - width = 83 - height = 33 - positionX = 21 - positionY = 56 - } - - date { - width = 60 - height = 5 - positionX = 130 - positionY = 84 - align = R - } - } - } - - body { - before { - html { - overview { - width = 170 - positionX = 20 - positionY = 100 - fontSize = 12 - } - } - } - - order { - width=170 - positionX=20 - spacingY = 10 - fontSize=8 - - summary < plugin.tx_cart.settings.showCartAction.summary - } - - after { - html { - greetings { - width = 170 - height = 20 - positionX = 20 - spacingY = 20 - } - } - } - } - } -} - -module.tx_cartpdf { - deliveryPdf < plugin.tx_cartpdf.deliveryPdf -} \ No newline at end of file +@import 'EXT:cart_pdf/Configuration/Sets/DeliveryPdf/setup.typoscript' diff --git a/Configuration/TypoScript/InvoicePdf/constants.typoscript b/Configuration/TypoScript/InvoicePdf/constants.typoscript index 181dbd6..141b870 100644 --- a/Configuration/TypoScript/InvoicePdf/constants.typoscript +++ b/Configuration/TypoScript/InvoicePdf/constants.typoscript @@ -1,6 +1 @@ -plugin.tx_cartpdf { - invoicePdf { - storageRepository = 1 - storageFolder = tx_cart/invoice_pdf - } -} +@import 'EXT:cart_pdf/Configuration/Sets/InvoicePdf/constants.typoscript' diff --git a/Configuration/TypoScript/InvoicePdf/setup.typoscript b/Configuration/TypoScript/InvoicePdf/setup.typoscript index d0eaef6..2c2ec80 100644 --- a/Configuration/TypoScript/InvoicePdf/setup.typoscript +++ b/Configuration/TypoScript/InvoicePdf/setup.typoscript @@ -1,152 +1 @@ -plugin.tx_cartpdf { - invoicePdf { - storageRepository = {$plugin.tx_cartpdf.invoicePdf.storageRepository} - storageFolder = {$plugin.tx_cartpdf.invoicePdf.storageFolder} - - debug = 0 - - # font = Helvetica - # fontStyle = - fontSize = 10 - - # drawColor = 0,0,0 - - enableFoldMarks = 1 - enableAddressFieldMarks = 1 - - header { - margin = 30mm - html { - logo { - width = 50 - positionX = 10 - positionY = 5 - templatePath = /InvoicePdf/Header/ - file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png - } - - content { - width = 120 - positionX = 80 - positionY = 5 - templatePath = /InvoicePdf/Header/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 24 - x2 = 200 - y2 = 24 - style { - width = 0.5 - } - } - } - } - - footer { - margin = 40mm - - html { - content { - width = 190 - height = 35 - positionX = 15 - positionY = 265 - templatePath = /InvoicePdf/Footer/ - fontSize = 8 - } - - page { - width = 100 - height = 10 - positionX = 115 - positionY = 290 - templatePath = /InvoicePdf/Footer/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 262 - x2 = 200 - y2 = 262 - style { - width = 0.5 - } - } - } - } - - letterhead { - html { - envelopeAddress { - width = 83 - height = 10 - positionX = 21 - positionY = 46 - fontSize = 6 - } - - invoiceAddress { - width = 83 - height = 33 - positionX = 21 - positionY = 56 - } - - date { - width = 60 - height = 5 - positionX = 130 - positionY = 84 - align = R - } - } - } - - body { - before { - html { - overview { - width = 170 - positionX = 20 - positionY = 100 - fontSize = 12 - } - } - } - - order { - width=170 - positionX=20 - spacingY = 10 - fontSize=8 - - summary < plugin.tx_cart.settings.showCartAction.summary - } - - after { - html { - greetings { - width = 170 - height = 20 - positionX = 20 - spacingY = 20 - } - } - } - } - } -} - -module.tx_cartpdf { - invoicePdf < plugin.tx_cartpdf.invoicePdf -} \ No newline at end of file +@import 'EXT:cart_pdf/Configuration/Sets/InvoicePdf/setup.typoscript' diff --git a/Configuration/TypoScript/OrderPdf/constants.typoscript b/Configuration/TypoScript/OrderPdf/constants.typoscript index 9606ec1..a608319 100644 --- a/Configuration/TypoScript/OrderPdf/constants.typoscript +++ b/Configuration/TypoScript/OrderPdf/constants.typoscript @@ -1,6 +1 @@ -plugin.tx_cartpdf { - orderPdf { - storageRepository = 1 - storageFolder = tx_cart/order_pdf - } -} +@import 'EXT:cart_pdf/Configuration/Sets/OrderPdf/constants.typoscript' diff --git a/Configuration/TypoScript/OrderPdf/setup.typoscript b/Configuration/TypoScript/OrderPdf/setup.typoscript index 62f2be0..172f08f 100644 --- a/Configuration/TypoScript/OrderPdf/setup.typoscript +++ b/Configuration/TypoScript/OrderPdf/setup.typoscript @@ -1,152 +1 @@ -plugin.tx_cartpdf { - orderPdf { - storageRepository = {$plugin.tx_cartpdf.orderPdf.storageRepository} - storageFolder = {$plugin.tx_cartpdf.orderPdf.storageFolder} - - debug = 0 - - # font = Helvetica - # fontStyle = - fontSize = 10 - - # drawColor = 0,0,0 - - enableFoldMarks = 1 - enableAddressFieldMarks = 1 - - header { - margin = 30mm - html { - logo { - width = 50 - positionX = 10 - positionY = 5 - templatePath = /OrderPdf/Header/ - file = EXT:cart_pdf/Documentation/Images/cart_pdf_logo.png - } - - content { - width = 120 - positionX = 80 - positionY = 5 - templatePath = /OrderPdf/Header/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 24 - x2 = 200 - y2 = 24 - style { - width = 0.5 - } - } - } - } - - footer { - margin = 40mm - - html { - content { - width = 190 - height = 35 - positionX = 15 - positionY = 265 - templatePath = /OrderPdf/Footer/ - fontSize = 8 - } - - page { - width = 100 - height = 10 - positionX = 115 - positionY = 290 - templatePath = /OrderPdf/Footer/ - fontSize = 8 - align = R - } - } - - line { - 1 { - x1 = 10 - y1 = 262 - x2 = 200 - y2 = 262 - style { - width = 0.5 - } - } - } - } - - letterhead { - html { - envelopeAddress { - width = 83 - height = 10 - positionX = 21 - positionY = 46 - fontSize = 6 - } - - invoiceAddress { - width = 83 - height = 33 - positionX = 21 - positionY = 56 - } - - date { - width = 60 - height = 5 - positionX = 130 - positionY = 84 - align = R - } - } - } - - body { - before { - html { - overview { - width = 170 - positionX = 20 - positionY = 100 - fontSize = 12 - } - } - } - - order { - width=170 - positionX=20 - spacingY = 10 - fontSize=8 - - summary < plugin.tx_cart.settings.showCartAction.summary - } - - after { - html { - greetings { - width = 170 - height = 20 - positionX = 20 - spacingY = 20 - } - } - } - } - } -} - -module.tx_cartpdf { - orderPdf < plugin.tx_cartpdf.orderPdf -} \ No newline at end of file +@import 'EXT:cart_pdf/Configuration/Sets/OrderPdf/setup.typoscript' diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 7163963..ccb1013 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,16 +1 @@ -plugin.tx_cartpdf { - view { - templateRootPath = EXT:cart_pdf/Resources/Private/Templates/ - partialRootPath = EXT:cart_pdf/Resources/Private/Partials/ - layoutRootPath = EXT:cart_pdf/Resources/Private/Layouts/ - } -} - -module.tx_cartpdf { - view { - templateRootPath = EXT:cart_pdf/Resources/Private/Templates/ - partialRootPath = EXT:cart_pdf/Resources/Private/Partials/ - layoutRootPath = EXT:cart_pdf/Resources/Private/Layouts/ - } -} - +@import 'EXT:cart_pdf/Configuration/Sets/CartPdf/constants.typoscript' diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 1dd3dec..9dc7570 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,28 +1 @@ -plugin.tx_cartpdf { - view { - templateRootPaths { - 0 = {$plugin.tx_cartpdf.view.templateRootPath} - } - partialRootPaths { - 0 = {$plugin.tx_cartpdf.view.partialRootPath} - } - layoutRootPaths { - 0 = {$plugin.tx_cartpdf.view.layoutRootPath} - } - } -} - -module.tx_cartpdf { - view { - templateRootPaths { - 0 = {$module.tx_cartpdf.view.templateRootPath} - } - partialRootPaths { - 0 = {$module.tx_cartpdf.view.partialRootPath} - } - layoutRootPaths { - 0 = {$module.tx_cartpdf.view.layoutRootPath} - } - } -} - +@import 'EXT:cart_pdf/Configuration/Sets/CartPdf/setup.typoscript'