<%- include('../partials/header') %> <% title = 'Ticket #' + ticket.id + ' — Gestión Operativa'; %> <% if (success_msg && success_msg.length > 0) { %> <% success_msg.forEach(msg => { %> <% }) %> <% } %> <% if (error_msg && error_msg.length > 0) { %> <% error_msg.forEach(msg => { %> <% }) %> <% } %>
Control del Ticket
<% if (user.rol === 'admin' || user.rol === 'superadmin') { %>
<% } %>
Prioridad: <% if (ticket.prioridad === 'critica') { %> Crítica <% } else if (ticket.prioridad === 'alta') { %> Alta <% } else if (ticket.prioridad === 'media') { %> Media <% } else { %> Baja <% } %>
Asignado a: <%= ticket.asignado_nombre || 'Sin asignar' %>
Visita en Terreno (FSM)
<% if (visita) { %> <%= visita.estado %> <% } %>
<% if (!visita) { %>

Si la avería o solicitud requiere inspección física o trabajo presencial en sitio, programa el despacho de un técnico hacia el Hub de Tareas.

<% } else { %>
1 📅 Programada
Técnico: <%= visita.tecnico_nombre %>
<%= visita.tecnico_email %>
<%= visita.fecha_visita ? new Date(visita.fecha_visita).toLocaleString('es-EC') : 'Sin fecha' %>
<% if (visita.ubicacion) { %>
<%= visita.ubicacion %>
<% } %>
2 📍 Check-in en Sitio
<% if (visita.historial && visita.historial.checkIn && visita.historial.checkIn.fecha) { %>
Arribo confirmado
<%= new Date(visita.historial.checkIn.fecha).toLocaleTimeString('es-EC') %>
<% if (visita.historial.checkIn.latitud) { %>
GPS: <%= visita.historial.checkIn.latitud %>, <%= visita.historial.checkIn.longitud %>
<% } %> <% } else { %> Pendiente de validación GPS <% } %>
3 📸 Avance y Evidencias
<% if (visita.historial && visita.historial.progreso_checklist) { %>
Checklist: <%= visita.historial.progreso_checklist.completados %>/<%= visita.historial.progreso_checklist.total %>
<% if (visita.historial.progreso_checklist.items && visita.historial.progreso_checklist.items.length > 0) { %>
    <% visita.historial.progreso_checklist.items.forEach(item => { %>
  • <%= item.texto %>
  • <% }) %>
<% } %> <% } else { %>
Checklist en proceso
<% } %> <% if (visita.historial && visita.historial.evidencias && visita.historial.evidencias.length > 0) { %>
Fotos de campo:
<% visita.historial.evidencias.forEach(foto => { const fotoUrl = foto.url.startsWith('http') ? foto.url : ('https://tareas.telcotronics.com' + foto.url); %> Evidencia <% }) %>
<% } %> <% if (visita.historial && visita.historial.firma_cliente && visita.historial.firma_cliente.firmado) { const firmaUrl = visita.historial.firma_cliente.firmaUrl ? (visita.historial.firma_cliente.firmaUrl.startsWith('http') ? visita.historial.firma_cliente.firmaUrl : ('https://tareas.telcotronics.com' + visita.historial.firma_cliente.firmaUrl)) : null; %>
Firmado: <%= visita.historial.firma_cliente.nombreFirmante %>
<% if (firmaUrl) { %> <% } %> <% } else { %> Pendiente firma cliente <% } %>
4 🏁 Finalización
<% if (visita.estado === 'completada') { %>
Visita Finalizada
<% } else { %>
En gestión por personal de campo
<% } %>
<% if (visita.historial && visita.historial.timeline_eventos && visita.historial.timeline_eventos.length > 0) { %>
    <% visita.historial.timeline_eventos.forEach(ev => { %>
  • <%= ev.titulo %>
    <% if (ev.descripcion) { %>
    <%= ev.descripcion %>
    <% } %>
    <%= new Date(ev.fecha).toLocaleString('es-EC') %> - <%= ev.usuarioNombre || 'Sistema' %>
  • <% }) %>
<% } %> <% } %>
<%= (ticket.usuario_nombre || 'C').charAt(0).toUpperCase() %>
<%= ticket.usuario_nombre %> Cliente Solicitante
<%= new Date(ticket.created_at).toLocaleString('es-ES') %>
<%= ticket.mensaje %>
Conversación y Actuaciones (<%= respuestas.length %>)
<% if (respuestas.length === 0) { %>
Aún no se han emitido respuestas
Sé el primero en responder o emitir instrucciones al cliente.
<% } %>
<% respuestas.forEach(r => { %> <% const isStaff = ['agent', 'admin', 'superadmin'].includes(r.usuario_rol); %>
<%= (r.usuario_nombre || 'U').charAt(0).toUpperCase() %>
<%= r.usuario_nombre %> <% if (isStaff) { %> Agente Oficial <% } else { %> Cliente <% } %>
<%= new Date(r.created_at).toLocaleString('es-ES') %>
<%= r.mensaje %>
<% }) %>
Emitir Respuesta Oficial al Cliente
El cliente recibirá una notificación y podrá responder en el hilo.
<%- include('../partials/footer') %>