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/vendor/fooman/pdfcustomiser-implementation-m2/src/Block/Pdf/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/fooman/pdfcustomiser-implementation-m2/src/Block/Pdf/Order.php
<?php
namespace Fooman\PdfCustomiser\Block\Pdf;

/**
 * Create html for generating order pdf
 *
 * @author     Kristof Ringleff
 * @copyright  Copyright (c) 2009 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.
 */
class Order extends AbstractSalesDocument
{
    const XML_PATH_TITLE = 'sales_pdf/order/ordertitle';
    const XML_PATH_ADDRESSES = 'sales_pdf/order/orderaddresses';
    const XML_PATH_COLUMNS = 'sales_pdf/order/columns';
    const XML_PATH_CUSTOMTEXT = 'sales_pdf/order/ordercustom';
    const XML_PATH_GROUPTEXT = 'sales_pdf/order/grouptext';
    const XML_PATH_SORTBY = 'sales_pdf/order/sortby';

    /**
     * @return \Magento\Sales\Api\Data\OrderInterface
     */
    public function getOrder()
    {
        return $this->getData('order');
    }

    /**
     * @return \Magento\Sales\Api\Data\OrderInterface
     */
    public function getSalesObject()
    {
        return $this->getOrder();
    }

    /**
     * get visible order items
     * overridden as property different for orders
     *
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getVisibleItems()
    {
        $items = [];
        $allItems = $this->getSalesObject()->getItems();
        if ($allItems) {
            foreach ($allItems as $item) {
                if ($this->shouldDisplayItem($item)) {
                    $items[] = $this->prepareItem($item);
                }
            }
        }
        if ($this->getSortColumnsBy()) {
            uasort($items, [$this, 'sort']);
        }

        return $items;
    }

    /**
     * We generally don't want to display subitems
     *
     * @param $item
     *
     * @return bool
     */
    public function shouldDisplayItem($item)
    {
        return !$item->getParentItemId();
    }

    /**
     * Remove some fields on bundles
     *
     * @param $item
     *
     * @return mixed
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function prepareItem($item)
    {
        $this->addProductAttributeValues($item, $item);
        $suppressedColumns = [];
        if ($item->getProductType() == \Magento\Bundle\Model\Product\Type::TYPE_CODE
            && $item->isChildrenCalculated()) {
            $suppressedColumns = [
                'price',
                'base_price',
                'original_price',
                'row_total',
                'row_total_incl_tax',
                'base_row_total',
                'base_row_total_incl_tax',
                'tax_amount',
                'base_tax_amount'
            ];
        }
        if ($item->getProductType() == \Magento\Bundle\Model\Product\Type::TYPE_CODE
            && $item->isShipSeparately()) {
            $suppressedColumns[] = 'qty';
            $suppressedColumns[] = 'qty_ordered';
        }
        $item->setFoomanPdfSuppressedColumn($suppressedColumns);

        return $item;
    }

    /**
     * get main heading for order title ie ORDER CONFIRMATION
     *
     * @return string
     * @access public
     */
    public function getTitle()
    {
        return $this->_scopeConfig->getValue(
            self::XML_PATH_TITLE,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $this->getStoreId()
        );
    }

    /**
     * @return mixed
     */
    public function getAddressesToDisplay()
    {
        return $this->_scopeConfig->getValue(
            self::XML_PATH_ADDRESSES,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $this->getStoreId()
        );
    }

    /**
     * @return mixed
     */
    public function getColumnConfig()
    {
        return $this->_scopeConfig->getValue(
            self::XML_PATH_COLUMNS,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $this->getStoreId()
        );
    }

    /**
     * @return mixed
     */
    public function getCustomText()
    {
        return $this->_scopeConfig->getValue(
            self::XML_PATH_CUSTOMTEXT,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $this->getStoreId()
        );
    }

    protected function getSortColumnsBy()
    {
        return $this->_scopeConfig->getValue(
            self::XML_PATH_SORTBY,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $this->getStoreId()
        );
    }
}

Spamworldpro Mini