login controller:
Código
<?php class Login extends MY_Controller { public function __construct(){ parent::__construct(); } public function index(){ $data['module'] = 'Login'; $this->load->view('login',$data); } public function getAccess(){ if ($this->session->userdata('logged_in') == TRUE){ redirect('home'); }else{ $username = $this->security->xss_clean($this->input->post('username')); $password = $this->security->xss_clean($this->input->post('password')); $array = $this->user->login($username,$password); if ($array[0] == 0) { echo 0; }else{ 'id' => $array[0]['id'], 'name' => $array[0]['nombre'], 'last_name' => $array[0]['apellido'], 'type' => $array[0]['id_perfil'], 'logged_in' => TRUE ); $this->session->set_userdata('log',$data_session); } } } public function logout(){ $this->session->sess_destroy(); redirect('login'); } public function getModules($id_module){ if($this->session->userdata('log')){ $data = $this->session->userdata('log'); $seccions = $this->module->get_rows(); foreach ($seccions as $index => $sección){ $modules = $this->module->query("SELECT CONCAT('".$sección['id']."',storelte_modulo.id) AS id,CONCAT('".base_url('assets/img/sidebar')."','/',storelte_modulo.icon) as icon, storelte_modulo.modulo AS value,storelte_modulo.seccion_id,CONCAT('".base_url()."',storelte_modulo.url) AS url FROM storelte_modulo INNER JOIN storelte_modulo_perfil ON storelte_modulo_perfil.modulo_id = storelte_modulo.id WHERE seccion_id = $sección[id] AND storelte_modulo_perfil.perfiles_id = $data[id] AND storelte_modulo_perfil.STATUS = 1"); $seccions[$index]['data']= $modules; } foreach ($seccions as $item) $this->data['fields'] = $menu; $this->json($this->data); $this->load->view('home',$this->data); } } }
home controller:
Código
class Home extends MY_Controller { public function __construct(){ parent::__construct(); $this->isLogged(); } public function index(){ $data = $this->session->userdata('log'); $data['module'] = "Home"; $this->load->view('header',$data); $this->load->view('home',$data); } }
view home
Código