Skip to main content

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

1

Open the New Department Modal

Click the “Añadir nuevo” button in the top-right corner of the departments page.
2

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
3

Submit the Form

Click “Crear Departamento” to add the new department to the system.
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
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

1

Click the Edit Button

In the departments table, click the edit icon (pen) in the Actions column for the department you want to modify.
2

Change the Department Name

Update the name in the “Nombre del departamento” field.
3

Save Changes

Click “Guardar Cambios” to update the department. The form submits to functions/editarDepartamento.php.
Changing a department name will affect all employees and vacancies associated with that department.

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.
Important Considerations Before Deleting:
  • Ensure no employees are currently assigned to this department
  • Verify no active job vacancies reference this department
  • Deletion is permanent and cannot be undone

Form Fields and Validation

Field NameTypeRequiredValidationDatabase Column
nombreTextYesNon-empty stringnombre
created_atTimestampAutoSystem-generatedcreated_at

Validation Rules

// Server-side validation
if ($nombre === '') {
    die("❌ Nombre requerido");
}
The department name cannot be empty. All other validations are handled at the database level.

Data Structure

Database Table: departamento

{
  "id": "auto-incremented integer",
  "nombre": "string",
  "created_at": "timestamp (Y-m-d H:i:s)"
}

Example Record

{
  "id": 5,
  "nombre": "Recursos Humanos",
  "created_at": "2024-03-15 10:30:00"
}

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 (uses supabase_request_service with service role)
  • POST /functions/editarDepartamento.php - Update department

JavaScript Files

  • main.js - Core CMS functionality and alert handling
  • maindepartamentos.js - Department-specific interactions (edit modal, delete confirmation)

User Workflows

Setting Up Organizational Structure

1

Plan Your Departments

List all organizational units in your company (HR, IT, Sales, Operations, etc.).
2

Create Each Department

Use the “Añadir nuevo” button to create each department one by one.
3

Verify the List

Review the departments table to ensure all units are properly created.
4

Proceed to Employee Setup

Once departments are created, you can begin adding employees and assigning them to their respective departments.

Reorganizing Department Names

1

Review Current Structure

Check the departments table for any names that need updating due to organizational changes.
2

Edit Department Names

Click the edit icon for each department that needs to be renamed.
3

Verify Impact

Remember that changing a department name will update it everywhere it’s referenced (employee profiles, job postings).

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:
  • ✅ Departamento creado - Department successfully created
  • Success messages appear in green alerts and auto-dismiss
  • ❌ Nombre requerido - Department name field is empty
  • ❌ Error al crear departamento: - Database or API error occurred
  • Error messages appear in red alerts

Build docs developers (and LLMs) love