Example #1
0
 public function listar($campo = 'Estado', $orden = 'asc', $limit = '5', $offset = 0)
 {
     $this->titulo = 'presupuestos';
     if ($this->uri->segment(1) == 'cliente') {
         $this->permisos('cliente');
         $this->load->library('cart');
         $this->pagina = 'listado presupuesto';
         $this->carpeta = 'cliente';
         $this->estilo = '';
         $this->javascript = array('menu_cliente', 'jquery-ui', 'tamanyo', 'confirmacion');
         $datos['presupuestos'] = Presupuesto_model::cliente($this->session->userdata('email'));
         $this->mostrar($datos);
     } else {
         if ($this->uri->segment(1) == 'admin') {
             $this->permisos('admin');
             $this->pagina = 'presupuestos';
             $this->carpeta = 'administrador';
             $this->menu = 'menu_admin_presupuestos';
             $this->estilo = 'tablas';
             $this->javascript = array('marcar_checkbox', 'confirmacion');
             $datos['buscador'] = array('class' => 'search-query input-medium', 'type' => 'text', 'name' => 'buscador', 'placeholder' => 'Buscar', 'autofocus' => 'autofocus');
             $datos['boton'] = array('class' => 'btn', 'id' => 'buscador', 'name' => 'button', 'value' => 'Buscar');
             $datos['borrar'] = array('class' => 'btn btn-danger', 'id' => 'borrar', 'value' => 'Borrar selección', 'data-confirm' => "¿Estás seguro?");
             if (Presupuesto_model::numero() == 0) {
                 $this->registrar();
             } else {
                 $opciones = $this->seleccion(Presupuesto_model::numero());
                 $datos['opciones'] = $opciones;
                 $datos['numero'] = $opciones;
                 if ($this->input->post('cantidad') != '') {
                     if ($opciones[$this->input->post('cantidad')] == 'Todo') {
                         $limit = Presupuesto_model::numero();
                     } else {
                         $limit = $opciones[$this->input->post('cantidad')];
                     }
                 }
                 $datos['elementos'] = $limit;
                 if ($this->input->post('cantidad') != '') {
                     $datos['limit'] = $this->input->post('cantidad');
                 } else {
                     $aux = 0;
                     if ($limit % 5 != 0) {
                         $aux = 1;
                     }
                     $datos['limit'] = floor($limit / 5) - 1 + $aux;
                 }
                 $datos['fields'] = array('Nombre' => 'Cliente', 'EmailCliente' => 'Email', 'Estado' => 'Estado', 'FechaSolicitud' => 'Solicitado', 'Tipo' => 'Tipo', 'Direccion' => 'Dirección', 'Ciudad' => 'Ciudad', 'Provincia' => 'Provincia');
                 $datos['presupuestos'] = Presupuesto_model::obtener($campo, $orden, $offset, $limit);
                 $config = array();
                 $config['base_url'] = base_url() . "admin/presupuesto/" . $campo . "/" . $orden . "/" . $limit . "/";
                 $config['total_rows'] = Presupuesto_model::numero();
                 $config['per_page'] = $limit;
                 $config['uri_segment'] = 6;
                 $config['prev_link'] = 'anterior';
                 $config['next_link'] = 'siguiente';
                 $config['first_link'] = '<<';
                 $config['last_link'] = '>>';
                 $config['num_tag_open'] = '<li>';
                 $config['num_tag_close'] = '</li>';
                 $config['cur_tag_open'] = '<li class="disabled"><a href="#">';
                 $config['cur_tag_close'] = '</a></li>';
                 $config['prev_tag_open'] = '<li>';
                 $config['prev_tag_close'] = '</li>';
                 $config['next_tag_open'] = '<li>';
                 $config['next_tag_close'] = '</li>';
                 $config['first_tag_open'] = '<li>';
                 $config['first_tag_close'] = '</li>';
                 $config['last_tag_open'] = '<li>';
                 $config['last_tag_close'] = '</li>';
                 $this->pagination->initialize($config);
                 $datos['links'] = $this->pagination->create_links();
                 $datos['campo'] = $campo;
                 $datos['orden'] = $orden;
                 $this->mostrar($datos);
             }
         }
     }
 }