<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Main extends CI_Controller {

    public function index() {
        $this->load->helper('url');
        $this->load->helper('session');
        if (check_id()) {
            $usuario_json = array(
                'id' => $_SESSION[$this->config->item('project_name')]['user']['id'],
                'username' => $_SESSION[$this->config->item('project_name')]['user']['username']
            );
            $data['usuario'] = str_replace("\"", "'", json_encode($usuario_json));
            $this->load->model('roles_model');
            $rol = $this->roles_model->get_rol_by_id(get_rol_id());
            $data['rol_nombre'] = (ENVIRONMENT == 'development') ? 'DEV-' : ((ENVIRONMENT == 'testing') ? 'TEST-' : '');
            $data['rol_nombre'] .= $rol['rol_nombre'];
        } else {
            $data['usuario'] = 'false';
            $data['rol_nombre'] = '';
        }
        $data['random'] = "?r=" . rand(1, 15000);
        $data['intentos_captcha'] = check_intentos_captcha();
        $data['page_title'] = $this->config->item("page_title");
        $data['google_maps_api_key'] = $this->config->item('google_maps_api_key');
        $data['content_path'] = $this->config->item('content_path');
        $this->load->view('main_view', $data);
    }

}
