Ejemplo n.º 1
0
 public function filters($offset = 0)
 {
     $string = '%' . $this->input->post('nivel') . '%';
     $condiciones = '';
     $valores = array();
     if ($string != '%%') {
         $condiciones .= " nivel LIKE ?";
         $valores['nivel'] = $string;
     }
     $conditions = array_merge(array($condiciones), $valores);
     $config['base_url'] = site_url('niveles/index');
     $config['total_rows'] = Level::count(array('conditions' => $conditions));
     $config['per_page'] = '10';
     $config['num_links'] = '10';
     $config['first_link'] = '← primero';
     $config['last_link'] = 'último →';
     $this->load->library('pagination', $config);
     $niveles = Level::all(array('conditions' => $conditions, 'limit' => $config['per_page'], 'offset' => $offset));
     $this->table->set_heading('Orden', 'Nivel', 'Acciones');
     foreach ($niveles as $nivel) {
         $this->table->add_row($nivel->id, $nivel->nivel, anchor('niveles/editar/' . $nivel->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar"') . ' ' . anchor('niveles/eliminar/' . $nivel->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar"'));
     }
     echo $this->table->generate();
     echo '<div class="pagination">';
     echo $this->pagination->create_links();
     echo '</div>';
 }