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/GoToButton.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 GoToButton 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' => __('Go To'),
                'class_name' => SplitButton::class,
                'class' => 'save primary',
                'sort_order' => 30,
                'options' => $options,
            ];
        }

        return [];
    }

    protected function _getSubButtons()
    {
        $this->options = [];
        $this->_getSubButton('shipment', 'Shipment');
        $this->_getSubButton('refund', 'Creditmemo');
        $this->_getSubButton('order', 'Order');

        return $this->options;
    }

    /**
     * @param $documentType
     * @param $label
     * @throws FileSystemException
     */
    protected function _getSubButton($documentType, $label)
    {
        if ($documentType == 'shipment' && $this->entity && $this->entity->getOrderSubType() === "shipment") {
            $this->options[] = [
                'id' => 'extmag_shiplab_goto_' . $documentType,
                'label' => __($label),
                'onclick' => sprintf("location.href = '%s';", $this->getUrl(
                    "sales/shipment/view",
                    ['shipment_id' => $this->entity->getOrderSubId()]
                )),
                'button_class' => 'goto_link',
            ];
        } elseif ($documentType == 'refund' && $this->entity && $this->entity->getOrderSubType() === "refund") {
            $this->options[] = [
                'id' => 'extmag_shiplab_goto_' . $documentType,
                'label' => __($label),
                'onclick' => sprintf("location.href = '%s';", $this->getUrl(
                    "sales/creditmemo/view",
                    ['creditmemo_id' => $this->entity->getOrderSubId()]
                )),
                'button_class' => 'goto_link',
            ];
        } elseif ($documentType == 'order' && $this->entity) {
            $this->options[] = [
                'id' => 'extmag_shiplab_goto_' . $documentType,
                'label' => __($label),
                'onclick' => sprintf("location.href = '%s';", $this->getUrl(
                    "sales/order/view",
                    ['order_id' => $this->entity->getOrderId()]
                )),
                'button_class' => 'goto_link',
            ];
        }
    }
}

Spamworldpro Mini