{* todo wpj_new remove *}
{if $wpj_new}
   <a class="btn btn-secondary btn-block btn-icon-both" data-toggle="dropdown">
      <span class="bi bi-clock"></span>{'period'|translate:"productsFilter"}<span class="bi bi-chevron-down"></span>
   </a>
{else}
   <a class="btn btn-primary btn-sm"  data-toggle="dropdown">
      <span class="glyphicon glyphicon-time"></span>&nbsp;<span class="caret"></span>
   </a>
{/if}
<ul class="dropdown-menu pull-right" data-{$selector_from}{$selector_to}>
   <li><a data-date="today">{'today'|translate:'stats'}</a></li>
   <li><a data-date="yesterday">{'yesterday'|translate:'stats'}</a></li>
   <li><a data-date="lastSevenDays">{'lastSevenDays'|translate:'stats'}</a></li>
   <li><a data-date="lastMonth">{'lastMonth'|translate:'stats'}</a></li>
   <li><a data-date="lastYear">{'lastYear'|translate:'stats'}</a></li>
   <li><a data-date="thisWeek">{'thisWeek'|translate:'stats'}</a></li>
   <li><a data-date="thisMonth">{'thisMonth'|translate:'stats'}</a></li>
   <li><a data-date="thisYear">{'thisYear'|translate:'stats'}</a></li>
   <li><a data-date="previousWeek">{'previousWeek'|translate:'stats'}</a></li>
   <li><a data-date="previousMonth">{'previousMonth'|translate:'stats'}</a></li>
   <li><a data-date="previousYear">{'previousYear'|translate:'stats'}</a></li>
</ul>
<script type="text/javascript">
   wpj.formUtils.dateIntervalPicker('{$selector_from}', '{$selector_to}', function (activeItem, selectedInterval){
      var stringIntervals = {
         'yesterday': 'day',
         'today': 'day',
         'lastSevenDays': 'day',
         'lastMonth': 'day',
         'lastYear': 'month',
         'thisWeek': 'day',
         'thisMonth': 'day',
         'thisYear': 'month',
         'previousWeek': 'day',
         'previousMonth': 'day',
         'previousYear': 'month',
      };

      var stringInterval = stringIntervals[selectedInterval];

      activeItem.closest("div.tab-pane").find("[data-display-area] input[value^='" + stringInterval + "']").attr('checked', true).trigger('click');
   });
</script>
