Documentation Index
Fetch the complete documentation index at: https://mintlify.com/obando1998/Proyecto_UCP/llms.txt
Use this file to discover all available pages before exploring further.
HomeController
Controllers/HomeController.php
The HomeController manages the main dashboard view for all authenticated users. It provides access to return statistics, both for specific dates and historical data.
Overview
- Purpose: Display dashboard with statistics and date filtering
- Access Level: All authenticated users (requires
$_SESSION['logged_in']) - Model Used:
DevolucionModel - View:
Views/home/dashboard.php
Class Structure
HomeController.php
Methods
__construct()
Initializes the controller with authentication and database connection. Behavior:- Starts PHP session if not already active
- Checks for authenticated user (
$_SESSION['logged_in']) - Redirects to login page if not authenticated
- Instantiates
DevolucionModelfor data access
index()
Displays the dashboard with statistics and date filtering capability. Route:index.php?url=home/index
Query Parameters:
Date filter in
Y-m-d format (e.g., “2024-03-05”). Defaults to current date.- $fechaFiltro - Selected date or current date
- $statsHoy - Statistics for the filtered date
- $statsGeneral - All-time statistics (no date filter)
- $fechas - Array of available dates with returns
$statsHoy and $statsGeneral contain:
Total number of returns
Total weight in kilograms (using COALESCE, defaults to 0)
Total units across all returns
Count of returns with estado = ‘Pendiente’
Count of returns with estado = ‘Aprobado’
Count of returns with estado = ‘Rechazado’
Count of returns with motivo = ‘Devolucion’
Count of returns with motivo = ‘Faltante’
Count of returns with motivo = ‘Sobrante’
View Integration
The dashboard view (Views/home/dashboard.php) receives these variables and displays:
- Date selector dropdown populated with
$fechas - Today’s statistics from
$statsHoy - Historical statistics from
$statsGeneral - Charts and graphs using the statistics data
Use Cases
1. View Today’s Dashboard
2. View Historical Date
3. Compare Day vs All-Time
The controller provides both filtered and unfiltered statistics, allowing the view to display:- Progress bars showing today vs historical totals
- Percentage breakdowns by status
- Trend analysis
Security
Session Requirements:$_SESSION['logged_in']must betrue- No specific grado (role) requirement - all authenticated users can access
Related Components
- DevolucionModel - Provides
obtenerEstadisticas()andobtenerFechas()methods - AuthController - Handles authentication and role-based redirects
- Dashboard Analytics Feature - User-facing documentation