16 class View extends \Magento\Backend\Block\Widget\Form\Container
57 \
Magento\Sales\Helper\Reorder $reorderHelper,
60 $this->_reorderHelper = $reorderHelper;
62 $this->_salesConfig = $salesConfig;
63 parent::__construct($context,
$data);
76 $this->_objectId =
'order_id';
77 $this->_controller =
'adminhtml_order';
78 $this->_mode =
'view';
85 $this->setId(
'sales_order_view');
93 $onclickJs =
'jQuery(\'#order_edit\').orderEditDialog({message: \'' 95 .
'\'}).orderEditDialog(\
'showDialog\');';
100 'label' =>
__(
'Edit'),
101 'class' =>
'edit primary',
102 'onclick' => $onclickJs,
103 'data_attribute' => [
104 'mage-init' =>
'{"orderEditDialog":{}}',
114 'label' =>
__(
'Cancel'),
116 'id' =>
'order-view-cancel-button',
117 'data_attribute' => [
125 $message =
__(
'Are you sure you want to send an order email to customer?');
129 'label' =>
__(
'Send Email'),
130 'class' =>
'send-email',
131 'onclick' =>
"confirmSetLocation('{$message}', '{$this->getEmailUrl()}')" 138 'This will create an offline refund. ' .
139 'To create an online refund, open an invoice and create credit memo for it. Do you want to continue?' 141 $onClick =
"setLocation('{$this->getCreditmemoUrl()}')";
142 if (
$order->getPayment()->getMethodInstance()->isGateway()) {
143 $onClick =
"confirmSetLocation('{$message}', '{$this->getCreditmemoUrl()}')";
147 [
'label' =>
__(
'Credit Memo'),
'onclick' => $onClick,
'class' =>
'credit-memo']
153 $message =
__(
'Are you sure you want to void the payment?');
157 'label' =>
__(
'Void'),
158 'onclick' =>
"confirmSetLocation('{$message}', '{$this->getVoidPaymentUrl()}')" 167 'label' =>
__(
'Hold'),
168 'class' =>
__(
'hold'),
169 'id' =>
'order-view-hold-button',
170 'data_attribute' => [
181 'label' =>
__(
'Unhold'),
182 'class' =>
__(
'unhold'),
183 'id' =>
'order-view-unhold-button',
184 'data_attribute' => [
192 if (
$order->canReviewPayment()) {
193 $message =
__(
'Are you sure you want to accept this payment?');
197 'label' =>
__(
'Accept Payment'),
198 'onclick' =>
"confirmSetLocation('{$message}', '{$this->getReviewPaymentUrl('accept')}')" 201 $message =
__(
'Are you sure you want to deny this payment?');
205 'label' =>
__(
'Deny Payment'),
206 'onclick' =>
"confirmSetLocation('{$message}', '{$this->getReviewPaymentUrl('deny')}')" 210 if (
$order->canFetchPaymentReviewUpdate()) {
212 'get_review_payment_update',
214 'label' =>
__(
'Get Payment Update'),
221 if ($this->_isAllowedAction('Magento_Sales::invoice
') && $order->canInvoice()) { 222 $_label = $order->getForcedShipmentWithInvoice() ? __('Invoice and Ship
') : __('Invoice
'); 227 'onclick
' => 'setLocation(\
'' . $this->
getInvoiceUrl() .
'\')
', 233 if ($this->_isAllowedAction( 234 'Magento_Sales::ship
' 235 ) && $order->canShip() && !$order->getForcedShipmentWithInvoice() 240 'label
' => __('Ship
'), 241 'onclick
' => 'setLocation(\
'' . $this->
getShipUrl() .
'\')
', 247 if ($this->_isAllowedAction( 248 'Magento_Sales::reorder
' 249 ) && $this->_reorderHelper->isAllowed( 251 ) && $order->canReorderIgnoreSalable() 256 'label
' => __('Reorder
'), 257 'onclick
' => 'setLocation(\
'' . $this->
getReorderUrl() .
'\')
', 269 public function getOrder() 271 return $this->_coreRegistry->registry('sales_order
'); 279 public function getOrderId() 281 return $this->getOrder() ? $this->getOrder()->getId() : null; 289 public function getHeaderText() 291 $_extOrderId = $this->getOrder()->getExtOrderId(); 293 $_extOrderId = '[
' . $_extOrderId . ']
'; 298 'Order # %1 %2 | %3
', 299 $this->getOrder()->getRealOrderId(), 302 $this->_localeDate->date(new \DateTime($this->getOrder()->getCreatedAt())), 303 \IntlDateFormatter::MEDIUM, 316 public function getUrl($params = '', $params2 = []) 318 $params2['order_id
'] = $this->getOrderId(); 319 return parent::getUrl($params, $params2); 327 public function getEditUrl() 329 return $this->getUrl('sales/order_edit/start
'); 337 public function getEmailUrl() 339 return $this->getUrl('sales
357 public function getInvoiceUrl() 359 return $this->getUrl('sales/order_invoice/start
'); 367 public function getCreditmemoUrl() 369 return $this->getUrl('sales/order_creditmemo/start
'); 377 public function getHoldUrl() 379 return $this->getUrl('sales
397 public function getShipUrl() 399 return $this->getUrl('adminhtml/order_shipment/start
'); 407 public function getCommentUrl() 409 return $this->getUrl('sales
438 protected function _isAllowedAction($resourceId) 440 return $this->_authorization->isAllowed($resourceId); 448 public function getBackUrl() 450 if ($this->getOrder() && $this->getOrder()->getBackUrl()) { 451 return $this->getOrder()->getBackUrl(); 454 return $this->getUrl('sales
465 reviewPayment
', ['action
' => $action]); 472 protected function getEditMessage($order) 474 // see if order has non-editable products as items 475 $nonEditableTypes = $this->getNonEditableTypes($order); 476 if (!empty($nonEditableTypes)) { 478 'This order contains (%1) items and therefore cannot be edited through the admin interface. ' .
479 'If you wish to
continue editing, the (%2) items will be removed, ' .
480 ' the order will be canceled and a new order will be placed.',
481 implode(', ', $nonEditableTypes),
482 implode(', ', $nonEditableTypes)
485 return __('Are you sure? This order will be canceled and a new one will be created instead.');
495 $this->
getOrder()->getResource()->aggregateProductsByTypes(
497 $this->_salesConfig->getAvailableProductTypes(),
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, \Magento\Sales\Model\Config $salesConfig, \Magento\Sales\Helper\Reorder $reorderHelper, array $data=[])
getReviewPaymentUrl($action)
getNonEditableTypes($order)
_isAllowedAction($resourceId)
return['app/code */registration.php', 'app/design */registration.php', 'lib/internal **/registration.php']
foreach( $block->getMultipleRows( $_item) as $_i)($_isFirstRow) continue