Fullcalendar with the Scheduler plugin does not mark events

0

I have this code to make a schedule of appointments with Fullcalendar and Scheduler.

It is not marking the days when I book in the calendar, in the bank it records the days marked, but as I said do not mark in the calendar.

This is the part where you pick the marked days

if(isset($_POST['action']) or isset($_GET['view']))
{
   if(isset($_GET['view']))
    {
        header('Content-Type: application/json');
        $start = mysqli_real_escape_string($connection,$_GET["start"]);
        $end = mysqli_real_escape_string($connection,$_GET["end"]);

        $result = mysqli_query($connection,"SELECT 'id', 'start' ,'end' ,'title','ativo' FROM  'events' where (date(start) >= '$start' AND date(start) <= '$end' AND ativo='sim'  ) ");
        while($row = mysqli_fetch_assoc($result))
        {

            $events[] = $row; 
        }


        echo json_encode($events); 



        exit;
    }

    elseif($_POST['action'] == "update")
    {
        mysqli_query($connection,"UPDATE 'events' set 
            'start' = '".mysqli_real_escape_string($connection,date('Y-m-d H:i:s',strtotime($_POST["start"])))."', 
            'end' = '".mysqli_real_escape_string($connection,date('Y-m-d H:i:s',strtotime($_POST["end"])))."' 
            where uid = '".mysqli_real_escape_string($connection,$uid)."' and id = '".mysqli_real_escape_string($connection,$_POST["id"])."'");
        exit;
    }
    elseif($_POST['action'] == "delete") 
    {
        mysqli_query($connection,"DELETE from 'events' where uid = '".mysqli_real_escape_string($connection,$uid)."' and id = '".mysqli_real_escape_string($connection,$_POST["id"])."'");
        if (mysqli_affected_rows($connection) > 0) {
            echo "1";
        }
        exit;
    }
}

this is my complete code

Html

<div class="col-md-6 agenda_espaco">                
<h2><span class="negrito">Agende sua </span> <span class="cor_destaque">Consulta</span></h2>  

    <!-- add calander in this div -->

<div id="calendar"></div>

</div>

JS

$(function() {

  $('#calendar').fullCalendar({
    defaultView: 'agendaFourDay',
    groupByDateAndResource: true,
    weekends: false,
    editable: true,
            selectable: true,
            allDaySlot: false,
    schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
    header: {
      left: 'prev,next,today',
      center: 'title',
      right: 'agendaDay,agendaFourDay'
    },
    views: {
      agendaFourDay: {
        type: 'agenda',
        duration: { days: 4 }
      }
    },

    viewRender: function(currentView){
        var minDate = moment();
        var maxDate = moment().add(2,'weeks');
    },

    viewRender: function(i){
   var ini = moment();
   if(ini >= i.start && ini <= i.end){
      $(".fc-prev-button")
      .prop('disabled', true) 
      .addClass('fc-state-disabled'); 
   }else{
      $(".fc-prev-button")
      .removeClass('fc-state-disabled')
      .prop('disabled', false); 
   }
},

    resources: [
      { id: 'a', title: 'Sala 1 Manoel' },
      { id: 'b', title: 'Sala 2 Larissa' },
      { id: 'c', title: 'Sala 3 Marcos' }
    ],


            events: "agendar.php?view=1",


            eventClick:  function(event, jsEvent, view) {
                endtime = $.fullCalendar.moment(event.end).format('h:mm');
                starttime = $.fullCalendar.moment(event.start).format('dddd, D MMMM YYYY, h:mm');
                var mywhen = starttime + ' - ' + endtime;
                $('#modalTitle').html(event.title);
                $('#modalWhen').text(mywhen);
                $('#eventID').val(event.id);
                $('#calendarModal').modal();
            },

            //header and other values
            select: function(start, end, jsEvent) {
                endtime = $.fullCalendar.moment(end).format('h:mm');
                starttime = $.fullCalendar.moment(start).format('dddd, MMMM Do YYYY, h:mm');
                var mywhen = starttime + ' - ' + endtime;
                start = moment(start).format();
                end = moment(end).format();
                $('#createEventModal #startTime').val(start);
                $('#createEventModal #endTime').val(end);
                $('#createEventModal #when').text(mywhen);
                $('#createEventModal').modal('toggle');
           },
           eventDrop: function(event, delta){
               $.ajax({
                   url: 'index.php',
                   data: 'action=update&title='+event.title+'&start='+moment(event.start).format()+'&end='+moment(event.end).format()+'&id='+event.id ,
                   type: "POST",
                   success: function(json) {
                   //alert(json);
                   }
               });
           },
           eventResize: function(event) {
               $.ajax({
                   url: 'index.php',
                   data: 'action=update&title='+event.title+'&start='+moment(event.start).format()+'&end='+moment(event.end).format()+'&id='+event.id,
                   type: "POST",
                   success: function(json) {
                       //alert(json);
                   }
               });
           }
        });

       $('#submitButton').on('click', function(e){
           // We don't want this to act as a link so cancel the link action
           e.preventDefault();
           doSubmit();
       });

       $('#deleteButton').on('click', function(e){
           // We don't want this to act as a link so cancel the link action
           e.preventDefault();
           doDelete();
       });

       function doDelete(){
           $("#calendarModal").modal('hide');
           var eventID = $('#eventID').val();
           $.ajax({
               url: 'index.php',
               data: 'action=delete&id='+eventID,
               type: "POST",
               success: function(json) {
                   if(json == 1)
                        $("#calendar").fullCalendar('removeEvents',eventID);
                   else
                        return false;


               }
           });
       }
       function doSubmit(){
           $("#createEventModal").modal('hide');
           var title = $('#title').val();
           var startTime = $('#startTime').val();
           var endTime = $('#endTime').val();

           $.ajax({
               url: 'index.php',
               data: 'action=add&title='+title+'&start='+startTime+'&end='+endTime,
               type: "POST",
               success: function(json) {
                   $("#calendar").fullCalendar('renderEvent',
                   {
                       id: json.id,
                       title: title,
                       start: startTime,
                       end: endTime,
                   },
                   true);
               }
           });

       }
    });
    
asked by anonymous 18.10.2018 / 14:23

0 answers