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?
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.
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.