Skip to main content

Overview

The supplier management system maintains contact information for vendors who provide merchandise to your store. Supplier records are linked to merchandise reception records, creating a complete audit trail of where inventory originates.
Suppliers are also called “proveedores” in the system. Each supplier record includes company name, phone number, and address.

Why Supplier Records Matter

Supplier tracking provides:
  • Supply chain visibility: Know which vendors supply which products
  • Reception auditing: Track merchandise receptions by supplier
  • Contact management: Quick access to phone numbers and addresses for reordering
  • Quality tracking: Identify patterns if certain suppliers have recurring issues
  • Business relationships: Maintain historical records of all vendor partnerships
Suppliers with merchandise reception history cannot be deleted due to foreign key constraints that preserve data integrity.

Accessing Supplier Management

Navigate to the Proveedores page (proveedores.php) from the main navigation menu.

Interface Layout

The page uses a split-screen layout:
  • Left Panel (4 columns): Quick-add form for creating new suppliers
  • Right Panel (8 columns): Table displaying all supplier records with edit and delete actions

Creating a New Supplier

1

Locate the creation form

On the left side of the page, find the “Nuevo Proveedor” card with a dark header.
2

Enter supplier name

In the “Nombre / Empresa” field, enter the supplier or company name.Examples:
  • Textiles del Norte S.A.
  • Distribuidora García
  • Importaciones Rodríguez Hnos.
  • ABC Fashion Suppliers
  • María Elena - Mayorista
Include legal entity suffixes (S.A., S.R.L., etc.) for proper identification.
3

Enter phone number (optional)

In the “Teléfono (10 dígitos)” field, enter a 10-digit phone number.Format: Numbers only, no spaces or dashes
  • ✅ Correct: 5551234567
  • ❌ Incorrect: 555-123-4567 or 555 123 4567
Field constraints:
  • Maximum length: 10 characters (enforced by maxlength="10")
  • Optional field (can be left empty)
If the supplier has multiple contact numbers, choose the primary contact number. Use the address field for additional contact info.
4

Enter address (optional)

In the “Dirección” textarea (2 rows), enter the supplier’s address.Examples:
  • Av. Reforma 123, Col. Centro, CDMX
  • Calle Principal 45, Guadalajara, Jalisco
  • Km 15 Carretera a León, Aguascalientes
You can include:
  • Street address
  • City and state
  • Additional contact information
  • Email addresses
  • Alternative phone numbers
Use the address field flexibly for any supplier contact details that don’t fit in the phone number field.
5

Save the supplier record

Click the “Guardar Proveedor” button (full-width blue button) to create the supplier.
6

Verify creation

After successful creation:
  • Page reloads with ?msg=creado in the URL
  • New supplier appears in the table on the right
  • Form clears and is ready for the next entry
  • Supplier is now available in merchandise reception dropdowns

Database Operation

INSERT INTO proveedor (nombre, telefono, direccion) VALUES (?, ?, ?)
The id_proveedor is auto-generated as the primary key.

Error Handling

If creation fails, an error message displays:
<div class="alert alert-danger alert-dismissible fade show">
    Error al crear: [error message]
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>

Viewing Suppliers

The supplier table displays:
ColumnDescription
IDAuto-generated unique identifier
ProveedorCompany name (bold) with address below (small, muted text)
ContactoPhone number
AccionesEdit (yellow) and Delete (red) buttons in a button group
The table shows the address directly under the company name for quick reference without cluttering the table.

Editing a Supplier

Supplier editing uses a modal dialog for a streamlined update experience.
1

Click Edit button

In the supplier table, locate the supplier you want to modify and click the yellow “Editar” button.
2

Modal opens with current data

The “Modificar Proveedor” modal appears with pre-populated fields:
  • Hidden field: id_proveedor
  • Nombre / Empresa: Current supplier name
  • Teléfono: Current phone number (10 character max)
  • Dirección: Current address (3-row textarea)
3

Update supplier information

Modify any fields as needed:Nombre / Empresa (required)
  • Correct spelling or naming errors
  • Update to reflect company rebranding
  • Add or remove legal entity suffixes
Teléfono (optional, max 10 characters)
  • Update primary contact number
  • Can be left blank if unknown
  • Only numbers, no formatting characters
Dirección (optional)
  • Update physical address
  • Add email addresses or additional contacts
  • Correct location information
4

Save changes

Click “Actualizar Cambios” (blue button) to save, or “Cerrar” (gray button) to cancel.
5

Verify update

After saving:
  • Modal closes automatically
  • Page reloads with ?msg=actualizado
  • Updated information appears in the table
  • Changes are immediately reflected in reception dropdowns
The modal is populated using JavaScript with proper escaping:
function abrirEditar(id, nombre, telefono, direccion) {
    document.getElementById('edit_id').value = id;
    document.getElementById('edit_nombre').value = nombre;
    document.getElementById('edit_telefono').value = telefono;
    document.getElementById('edit_direccion').value = direccion;
    
    var myModal = new bootstrap.Modal(document.getElementById('modalEditarProv'));
    myModal.show();
}
Special characters in supplier names and addresses are escaped using addslashes() to prevent JavaScript injection issues.

Deleting a Supplier

Supplier deletion is permanent and cannot be undone. Deleted supplier records cannot be recovered.
1

Locate the supplier

Find the supplier record you want to delete in the table.
2

Click Delete button

Click the red “Eliminar” button in the Acciones column.
3

Confirm deletion

A browser confirmation dialog appears:
“¿Estás seguro de eliminar este proveedor?”
  • Click OK to proceed with deletion
  • Click Cancel to abort
4

Handle result

Success Case:
  • Page reloads with ?msg=eliminado
  • Supplier removed from the table
  • Supplier no longer appears in reception dropdowns
Failure Case:
  • Error alert displayed:
    “No se puede eliminar este proveedor porque tiene registros de mercancía asociados.”
  • Supplier remains in the system
  • Database referential integrity preserved

Why Deletion Fails

Suppliers cannot be deleted if they have associated records in the registro table (merchandise receptions). This is enforced by a foreign key constraint:
ALTER TABLE registro 
ADD CONSTRAINT fk_registro_proveedor 
FOREIGN KEY (id_proveedor) REFERENCES proveedor(id_proveedor);
Alternative to deletion: Instead of deleting suppliers with history, update their name to indicate inactive status:[INACTIVE] Textiles del Norte S.A.This preserves audit trails while clearly marking the supplier as no longer active.

Common Use Cases

When first configuring TiendaRopa:
  1. Gather supplier information: Collect names, phone numbers, and addresses from existing records
  2. Prioritize active suppliers: Enter currently active vendors first
  3. Use consistent naming: Decide on a naming convention (e.g., always include legal entity suffix)
  4. Verify contact info: Confirm phone numbers and addresses are current before entering
  5. Test in receptions: Create a test merchandise reception to ensure suppliers appear correctly
Create 3-5 test suppliers initially to verify the system works correctly before bulk data entry.
When a supplier moves or changes phone numbers:
  1. Click Editar on the supplier’s row
  2. Update the Teléfono and/or Dirección fields
  3. Click Actualizar Cambios
  4. Verify the changes appear in the table
Contact information updates do not affect historical reception records—those maintain the information as it was at the time of reception.
If a supplier changes their company name:Option 1: Update the existing record
  1. Edit the supplier
  2. Change Nombre / Empresa to the new name
  3. Add a note in Dirección about the name change: Formerly known as [Old Name] - Changed March 2026
Option 2: Create a new supplier and mark the old one inactive
  1. Create a new supplier with the new name
  2. Edit the old supplier to add [INACTIVE - REBRANDED] prefix
  3. Add a reference in the address field: Now operating as [New Name]
Choose Option 1 if you want unified reporting, Option 2 if you want to track the transition period separately.
Sometimes you receive merchandise from suppliers whose complete information you don’t have:
  1. Create the supplier with the information you do have
  2. Use placeholder text in missing fields:
    • Teléfono: Leave blank or enter 0000000000
    • Dirección: Enter Información pendiente or TBD
  3. Update the record later when you obtain complete information
Don’t skip creating the supplier record. Having incomplete data is better than having no audit trail.
If you accidentally created duplicate suppliers:
  1. Identify the duplicates: Look for similar names in the table
  2. Choose the primary record: Select which record to keep (usually the one with more complete info)
  3. Update reception records: This requires database access
    -- Update all receptions from duplicate to primary
    UPDATE registro 
    SET id_proveedor = [primary_id] 
    WHERE id_proveedor = [duplicate_id];
    
  4. Delete the duplicate: Once no receptions reference it, you can delete it
Contact your database administrator or developer to perform the SQL update safely.

Troubleshooting

Error message:
“No se puede eliminar este proveedor porque tiene registros de mercancía asociados.”
Why it happens: The supplier has merchandise reception records in the registro table.Solution options:
  1. Mark as inactive: Edit the name to [INACTIVE] Supplier Name
  2. Keep the record: Retain for historical reference
  3. Database-level deletion (advanced):
    -- Check which receptions reference this supplier
    SELECT * FROM registro WHERE id_proveedor = X;
    
    -- Option A: Reassign receptions to another supplier
    UPDATE registro SET id_proveedor = Y WHERE id_proveedor = X;
    
    -- Option B: Delete reception records (loses history!)
    DELETE FROM registro WHERE id_proveedor = X;
    
    -- Then delete supplier
    DELETE FROM proveedor WHERE id_proveedor = X;
    
Database-level deletion requires careful consideration and should only be done by authorized personnel.
The phone field has maxlength="10" enforced:If your phone numbers need more digits:
  • For international numbers, use the address field
  • For extensions, add to address: Tel: 5551234567 Ext. 123
  • Contact your developer to increase the field length if needed
If the number has fewer than 10 digits:
  • Pad with zeros: 5551230000555123
  • Or leave the field blank and put the number in the address field
If a newly created supplier isn’t available when registering merchandise receptions:
  1. Verify creation: Check that the supplier appears in the Proveedores table
  2. Refresh the reception page: Dropdowns are populated on page load
  3. Check database: Query the proveedor table to confirm the record exists
  4. Clear browser cache: Try a hard refresh (Ctrl+F5 or Cmd+Shift+R)
  5. Check for JavaScript errors: Open browser console (F12) and look for errors
This usually indicates a JavaScript issue with special characters:
  1. Open browser console (F12)
  2. Look for JavaScript errors when clicking Editar
  3. Check if the supplier name or address contains special characters:
    • Quotes (" or ')
    • Backslashes (\)
    • Line breaks
Workaround:
  • Edit the supplier by recreating it with a simpler name
  • Contact your developer to improve character escaping
Technical note: The issue is usually in the addslashes() PHP function not handling certain characters correctly.
If you see “Error al crear: [message]” or “Error al actualizar: [message]”:Common causes:
  1. Database connection failure: Check that the database server is running
  2. Character encoding issues: Ensure special characters (á, é, í, ó, ú, ñ) are handled correctly
  3. Field validation: Verify nombre is not empty (it’s required)
  4. Constraint violations: Check for unique constraint violations if applicable
Debugging steps:
  1. Try creating a supplier with simple ASCII characters: “Test Supplier”
  2. If that works, the issue is with special characters
  3. Check PHP error logs for detailed error messages
  4. Contact your system administrator with the error message

Integration with Merchandise Reception

Suppliers are primarily used in the Recepciones de Mercancía module (registros.php).

Reception Form Integration

When registering a merchandise reception, you select the supplier from a dropdown:
<div class="mb-3">
    <label>Proveedor</label>
    <select name="id_proveedor" class="form-select" required>
        <?php
        $provs = $conn->query("SELECT id_proveedor, nombre FROM proveedor");
        while($pr = $provs->fetch()) {
            echo "<option value='{$pr['id_proveedor']}'>{$pr['nombre']}</option>";
        }
        ?>
    </select>
</div>

Reception History Query

To view all receptions from a specific supplier:
SELECT r.fecha_registro, p.nombre as prenda, e.nombre as empleado, prov.nombre as proveedor
FROM registro r
JOIN prenda p ON r.id_prenda = p.id_prenda
JOIN empleado e ON r.id_empleado = e.id_empleado
JOIN proveedor prov ON r.id_proveedor = prov.id_proveedor
WHERE prov.id_proveedor = ?
ORDER BY r.fecha_registro DESC;
Future enhancements could include a “View Receptions” link in the supplier table that filters the reception history page by that supplier.

Database Schema

Review the proveedor table structure and foreign key relationships

Best Practices

1

Establish naming conventions

Decide how to format supplier names:
  • Always include legal entity suffix (S.A., S.R.L., etc.)
  • Use consistent capitalization
  • Decide whether to use full names or abbreviations
Example: “ABC Textiles S.A. de C.V.” vs. “ABC Textiles” vs. “abc textiles”
2

Keep contact information current

Regularly verify and update:
  • Phone numbers (suppliers may change contact numbers)
  • Addresses (suppliers may relocate)
  • Add email addresses to the address field for easy reference
3

Never delete suppliers with history

Preserve supplier records that have reception history for audit purposes. Use the [INACTIVE] naming convention instead of deletion.
4

Include complete information

Even though phone and address are optional, include as much detail as possible:
  • Helps with reordering
  • Useful for warranty claims
  • Essential for returns or exchanges
  • Supports supply chain auditing
5

Document supplier relationships

Use the address field creatively:
  • Note payment terms: “NET 30 payment terms”
  • Add account numbers: “Acct #12345”
  • Note special contacts: “Contact: Juan García for rush orders”
  • Add email: “[email protected]
6

Regular supplier audits

Periodically review your supplier list:
  • Mark inactive suppliers
  • Update contact information
  • Consolidate duplicates
  • Verify all active suppliers have complete information

Future Enhancements

While not currently implemented, future versions could include:
  • Supplier performance tracking: Rate suppliers based on quality, timeliness, pricing
  • Contact person management: Multiple contacts per supplier with roles
  • Document attachments: Store contracts, certificates, or correspondence
  • Purchase order integration: Link suppliers to purchase orders
  • Payment terms tracking: Record and monitor payment agreements
  • Supplier categories: Group suppliers by type (domestic, international, etc.)
  • Automatic reorder suggestions: Based on supplier lead times and stock levels

Build docs developers (and LLMs) love