Totalbar.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order;
  7. /**
  8. * Adminhtml creditmemo bar
  9. *
  10. * @deprecated 101.0.6
  11. * @api
  12. * @author Magento Core Team <core@magentocommerce.com>
  13. * @since 100.0.2
  14. */
  15. class Totalbar extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder
  16. {
  17. /**
  18. * Totals
  19. *
  20. * @var array
  21. */
  22. protected $_totals = [];
  23. /**
  24. * Retrieve required options from parent
  25. *
  26. * @return void
  27. * @throws \Magento\Framework\Exception\LocalizedException
  28. */
  29. protected function _beforeToHtml()
  30. {
  31. if (!$this->getParentBlock()) {
  32. throw new \Magento\Framework\Exception\LocalizedException(
  33. __('Please correct the parent block for this block.')
  34. );
  35. }
  36. $this->setOrder($this->getParentBlock()->getOrder());
  37. $this->setSource($this->getParentBlock()->getSource());
  38. $this->setCurrency($this->getParentBlock()->getOrder()->getOrderCurrency());
  39. foreach ($this->getParentBlock()->getOrderTotalbarData() as $v) {
  40. $this->addTotal($v[0], $v[1], $v[2]);
  41. }
  42. parent::_beforeToHtml();
  43. }
  44. /**
  45. * Get totals
  46. *
  47. * @return array
  48. */
  49. protected function getTotals()
  50. {
  51. return $this->_totals;
  52. }
  53. /**
  54. * Add total
  55. *
  56. * @param string $label
  57. * @param float $value
  58. * @param bool $grand
  59. * @return $this
  60. */
  61. public function addTotal($label, $value, $grand = false)
  62. {
  63. $this->_totals[] = ['label' => $label, 'value' => $value, 'grand' => $grand];
  64. return $this;
  65. }
  66. }