Overview
The employee management system tracks staff members who interact with the inventory system. Employee records are essential for audit trails, as they link to product edits, stock movements, price changes, and merchandise receptions.Why Employee Records Matter
Employee tracking provides accountability across the system:- Product Edits: When editing products, you must select which employee made the change
- Price Changes: All price updates are logged with the employee who authorized them
- Stock Movements: Inventory entries, exits, and adjustments track the authorizing employee
- Merchandise Reception: Product receptions record which employee received the goods
Accessing Employee Management
Navigate to the Gestión de Empleados page (empleados.php) from the main navigation menu.
Interface Layout
The page uses a two-column layout:- Left Panel (4 columns): Quick registration form for new employees
- Right Panel (8 columns): Table of all employees with edit and delete options
Creating a New Employee
Locate the registration form
Enter employee name
- Juan García Martínez
- María Elena Rodríguez
- Carlos Alberto López
Select employee role
- empleado - Standard employee role
- gerente - Manager role
Save the employee record
Database Operation
id_empleado is auto-generated as a primary key.
Viewing Employees
The employee table displays:| Column | Description |
|---|---|
| ID | Auto-generated unique identifier |
| Nombre | Employee’s full name |
| Puesto | Role badge (blue for empleado, red for gerente) |
| Acción | Edit and Delete buttons (yellow and red) |
Role Badge Colors
- empleado: Blue badge (
badge bg-info) - gerente: Red badge (
badge bg-danger)
Editing an Employee
Employee editing uses a modal dialog to update name or role without leaving the page.Click Edit button
Modal opens with current data
- Hidden field:
id_empleado - Nombre del Empleado: Current name
- Cambiar Puesto: Current role selected in dropdown
Update employee information
- Correct spelling errors
- Update to reflect legal name changes
- Adjust formatting
- Promote employee to gerente
- Demote gerente to empleado
- Correct role assignment errors
Modal JavaScript Implementation
Deleting an Employee
Confirm deletion
“¿Estás seguro de eliminar este empleado?”
- Click OK to proceed
- Click Cancel to abort
Handle result
- Page reloads with
?msg=eliminado - Employee removed from table
- Employee no longer appears in system dropdowns
- Alert displayed: “No se puede eliminar este empleado porque tiene registros de mercancía asociados.”
- Employee remains in the system
- Database integrity preserved
Why Deletion Fails
Employees cannot be deleted if they have associated records in:- registro table: Merchandise receptions the employee received
- actualizacion table: Price changes the employee authorized
- movimiento_stock table: Stock movements the employee processed
Employee Roles Explained
empleado (Employee)
Purpose: Standard staff members who handle day-to-day operations Typical responsibilities:- Receiving merchandise
- Processing stock movements
- Basic product edits
- Regular inventory updates
gerente (Manager)
Purpose: Supervisory staff with broader responsibilities Typical responsibilities:- Authorizing price changes
- Approving large stock adjustments
- Overseeing inventory accuracy
- Managing employee records
Future Role Enhancements
While the current system treats roles as labels, future versions could implement:- Permission-based access control: Restrict certain operations to managers
- Approval workflows: Require manager approval for price changes over a threshold
- Reporting access: Limit financial reports to management roles
- Audit filtering: Filter audit logs by role to identify patterns
Common Use Cases
Setting up initial employee roster
Setting up initial employee roster
- Create manager accounts first: Register all gerente-level staff
- Add employee accounts: Register all empleado-level staff
- Verify in dropdowns: Check that all names appear correctly in product edit forms
- Test role badges: Ensure managers show red badges and employees show blue
Promoting an employee to manager
Promoting an employee to manager
- Click Editar on the employee’s row
- In the modal, change Cambiar Puesto from “empleado” to “gerente”
- Click Guardar Cambios
- Verify the badge changes from blue to red
Handling employee departures
Handling employee departures
- Delete the employee using the Eliminar button
- Cannot delete (foreign key constraint)
- Update name to: “[INACTIVE - DATE] Original Name”
- Example: “[INACTIVE - 2026-03-15] Juan García”
- This preserves audit trails while indicating inactive status
Correcting employee name spelling
Correcting employee name spelling
- Click Editar on the employee
- Update the Nombre del Empleado field
- Click Guardar Cambios
- Name updates throughout the system immediately
- All historical records now show the corrected name
Troubleshooting
Cannot delete employee - has associated records
Cannot delete employee - has associated records
“No se puede eliminar este empleado porque tiene registros de mercancía asociados.”Why it happens:
- Employee has received merchandise (
registrotable) - Employee has authorized price changes (
actualizaciontable) - Employee has processed stock movements (
movimiento_stocktable)
- Mark as inactive by updating the name: “[INACTIVE] Name”
- Keep the record in the system for data integrity
- Contact a database administrator if deletion is absolutely necessary
Employee doesn't appear in dropdown menus
Employee doesn't appear in dropdown menus
Role badge shows wrong color
Role badge shows wrong color
puesto field:- Blue (bg-info): puesto = ‘empleado’
- Red (bg-danger): puesto = ‘gerente’
- Edit the employee
- Check the selected value in Cambiar Puesto
- Select the correct role
- Save changes
- Refresh the page to see the updated badge
Edit modal shows wrong employee data
Edit modal shows wrong employee data
- Open browser console (F12)
- Look for JavaScript errors
- Check that special characters in names are handled correctly
- Verify Bootstrap is loaded
- Try editing a different employee to isolate the issue
Cannot save employee - form validation fails
Cannot save employee - form validation fails
- Nombre Completo: Cannot be empty
- Puesto: Must select either “empleado” or “gerente”
- Ensure the name field has text
- Ensure a role is selected in the dropdown
- Check browser console for validation errors
- Try a different browser if issues persist
Employee Audit Trail Integration
Product Edits
When editing products (editar.php), the employee dropdown is required:
Price Change History
Price updates create audit records with employee attribution:actualizaciones.php).
Stock Movements
Inventory operations require an authorizing employee:Merchandise Reception
Product receptions record which employee received the goods:Related Features
Managing Products
Stock Operations
Database Schema
Best Practices
Create employee records before operations
Use full legal names
Assign roles accurately
Never delete employees with history
Review employee actions regularly