FullCalendar remember every month

0

I'm working with FullCalendar plugin with PHP and MySQL. I need to make a reminder remember every month, for example, remember every 5 days a payment. I already searched google and I did not find it.

    
asked by anonymous 05.12.2017 / 11:31

3 answers

0

I am pulling the data from a mysql database:                include_once ("../config/connect.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.'); 
                }
            }
        });
    }

});

        

    
05.12.2017 / 22:34
0

I was able to do this by inserting into the registration code. If it is doubtful for someone one day to follow what I have done, if I can help: I've captured the $ start variable that is responsible for the date:

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

  '$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.

    
07.12.2017 / 00:35
0

There are several ways to do it, I'll just give you a few starting tips for an implementation idea (may not be the most correct / efficient):

  • Instead of repeating the events in the DB, that is, for each day 5, we have only one event that will repeat itself ... we will then have to add a new event_time_table (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 in js making a post to a php page that will return a json with the events ... the request will be made in the 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" json we will:
    Select all events between intervalStart and intervalEnd and that repeat "never";
    Select all events that have repeats other than "never"; Home Treat repetition of events: We obtain information about the start date of the event. If the event, for example, has a "weekly" repetition and if we analyze the date we know it is started at a second: in every second between the intervalStart and intervalEnd values we will have an event. (remember to keep the difference between the start and end dates) ... And so on for the other event repeats (following a similar logic).

  • Well, in the yearly repeating events we can filter on the select month and only bring the month (month) between the intervalStart and intervalEnd (we can see the weekly view for example July 30 - August 5, 2018 [in which we have 2 different months] ... in this case would get WHERE MONTH (start_date) IN ('7', '8')).
    Events (regardless of repetition) are stored in an array that will later be passed to json ( json_encode a>)

... It's just an initial idea (without even being tested) and maybe it's a bit difficult to understand by the text

    
29.08.2018 / 19:26