<?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 Cliente(s)</h3>
      <div class="users">
        <div class="filters filter_responsive">
            <form method="POST" action="<?= $base; ?>/reportclients">
                <input type="hidden" id="isclear" name="filter[clear]">
                <div class="filter-items">
                    <select class="form-control" name="filter[searchType]">
                        <option value="" >Status</option>
                        <option value="1" <?= ($arrayInfo['filter']['searchType'] == '1')?'selected':'' ?> >Ativo</option>
                        <option value="2" <?= ($arrayInfo['filter']['searchType'] == '2')?'selected':'' ?> >Inativo</option>
                    </select>

                    <select class="form-control" name="filter[state]">
                        <option value="">Estado</option>
                        <?php foreach($arrayInfo['stateList'] as $state): ?>
                            <option value="<?= $state['uf'] ?>" <?= ($arrayInfo['filter']['state'] ==  $state['uf'])?'selected':'' ?> ><?= $state['uf'] ?></option>
                        <?php endforeach; ?>
                    </select>

                    <select class="form-control" name="filter[classification]">
                        <option value="">Classificação</option>
                        <option value="GOLD" <?= ($arrayInfo['filter']['classification'] == 'GOLD')?'selected':'' ?> >GOLD</option>
                        <option value="MASTER" <?= ($arrayInfo['filter']['classification'] == 'MASTER')?'selected':'' ?> >MASTER</option>
                        <option value="CLASSIC" <?= ($arrayInfo['filter']['classification'] == 'CLASSIC')?'selected':'' ?> >CLASSIC</option>
                        <option value="PRATA" <?= ($arrayInfo['filter']['classification'] == 'PRATA')?'selected':'' ?> >PRATA</option>
                        <option value="BRONZE" <?= ($arrayInfo['filter']['classification'] == 'BRONZE')?'selected':'' ?> >BRONZE</option>


                        <?php foreach($classification_clients as $classification): ?>
                            <option value="<?= $classification ?>" <?= ($arrayInfo['filter']['classification'] == $classification)?'selected':'' ?> ><?= $classification ?></option>
                        <?php endforeach; ?>
                    </select>

                    <select class="form-control" name="filter[type]">
                        <option value="" >Tipo</option>
                        <option value="1" <?= ($arrayInfo['filter']['type'] == '1')?'selected':'' ?> >PF</option>
                        <option value="2" <?= ($arrayInfo['filter']['type'] == '2')?'selected':'' ?> >PJ</option>
                    </select>

                    <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']; ?>">
                    
                    <button type="submit" class="proccess">PROCESSAR</button>
                    <button id="reports_clients" class="proccess">LIMPAR</button>
                </div>
            </form>

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

        <table class="table table-hover" id="reports">
            <tbody>
            <tr>
                <th scope="col">Item</th>
                <th scope="col">Status</th>
                <th scope="col">Classe</th>
                <th scope="col">Tipo</th>
                <th scope="col">Nome do Cliente</th>
                <th scope="col">Nome do Responsável</th>
                <th scope="col">Fone Contato</th>
                <th scope="col">Cidade-UF</th>
            </tr>

            <?php foreach($arrayInfo['clientsInfo'] as $key => $client): ?>
                <tr>
                    <td><?= ($key + 1) ?></td>
                    <td><?= ($client['status'] == 1)?'Ativo':'Inativo' ?></td>
                    <td><?= $client['classification'] ?></td>
                    <td><?= ($client['type'] == 1)?'PF':'PJ' ?></td>
                    <td><?= $client['name'] ?></td>
                    <td><?= $client['buyer'] ?></td>
                    <td><?= $client['first_phone'] ?></td>
                    <td><?= $client['city_name'] ?> - <?= $client['state'] ?></td>
                </tr>
            <?php endforeach; ?>

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

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