简体   繁体   中英

Grocery Crud not showing all items added

I have 'intervalosHorarios' and 'entregas' in my proyect, and when i clic on an 'intervaloHorario' it shows 'entregas' from that 'intervaloHorario'. The problem is to add more 'entregas' because it's showing only the fist one added. I wanna show all 'entregas' inside that 'intervaloHorario'. Any ideas?

Tables 在此处输入图片说明

Controller

public function entregas_lista($idCarga) {

        $crud = new grocery_CRUD();

        $datos = array(
            'title' => "entregas", // En la vista 'header' tendré una variable $title
            'username' => "Administrador"
        );

        $this->load->view('commons/header', $datos);

        //Quitamos los botones de añadir y quitar
        $crud->unset_add();
        $crud->unset_edit();

        $crud->set_language("spanish");
        $crud->set_theme('bootstrap');
        $crud->set_table('entregas');



        $crud->where('idCarga =', $idCarga);



        $crud->display_as('idCarga', 'Nº Entrega');
        $crud->set_subject('Carga / Descarga'); 
      $crud->set_relation('idIntervaloHorario', 'intervalosHorarios', 'intervaloHorario');

        $crud->columns('fechaCita', 'horaCita', 'numeroEntrega', 'cliente', 'Origen', 'Destino', 'cargaPrevista', 'entregaPrevista', 'accion', 'estado');




        $output = $crud->render();




        $this->_example_output($output);


        //---------------   Cargo la vista 'commons/footer.php'  ------------- /
        $this->load->view('commons/footer');
    }




    function _example_output($output = null) {
        $this->load->view('example', (array) $output);
    }

When I clic on 'De 12:00 a 13:30 it shows the same rows that 'De 7:00 a 8:30' link, and if i uncomment 'where' clause, it shows fine (the information of that link) but only with one row.

Interval table 在此处输入图片说明

Delivery table 在此处输入图片说明

You are setting $crud->where('idCarga =', $idCarga); and I suppose that $idCarga is the PK of 'Entregas' table and PK's are unique. So it can be only one row for each PK.

EDIT: $crud->where('entregas.idIntervaloHorario =', $idCarga); to mach every row which has FK of 'IntervalosHorarios' table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM