How do I display a Modal when the event is on an existing date in FullCalendar

0

I have a system I'm using FullCalendar for for CRUD. It's working OK, but I was attacking a detail that had gone unnoticed. When the user drags a particular event to another date at the same time, I would like a modal to appear that says an event already exists at this time.

The structure looks like this:

......
      $.ajax({
       url:"alterar-dia-agenda.php",
       type:"POST",
       data:{start:start,id:id},

       success:function(sucesso){
            $('#confirmar').modal('show');
            temporiza();
            setTimeout(function() {
               $('.modal').modal('hide');
            }, 2000);
            calendar.fullCalendar('refetchEvents');
        }
      });
......

change-agenda.php

public function alterarDiaAgenda($id,$titulo,$cor,$data){

  $sqlVerificar = mysqli_query($this->conexao,"SELECT * FROM pe_agenda WHERE DataAgenda = IdAgenda = '".mysqli_real_escape_string($this->conexao,$id)."' AND '".mysqli_real_escape_string($this->conexao,$data)."';");

  if(mysqli_num_rows($sqlVerificar) > 0){
    //return algo;
   }else{
   mysqli_query($this->conexao,"UPDATE pe_agenda SET DataAgenda = '".$data."' WHERE IdAgenda = '".$id."';");
   }
}

When the change occurs, it activates this modal:

<div class="modal fade" id="confirmar" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header btn-success">
                <h4 class="modal-title text-center"><i class="fas fa-check"></i> Evento Alterado com sucesso!</h4>
            </div>
        </div>
    </div>
</div>

But I would like to do the same if there is an event at the same time, activate the modal below:

<div class="modal fade" id="erro" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header btn-danger">
                <h4 class="modal-title text-center"><i class="fas fa-check"></i> Já existe um evento nesse horário!</h4>
            </div>
        </div>
    </div>
</div>
    
asked by anonymous 04.06.2018 / 22:48

0 answers