![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/fooman/printorderpdf-implementation-m2/src/Model/Pdf/ |
<?php /** * @copyright Copyright (c) 2015 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Fooman\PrintOrderPdf\Model\Pdf; use Magento\Sales\Model\Order\Pdf\Invoice; class Order extends Invoice { /** * @var \Magento\Store\Model\App\Emulation */ private $appEmulation; public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Stdlib\StringUtils $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\App\Emulation $appEmulation, array $data = [] ) { $this->appEmulation = $appEmulation; parent::__construct( $paymentData, $string, $scopeConfig, $filesystem, $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, $localeDate, $inlineTranslation, $addressRenderer, $storeManager, $appEmulation, $data ); } /** * Return PDF document * * @param \Magento\Sales\Model\Order[] $orders * * @return \Zend_Pdf * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_Pdf_Exception */ public function getPdf($orders = []) { $this->_beforeGetPdf(); $this->_initRenderer('order'); $pdf = new \Zend_Pdf(); $this->_setPdf($pdf); foreach ($orders as $order) { if ($order->getStoreId()) { $this->appEmulation->startEnvironmentEmulation( $order->getStoreId(), \Magento\Framework\App\Area::AREA_FRONTEND, true ); } $page = $this->newPage(); $this->_setFontBold($page, 10); $order->setOrder($order); /* Add image */ $this->insertLogo($page, $order->getStore()); /* Add address */ $this->insertAddress($page, $order->getStore()); /* Add head */ $this->insertOrder( $page, $order, $this->_scopeConfig->isSetFlag( self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $order->getStoreId() ) ); /* Add table */ $this->_drawHeader($page); /* Add body */ foreach ($order->getAllItems() as $item) { if ($item->getParentItem()) { continue; } /* Keep it compatible with the invoice */ $item->setQty($item->getQtyOrdered()); $item->setOrderItem($item); /* Draw item */ $this->_drawItem($item, $page, $order); $page = end($pdf->pages); } /* Add totals */ $this->insertTotals($page, $order); if ($order->getStoreId()) { $this->appEmulation->stopEnvironmentEmulation(); } } $this->_afterGetPdf(); return $pdf; } }