Spamworldpro Mini Shell
Spamworldpro


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/Preference/Block/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/code/Cnc/PdfCustomiser/Preference/Block/Invoice.php
<?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\Preference\Block;

use Cnc\PdfCustomiser\ViewModel\ColumnConverter;
use Magento\Framework\App\ResourceConnection;
use Fooman\PdfCustomiser\Block\Pdf\AddressFormatter;
use Magento\Customer\Api\CustomerRepositoryInterface;

class Invoice extends \Fooman\PdfCustomiser\Block\Invoice
{
    /**
     * @var \Fooman\PdfCore\Helper\Locale
     */
    private $localeHelper;

    /**
     * @var \Fooman\PdfDesign\Model\TemplateFileDecider
     */
    private $templateFileDecider;

    /**
     * @var ColumnConverter
     */
    private $columnConverter;

    /**
     * @var ResourceConnection
     */
    private $resource;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode,
        \Fooman\PdfCore\Model\Template $template,
        \Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
        \Magento\Payment\Helper\Data $paymentHelper,
        \Fooman\PdfCore\Helper\Logo $logoHelper,
        \Fooman\PdfCore\Model\IntegratedLabels\ContentFactory $integratedLabelsContentFactory,
        \Magento\Catalog\Model\ProductFactory $productFactory,
        \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory,
        \Magento\GiftMessage\Api\OrderRepositoryInterface $giftMessageOrderRepo,
        \Magento\Framework\App\AreaList $areaList,
        \Fooman\PdfCore\Helper\ParamKey $paramKeyHelper,
        \Fooman\PdfDesign\Model\DesignProvider $designProvider,
        \Fooman\PdfDesign\Model\TemplateFileDecider $templateFileDecider,
        \Fooman\PdfCore\Helper\Locale $localeHelper,
        ColumnConverter $columnConverter,
        ResourceConnection $resource,
        AddressFormatter $addressFormatter,
        CustomerRepositoryInterface $customerRepo,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $maliciousCode,
            $template,
            $paymentHelper,
            $logoHelper,
            $integratedLabelsContentFactory,
            $giftMessageOrderRepo,
            $paramKeyHelper,
            $designProvider,
            $addressFormatter,
            $customerRepo,
            $data
        );
        $this->localeHelper = $localeHelper;
        $this->templateFileDecider = $templateFileDecider;
        $this->columnConverter = $columnConverter;
        $this->resource = $resource;
    }

    public function getTemplateVars()
    {
        $invoiceDetails = $this->getInvoiceData($this->getInvoice()->getId());
        return array_merge(
            parent::getTemplateVars(),
            [
                'invoice' => $this->getInvoice(),
                'content_block_1' => isset($invoiceDetails['content_block_1']) ?
                    $invoiceDetails['content_block_1'] : '',
                'content_block_2' => isset($invoiceDetails['content_block_2']) ?
                    $invoiceDetails['content_block_2'] : '',
            ]
        );
    }

    public function getItemsBlock($styling = [])
    {
        $html = '';
        foreach ($this->getVisibleItems() as $item) {
            $dataArray = [
                'tableColumns' => $this->getTableColumns(),
                'currency_code' => $this->getOrder()->getOrderCurrencyCode(),
                'rtl' => $this->localeHelper->isRightToLeftByStoreId($this->getOrder()->getStoreId())
            ];
            if ($this->shouldDisplayBothCurrencies()) {
                $dataArray['base_currency_code']= $this->getOrder()->getBaseCurrencyCode();
            }

            $block = $this->getLayout()->createBlock(
                \Fooman\PdfCustomiser\Block\Table::class,
                'pdfcustomiser.items' . uniqid(),
                ['data' => $dataArray]
            );

            $block->setTemplate($this->templateFileDecider->pick($this->getDesign(), 'table-invoice'));
            $block->setFoomanDesign($this->getDesign());
            $block->setStyling($styling);
            $block->setCollection([$item]);
            $block->setColumnConverter($this->columnConverter);
            $html .= $block->toHtml();
        }

        return $html;
    }

    protected function getProductAttributes()
    {
        $productAttributes = [];
        $config = $this->getColumnConfig();
        if ($config) {
            if (is_string($config)) {
                $config = json_decode($config, true);
            }
            foreach ($config as $column) {
                if (strpos($column['columntype'], 'product/') !== false) {
                    $productAttributes[] = str_replace('product/', '', $column['columntype']);
                }
            }
        }

        $productAttributes []= 'cnc_state_of_wear';
        $productAttributes []= 'cnc_guarantee_duration';
        $productAttributes []= 'cnc_guarantee_type';
        return $productAttributes;
    }

    /**
     * @param string $invoiceId
     * @return array|mixed|null
     */
    public function getInvoiceData($invoiceId)
    {
        $sql = 'SELECT * FROM cnc_invoice_details WHERE entity_id = ' . $invoiceId . ' AND entity_type =\'invoice\'';
        return $this->resource->getConnection()->fetchRow($sql);
    }
}

Spamworldpro Mini