<?php

namespace App\Controllers;

use CodeIgniter\Exceptions\PageNotFoundException;


class Home extends BaseController
{
    public function dashboard()
    {
        /*if (session()->get('usuario')["perfil_id"]==2) {
            return redirect()->to(site_url('inicio'));
        }*/
        permiso('Dashboard', 'Visualizar', true);
        $data['eventos'] = model('EventoModel')->getEventosPorOrganizacion(null, null, 3, true);
        $dashboardModel = new \App\Models\DashboardModel();
        $data['stats'] = $dashboardModel->getDashboardStats();

        return view('home/dashboard', $data);
    }

    public function index()
    {
        $data['eventos'] = model('EventoModel')->getEventosPorOrganizacion(null, null, 3, true);
        $data['archivos'] = model('ArchivoModel')->getArchivosConPermisos([], 5);
        return view('home/dashboard_inicio', $data);
    }

    public function view(string $page = 'home')
    {
        if (! is_file(APPPATH . 'Views/' . $page . '.php')) {
            // Whoops, we don't have a page for that!
            throw new PageNotFoundException($page);
        }

        return view($page);
    }

}
