<?php

    $acao = 'cadastrar';
    $id = "";
 
    $mod = 'usuario_evento';
    $titulo = 'Stand';

    $usuario_evento = (new UsuarioEvento)->and("usuario_evento_id", $id)->consultar();

?>



<!-- Full screen modal -->
<!-- Modal -->
<div class="modal fade" id="modalModelo" tabindex="-1" aria-labelledby="modalExcluirLabel" aria-hidden="true">
  <div class="modal-dialog  modal-fullscreen">
    <div class="modal-content">
      <div class="modal-header bg-dark">
        <h5 class="modal-title " id="modalExcluirLabel"><?=$titulo?></h5>
        <button type="button" class="btn-close bg-white" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
            <div class="text-center ">
            <?php if ($acao == 'editar'):?>
                <i class="fa-regular fa-edit me-2 mt-3 mb-5 fa-5x text-warning"></i>  
            <?php else:?>
                <i class="fa-regular fa-plus me-2 mt-3 mb-5 fa-5x text-info"></i>  
            <?php endif?>
            </div>
            <div class="alert alert-success text-center " role="alert">
                <h5 class="mb-4 mt-4 text-dark">Registrado realizado com Sucesso!</h5>
            </div>
            <div class="text-center mt-5">
                <a type="button" class="btn btn-info" href="">Sair</a>
            </div>
      </div>
      <div class="modal-footer bg-dark">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Sair</button>
      </div>
    </div>
  </div>
</div>



<div class="container-fluid pt-4 px-4">
    <div class="row g-4">
        <div class="col-sm-6 col-xl-3">
            <div class="bg-secondary rounded d-flex align-items-center justify-content-between p-4">
                <i class="fa fa-user fa-3x text-primary"></i>
                <div class="ms-3">
                    <?php $usuarios = (new Usuario)->contar(); ?>
                    <p class="mb-2">Usuários</p>
                    <h6 class="mb-0 ml-4  text-center"><?= $usuarios = (new Usuario)->contar() ?></h6>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="bg-secondary rounded d-flex align-items-center justify-content-between p-4">
                <i class="fa fa-users fa-3x text-primary"></i>
                <div class="ms-3">
                    <p class="mb-2">Participantes</p>
                    <h6 class="mb-0  text-center"><?= $participante = (new Participante)->contar() ?></h6>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="bg-secondary rounded d-flex align-items-center justify-content-between p-4">
                <i class="fa fa-receipt fa-3x text-primary"></i>
                <div class="ms-3">
                    <p class="mb-2">Ingressos</p>
                    <h6 class="mb-0 text-center"><?= $ingresso = (new Ingresso)->contar() ?></h6>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-xl-3">
            <div class="bg-secondary rounded d-flex align-items-center justify-content-between p-4">
                <i class="fa fa-qrcode fa-3x text-primary"></i>
                <div class="ms-3">
                    <p class="mb-2">Pagamentos</p>
                    <h6 class="mb-0  text-center"><?= $pagamento = (new IngressoParticipante)->contar() ?></h6>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Sale & Revenue End -->


<!-- Sales Chart Start -->
<div class="container-fluid pt-4 px-4">
<?php 
    $eventos = (new Evento)->listar();
    $usuarios = (new Usuario)
        ->and('usuario_nivel','Administrador', '!=')
        ->andIsNull('usuario_evento_usuario')
        ->listar();
  
?>
    <div class="row g-4">
        <div class="col-sm-12 col-xl-12">
            <div class="bg-secondary text-center rounded p-4">
                <div class="d-flex justify-content-between mb-4">
                    <h6 class="mb-0">Eventos/Stands</h6>
                    <a href="">Ver Mais</a>
                </div>
                <div class="container">
                    <form action="" method="POST" name="form_<?=$mod?>" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-6">
                            <div class=" p-3">
                                <h6>Selecione um Usuário</h6>
                                <div class="form-floating mb-3">
                                    <select id="floatingSelect" name="usuario_evento_usuario" class="form-select" value="">
                                        <?php foreach ($usuarios as $usuario) : ?>
                                            <option value="<?= ($usuario)->usuario_id ?>" ><?= ($usuario)->usuario_login ?></option>
                                        <?php endforeach ?>
                                    </select>
                                    <label for="floatingInput">Selecione o usuário</label>
                                </div>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class=" p-3">
                             <h6>Selecione um Evento/Stand</h6>
                                <div class="form-floating mb-3">
                                    <select id="floatingSelect" name="usuario_evento_evento" class="form-select" value="">
                                        <?php foreach ($eventos as $evento) : ?>
                                            <option value="<?= ($evento)->evento_id ?>" ><?= ($evento)->evento_nome .' - '. ($evento)->evento_local ?></option>
                                        <?php endforeach ?>
                                    </select>
                                    <label for="floatingInput">Selecione o Evento/Stand</label>
                                </div>
                            </div>
                        </div>
                        <div class="text-center">
                        <input type="hidden" name="acao" value="cadastrar">
                        <button type="button" class="btn btn-primary envia_formulario"><?=$acao?></button>
                    </div>
                    </div>
                </form> 
                </div>
                <!-- <canvas id="worldwide-sales"></canvas> -->
            </div>
        </div>
    </div>
</div>






<div class="container-fluid pt-4 px-4">
    <div class="row g-4">
        <div class="col-sm-12 col-xl-6">
            <div class="bg-secondary text-center rounded p-4">
                <div class="d-flex align-items-center justify-content-between mb-4">
                    <h6 class="mb-0">Programações</h6>
                    <a href="">Ver Mais</a>
                </div>
                <canvas id="worldwide-sales"></canvas>
            </div>
        </div>
        <div class="col-sm-12 col-xl-6">
            <div class="bg-secondary text-center rounded p-4">
                <div class="d-flex align-items-center justify-content-between mb-4">
                    <h6 class="mb-0">Lista de Presença</h6>
                    <a href="">Ver Mais</a>
                </div>
                <canvas id="salse-revenue"></canvas>
            </div>
        </div>
    </div>
</div>


<script>
    $(document).ready(function() {
        mascaras();
        $('.envia_formulario').on('click', function() {
            var dadosForm = $(this).closest('form');
            var dados = new FormData(dadosForm[0]);
            $.ajax({
                type: "POST",
                enctype: "multipart/form-data",
                url: "<?= __URLSITE__ ?>modulos/<?=$mod?>/controller.php",
                data: dados,
                processData: false,
                contentType: false,
                cache: false,
                timeout: 600000,
                success: function(dados) {
                    // retorno = JSON.parse(dados);
                    $('#modalModelo').modal('show');
                }
            });
        });
    });
</script>