Filter fullcalendar events

0

I need to filter the events that are shown on the screen by means of a select, that when selecting a value, in this case one of the career leaders, only shows the events belonging to that career leader, for which I am using .change of javascript. The events are fine if I remove the where to the function of the model, but obviously all are shown. I hope you can help me, thank you.

Controller

 public function geteventos(){

   $rut_usu = $this->input->post('rut_jc');

   $r = $this->mCalendar->geteventos();
   echo json_encode($r, $rut_usu);

   }

Model

 public function geteventos($rut_usu){


 $this->db->select('CONCAT(estudiantes.pnombre," ", estudiantes.apellido_pa," ", estudiantes.apellido_ma,", ",motivos_citas.descripcion_mot) As title ,citas.id_ci id, citas.fecha_ini start, citas.fecha_ter end, citas.id_mot mot, CONCAT(estudiantes.pnombre," ", estudiantes.apellido_pa," ", estudiantes.apellido_ma) as estudiante');
 $this->db->select('CONCAT(usuarios.pnombre," ", usuarios.apellido_pa," ", usuarios.apellido_ma) as jefe_c, estudiantes.rut_estu rut_estudiante');
 $this->db->from('citas');
 $this->db->join('estudiantes', 'citas.rut_estu = estudiantes.rut_estu');
 $this->db->join('motivos_citas','citas.id_mot = motivos_citas.id_mot');
 $this->db->join('usuarios','citas.rut_usu = usuarios.rut_usu');
 $this->db->where('rut_usu',$rut_usu); //filtramos los eventos

 return $this->db->get()->result();


 }

Javascript to filter events

$("#rut_jc").change(function(){

 var rut_usu = $("#rut_jc").val();

 //rut_jc es el select

 $.ajax({

 url: "<?php echo base_url(); ?>" + "cCalendar/geteventos/",
 type: 'post',
 data: { "rut_jc": rut_usu },

 success: function(response){ 

      //actualizamos los eventos
       $("#calendar").fullCalendar('refetchEvents');

   }

  });
 });

Javascript of how I show the events

$('#calendar').fullCalendar({

 header: {
 left: 'prev,next today',
 center: 'title',
 right: 'month,agendaWeek,agendaDay,listMonth'

 },

defaultDate: new Date(),
navLinks: true, // can click day/week names to navigate views
businessHours: true, // display business hours

events: function(start, end, timezone, callback) {

 $.post('<?php echo base_url(); ?>cCalendar/geteventos',

  { "start": start.format("YYYY-MM-DD"), "end": end.format("YYYY-MM-DD") },

  function (data) {

    callback($.parseJSON(data));

     });
   },

 dayClick: function (date, jsEvent, view) {

 date_last_clicked = $(this);
 //$(this).css('background-color', '#bed7f3');
 $('#modal_registrar').modal();


 },

 eventClick: function(event, jsEvent, view) {


      $('#event_id').val(event.id);
      $('#id_mot2').val(event.mot);
      $('#nombre_estudiante').val(event.estudiante);
      $('#jc2').val(event.jefe_c);
      $('#rut_estudiante').val(event.rut_estudiante)

       $('#start_f').val(moment(event.start).format('DD/MM/YYYY HH:mm:ss'));

        $('#end_f').val(moment(event.end).format('DD/MM/YYYY HH:mm'));


       $('#modal_editar').modal();


    },


   minTime: "08:30:00",
   maxTime: "23:00:00"

  });
    
asked by CristianOx21 02.10.2017 в 21:40
source

0 answers