Overview
The Technical Routes module enables advisors and technicians to plan, manage, and track technical visit routes. It features client search integration, address management, automatic route numbering, and collaborative route planning where multiple advisors can contribute to shared routes. Controller:RutaTecnicaController (app/Http/Controllers/RutaTecnicaController.php:13)Model:
RutaTecnica (app/Models/RutaTecnica.php:9)Vue Components:
resources/js/Pages/RutasTecnicas/index.vueresources/js/Pages/RutasTecnicas/Create.vueresources/js/Pages/RutasTecnicas/Edit.vueresources/js/Pages/RutasTecnicas/Show.vue
senco360 connection, table RT_rutastecnicas
Key Features
Route Management
Create weekly routes with start/end dates and multiple visits
Client Search
Real-time client search from SQL Server view with advisor assignment validation
Address Management
Fetch client addresses dynamically with contact recommendations
Collaborative Routes
Multiple advisors can add visits to shared routes with technicians
Auto-Numbering
Automatic route number generation with format RT-YYYYMMDD-XXXX
Auto-Close
Routes automatically close on Friday at 2 PM
Data Model
TheRutaTecnica model represents individual visits within a route:
Key Attributes
- Primary Key:
IdVisita(auto-increment) - Route Grouping:
NumeroRuta- All visits with same route number belong together - Ownership:
CodVendedor- The advisor who created the visit - Assignment:
CodTecnico- The technician who will perform the visit
Permissions
Routes require specific permissions configured via middleware (RutaTecnicaController.php:18-23):rutas-tecnicas.crear: Create routes and add visitsrutas-tecnicas.ver: View routesrutas-tecnicas.editar: Edit routesrutas-tecnicas.eliminar: Delete routesrutas-tecnicas.ver-todos: View all routes (supervisors/admins)
super-adminAsistenteVentasGerenciasupervisor
API Endpoints
List Routes
fecha_inicio: Filter by start datefecha_fin: Filter by end date
rutas: Grouped routes with visit countsfiltros: Applied filter valuespermisos: User permissions objecterror: Error message (if user has no vendor code)
NumeroRuta and returned with:
NumeroRuta: Route identifierFechaInicio: Start date (formatted: YYYY-MM-DD Day)FechaFin: End date (formatted: YYYY-MM-DD Day)CodVendedor: Route ownercerrada: Closed statustotalVisitas: Visit countvisitas: Array of visits
View Route Details
- Advisors can only view routes they own or where they share a technician
- Supervisors/admins can view all routes
Create Route Form
technicalUsers: Available technicians for the advisorrutaAbierta: Existing open route data (if any)mensaje: Informational message about existing route
Store New Route
- Validates using
StoreRutaTecnicaRequest - Checks for existing open routes with overlapping dates
- Validates technician codes against user’s allowed technicians
RT-YYYYMMDD-#### (e.g., RT-20260304-0001)
Collaborative Logic:
If an open route exists for the selected dates and technician:
- User is redirected to edit that route
- Multiple advisors can contribute visits to the same route
Edit Route Form
- Users can only edit their own visits
- Supervisors/admins can edit any visit
- Closed routes cannot be edited
numeroRuta: Route identifierfecha_inicio: Start date (formatted)fecha_fin: End date (formatted)fecha_inicio_raw: Start date (YYYY-MM-DD)fecha_fin_raw: End date (YYYY-MM-DD)visitas: All visits with ownership flagstechnicalUsers: Available technicians
es_propia boolean indicating if current user owns it.
Implementation: RutaTecnicaController.php:599-692
Update Route
- Existing visits (with
idVisita) are updated - New visits (without
idVisita) are created with current user’sCodVendedor - Visits not in the array are deleted (only if owned by current user)
- Users can only update/delete their own visits
- Supervisors/admins can modify any visit
- Error thrown if user tries to modify another advisor’s visit
Client Search API
Search Clients
V_360_tec_clientes.
Query Parameters:
q: Search term (minimum 2 characters)
- Only returns clients assigned to the authenticated user’s advisor code
- Searches by NIT or client name
- Limited to 10 results
rutas-tecnicas.crear
Get Client Addresses
V_360_tec_clientes_sedes.
Response:
Get Contact Recommendations
direccion: Address to search for
- Searches last 10 visits to the same address
- Removes duplicates by contact name + phone combination
- Orders by most recent visit
Automatic Route Numbering
Route numbers follow the formatRT-YYYYMMDD-####:
RT-20260304-0001, RT-20260304-0002
Implementation: RutaTecnica.php:64-89
Auto-Close Feature
Routes automatically close on Friday at 2 PM (14:00):- When viewing route index (
index()method) - When opening create form (
create()method)
Date Formatting
All dates include day of week in Spanish:2026-03-04 Jue
Implementation: RutaTecnicaController.php:29-44
Collaborative Routes
Multiple advisors can work on the same route if they share technicians:Shared Technician Logic
Advisors can access routes where:- They are the route owner (
CodVendedormatches) - OR they share a technician with the route (
CodTecnicoin their technicalUsers)
User Relationships
TheUser model includes many-to-many relationships:
Access Control Examples
Scenario 1: Advisor A creates route with Technician T1. Advisor B also works with T1.
Result: Both advisors can view and add visits to the route.
Result: Both advisors can view and add visits to the route.
Scenario 2: Advisor A tries to edit Advisor B’s visit in a shared route.
Result: Error - “Esta visita fue agregada por el asesor B. Coordina directamente con él para modificarla.”
Result: Error - “Esta visita fue agregada por el asesor B. Coordina directamente con él para modificarla.”
Usage Workflow
Create New Route
Navigate to
/rutas-tecnicas/create. If an open route exists, you’ll be prompted to use it or create new.Important: Once a route is closed, it cannot be modified. Plan visits before the Friday 2 PM deadline.