get id in FullCalendar

0

Hello, I would like to know how to get the value of an id in FullCalendar follows the code.

<?php
//session_start();
include_once("conexao.php");
$result_events = "SELECT id, title, color, start, end FROM events";
$resultado_events = mysqli_query($conexao, $result_events);
?>
<?php
        if(isset($_POST['cancel'])){
            $botao=$_POST['cancel'];
        echo "enviado,  $botao";

    }else{
        echo "valor nao enviado";
    }
?>
<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset='utf-8' />

        <h1 style="text-align: center">Horarios para a semana</h1>
        <link href='css/bootstrap.min.css' rel='stylesheet'>
        <link href='css/fullcalendar.min.css' rel='stylesheet' />
        <link href='css/fullcalendar.print.min.css' rel='stylesheet' media='print' />
        <link href='css/personalizado.css' rel='stylesheet' />
        <script src='js/jquery.min.js'></script>
        <script src='js/bootstrap.min.js'></script>
        <script src='js/moment.min.js'></script>
        <script src='js/fullcalendar.min.js'></script>
        <script src='locale/pt-br.js'></script>
        <script>
            $(document).ready(function() {
                $('#calendar').fullCalendar({
                    defaultView: 'agendaWeek',
                    header: {

                        left: 'prev next today',
                        center: 'title',
                        right: ',agendaWeek,agendaDay'//alterar antes da primeira virgula para mostrar o mes

                    },
                    defaultDate: Date(),
                    navLinks: true, // can click day/week names to navigate views
                    editable: true,
                    eventLimit: true, // allow "more" link when too many events
                    eventClick: function(event) {

                        $('#visualizar #id').text(event.id);
                        $('#visualizar #id').val(event.id);
                        $('#visualizar #title').text(event.title);
                        $('#visualizar #title').val(event.title);
                        $('#visualizar #start').text(event.start.format('DD/MM/YYYY HH:mm:ss'));
                        $('#visualizar #start').val(event.start.format('DD/MM/YYYY HH:mm:ss'));
                        $('#visualizar #end').text(event.end.format('DD/MM/YYYY HH:mm:ss'));
                        $('#visualizar #end').val(event.end.format('DD/MM/YYYY HH:mm:ss'));
                        $('#visualizar #color').val(event.color);
                        $('#visualizar').modal('show');
                        return false;

                    },

                    selectable: true,
                    selectHelper: true,
                    select: function(start, end){
                        $('#cadastrar #start').val(moment(start).format('DD/MM/YYYY HH:mm:ss'));
                        $('#cadastrar #end').val(moment(end).format('DD/MM/YYYY HH:mm:ss'));
                        $('#cadastrar').modal('show');                      
                    },
                    events: [
                        <?php
                            while($row_events = mysqli_fetch_array($resultado_events)){
                                ?>
                                {
                                id: '<?php echo $row_events['id']; ?>',


                                title: '<?php echo $row_events['title']; ?>',
                                start: '<?php echo $row_events['start']; ?>',
                                end: '<?php echo $row_events['end']; ?>',
                                color: '<?php echo $row_events['color']; ?>',
                                },<?php
                            }
                        ?>
                    ]
                });
            });

            //Mascara para o campo data e hora
            function DataHora(evento, objeto){
                var keypress=(window.event)?event.keyCode:evento.which;
                campo = eval (objeto);
                if (campo.value == '00/00/0000 00:00:00'){
                    campo.value=""
                }

                caracteres = '0123456789';
                separacao1 = '/';
                separacao2 = ' ';
                separacao3 = ':';
                conjunto1 = 2;
                conjunto2 = 5;
                conjunto3 = 10;
                conjunto4 = 13;
                conjunto5 = 16;
                if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (19)){
                    if (campo.value.length == conjunto1 )
                    campo.value = campo.value + separacao1;
                    else if (campo.value.length == conjunto2)
                    campo.value = campo.value + separacao1;
                    else if (campo.value.length == conjunto3)
                    campo.value = campo.value + separacao2;
                    else if (campo.value.length == conjunto4)
                    campo.value = campo.value + separacao3;
                    else if (campo.value.length == conjunto5)
                    campo.value = campo.value + separacao3;
                }else{
                    event.returnValue = false;
                }
            }
        </script>
    </head>
    <body>
        <div class="container">
            <div class="page-header">
                <!-- <h1>Agenda</h1> -->
            </div>
            <?php
            if(isset($_SESSION['msg'])){
                echo $_SESSION['msg'];
                unset($_SESSION['msg']);
            }
            ?>

            <div id='calendar'></div>
        </div>

        <div class="modal fade" id="visualizar" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title text-center">Desmarcar horário</h4>
                    </div>
                    <div class="modal-body">
                        <div class="visualizar">
                            <dl class="dl-horizontal">
                                <dt>Id</dt>
                                <dd id="id"></dd>
                                <dt>Serviço</dt>
                                <dd id="title"></dd>
                                <dt>Inicio do Evento</dt>
                                <dd id="start"></dd>
                                <dt>Fim do Evento</dt>
                                <dd id="end"></dd>
                            </dl>
                            <form action="agenda.php" method="POST" >
                            <button type="submit" name="cancel" class="btn btn-canc-vis btn-warning" value="enviar o valor do id">Cancelar</button>
                        </form>
                        </div>

                    </div>
                </div>
            </div>
        </div>

        <script>
            $('.btn-canc-vis').on("click", function() {
                $('.form').slideToggle();
                $('.visualizar').slideToggle();
            });
            $('.btn-canc-edit').on("click", function() {
                $('.visualizar').slideToggle();
                $('.form').slideToggle();
            });
        </script>
    </body>
</html>
    
asked by anonymous 20.11.2018 / 00:52

1 answer

0

Try to create a form with an input by picking the id:

<form class="form-horizontal" method="POST" action="DESTINO QUE VOCÊ QUER MANDAR (exemplo.php)">
      <input type="hidden" class="form-control" name="id" id="id">
      <button type="submit">Excluir</button>
</form>
    
22.11.2018 / 19:36