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/Block/Adminhtml/Label/View/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/shiplab/Block/Adminhtml/Label/View/DownloadButton.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\Shiplab\Block\Adminhtml\Label\View;

use Extmag\Shiplab\Model\Label;
use Extmag\Shiplab\Ui\Component\Control\SplitButton;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class DownloadButton extends GenericButton implements ButtonProviderInterface
{
    /**
     * @var Label $entity
     */
    protected $entity;

    /**
     * @var Label[] $entities
     */
    protected $entities;

    protected $options;

    /**
     * @return array
     */
    public function getButtonData()
    {
        $this->entity = $this->getEntity();
        $this->entities = $this->getEntities();
        $options = $this->_getSubButtons();
        if (!empty($options)) {
            return [
                'label' => __('Download'),
                'class_name' => SplitButton::class,
                'class' => 'save primary',
                'sort_order' => 50,
                'options' => $options,
            ];
        }

        return [];
    }

    protected function _getSubButtons()
    {
        $this->options = [];
        $this->_getSubButton('label', '', 'Labels');
        $this->_getSubButton('invoice', 'pdf', 'Invoice');
        $this->_getSubButton('turn_in_copy', 'pdf', 'Turn In Page');
        $this->_getSubButton('hvr', 'html', 'High Value Report');
        $this->_getSubButton('dg_paper', 'pdf', 'Dangerous Goods Paper');
        $this->_getSubButton('archive', '', 'Archive Document');

        return $this->options;
    }

    /**
     * @param $documentType
     * @param $ext
     * @param $label
     * @throws FileSystemException
     */
    protected function _getSubButton($documentType, $ext, $label)
    {
        if (($documentType == 'label' && $this->manager->isNotThermalLabel($this->entities))
            || ($documentType != 'label' && $this->isDocumentsExists($this->entities, $documentType, $ext) === true)
        ) {
            $this->options[] = [
                'id' => 'extmag_shiplab_download_' . $documentType,
                'label' => __($label),
                'onclick' => sprintf("location.href = '%s';", $this->getDownloadUrl($documentType)),
                'button_class' => 'download_link',
            ];
        }
    }

    /**
     * @param $docType
     * @return string
     */
    protected function getDownloadUrl($docType)
    {
        return $this->getUrl(
            'extmag_shiplab/printer/download',
            ['document_type' => $docType, 'label_ids' => implode(",", $this->getEntityIds())]
        );
    }
}

Spamworldpro Mini