![]() 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/Rma/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Block\Rma; use Extmag\Shiplab\Model\Label; use Extmag\Shiplab\Model\ResourceModel\Label\Collection; use Extmag\Shiplab\Model\ResourceModel\Label\CollectionFactory; use Magento\Framework\Escaper; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Element\Template\Context; use Magento\Theme\Block\Html\Pager; /** * RMA block * * @api * @since 100.0.2 */ class View extends Template { /** * @var string */ protected $_template = 'Extmag_Shiplab::rma/view.phtml'; /** * @var CollectionFactory */ protected $labelCollectionFactory; /** * @var Collection */ protected $labels; /** * @var Escaper */ public $escaper; /** * @param Context $context * @param CollectionFactory $labelCollectionFactory * @param array $data */ public function __construct( Context $context, CollectionFactory $labelCollectionFactory, array $data = [] ) { parent::__construct($context, $data); $this->labelCollectionFactory = $labelCollectionFactory; $this->escaper = $context->getEscaper(); } /** * @return void */ protected function _construct() { parent::_construct(); $this->pageConfig->getTitle()->set(__('My RMA')); } /** * @return bool|Collection */ public function getLabels() { if (!$this->labels) { $this->labels = $this->labelCollectionFactory->create(); $this->labels ->addFieldToFilter('order_id', $this->getRequest()->getParam('order_id')) ->addFieldToFilter('status', 1) ->addFieldToFilter('type_direction', 'refund') ->addFieldToFilter('order_sub_type', ['neq' => 'refund']) ->addFieldToFilter('extension', ['in' => ['PDF', 'GIF']]) ->setOrder('created_time'); } return $this->labels; } /** * @param Label $label * @return array */ public function getProducts(Label $label) { $requestData = json_decode($label->getRequest(), true); return [$requestData['packages'][0]['products'] ?? [], $requestData['products'] ?? []]; } /** * @param Label $label * @return string */ public function getComment(Label $label) { $requestData = json_decode($label->getRequest(), true); return $requestData['comment'] ?? ''; } /** * @return $this * @throws LocalizedException */ protected function _prepareLayout() { parent::_prepareLayout(); if ($this->getLabels()) { $pager = $this->getLayout()->createBlock( Pager::class, 'extmag_shiplab.rma.view.pager' )->setCollection( $this->getLabels() ); $this->setChild('pager', $pager); $this->getLabels()->load(); } return $this; } /** * @return string */ public function getPagerHtml() { return $this->getChildHtml('pager'); } /** * @param object $label * @return string */ public function getPrintUrl($label) { return $this->getUrl('extmag_shiplab/label/printer', ['label_id' => $label->getId()]); } }