Items.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Sales order view items block
  8. */
  9. namespace Magento\Sales\Block\Order\Creditmemo;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Items extends \Magento\Sales\Block\Items\AbstractItems
  15. {
  16. /**
  17. * Core registry
  18. *
  19. * @var \Magento\Framework\Registry
  20. */
  21. protected $_coreRegistry = null;
  22. /**
  23. * @param \Magento\Framework\View\Element\Template\Context $context
  24. * @param \Magento\Framework\Registry $registry
  25. * @param array $data
  26. */
  27. public function __construct(
  28. \Magento\Framework\View\Element\Template\Context $context,
  29. \Magento\Framework\Registry $registry,
  30. array $data = []
  31. ) {
  32. $this->_coreRegistry = $registry;
  33. parent::__construct($context, $data);
  34. }
  35. /**
  36. * Retrieve current order model instance
  37. *
  38. * @return \Magento\Sales\Model\Order
  39. */
  40. public function getOrder()
  41. {
  42. return $this->_coreRegistry->registry('current_order');
  43. }
  44. /**
  45. * @param object $creditmemo
  46. * @return string
  47. */
  48. public function getPrintCreditmemoUrl($creditmemo)
  49. {
  50. return $this->getUrl('*/*/printCreditmemo', ['creditmemo_id' => $creditmemo->getId()]);
  51. }
  52. /**
  53. * @param object $order
  54. * @return string
  55. */
  56. public function getPrintAllCreditmemosUrl($order)
  57. {
  58. return $this->getUrl('*/*/printCreditmemo', ['order_id' => $order->getId()]);
  59. }
  60. /**
  61. * Get creditmemo totals block html
  62. *
  63. * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
  64. * @return string
  65. */
  66. public function getTotalsHtml($creditmemo)
  67. {
  68. $totals = $this->getChildBlock('creditmemo_totals');
  69. $html = '';
  70. if ($totals) {
  71. $totals->setCreditmemo($creditmemo);
  72. $html = $totals->toHtml();
  73. }
  74. return $html;
  75. }
  76. /**
  77. * Get html of creditmemo comments block
  78. *
  79. * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
  80. * @return string
  81. */
  82. public function getCommentsHtml($creditmemo)
  83. {
  84. $html = '';
  85. $comments = $this->getChildBlock('creditmemo_comments');
  86. if ($comments) {
  87. $comments->setEntity($creditmemo)->setTitle(__('About Your Refund'));
  88. $html = $comments->toHtml();
  89. }
  90. return $html;
  91. }
  92. }