Viewing file: perfiles.php (3.31 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); }
class Perfiles extends CI_Controller {
public function __construct() { parent::__construct(); $this->load->model('consultas_model'); /* Cargamos la base de datos */ $this->load->database(); $this->load->library('javascript'); /* Cargamos la libreria*/ $this->load->library('grocery_crud'); $this->load->library('session'); /* Añadimos el helper al controlador */ $this->load->helper('url'); // $this->load->library('encrypt'); error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); }
public function index() { if ($this->session->userdata('loginuser') == TRUE) { try {
/* Creamos el objeto */ $crud = new grocery_CRUD();
/* Seleccionamos el tema */ $crud->set_theme('flexigrid'); //$crud->set_theme('bootstrap'); /* Seleccionmos el nombre de la tabla de nuestra base de datos*/ $crud->set_table('tbl_usrs');
// $crud->set_relation('nombre','stock_productos','stock'); /* Le asignamos un nombre */ $crud->set_subject('USUARIOS');
$listadoPermisos = array( "ADMINISTRADOR", "vendedor_externo", "AUTORIZADOR", "LOGISTICA", "facturador", "vendedor", "CLIENTE", ); /* Asignamos el idioma español */ $crud->set_language('spanish'); $crud->field_type('perfil', 'set', $listadoPermisos);
$crud->required_fields( 'username', 'password', 'perfil' );
/* Aqui le indicamos que campos deseamos mostrar */ $crud->columns( 'username', 'password', 'perfil' ); $crud->callback_before_insert(array($this, 'encrypt_password')); $crud->callback_before_update(array($this, 'encrypt_password')); /* Generamos la tabla */ $output = $crud->render(); $data = array("pepe" => $output, "contenido" => "productos/administracion", "titulo" => "ADMINISTRACION USUARIOS", );
/* La cargamos en la vista situada en /applications/views/productos/administracion.php */ $this->load->view('template', $data);
} catch (Exception $e) { /* Si algo sale mal cachamos el error y lo mostramos */ show_error($e->getMessage() . ' --- ' . $e->getTraceAsString()); } } else {
redirect(base_url() . 'login', 'refresh'); } }
public function encrypt_password($post_array, $primary_key = null) { if (!empty($post_array["password"])) { $post_array["password"] = md5($post_array["password"]); } return $post_array;
} public function getUsuariosAajax() { $respuesta = $this->consultas_model->getUsuariosAajax(); return $respuesta; }
}
|