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/PrintButton.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

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

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

class PrintButton extends GenericButton implements ButtonProviderInterface
{
    /**
     * @var Label $entity
     */
    private $entity;

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

    /**
     * @var array $options
     */
    private $options;

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

        return null;
    }

    /**
     * @return array
     * @throws FileSystemException
     */
    protected function _getSubButtons()
    {
        $this->options = [];
        if (!empty($this->entity)) {
            $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('hvr', $this->entity->getExtension(), '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->isDocumentsExists($this->entities, $documentType, $ext) === true
        ) {
            $this->options[] = [
                'id' => 'extmag_shiplab_print_' . $documentType,
                'label' => __($label),
                'onclick' => null,
                'class' => 'print_local',
                'data_attribute' => [
                    'link' => $this->getUrl(
                        'extmag_shiplab/printer/massPrint',
                        [
                            'document_type' => $documentType,
                            'namespace' => 'labels',
                            '_query' => ['selected' => $this->getEntityIds()],
                        ]
                    ),
                ],
            ];
        }
    }
}

Spamworldpro Mini