grid.phtml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. ?>
  8. <?php
  9. /** @var $block \Magento\Reports\Block\Adminhtml\Grid */
  10. $numColumns = sizeof($block->getColumns());
  11. ?>
  12. <?php if ($block->getCollection()): ?>
  13. <?php if ($block->canDisplayContainer()): ?>
  14. <div id="<?= /* @escapeNotVerified */ $block->getId() ?>">
  15. <?php else: ?>
  16. <?= $block->getLayout()->getMessagesBlock()->getGroupedHtml() ?>
  17. <?php endif; ?>
  18. <?php if ($block->getStoreSwitcherVisibility() || $block->getDateFilterVisibility()): ?>
  19. <div class="admin__data-grid-header admin__data-grid-toolbar">
  20. <div class="admin__data-grid-header-row">
  21. <?php if ($block->getDateFilterVisibility()): ?>
  22. <div class="admin__filter-actions" data-role="filter-form" id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_range') ?>">
  23. <span class="field-row">
  24. <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
  25. class="admin__control-support-text">
  26. <span><?= /* @escapeNotVerified */ __('From') ?>:</span>
  27. </label>
  28. <input class="input-text no-changes required-entry admin__control-text"
  29. type="text"
  30. id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
  31. name="report_from"
  32. value="<?= $block->escapeHtml($block->getFilter('report_from')) ?>">
  33. <span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from_advice') ?>"></span>
  34. </span>
  35. <span class="field-row">
  36. <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
  37. class="admin__control-support-text">
  38. <span><?= /* @escapeNotVerified */ __('To') ?>:</span>
  39. </label>
  40. <input class="input-text no-changes required-entry admin__control-text"
  41. type="text"
  42. id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
  43. name="report_to"
  44. value="<?= $block->escapeHtml($block->getFilter('report_to')) ?>"/>
  45. <span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to_advice') ?>"></span>
  46. </span>
  47. <span class="field-row admin__control-filter">
  48. <label for="<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>"
  49. class="admin__control-support-text">
  50. <span><?= /* @escapeNotVerified */ __('Show By') ?>:</span>
  51. </label>
  52. <select name="report_period" id="<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>" class="admin__control-select">
  53. <?php foreach ($block->getPeriods() as $_value => $_label): ?>
  54. <option value="<?= /* @escapeNotVerified */ $_value ?>" <?php if ($block->getFilter('report_period') == $_value): ?> selected<?php endif; ?>><?= /* @escapeNotVerified */ $_label ?></option>
  55. <?php endforeach; ?>
  56. </select>
  57. <?= $block->getRefreshButtonHtml() ?>
  58. </span>
  59. <script>
  60. require([
  61. "jquery",
  62. "mage/calendar"
  63. ], function($){
  64. $("#<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_range') ?>").dateRange({
  65. dateFormat:"<?= /* @escapeNotVerified */ $block->getDateFormat() ?>",
  66. buttonText:"<?= /* @escapeNotVerified */ __('Select Date') ?>",
  67. from:{
  68. id:"<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
  69. },
  70. to:{
  71. id:"<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
  72. }
  73. });
  74. });
  75. </script>
  76. </div>
  77. <?php endif; ?>
  78. <?php if ($block->getChildBlock('grid.export')): ?>
  79. <?= $block->getChildHtml('grid.export') ?>
  80. <?php endif; ?>
  81. </div>
  82. </div>
  83. <?php endif; ?>
  84. <div class="admin__data-grid-wrap admin__data-grid-wrap-static">
  85. <table class="data-grid" id="<?= /* @escapeNotVerified */ $block->getId() ?>_table">
  86. <?= $block->getChildHtml('grid.columnSet') ?>
  87. </table>
  88. </div>
  89. </div>
  90. <?php if ($block->canDisplayContainer()): ?>
  91. <script>
  92. require([
  93. "jquery",
  94. "validation",
  95. "mage/mage",
  96. "mage/adminhtml/grid"
  97. ], function(jQuery){
  98. //<![CDATA[
  99. <?= /* @escapeNotVerified */ $block->getJsObjectName() ?> = new varienGrid('<?= /* @escapeNotVerified */ $block->getId() ?>', '<?= /* @escapeNotVerified */ $block->getGridUrl() ?>', '<?= /* @escapeNotVerified */ $block->getVarNamePage() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameSort() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameDir() ?>', '<?= /* @escapeNotVerified */ $block->getVarNameFilter() ?>');
  100. <?= /* @escapeNotVerified */ $block->getJsObjectName() ?>.useAjax = '<?php if ($block->getUseAjax()): /* @escapeNotVerified */ echo $block->getUseAjax(); endif; ?>';
  101. <?php if ($block->getDateFilterVisibility()): ?>
  102. <?= /* @escapeNotVerified */ $block->getJsObjectName() ?>.doFilterCallback = validateFilterDate;
  103. var period_date_from = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>');
  104. var period_date_to = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>');
  105. period_date_from.adviceContainer = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from_advice') ?>');
  106. period_date_to.adviceContainer = $('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to_advice') ?>');
  107. var validateFilterDate = function() {
  108. if (period_date_from && period_date_to) {
  109. var valid = true;
  110. jQuery(period_date_from).add(period_date_to).each(function() {
  111. valid = Validation.validate(this) && valid;
  112. });
  113. return valid;
  114. }
  115. else {
  116. return true;
  117. }
  118. }
  119. <?php endif;?>
  120. <?php if ($block->getStoreSwitcherVisibility()): ?>
  121. /* Overwrite function from switcher.phtml widget*/
  122. switchStore = function(obj) {
  123. if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
  124. var selectionType = 'website';
  125. } else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
  126. var selectionType = 'group';
  127. } else {
  128. var selectionType = 'store';
  129. }
  130. var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
  131. if (obj.switchParams) {
  132. storeParam += obj.switchParams;
  133. }
  134. var formParam = new Array('<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>', '<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>', '<?= /* @escapeNotVerified */ $block->getSuffixId('report_period') ?>');
  135. var paramURL = '';
  136. var switchURL = '<?= /* @escapeNotVerified */ $block->getAbsoluteGridUrl(['_current' => false]) ?>'.replace(/(store|group|website)\/\d+\//, '');
  137. for (var i = 0; i < formParam.length; i++) {
  138. if ($(formParam[i]).value && $(formParam[i]).name) {
  139. paramURL += $(formParam[i]).name + '=' + escape($(formParam[i]).value) + '&';
  140. }
  141. }
  142. setLocation(switchURL + storeParam + '?' + paramURL);
  143. }
  144. <?php endif; ?>
  145. //]]>
  146. });
  147. </script>
  148. <?php endif; ?>
  149. <?php endif; ?>