The reports module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nieto2020/portalhub/llms.txt
Use this file to discover all available pages before exploring further.
modules/reportes/) gives advisors a structured way to compose and publish financial analyses for their clients. Every report is typed (Monthly, Quarterly, Annual, or Special), follows a three-stage editorial lifecycle, and is permanently linked to the asesor who authored it. Admins have full read access across all reports, while advisors see only their own work.
Report Fields
| Column | Type | Description |
|---|---|---|
id_reporte | int | Auto-increment primary key |
id_asesor | int (FK) | The advisor who created the report — ON DELETE CASCADE |
titulo | string | Report title |
descripcion | string | Short summary / abstract |
contenido | text | Full report body |
tipo | enum | Mensual, Trimestral, Anual, or Especial |
estado | enum | Borrador, Publicado, or Archivado |
fecha_creacion | datetime | Set to NOW() on insert |
fecha_actualizacion | datetime | Updated on every edit |
The
id_asesor foreign key is defined with ON DELETE CASCADE. If an advisor’s user account is removed from the system, all reports they authored are automatically deleted with it. Archive important reports before deactivating an asesor account.Report Types
Mensual
Monthly accounting summary — income, expenses, and tax obligations for a single calendar month.
Trimestral
Quarterly review covering a three-month fiscal period.
Anual
Year-end annual report, often aligned with the SAT fiscal year.
Especial
Ad-hoc or one-off analysis outside the regular reporting calendar.
Report Lifecycle (State Machine)
Reports follow a linear editorial workflow:| State | Description |
|---|---|
Borrador | Default on creation; report is being drafted and is not yet visible to clients |
Publicado | Report has been reviewed and released; visible to relevant clients |
Archivado | Report has been superseded or retired; preserved for audit purposes |
Creating a Report
Endpoint:POST modules/reportes/crear.php
Only ROL_ASESOR may create reports. The id_asesor is taken directly from the session — advisors cannot create reports on behalf of other advisors. titulo and descripcion are required; contenido, tipo, and estado fall back to safe defaults if omitted.
Required fields:
| Field | Type | Notes |
|---|---|---|
titulo | string | Cannot be empty after trim |
descripcion | string | Cannot be empty after trim |
| Field | Type | Default |
|---|---|---|
contenido | string | "" (empty) |
tipo | enum | "Mensual" |
estado | enum | "Borrador" |
- Request
- Success Response (201)
- Invalid Type (400)
- Access Denied (403)
Listing Reports
Endpoint:GET modules/reportes/listar.php
Returns reports joined with usuarios (advisor email) and perfiles (advisor full name), ordered by fecha_creacion DESC.
| Role | Filter Applied |
|---|---|
ROL_ASESOR (2) | Only reports where r.id_asesor = id_usuario |
ROL_ADMIN (1) | All reports, all advisors |
ROL_CLIENTE (3) | Published reports linked to the client’s assigned asesor |
SQL query (listar.php)
SQL query (listar.php)
Report Detail View
Endpoint:GET modules/reportes/detalle.php?id={id_reporte}
Returns the complete record for a single report, including all fields. Subject to the same ownership rules as the list endpoint — an advisor cannot retrieve another advisor’s report.
Dashboard KPIs
Endpoint:GET modules/reportes/dashboard.php
The dashboard endpoint is accessible to any authenticated user (checkAuth()) and aggregates platform-wide counts across users, appointments, accounting services, and payments into a single response.
Users
Total, active, and inactive user counts, broken down by client and advisor roles.
Appointments
Total appointment count with separate counts for
Programada and Cancelada states.Accounting Services
Total services with counts for
Pendiente, En proceso, and Completado states.Payments
Total payments with counts for
Pendiente and Aprobado states, plus total monto_total.