Grid.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Reports\Block\Adminhtml\Sales\Refunded;
  7. /**
  8. * Adminhtml refunded report grid block
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  12. */
  13. class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
  14. {
  15. /**
  16. * GROUP BY criteria
  17. *
  18. * @var string
  19. */
  20. protected $_columnGroupBy = 'period';
  21. /**
  22. * {@inheritdoc}
  23. * @codeCoverageIgnore
  24. */
  25. protected function _construct()
  26. {
  27. parent::_construct();
  28. $this->setCountTotals(true);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function getResourceCollectionName()
  34. {
  35. return $this->getFilterData()->getData('report_type') == 'created_at_refunded'
  36. ? \Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Refunded::class
  37. : \Magento\Sales\Model\ResourceModel\Report\Refunded\Collection\Order::class;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. protected function _prepareColumns()
  43. {
  44. $this->addColumn(
  45. 'period',
  46. [
  47. 'header' => __('Interval'),
  48. 'index' => 'period',
  49. 'sortable' => false,
  50. 'period_type' => $this->getPeriodType(),
  51. 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class,
  52. 'totals_label' => __('Total'),
  53. 'html_decorators' => ['nobr'],
  54. 'header_css_class' => 'col-period',
  55. 'column_css_class' => 'col-period'
  56. ]
  57. );
  58. $this->addColumn(
  59. 'orders_count',
  60. [
  61. 'header' => __('Refunded Orders'),
  62. 'index' => 'orders_count',
  63. 'type' => 'number',
  64. 'total' => 'sum',
  65. 'sortable' => false,
  66. 'header_css_class' => 'col-qty',
  67. 'column_css_class' => 'col-qty'
  68. ]
  69. );
  70. if ($this->getFilterData()->getStoreIds()) {
  71. $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
  72. }
  73. $currencyCode = $this->getCurrentCurrencyCode();
  74. $rate = $this->getRate($currencyCode);
  75. $this->addColumn(
  76. 'refunded',
  77. [
  78. 'header' => __('Total Refunded'),
  79. 'type' => 'currency',
  80. 'currency_code' => $currencyCode,
  81. 'index' => 'refunded',
  82. 'total' => 'sum',
  83. 'sortable' => false,
  84. 'rate' => $rate,
  85. 'header_css_class' => 'col-ref-total',
  86. 'column_css_class' => 'col-ref-total'
  87. ]
  88. );
  89. $this->addColumn(
  90. 'online_refunded',
  91. [
  92. 'header' => __('Online Refunds'),
  93. 'type' => 'currency',
  94. 'currency_code' => $currencyCode,
  95. 'index' => 'online_refunded',
  96. 'total' => 'sum',
  97. 'sortable' => false,
  98. 'rate' => $rate,
  99. 'header_css_class' => 'col-ref-online',
  100. 'column_css_class' => 'col-ref-online'
  101. ]
  102. );
  103. $this->addColumn(
  104. 'offline_refunded',
  105. [
  106. 'header' => __('Offline Refunds'),
  107. 'type' => 'currency',
  108. 'currency_code' => $currencyCode,
  109. 'index' => 'offline_refunded',
  110. 'total' => 'sum',
  111. 'sortable' => false,
  112. 'rate' => $rate,
  113. 'header_css_class' => 'col-ref-offline',
  114. 'column_css_class' => 'col-ref-offline'
  115. ]
  116. );
  117. $this->addExportType('*/*/exportRefundedCsv', __('CSV'));
  118. $this->addExportType('*/*/exportRefundedExcel', __('Excel XML'));
  119. return parent::_prepareColumns();
  120. }
  121. }