mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-08 01:37:36 +00:00
107 lines
2.9 KiB
PHP
107 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace Magento\Shipping\Block\Adminhtml\Order\Tracking;
|
|
|
|
use Magento\Framework\App\ObjectManager;
|
|
use Magento\Shipping\Helper\Data as ShippingHelper;
|
|
|
|
/**
|
|
* Shipment tracking control form
|
|
*
|
|
* @api
|
|
* @since 100.0.2
|
|
*/
|
|
class View extends \Magento\Shipping\Block\Adminhtml\Order\Tracking
|
|
{
|
|
/**
|
|
* @var \Magento\Shipping\Model\CarrierFactory
|
|
*/
|
|
protected $_carrierFactory;
|
|
|
|
/**
|
|
* @param \Magento\Backend\Block\Template\Context $context
|
|
* @param \Magento\Shipping\Model\Config $shippingConfig
|
|
* @param \Magento\Framework\Registry $registry
|
|
* @param \Magento\Shipping\Model\CarrierFactory $carrierFactory
|
|
* @param array $data
|
|
* @param ShippingHelper|null $shippingHelper
|
|
*/
|
|
public function __construct(
|
|
\Magento\Backend\Block\Template\Context $context,
|
|
\Magento\Shipping\Model\Config $shippingConfig,
|
|
\Magento\Framework\Registry $registry,
|
|
\Magento\Shipping\Model\CarrierFactory $carrierFactory,
|
|
array $data = [],
|
|
?ShippingHelper $shippingHelper = null
|
|
) {
|
|
$data['shippingHelper'] = $shippingHelper ?? ObjectManager::getInstance()->get(ShippingHelper::class);
|
|
parent::__construct($context, $shippingConfig, $registry, $data);
|
|
$this->_carrierFactory = $carrierFactory;
|
|
}
|
|
|
|
/**
|
|
* Prepares layout of block
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function _prepareLayout()
|
|
{
|
|
$onclick = "saveTrackingInfo($('shipment_tracking_info').parentNode, '" . $this->getSubmitUrl() . "')";
|
|
$this->addChild(
|
|
'save_button',
|
|
\Magento\Backend\Block\Widget\Button::class,
|
|
['label' => __('Add'), 'class' => 'save', 'onclick' => $onclick]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Retrieve save url
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSubmitUrl()
|
|
{
|
|
return $this->getUrl('adminhtml/*/addTrack/', ['shipment_id' => $this->getShipment()->getId()]);
|
|
}
|
|
|
|
/**
|
|
* Retrieve save button html
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSaveButtonHtml()
|
|
{
|
|
return $this->getChildHtml('save_button');
|
|
}
|
|
|
|
/**
|
|
* Retrieve remove url
|
|
*
|
|
* @param \Magento\Sales\Model\Order\Shipment\Track $track
|
|
* @return string
|
|
*/
|
|
public function getRemoveUrl($track)
|
|
{
|
|
return $this->getUrl(
|
|
'adminhtml/*/removeTrack/',
|
|
['shipment_id' => $this->getShipment()->getId(), 'track_id' => $track->getId()]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get carrier title
|
|
*
|
|
* @param string $code
|
|
*
|
|
* @return \Magento\Framework\Phrase|string|bool
|
|
*/
|
|
public function getCarrierTitle($code)
|
|
{
|
|
$carrier = $this->_carrierFactory->create($code);
|
|
return $carrier ? $carrier->getConfigData('title') : __('Custom Value');
|
|
}
|
|
}
|