Items.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Sales\Block\Order\Invoice;
  12. /**
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Items extends \Magento\Sales\Block\Items\AbstractItems
  17. {
  18. /**
  19. * Core registry
  20. *
  21. * @var \Magento\Framework\Registry
  22. */
  23. protected $_coreRegistry = null;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Framework\Registry $registry
  27. * @param array $data
  28. */
  29. public function __construct(
  30. \Magento\Framework\View\Element\Template\Context $context,
  31. \Magento\Framework\Registry $registry,
  32. array $data = []
  33. ) {
  34. $this->_coreRegistry = $registry;
  35. parent::__construct($context, $data);
  36. }
  37. /**
  38. * Retrieve current order model instance
  39. *
  40. * @return \Magento\Sales\Model\Order
  41. */
  42. public function getOrder()
  43. {
  44. return $this->_coreRegistry->registry('current_order');
  45. }
  46. /**
  47. * @param object $invoice
  48. * @return string
  49. */
  50. public function getPrintInvoiceUrl($invoice)
  51. {
  52. return $this->getUrl('*/*/printInvoice', ['invoice_id' => $invoice->getId()]);
  53. }
  54. /**
  55. * @param object $order
  56. * @return string
  57. */
  58. public function getPrintAllInvoicesUrl($order)
  59. {
  60. return $this->getUrl('*/*/printInvoice', ['order_id' => $order->getId()]);
  61. }
  62. /**
  63. * Get html of invoice totals block
  64. *
  65. * @param \Magento\Sales\Model\Order\Invoice $invoice
  66. * @return string
  67. */
  68. public function getInvoiceTotalsHtml($invoice)
  69. {
  70. $html = '';
  71. $totals = $this->getChildBlock('invoice_totals');
  72. if ($totals) {
  73. $totals->setInvoice($invoice);
  74. $html = $totals->toHtml();
  75. }
  76. return $html;
  77. }
  78. /**
  79. * Get html of invoice comments block
  80. *
  81. * @param \Magento\Sales\Model\Order\Invoice $invoice
  82. * @return string
  83. */
  84. public function getInvoiceCommentsHtml($invoice)
  85. {
  86. $html = '';
  87. $comments = $this->getChildBlock('invoice_comments');
  88. if ($comments) {
  89. $comments->setEntity($invoice)->setTitle(__('About Your Invoice'));
  90. $html = $comments->toHtml();
  91. }
  92. return $html;
  93. }
  94. }