Skip to content

Commit

Permalink
Merge pull request #34 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
Shinichi69 authored Oct 25, 2021
2 parents c25a72a + 7f9a09c commit ec298f9
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 251 deletions.
9 changes: 9 additions & 0 deletions Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,13 @@ public function getOrderStatusList()

return $statuses;
}

/**
* @return string
* @throws Exception
*/
public function getDate()
{
return Data::jsonEncode($this->helperData->getDateRange());
}
}
38 changes: 38 additions & 0 deletions Block/Store/Switcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Reports
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Reports\Block\Store;

use Magento\Backend\Block\Store\Switcher as BackendSwitcher;

/**
* Class Switcher
* @package Mageplaza\Reports\Block\Store
*/
class Switcher extends BackendSwitcher
{
/**
* Block template filename
*
* @var string
*/
protected $_template = 'Mageplaza_Reports::store/switcher.phtml';
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "4.1.1",
"version": "4.1.2",
"license": "proprietary",
"authors": [
{
Expand Down
62 changes: 36 additions & 26 deletions view/adminhtml/templates/dashboard/card.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
* @license https://www.mageplaza.com/LICENSE.txt
*/

/** @var \Mageplaza\Reports\Block\Dashboard\Card $block */
/** @var \Mageplaza\Reports\Block\Dashboard\AbstractClass $card */
$card = $block->getCard();
use Mageplaza\Reports\Block\Dashboard\AbstractClass;
use Mageplaza\Reports\Block\Dashboard\Card;
use Mageplaza\Reports\Helper\Data;

/** @var Card $block */
/** @var AbstractClass $card */

$card = $block->getCard();
?>
<div id="<?= /** @noEscape */ $card->getCardId() ?>"
class="<?= $card->getVisible() ? 'grid-stack-item' : 'hide' ?>"
Expand All @@ -37,57 +41,63 @@ $card = $block->getCard();
<div class="not-draggable">
<div class="dashboard-item-container">
<div class="dashboard-item-header">
<?php if ($title = $card->getTitle()): ?>
<?php if ($title = $card->getTitle()) : ?>
<div class="dashboard-item-title"><?= $block->escapeHtml($title) ?></div>
<?php endif; ?>
<?php if ($card->canShowDetail()): ?>
<?php if ($card->canShowDetail() && $card->getDetailUrl()) : ?>
<div class="view-detail">
<a href="<?= /** @noEscape */ $card->getDetailUrl() ?>"
<a href="<?= /** @noEscape */
$card->getDetailUrl() ?>"
target="_blank"><?= $block->escapeHtml(__('View Details')) ?></a>
</div>
<?php endif; ?>
<div style="clear: both"></div>
<?php if ($block->getRequest()->isAjax() && $block->getRequest()->getFullActionName() === 'mpreports_cards_loadcard'): ?>
<?php if ($block->getRequest()->isAjax()
&& $block->getRequest()->getFullActionName() === 'mpreports_cards_loadcard') : ?>
<?php
$totalLabel = $card->getTotal();
if ($totalLabel !== ''): ?>
if ($totalLabel !== '') : ?>
<div class="dashboard-sales-value">
<?= /** @noEscape */ $totalLabel ?>
<?= /** @noEscape */
$totalLabel ?>
<?php
$rate = $card->getRate();
if (($rate !== '') && $block->isCompare()): ?>
<div class="chart-rate <?= $rate > 0 ? 'up-rate mp-green' : ($rate < 0 ? 'down-rate mp-red' : '') ?>">
<?= /** @noEscape */ abs($rate) . '%' ?>
if (($rate !== '') && $block->isCompare()) : ?>
<div class="chart-rate <?= $rate > 0 ?
'up-rate mp-green' : ($rate < 0 ? 'down-rate mp-red' : '') ?>">
<?= /** @noEscape */
abs($rate) . '%' ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php if ($block->getRequest()->isAjax() && $block->getRequest()->getFullActionName() === 'mpreports_cards_loadcard'): ?>
<?php if ($block->getRequest()->isAjax()
&& $block->getRequest()->getFullActionName() === 'mpreports_cards_loadcard') : ?>
<?= $card->getContentHtml() ?>
<?php else: ?>
<div class="mp-card loading-mask">
<img src="<?= /** @noEscape */ $block->getViewFileUrl('images/loader-1.gif') ?>" alt="Loading..."/>
</div>
<?php else : ?>
<div class="mp-card loading-mask">
<img src="<?= /** @noEscape */
$block->getViewFileUrl('images/loader-1.gif') ?>" alt="Loading..."/>
</div>
<?php endif; ?>
<?php if ($block->getRequest()->getFullActionName() !== 'mpreports_cards_loadcard'): ?>
<?php if ($block->getRequest()->getFullActionName() !== 'mpreports_cards_loadcard') : ?>
<script>
require([
'jquery'
],function ($) {
var cardEl = $('#<?= /** @noEscape */ $card->getCardId() ?>');
], function ($) {
var cardEl = $('#<?= /** @noEscape */ $card->getCardId() ?>');
var boardEl = $('.grid-stack');
boardEl.on('mpCardLoaded', function () {
if(boardEl.data('isLoading') === true || cardEl.data('isLoaded')) {
if (boardEl.data('isLoading') === true || cardEl.data('isLoaded')) {
return;
}

var dateRangeEl = $('#daterange'),
var dateRangeEl = $('#daterange'),
compareDateRangeEl = $('#compare-daterange'),
isCompare = <?= /** @noEscape */ $block->isCompare() ?>;

var data = <?= \Mageplaza\Reports\Helper\Data::jsonEncode($card->getData()) ?>;
isCompare = <?= /** @noEscape */ $block->isCompare() ?>,
data = <?= /** @noEscape */ Data::jsonEncode($card->getData()) ?>;

data = dateRangeEl.data().startDate ? $.extend(data, {
dateRange: {
Expand All @@ -113,7 +123,7 @@ $card = $block->getCard();
cardEl.data('isLoaded', true);
boardEl.data('isLoading', false);
boardEl.trigger('mpCardLoaded');
cardEl.find('.dashboard-item-container').html('<?php __('Something went wrong while loading %1 card', $card->getTitle()) ?>');
cardEl.find('.dashboard-item-container').html('<?= __('Something went wrong while loading %1 card', $card->getTitle()) ?>');
}
})
});
Expand Down
8 changes: 4 additions & 4 deletions view/adminhtml/templates/menu.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ $storeFilterUrl = $block->getUrl('mpreports/details/storefilter', ['form_key' =>
<i class="fa fa-bars"></i>
</a>
<ul class="admin__action-dropdown-menu">
<?php foreach ($menu as $item): ?>
<?php foreach ($menu as $item) : ?>
<li><a href="<?= /** @noEscape */ $item['path'] ?>"><?= /** @noEscape */ $item['label'] ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<div class="date-range-picker">
<div class="date-range-picker" data-mage-init='{"initDateRange":{"date":<?= /** @noEscape */ $block->getDate() ?>}}'>
<div id="daterange">
<i class="fa fa-calendar"></i>
<span></span>
Expand All @@ -61,7 +61,7 @@ $storeFilterUrl = $block->getUrl('mpreports/details/storefilter', ['form_key' =>
</div>
<div class="customer-group">
<select id="customer-group-id">
<?php foreach ($block->getCustomerGroup() as $group): ?>
<?php foreach ($block->getCustomerGroup() as $group) : ?>
<option value="<?= /** @noEscape */ $group['value'] ?>"><?= /** @noEscape */ $group['label'] ?></option>
<?php endforeach; ?>
</select>
Expand All @@ -85,7 +85,7 @@ $storeFilterUrl = $block->getUrl('mpreports/details/storefilter', ['form_key' =>
<div class="admin__action-dropdown-menu _overflow" id="order_status">
<div class="admin__action-dropdown-menu-header"></div>
<div class="admin__action-dropdown-menu-content">
<?php foreach ($block->getOrderStatusList() as $status): ?>
<?php foreach ($block->getOrderStatusList() as $status) : ?>
<div class="admin__field-option" data-repeat-index="0">
<input class="admin__control-checkbox"
type="checkbox"
Expand Down
165 changes: 165 additions & 0 deletions view/adminhtml/templates/store/switcher.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Reports
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Mageplaza\Reports\Block\Store\Switcher;

/* @var Switcher $block */
/** @var SecureHtmlRenderer $secureRenderer */
?>
<?php if ($websites = $block->getWebsites()) : ?>
<div class="store-switcher store-view">
<span class="store-switcher-label"><?= $block->escapeHtml(__('Scope:')) ?></span>
<div class="actions dropdown closable">
<input type="hidden" name="store_switcher" id="store_switcher"
data-role="store-view-id" data-param="<?= $block->escapeHtmlAttr($block->getStoreVarName()) ?>"
value="<?= $block->escapeHtml($block->getStoreId()) ?>"
<?= /* @noEscape */ $block->getUiId() ?>/>
<?= /* @noEscape */
$secureRenderer->renderEventListenerAsTag(
'onchange',
'switchScope(this);',
'#store_switcher'
) ?>
<input type="hidden" name="store_group_switcher" id="store_group_switcher"
data-role="store-group-id" data-param="<?= $block->escapeHtmlAttr($block->getStoreGroupVarName()) ?>"
value="<?= $block->escapeHtml($block->getStoreGroupId()) ?>"
<?= /* @noEscape */ $block->getUiId() ?>/>
<?= /* @noEscape */
$secureRenderer->renderEventListenerAsTag(
'onchange',
'switchScope(this);',
'#store_group_switcher'
) ?>
<input type="hidden" name="website_switcher" id="website_switcher"
data-role="website-id" data-param="<?= $block->escapeHtmlAttr($block->getWebsiteVarName()) ?>"
value="<?= $block->escapeHtml($block->getWebsiteId()) ?>"
<?= /* @noEscape */ $block->getUiId() ?>/>
<?= /* @noEscape */
$secureRenderer->renderEventListenerAsTag(
'onchange',
'switchScope(this);',
'#website_switcher'
) ?>
<button
type="button"
class="admin__action-dropdown"
data-mage-init='{"dropdown":{}}'
data-toggle="dropdown"
aria-haspopup="true"
id="store-change-button">
<?= $block->escapeHtml($block->getCurrentSelectionName()) ?>
</button>
<ul class="dropdown-menu" data-role="stores-list">
<?php if ($block->hasDefaultOption()) : ?>
<li class="store-switcher-all
<?= !($block->getDefaultSelectionName() != $block->getCurrentSelectionName()) ?
' disabled' : '' ?>
<?= (!$block->hasScopeSelected()) ? ' current' : '' ?>">
<?php if ($block->getDefaultSelectionName() != $block->getCurrentSelectionName()) : ?>
<a data-role="store-view-id" data-value="" href="#">
<?= $block->escapeHtml($block->getDefaultSelectionName()) ?>
</a>
<?php else : ?>
<span><?= $block->escapeHtml($block->getDefaultSelectionName()) ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php foreach ($websites as $website) : ?>
<?php $showWebsite = false; ?>
<?php foreach ($website->getGroups() as $group) : ?>
<?php $showGroup = false; ?>
<?php foreach ($block->getStores($group) as $store) : ?>
<?php if ($showWebsite == false) : ?>
<?php $showWebsite = true; ?>
<li class="store-switcher-website
<?= (!($block->isWebsiteSwitchEnabled() && !$block->isWebsiteSelected($website))) ?
' disabled' : '' ?>
<?= ($block->isWebsiteSelected($website)) ? ' current' : '' ?>">
<?php if ($block->isWebsiteSwitchEnabled() && !$block->isWebsiteSelected($website)) : ?>
<a data-role="website-id"
data-value="<?= $block->escapeHtmlAttr($website->getId()) ?>" href="#">
<?= $block->escapeHtml($website->getName()) ?>
</a>
<?php else : ?>
<span><?= $block->escapeHtml($website->getName()) ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<?php if ($showGroup == false) : ?>
<?php $showGroup = true; ?>
<li class="store-switcher-store
<?= (!($block->isStoreGroupSwitchEnabled() &&
!$block->isStoreGroupSelected($group))) ? ' disabled' : '' ?>
<?= ($block->isStoreGroupSelected($group)) ? ' current' : '' ?>">
<?php if ($block->isStoreGroupSwitchEnabled() &&
!$block->isStoreGroupSelected($group)) : ?>
<a data-role="store-group-id"
data-value="<?= $block->escapeHtmlAttr($group->getId()) ?>" href="#">
<?= $block->escapeHtml($group->getName()) ?>
</a>
<?php else : ?>
<span><?= $block->escapeHtml($group->getName()) ?></span>
<?php endif; ?>
</li>
<?php endif; ?>
<li class="store-switcher-store-view
<?= (!($block->isStoreSwitchEnabled() && !$block->isStoreSelected($store))) ?
' disabled' : '' ?>
<?= ($block->isStoreSelected($store)) ? ' current' : '' ?>">
<?php if ($block->isStoreSwitchEnabled() && !$block->isStoreSelected($store)) : ?>
<a data-role="store-view-id"
data-value="<?= $block->escapeHtmlAttr($store->getId()) ?>" href="#">
<?= $block->escapeHtml($store->getName()) ?>
</a>
<?php else : ?>
<span><?= $block->escapeHtml($store->getName()) ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php if ($block->getShowManageStoresLink() &&
$block->getAuthorization()->isAllowed('Magento_Backend::store')) : ?>
<li class="dropdown-toolbar">
<a href="<?= /* @noEscape */ $block->getUrl('*/system_store') ?>">
<?= $block->escapeHtml(__('Stores Configuration')) ?>
</a>
</li>
<?php endif; ?>
</ul>
</div>
<?= $block->getHintHtml() ?>
</div>

<script type="text/x-magento-init">
{
"*": {
"Mageplaza_Reports/js/store-switcher": {
"useConfirm": <?= /* @noEscape */ (int) $block->getUseConfirm(); ?>,
"isUsingIframe": <?= /* @noEscape */ (int) $block->isUsingIframe(); ?>,
"switchUrl": "<?= $block->escapeUrl($block->getSwitchUrl()); ?>",
"storeId": <?= /* @noEscape */ (int) $block->getStoreId(); ?>
}
}
}
</script>
<?php endif; ?>
4 changes: 4 additions & 0 deletions view/adminhtml/web/js/detail/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ define([
$('body').on('click',function (e) {
if (!$(e.target).parents().hasClass('mp-rp-order-status')) {
$('.mp-rp-order-status').removeClass('_active');
if ($('.daterangepicker').is(':visible')) {
$('.drp-calendar.left').show();
$('.drp-calendar.right').show();
}
}
});
},
Expand Down
Loading

0 comments on commit ec298f9

Please sign in to comment.