Fullcalendar remember every month

Asked

Viewed 428 times

0

I am working with Fullcalendar plugin with PHP and Mysql. I need to make a reminder remember every month, for example, remember every day 5 a payment. I already googled and could not find.

  • 1

    And what you’ve already implemented?

  • post your code

3 answers

0

I’m pulling data from a mysql database: include_once(".. /config/conexao.php");

$result_event = "SELECT * FROM agendas";

$resultado_event = mysqli_query($conn, $result_event);

 ?>
 <div class="container">
         <div class="row">

 <script>
     $(document).ready(function(){
      $('#calendar').fullCalendar({ 
         header: {
               left: 'prev,next today',
               center: 'title',
               right: 'month,agendaWeek,agendaDay'
           },



     defaultDate: Date(),
        navLinks: true, // can click day/week names to navigate views
             editable: true,
             eventLimit: true, // allow "more" link when too many events
            selectable: true,
        selectHelper: true,
        select: function(start, end) {

            $('#ModalAdd #start').val(moment(start).format('DD/MM/YYYY HH:mm:ss'));
            $('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
            $('#ModalAdd').modal('show');
        },




    eventRender: function(event, element) {
            element.bind('dblclick', function() {                   
                $('#ModalEdit #id').val(event.id);
                $('#ModalEdit #title').val(event.title);
                $('#ModalEdit #color').val(event.color);
                $('#ModalEdit #pag_pagador').val(event.pag_pagador);
                $('#ModalEdit #pag_valor').val(event.pag_valor);
                $('#ModalEdit #pag_data').val(event.pag_data);
                $('#ModalEdit #pag_forma').val(event.pag_forma);
                $('#ModalEdit #pag_detalhe').val(event.pag_detalhe);
                $('#ModalEdit #ex_med_prof').val(event.ex_med_prof);
                $('#ModalEdit #detalhes').val(event.detalhes);
                $('#ModalEdit #todo_mes').val(event.todo_mes);

                $('#ModalEdit').modal('show');
            });
        },

    eventDrop: function(event, delta, revertFunc) { // si changement de position

            edit(event);

           },
            eventResize: function(event,dayDelta,minuteDelta,revertFunc) { // si changement de longueur

            edit(event);

        },

        events: [
               <?php
             while($row_events = mysqli_fetch_array($resultado_event)){
                ?>
           {
           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']; ?>',
           pag_pagador:'<?php echo $row_events['pag_pagador']; ?>',
           pag_valor:'<?php echo $row_events['pag_valor']; ?>',
           pag_data:'<?php echo $row_events['pag_data']; ?>',
           pag_forma:'<?php echo $row_events['pag_forma']; ?>',
           pag_detalhe:'<?php echo $row_events['pag_detalhe']; ?>',
           ex_med_prof:'<?php echo $row_events['ex_med_prof']; ?>',
           detalhes:'<?php echo $row_events['detalhes']; ?>',
           todo_mes:'<?php echo $row_events['todo_mes']; ?>',
            },              
           <?php
               }
            ?>
        ]
    })


    function edit(event){
           start = event.start.format('YYYY-MM-DD HH:mm:ss');
           if(event.end){
               end = event.end.format('YYYY-MM-DD HH:mm:ss');
           }else{
               end = start;
           }

            id =  event.id;

           Event = [];
           Event[0] = id;
           Event[1] = start;
           Event[2] = end;

           $.ajax({
             url: 'editEventDate.php',
             type: "POST",
             data: {Event:Event},
            success: function(rep) {
                if(rep == 'OK'){
                    alert('Alteração salvo com sucesso!');
                }else{
                    alert('Could not be saved. try again.'); 
                }
            }
        });
    }

});

0

I was able to do by entering the registration code. If it is a question for someone one day follows what I did, if I can help: I captured the $start variable that is responsible for the date:

$start = $_GET['start']; I did the formatting to receive in variable $date:

  '$data = new DateTime($start);
   $data->modify('-1 month');//para inserir o mês atual
     for ($i=1;$i<=$num_mes; $i++){//num_mes é a quantidade de meses a ser lembrada
       $data->modify('+1 month');//modifica o mês
      $tes = $data->format('Y-m-d h:i:s')."<br/>";'//formata o registro para que o mysql receba

And now just insert the INSERT command.

0

There are several ways to do it, I’ll just give you some initial hints for an implementation idea (may not be the most correct/efficient):

  • Instead of repeating the events in the comic book, that is, for every day 5, we have only one event that will be repeated... we will then have to add a new table repeating_event (where we have the values "never", "daily", "weekly", "monthly", "annual"), each entry in the event table will have a link to this new table

  • Calendar events will be added to js posting a php page that will return a json with the events ... the request will be made on callback viewRender. To get the values of the start date and end date of the view we use the intervalStart and intervalEnd properties of the View Object. These two values will be passed as parameters in the json link.

  • In the php file responsible for "writing" the json we will:
    Select all events between intervalStart and intervalEnd that repeat "never";
    Select all events that has repeat other than "never";
    Treat the repetition of events: We obtain information about the initial date of the event. If the event for example has "weekly" repetition and if by the analysis of the date we know that it is started to a second: every second between the interval values Tart and intervalEnd we will have an event. (remember to keep the difference between start and end dates)... And so on for the other repeats of events (following a similar logic).

  • Well, in the annual repeat events we can filter in select the month and only bring those of the month (months) between intervalStart and intervalEnd (we may be seeing the weekly view of for example Jul 30 - Aug 5, 2018 [in which we have 2 different months]... in this case would stay WHERE MONTH(start_date) IN ('7','8')).
    Events (independent of repetition) are stored in an array that will later be passed to json (json_encode)

... It’s just an initial idea (without even being tested) and maybe it’s a little hard to understand from the text

Browser other questions tagged

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