Skip to main content

Overview

The Dashboard is your central hub for monitoring all activity and statistics across the Grupo Mecsa CMS. It provides real-time insights into content, clients, projects, contacts, and HR operations.
The dashboard automatically adapts based on your user role, showing only the metrics and sections you have permission to view.

Key Features

Real-time Statistics

Track counts for content, clients, projects, contacts, vacancies, and employees

Role-Based Views

See only the data relevant to your role (Admin, RRHH, Proyecto, Comercial)

Recent Activity

View the latest contacts, projects, and job vacancies

Quick Actions

Access frequently-used modules directly from the dashboard

Dashboard Statistics

The dashboard fetches and displays counts from multiple tables:
dashboard.php
// Helper function to get record counts
function get_count($table) {
    $res = supabase_request('GET', "$table?select=id");
    return ($res['http'] >= 200 && $res['http'] < 300 && is_array($res['json'])) ? count($res['json']) : 0;
}

// Fetch totals
$total_contenidos = get_count('contenido');
$total_clientes = get_count('clientes');
$total_proyectos = get_count('Proyectos');
$total_contactos = get_count('contactos');
$total_vacantes = get_count('vacantes');
$total_empleados = get_count('empleados');

Displayed Metrics

For All Users

MetricDescriptionTable
ContentTotal published content itemscontenido
ClientsTotal registered clientsclientes
ProjectsTotal active and completed projectsProyectos
ContactsTotal contact form submissionscontactos

For HR Users

MetricDescriptionTable
VacanciesOpen job positionsvacantes
EmployeesCurrent employee countempleados

Recent Activity Feeds

The dashboard displays recent records from key tables:
dashboard.php
// Helper function to get recent records
function get_records($table, $select = '*', $order = 'created_at.desc', $limit = 5) {
    $res = supabase_request('GET', "$table?select=$select&order=$order&limit=$limit");
    return ($res['http'] >= 200 && $res['http'] < 300 && is_array($res['json'])) ? $res['json'] : [];
}

// Recent activity
$ultimos_contactos = get_records('contactos');
$ultimos_proyectos = get_records('Proyectos', 'id,nombre,cliente,created_at');
$ultimas_vacantes  = get_records('vacantes', 'titulo,created_at');

Recent Contacts

Displays the 5 most recent contact form submissions with:
  • Contact name and email
  • Submission date
  • Quick action buttons

Recent Projects

Shows the 5 latest projects with:
  • Project name
  • Associated client
  • Creation date
  • Link to project details

Recent Vacancies (HR Only)

Lists the 5 newest job postings with:
  • Position title
  • Creation date
  • Status (Active/Inactive)

Role-Based Access

The dashboard respects role permissions set in resolve_user.php:
dashboard.php
require_once __DIR__ . '/../functions/resolve_user.php';

// Available role variables:
// $is_admin - Full system access
// $is_rrhh - HR module access
// $is_proyecto - Project module access

Admin Users

  • See all metrics and statistics
  • Access all recent activity feeds
  • Can navigate to any module

HR Users

  • See HR-specific metrics (vacancies, employees)
  • Access employee and recruitment data
  • Limited access to client/project data

Project Users

  • Focus on projects and client relationships
  • Limited HR access

User Interface

Welcome Card

The dashboard greets users by name and displays:
  • Current time
  • Role-specific mini statistics
  • Quick access to relevant modules
dashboard.php
$userName = $_SESSION['user_name'] ?? $_SESSION['name'] ?? 'Administrador';
$firstName = explode(' ', $userName)[0];

Statistics Grid

Metrics are displayed in a responsive grid layout:
  • Large screens: 4 columns
  • Tablets: 2 columns
  • Mobile: 1 column

Quick Actions

From the dashboard, users can quickly navigate to:

Content

Manage website content

Clients

View client directory

Projects

Track project status

Contacts

Review inquiries

Employees

HR management

Email Builder

Create campaigns

Technical Details

Data Fetching

All dashboard data is fetched on page load using Supabase REST API:
  • Authentication: Requires valid session token
  • Schema: Queries cms schema by default
  • Performance: Lightweight queries using select=id for counts
  • Ordering: Recent records sorted by created_at.desc

Session Requirements

dashboard.php
session_start();
if (!isset($_SESSION['token'])) {
    header("Location: ../login.php");
    exit;
}

Best Practices

Check the dashboard regularly to stay informed about recent activity and system health.
The dashboard is read-only. Use the quick action links to manage records in their respective modules.

Next Steps

Clients

Learn about client management

Projects

Explore project tracking