<%- include('../partials/header') %> <% title = 'Ticket #' + ticket.id; %> <% if (success_msg && success_msg.length > 0) { %> <% success_msg.forEach(msg => { %>
<%= msg %>
<% }) %> <% } %> <% if (error_msg && error_msg.length > 0) { %> <% error_msg.forEach(msg => { %>
<%= msg %>
<% }) %> <% } %>

Ticket #<%= ticket.id %>: <%= ticket.asunto %>

Volver
Información

Estado: <%= ticket.status %>

Prioridad: <%= ticket.prioridad %>

Departamento: <%= ticket.departamento_nombre || 'Sin departamento' %>

Cliente: <%= ticket.usuario_nombre %> (<%= ticket.usuario_email %>)

Asignado: <%= ticket.asignado_nombre || 'Sin asignar' %>

Creado: <%= ticket.created_at %>

Acciones
<% if (user.rol === 'admin') { %>
<% } %>
Visita Técnica (FSM)
<% if (visita) { %> <%= visita.estado %> <% } %>
<% if (!visita) { %>

Si este ticket requiere intervención presencial en sitio o avería física, puedes programar la visita técnica directamente en el sistema central 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 %> - <%= ticket.created_at %>

<%= ticket.mensaje %>

Respuestas
<% if (respuestas.length === 0) { %>

No hay respuestas aún

<% } %> <% respuestas.forEach(r => { %>
<%= r.usuario_nombre %> <%= r.usuario_rol %> <%= r.created_at %>

<%= r.mensaje %>

<% }) %>
Responder
<%- include('../partials/footer') %>