<?php $render('header', ['loggedUser'=>$loggedUser, 'title'=>$titlePage]); ?>
<?=$render('sidebar', [
  'loggedUser'=>$loggedUser, 
  'pageActive'=>$pageActive,
  'permissions'=>$permissions
]);?>

<!-- Content System -->
<div class="content-wrapper">
  <div class="pages">
    <h3>Relatório de Aniversariantes</h3>
    <div class="users">

      <div class="filters filter_responsive">

        <form method="POST" action="<?= $base; ?>/reportbirthdays">
          <input type="hidden" id="isclear" name="filter[clear]">
          <div class="filter-items">
            <select class="form-control" name="filter[by]">
              <option value="">Todos</option>
              <option value="clients" <?= ($arrayInfo['filter']['by'] == 'clients')?'selected':''; ?> >Clientes</option>
              <option value="providers" <?= ($arrayInfo['filter']['by'] == 'providers')?'selected':''; ?> >Fornecedores</option>
              <option value="salesman" <?= ($arrayInfo['filter']['by'] == 'salesman')?'selected':''; ?> >Vendedores</option>
              <option value="shippingconpany" <?= ($arrayInfo['filter']['by'] == 'shippingconpany')?'selected':''; ?> >Transportadoras</option>
              <option value="users" <?= ($arrayInfo['filter']['by'] == 'users')?'selected':''; ?> >Usuários</option>         
            </select>

            <div class="dates" style="display: flex; margin-right: 10px;">
              <input type="text" name="filter[d_init]" id="dateInit" class="form-control" style="width: 120px!important;" placeholder="00/00/0000" value="<?= $arrayInfo['filter']['d_init']; ?>">

              <input type="text" name="filter[d_end]" id="dateEnd" class="form-control" style="width: 120px!important; margin-left: 10px;" placeholder="00/00/0000" value="<?= $arrayInfo['filter']['d_end']; ?>">
            </div>

            <select class="form-control" name="filter[print]">
              <option value="">Formato</option>
              <option value="P" <?= ($arrayInfo['filter']['print'] == 'P')?'selected':'' ?> >Retrato</option>
              <option value="L" <?= ($arrayInfo['filter']['print'] == 'L')?'selected':'' ?> >Paisagem</option>
            </select>

            <input type="text" name="filter[limit]" id="max_result" class="form-control" value="<?= $arrayInfo['filter']['limit']; ?>" style="display: none;">

            <button type="submit" id="submit_form" class="proccess">PROCESSAR</button>
            <button id="reports_byrthdays" class="proccess">LIMPAR</button>
          </div>
        </form>

        <div class="filter-buttons">
          <a href="<?= $base; ?>/reportbirthdayspdf" target="_blank" class="btn btn-success">PDF</a>
          <a href="<?= $base; ?>/reportbirthdayscsv" target="_blank" class="btn btn-success">Excel</a>
        </div>
      </div>


      <table class="table table-bordered">
        <tbody>
          <tr>
            <th scope="col">Item</th>
            <th scope="col">Data do aniversário</th>
            <th scope="col">Nome do aniversariante</th>
            <th scope="col">Módulo</th>
            <th scope="col">Status no sistema</th>
            <th scope="col">Fone contato</th>
            <th scope="col">E-mail</th>       
            <th scope="col">Cidade-UF</th>
          </tr>

          <?php foreach($arrayInfo['content']['result'] as $key => $birthdays): ?>
            <tr>
              <td><?= ($key + 1); ?></td>
              <td><?= $birthdays['birth_date']; ?></td>
              <td><?= $birthdays['name']; ?></td>
              <td><?= (isset($birthdays['model']))?$birthdays['model']:$arrayInfo['content']['model']; ?></td>
              <td><?= ($birthdays['status'] == 1)?'Ativo':'Inativo'; ?></td>
              <td><?= $birthdays['first_phone']; ?></td>
              <td><?= $birthdays['email']; ?></td>
              <td><?= (isset($birthdays['city']) && !empty($birthdays['city']))?$birthdays['city'] .'-'. $birthdays['state']:''; ?></td>
            </tr>
          <?php endforeach; ?>      

        </tbody>
      </table>
    </div>

    <script src="<?= $base; ?>/assets/js/reports.js"></script>
    <script src="<?= $base; ?>/assets/js/birthdays_reports.js"></script>
  </div>  		
</div>
<!-- /.content-system -->

<?=$render('footer');?>