Documentation Index
Fetch the complete documentation index at: https://mintlify.com/emmanueljarquin-sys/GrupoMecsaCMS/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Department Management module provides a simple interface to create, view, edit, and delete organizational departments. Departments are used throughout the system to categorize employees and job vacancies.Departments created here are automatically available in the employee and vacancy modules as dropdown options.
Key Features
Department Registry
Maintain a centralized list of all organizational departments.
Quick Creation
Add new departments with a simple form requiring only a name.
Edit Capabilities
Update department names as your organization evolves.
Timestamp Tracking
Automatic recording of creation dates for audit purposes.
CRUD Operations
Create New Department
Open the New Department Modal
Click the “Añadir nuevo” button in the top-right corner of the departments page.
Enter Department Name
Fill in the “Nombre del departamento” field. This is the only required field.Examples:
- Recursos Humanos
- Tecnología
- Ventas
- Operaciones
- Administración
The system automatically generates a unique ID and records the creation timestamp when a new department is created.
Read/View Departments
The departments table displays:- ID - Unique department identifier
- Nombre - Department name
- Creado - Creation date (format: Y-m-d)
- Acciones - Edit and delete action buttons
Pagination Support
Pagination Support
The department list supports pagination with configurable rows per page (default: 10 departments per page). Navigate using the pagination controls at the bottom of the table.
Update Department
Click the Edit Button
In the departments table, click the edit icon (pen) in the Actions column for the department you want to modify.
Delete Department
Click the delete icon (trash) in the Actions column for any department. A confirmation prompt will appear before the department is permanently removed.Form Fields and Validation
| Field Name | Type | Required | Validation | Database Column |
|---|---|---|---|---|
nombre | Text | Yes | Non-empty string | nombre |
created_at | Timestamp | Auto | System-generated | created_at |
Validation Rules
Data Structure
Database Table: departamento
Example Record
Role-Based Access
Access to the Department Management module requires an active session with a valid authentication token. Users without a valid
$_SESSION['token'] will be redirected to the login page.Required Permissions
- View Departments - Authenticated users
- Create Department - Users with write permissions
- Edit Department - Users with write permissions
- Delete Department - Users with delete permissions (use with caution)
Integration with Other Modules
Departments are referenced in:Employee Management
Employees are assigned to departments via the department dropdown selector.
Job Vacancies
Job postings specify which department the position belongs to.
Department Data Flow
Technical Details
API Endpoints
- GET
/departamento?select=*&order=created_at.desc&limit={perPage}&offset={offset}- Fetch paginated departments - GET
/departamento?select=id- Get total count for pagination - GET
/departamento?select=nombre- Get department names for dropdowns (used in other modules) - POST
/departamento- Create new department (usessupabase_request_servicewith service role) - POST
/functions/editarDepartamento.php- Update department
JavaScript Files
main.js- Core CMS functionality and alert handlingmaindepartamentos.js- Department-specific interactions (edit modal, delete confirmation)
User Workflows
Setting Up Organizational Structure
Plan Your Departments
List all organizational units in your company (HR, IT, Sales, Operations, etc.).
Reorganizing Department Names
Review Current Structure
Check the departments table for any names that need updating due to organizational changes.
Best Practices
Naming Conventions
Use clear, consistent department names (e.g., “Recursos Humanos” not “RH” or “rrhh”).
Before Deleting
Always check employee and vacancy associations before deleting a department.
Organizational Alignment
Keep department structure aligned with your actual organizational chart.
Regular Review
Periodically review and update department names as your organization evolves.
Flash Messages
The system provides feedback through flash messages:Success Messages
Success Messages
- ✅ Departamento creado - Department successfully created
- Success messages appear in green alerts and auto-dismiss
Error Messages
Error Messages
- ❌ Nombre requerido - Department name field is empty
- ❌ Error al crear departamento: - Database or API error occurred
- Error messages appear in red alerts