<section class="content-header">
    <h1><i class='fa-fw fa fa-bar-chart'></i> <?php echo $_translator->_getTranslation('Reportes');?></small></h1>
    <ol class="breadcrumb">
        <li><a href="<?php echo ROOT_HOST?>/Controller/Inicio.php"><i class="fa fa-dashboard"></i><?php echo $_translator->_getTranslation('Inicio')?></a></li>
      <li class="active"><?php echo $_translator->_getTranslation('Reportes');?></li>
    </ol>
</section>
<section class="content">
<div class="box">
  <div class="box-header with-border">
    <h3 class="box-title"></h3>
    <div class="box-tools pull-right"></div><!-- /.box-tools -->
  </div><!-- /.box-header -->
  <div class="box-body">
    <div class='flashmessenger'><?php $flashmessenger->showMessage();?></div>
    <div class="clear"></div>
    <div class="grid-container">
        <?php 
        $login = new Login();
        switch($login->getRole()){
            case '1':?>
                <!--<a class="grid-item"  href="?action=create&report=inventario&output=screen">
                    <i class="fa fa-signal"></i><br /><?php echo $_translator->_getTranslation('Inventario');?>
                </a>-->
                <a class="grid-item _report" data-reportname="sales_by_customer_grouped_by_product" data-toggle='modal' data-target='#modalFiltroReportes'>
                    <i class="fa fa-signal"></i><br /><?php echo $_translator->_getTranslation('Ventas por cliente');?>
                </a> 
                <?php
                break;
        } ?>
    </div> 
    <?php 
    if(isset($_reporte)){ 
        include $_reporte->getTemplateReporteOnScreen();
    } ?>
  </div><!-- /.box-body -->
</div><!-- /.box -->
</section>
 <?php include ROOT."/Rewards/View/Modal/filtroReportes.php";?>
<div class="box">
    <?php if(isset($_reporte)){
        include $_reporte->getTemplateReporteOnScreen();
    }
?>
</div>
<style>
  .grid-container {
    display: grid;
    grid-template-columns: 20% 20% 20% 20% 20%;
    /*background-color: #2196F3;*/
    padding: 10px;
  }
  .grid-item {
    /*background-color: rgba(255, 255, 255, 0.8);*/
    border: 1px solid #ccc;
    padding: 20px;
    font-size: 1.5rem;
    text-align: center;
    cursor: pointer;
  }
 
</style>
<script type="text/javascript">
    $("#fechaInicio,#fechaFin").datetimepicker({
            format: 'MM/DD/YYYY'
      });

    $('.linkSendMail').click( function(e) {
        e.preventDefault(); 
        $('#modalSendReportToMail').modal('show');
        $("#optionsFromGet").val(this.href);
        return false; 
    });
    
    $('._report').on('click',function(){setFilterReport(this);});
    
    
    
    function setFilterReport(report){
        var reportName = $(report).data('reportname'); 
        $('#reporte').val(reportName);
        $.post('/Rewards/Controller/RewardsReports.php',{
            action: 'ajax',
            request: 'getFiltersReport',
            report: reportName
        },function(data){
            if(data.response){
                $('#filtersArea').html(data.filters);
                $('select').select2();
                $('#startDate,#endDate').datetimepicker({format: 'MM/DD/YYYY'});      
            }
        },'json');
    }
    
</script>