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/extmag/shiplab/Controller/Adminhtml/Pickup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/shiplab/Controller/Adminhtml/Pickup/PackingSlips.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\Shiplab\Controller\Adminhtml\Pickup;

use Extmag\Shiplab\Controller\Adminhtml\Pickup;
use Extmag\Shiplab\Model\ResourceModel\Label\Collection;
use Extmag\Shiplab\Model\ResourceModel\Pickup\CollectionFactory;
use Exception;
use Magento\Backend\Model\View\Result\Redirect;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filesystem\DirectoryList;

class PackingSlips extends Pickup
{
    /**
     * Authorization level of a basic admin session
     *
     * @see _isAllowed()
     */
    public const ADMIN_RESOURCE = 'Extmag_Shiplab::shiplab_pickup_index';

    /**
     * @return ResponseInterface|Redirect
     * @throws LocalizedException|Exception
     */
    public function execute()
    {
        /** @var Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        $collection = $this->filter->getCollection($this->pickupCollectionFactory->create());
        $collectionSize = $collection->count();
        if ($collectionSize > 0) {
            $labels = [];
            /**
             * @var \Extmag\Shiplab\Model\Pickup $item
             */
            foreach ($collection as $item) {
                /**
                 * @var Collection $labelsCollection
                 */
                $labelsCollection = $this->labelCollectionFactory->create();
                $labelsCollection->addFieldToFilter('entity_id', ['in' => explode(",", $item->getLabelIds())]);
                foreach ($labelsCollection as $labelCol) {
                    $labels[] = $labelCol;
                }
            }

            $pdf = $this->pickupPDF->getPdf($labels);
            if (!empty($pdf)) {
                return $this->fileFactory->create(
                    "Packing-Slips-for-Shipping-Labels",
                    $pdf->render(),
                    DirectoryList::SYS_TMP,
                    'application/pdf'
                );
            }
        }

        $this->messageManager->addErrorMessage(__("Packing Slips is not created"));
        return $resultRedirect->setRefererOrBaseUrl();
    }
}

Spamworldpro Mini