I have a problem with Fullcalendar and the INNER JOIN framework Codeigniter

0

Already update my publication, I already recognize the id of the project and I do the JOIN well, in an alert you can see the result of the query, I already painted the calendar but as if it were empty. The phases do not place them.

What I intend is to join phases of projects, these phases are according to time and according to users. The following tables enter the JOIN query

  

- > Projects

     

- > Phases

     

- > phases_project

     

- > Users

     

- > users_projects

The result I hope for are the dates and the name of the phases contained in Project 1, for example, but obviously I have to verify it with the login session of the logged user.

I have my eyesight

    <link href="<?php echo base_url();?>assets/fullcalendar/fullcalendar.css" rel='stylesheet' />
    <link href='<?php echo base_url();?>assets/fullcalendar/fullcalendar.print.css' rel='stylesheet' media='print' />
    <script src='<?php echo base_url();?>assets/fullcalendar/lib/moment.min.js'></script>
    <script src='<?php echo base_url();?>assets/fullcalendar/lib/jquery.min.js'></script>
    <script src='<?php echo base_url();?>assets/fullcalendar/fullcalendar.min.js'></script>
    <script src='<?php echo base_url();?>assets/fullcalendar/locale-all.js'></script>
    <input type="hidden"  value="<?php echo $idProyecto ?>" name="idProyecto" id="idProyecto">
    <script type="text/javascript">  var idProyecto = $("#idProyecto").val(); </script>
    <script>

      $(document).ready(function() {
        $.post('<?php echo base_url('index.php');?>/calendario/getFasesR/'+idProyecto,//-->NO MOVER
          function(data){
            alert(data);
            console.log(data);

          $('#calendar').fullCalendar({
          locale: 'es',
          header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,basicWeek,basicDay'
          },
          defaultDate: new Date(),
          navLinks: true, // can click day/week names to navigate views
          editable: true,
          eventLimit: true, // allow "more" link when too many events
          events: data

        });

      });




      });

    </script>
    <style>


      #calendar {
        max-width: 800px;
        margin: 0 auto;
      }

    </style>


    </head>
  <body> 

  <div id="calendar">

  </div>
<br>

  <!-- jQuery library 
  <script src="<?php// echo base_url();?>assets/js/jquery.min.js"></script>  -->
 <!-- Include all compiled plugins (below), or include individual files as needed 
  <script src="<?php echo base_url();?>assets/js/bootstrap.js"></script> -->  


<!--EliminaUsuario
  <script src="<?php echo base_url();?>assets/js/userElimina.js"></script>-->
  <!-- Custom js 
  <script src="<?php echo base_url();?>assets/js/custom.js"></script> -->

</body>
</html>

My Controller

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Calendario extends CI_Controller {

    public function __construct()
    {
        parent::__construct();  

        $this->load->model('Fase_model');
    }
    function index(){

    }

    public function getFasesR($id){

        $fases = $this->Fase_model->getFasesByAs($id, $this->session->userdata('idusuarios'));
        //$fases = $this->Fase_model->getFasesR();
        echo json_encode($fases);
    }

}
?>

And this my function in model

 function getFasesByAs($idproyecto, $idusuarios){
        $this->db->select('f.idfases id, f.nombreFase title, f.fechaInicioFase start, f.fechaFinFase end');
        $this->db->from('fases_proyecto fp');
        $this->db->join('proyecto p', 'fp.proyecto_idproyecto = p.idproyecto');
        $this->db->join('fases f', 'fp.fases_idfases = f.idfases');
        $this->db->join('proyecto_usuarios pu', 'pu.proyecto_idproyecto = p.idproyecto');
        $this->db->join('usuarios u', 'pu.usuarios_idusuarios = u.idusuarios');
        $this->db->where('fp.proyecto_idproyecto',$idproyecto);
        $this->db->where('pu.usuarios_idusuarios',$idusuarios);
        return $this->db->get()->result();
}

After the console.log (data)

    
asked by Yadira Franco 31.07.2017 в 17:59
source

1 answer

0

if you want to load the page

<script type="text/javascript"> 
  $(document).ready(function(){ 
     var id = $('#idproyecto').val(); 
     $('#calendario').fullCalendar({ 
       header: { 
       left: 'title', 
       center: 'agendaDay,agendaWeek,month', 
       right: 'prev,next today' 
    }, 
    editable: false, 
    firstDay: 1, 
    selectable: true, 
    defaultView: 'month', 
    events: 
    { 
      url: '<?= base_url() ?>calendario/getFasesR/'+id, 
      textColor: 'black', 
      editable: true 
    }, 
   }); 
}); 
</script>

that's the right way to do it it is not necessary to make a post before since in evets through the url we indicate where the json is going to take that the calendar should show in your case the path of your controller which happened the project id that I get through var id = $ ('# idproyecto'). val ();

    
answered by 01.08.2017 / 19:07
source