135 lines
4.1 KiB
PHP
135 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace Stemcell\Sales\Block\Adminhtml\Order;
|
|
|
|
use Magento\Backend\Block\Widget\Context;
|
|
use Magento\Backend\Block\Widget\Form\Container;
|
|
use Magento\Framework\App\ObjectManager;
|
|
use Magento\Framework\View\Helper\SecureHtmlRenderer;
|
|
use Magento\Sales\Model\ConfigInterface;
|
|
use Magento\Sales\Model\Order;
|
|
|
|
class View extends \Magento\Sales\Block\Adminhtml\Order\View
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getReviewUrl()
|
|
{
|
|
return $this->getUrl('stemcell_sales/*/review');
|
|
}
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @return void
|
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
*/
|
|
protected function _construct()
|
|
{
|
|
$this->_objectId = 'order_id';
|
|
$this->_controller = 'adminhtml_order';
|
|
$this->_mode = 'view';
|
|
|
|
Container::_construct();
|
|
|
|
$this->removeButton('delete');
|
|
$this->removeButton('reset');
|
|
$this->removeButton('save');
|
|
$this->setId('sales_order_view');
|
|
$order = $this->getOrder();
|
|
|
|
if (!$order) {
|
|
return;
|
|
}
|
|
|
|
if ($this->_isAllowedAction('Magento_Sales::cancel')
|
|
&& $order->canCancel()
|
|
&& $order->getState() != Order::STATE_PROCESSING
|
|
) {
|
|
$this->addButton(
|
|
'order_cancel',
|
|
[
|
|
'label' => __('Cancel'),
|
|
'class' => 'cancel',
|
|
'id' => 'order-view-cancel-button',
|
|
'data_attribute' => [
|
|
'url' => $this->getCancelUrl()
|
|
]
|
|
]
|
|
);
|
|
$this->addButton(
|
|
'order_reject',
|
|
[
|
|
'label' => __('驳回'),
|
|
'class' => 'order_reject',
|
|
'onclick' => 'orderReject()'
|
|
]
|
|
);
|
|
|
|
}
|
|
|
|
// if ($this->_isAllowedAction('Magento_Sales::email') && !$order->isCanceled()) {
|
|
// $message = __('Are you sure you want to send an order email to customer?');
|
|
// $this->addButton(
|
|
// 'send_notification',
|
|
// [
|
|
// 'label' => __('Send Email'),
|
|
// 'class' => 'send-email',
|
|
// 'onclick' => "confirmSetLocation('{$message}', '{$this->getEmailUrl()}')"
|
|
// ]
|
|
// );
|
|
// }
|
|
|
|
if ($this->_isAllowedAction(
|
|
'Magento_Sales::ship'
|
|
) && $order->canShip() && !$order->getForcedShipmentWithInvoice()
|
|
) {
|
|
|
|
$this->addButton(
|
|
'order_ship',
|
|
[
|
|
'label' => __('Ship'),
|
|
'onclick' => 'setLocation(\'' . $this->getShipUrl() . '\')',
|
|
'class' => 'ship'
|
|
]
|
|
);
|
|
if ($order->getState() != Order::STATE_PROCESSING) {
|
|
$this->addButton(
|
|
'order_review',
|
|
[
|
|
'label' => __('审核'),
|
|
'class' => 'order_review',
|
|
'onclick' => 'setLocation(\'' . $this->getReviewUrl() . '\')',
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
if ($this->_isAllowedAction(
|
|
'Magento_Sales::reorder'
|
|
) && $this->_reorderHelper->isAllowed(
|
|
$order->getStore()
|
|
) && $order->canReorderIgnoreSalable()
|
|
) {
|
|
$this->addButton(
|
|
'order_reorder',
|
|
[
|
|
'label' => __('Reorder'),
|
|
'onclick' => 'setLocation(\'' . $this->getReorderUrl() . '\')',
|
|
'class' => 'reorder'
|
|
]
|
|
);
|
|
}
|
|
$this->removeButton('order_edit');
|
|
$this->removeButton('order_invoice');
|
|
$this->removeButton('order_hold');
|
|
$this->removeButton('send_notification');
|
|
if ($order->getState() == Order::STATE_PROCESSING) {
|
|
$this->removeButton('order_cancel');
|
|
}
|
|
}
|
|
}
|