Grid.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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\Invoiced;
  7. /**
  8. * Adminhtml invoiced 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 condition
  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_invoice'
  36. ? \Magento\Sales\Model\ResourceModel\Report\Invoiced\Collection\Invoiced::class
  37. : \Magento\Sales\Model\ResourceModel\Report\Invoiced\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' => __('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. $this->addColumn(
  71. 'orders_invoiced',
  72. [
  73. 'header' => __('Invoiced Orders'),
  74. 'index' => 'orders_invoiced',
  75. 'type' => 'number',
  76. 'total' => 'sum',
  77. 'sortable' => false,
  78. 'header_css_class' => 'col-invoiced',
  79. 'column_css_class' => 'col-invoiced'
  80. ]
  81. );
  82. if ($this->getFilterData()->getStoreIds()) {
  83. $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
  84. }
  85. $currencyCode = $this->getCurrentCurrencyCode();
  86. $rate = $this->getRate($currencyCode);
  87. $this->addColumn(
  88. 'invoiced',
  89. [
  90. 'header' => __('Total Invoiced'),
  91. 'type' => 'currency',
  92. 'currency_code' => $currencyCode,
  93. 'index' => 'invoiced',
  94. 'total' => 'sum',
  95. 'sortable' => false,
  96. 'rate' => $rate,
  97. 'header_css_class' => 'col-total-invoiced',
  98. 'column_css_class' => 'col-total-invoiced'
  99. ]
  100. );
  101. $this->addColumn(
  102. 'invoiced_captured',
  103. [
  104. 'header' => __('Paid Invoices'),
  105. 'type' => 'currency',
  106. 'currency_code' => $currencyCode,
  107. 'index' => 'invoiced_captured',
  108. 'total' => 'sum',
  109. 'sortable' => false,
  110. 'rate' => $rate,
  111. 'header_css_class' => 'col-total-invoiced-paid',
  112. 'column_css_class' => 'col-total-invoiced-paid'
  113. ]
  114. );
  115. $this->addColumn(
  116. 'invoiced_not_captured',
  117. [
  118. 'header' => __('Unpaid Invoices'),
  119. 'type' => 'currency',
  120. 'currency_code' => $currencyCode,
  121. 'index' => 'invoiced_not_captured',
  122. 'total' => 'sum',
  123. 'sortable' => false,
  124. 'rate' => $rate,
  125. 'header_css_class' => 'col-total-invoiced-not-paid',
  126. 'column_css_class' => 'col-total-invoiced-not-paid'
  127. ]
  128. );
  129. $this->addExportType('*/*/exportInvoicedCsv', __('CSV'));
  130. $this->addExportType('*/*/exportInvoicedExcel', __('Excel XML'));
  131. return parent::_prepareColumns();
  132. }
  133. }