Fullcalendar does not return all records

Asked

Viewed 116 times

0

Good afternoon, I have a problem in fullcalendar, it returns only 7 records from
bank, if I put more does not return anything. Someone has gone through this, as do to return more records, need to set some configuration ?
Below the scripts.

Script :

        $(document).ready(function () {

            // page is now ready, initialize the calendar...
            //select: function (start, end, allDay) {
            //    start = $.fullCalendar.formatRange(start, start, 'YYYY-MM-DD');
            //    document.location.href = 'form_cadastro.php?novo=' + start ;
            //},
            var currentDate = moment().format("YYYY-MM-DD");
            //CARREGA CALENDÁRIO E EVENTOS DO BANCO
            $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                defaultDate: currentDate,
                editable: true,
                eventLimit: true,
                events: {
                    **url: 'events.php'**,
                    type: 'POST',
                    **error: function () {
                        alert('Problemas ao trazer os dados');**
                    }
                },
                eventColor: '#dd6777',

                // put your options and callbacks here
                lang: 'pt-br',
                selectable: true,
                editable: true,
                select: function (start, end, allDay) {
                    $("#addEvent").show();
                    $("#editEvent").hide();
                    $("#addNew-event").modal("show");
                    $("#addNew-event input:text").val("");
                    $("#getStart").val(start);
                    $("#getEnt").val(end);
                },
                eventClick: function (event, element) {
                    $("#addEvent").hide()
                    $("#editEvent").show().data("ev", event);
                    $("#addNew-event").modal("show");
                    $("#addNew-event input:text").val("");
                    $("#eventName").val(event.title);
                }
            });

            $("body").on("click", "#addEvent", function () {
                var eventName = $("#eventName").val();
                $("#calendar").fullCalendar("renderEvent", {
                    title: eventName,
                    start: $("#getStart").val(),
                    end: $("#getEnd").val()
                },
                        true);

                $("#addNew-event form")[0].reset();
                $("#addNew-event").modal("hide");
            });
            $("body").on("click", "#editEvent", function () {
                var eventName = $("#eventName").val();
                var ev = $(this).data("ev");
                ev.title = eventName;
                $("#calendar").fullCalendar("updateEvent", ev);

                $("#addNew-event form")[0].reset();
                $("#addNew-event").modal("hide");
            });

        });

Events.php

<?php

include_once "db_config.php";

$consulta = $bdd->query("SELECT * FROM calendar ORDER BY id");
if ($consulta !== FALSE):
    if ((int) $consulta->rowCount() > 0):
    // Tem REgistro
    else:
        echo 'A tabela está vazia';
    endif;
else:
    echo 'Problema ao tentar abrir o banco!!';
endif;

// Retorna um array
$events = array();

// Busca os resultados
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)):
    $vetor = array();
    $vetor['id'] = $linha['id'];
    $vetor['title'] = $linha['title'];
    $vetor['start'] = $linha['startdate'];
    $vetor['end'] = $linha['enddate'];
    $vetor['allDay'] = $linha['allDay'];
    // Mesclar a matriz de evento com a matriz de retorno
    array_push($events, $vetor);
endwhile;

echo json_encode($events);
//echo json_encode($consulta->fetchAll(PDO::FETCH_ASSOC));
?>
  • Thank you. I was reissuing..

  • You are calling twice the script on purpose?

  • Thank you for responding. Lack of knowledge. How would I show and include in the same script? can help me ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.