<?php
if (isset($url_id)) {
    $acao = 'excluir';
    $id = $url_id;
}

$categoria_evento = (new Programacao)->and("programacao_id", $id)->consultar();
$titulo = 'Programacao';
$mod = 'programacao';
?>

<!-- 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 ">
                <i class="fa-regular fa-trash-can me-2 mt-3 mb-5 fa-5x text-danger"></i>
            </div>
            <div class="alert alert-success text-center " role="alert">
                <h5 class="mb-4 mt-4 text-dark">Registro Exluído com Sucesso!</h5>
            </div>
            <div class="text-center mt-5">
                <a type="button" class="btn btn-outline-info" href="<?= __URLSITE__ ?>configuracoes/<?=$mod?>/listagem">Voltar para Listagem</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>


<!-- Form Start -->
<form action="" method="POST" name="form_<?=$mod?>" enctype="multipart/form-data">
    <div class="col-12">
        <nav class=" bg-secondary rounded h-100 p-4 navbar bg-body-tertiary">
            <div class="container-fluid ">
                <a class="navbar-brand text-center"><i class="fas fa-calendar-alt me-2"></i><?=$titulo?></a>
            </div>
        </nav>
    </div>
    <div class="container-fluid pt-4 px-4">
        <div class="row g-4">
            <div class="col-sm-12 col-xl-12">
                <div class="alert alert-warning text-center " role="alert">
                    <h5 class="mb-4 mt-4 text-dark">Deseja realmente realizar a exclusão do Registro?</h5>
                </div>

                <div class="text-center">
                    <input type="hidden" name="acao" value="<?= $acao ?>">
                    <input type="hidden" name="programacao_id" value="<?= $id ?>">
                    <!-- <button type="button" class="btn btn-primary envia_formulario"  data-bs-toggle="modal" data-bs-target="#modalExcluir"><?= $acao ?></button> -->
                    <button type="button" class="btn btn-primary envia_formulario" ><?= $acao ?></button>
                </div>
                <!-- </div> -->
            </div>
        </div>
    </div>
</form>


<!-- Form End -->
<script>
    $(document).ready(function() {
        $('.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/configuracoes/<?=$mod?>/controller.php",
                data: dados,
                processData: false,
                contentType: false,
                cache: false,
                timeout: 600000,
                success: function(dados) {
                    // retorno = JSON.parse(dados);
                    // alert(retorno.msg_string);
                    $('#modalModelo').modal('show');
                }
            });
        });
    });
</script>