![]() 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/app/code/Cnc/PdfCustomiser/Controller/Adminhtml/Order/ |
<?php /** * Copyright (c) 2021 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * Krzysztof Majkowski <[email protected]> <[email protected]> */ namespace Cnc\PdfCustomiser\Controller\Adminhtml\Order; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Registry; class PrepareExportInvoice extends \Magento\Backend\App\Action { const ADMIN_RESOURCE = 'Magento_Sales::sales_order'; /** * @var \Magento\Framework\View\Result\PageFactory */ private $resultPageFactory; /** * @var Registry */ private $registry; /** * @var ResourceConnection */ private $resource; public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory, Registry $registry, ResourceConnection $resource ) { parent::__construct($context); $this->resultPageFactory = $resultPageFactory; $this->registry = $registry; $this->resource = $resource; } public function execute() { $orderId = $this->getRequest()->getParam('order_id'); $data = $this->getData($orderId); if (!$data) { $data = [ 'entity_id' => $orderId, ]; } $this->registry->register('invoice_details', $data); $this->registry->register('order_id', $orderId); $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->prepend(__('Prepare Export Invoice')); return $resultPage; } /** * @param $orderId * @return mixed */ public function getData($orderId) { $sql = 'SELECT * FROM cnc_invoice_details WHERE entity_id = ' . $orderId . ' AND entity_type =\'export_invoice\''; return $this->resource->getConnection()->fetchRow($sql); } }