- ${compShort}
- ${guildName}
+ ${compShort}
+ ${guildName}
${name}
@@ -395,16 +434,37 @@
currentServiceId = id;
document.getElementById('detId').value = s.id;
- document.getElementById('modTime').innerText = raw.scheduled_time ? `Turno: ${raw.scheduled_time}` : "Sin hora exacta";
+ document.getElementById('modTime').innerText = raw.scheduled_time || "S/H";
document.getElementById('detRef').innerText = s.service_ref || "S/R";
+
+ let compRaw = raw["Compañía"] || raw["COMPAÑIA"] || raw["Procedencia"] || "Particular";
+ document.getElementById('detCompany').innerText = compRaw;
+
document.getElementById('detName').innerText = raw["Nombre Cliente"] || "Asegurado";
+
const fullAddress = `${raw["Dirección"] || ""}, ${raw["Código Postal"] || ""} ${raw["Población"] || ""}`;
document.getElementById('detAddress').innerText = fullAddress;
+ // Extraer teléfono
+ const rawPhone = raw["Teléfono"] || raw["TELEFONOS"] || raw["TELEFONO"] || "";
+ const matchPhone = rawPhone.toString().match(/[6789]\d{8}/);
+ document.getElementById('detPhoneRaw').value = matchPhone ? matchPhone[0] : "";
+
+ // Urgencia
+ const isUrgent = s.is_urgent;
+ const banner = document.getElementById('urgentBanner');
+ if (isUrgent) banner.classList.remove('hidden');
+ else banner.classList.add('hidden');
+
+ // Descripción principal
+ let desc = raw["Descripción"] || raw["DESCRIPCION"] || "No hay notas de avería.";
+ document.getElementById('detDesc').innerHTML = desc.replace(/\n/g, '
');
+
+ // VOLCAR TODOS LOS DATOS EXTRA
const detailsContainer = document.getElementById('detExtraInfo');
let detailsHtml = '';
- const skipKeys = ["Nombre Cliente", "CLIENTE", "Dirección", "DOMICILIO", "Población", "POBLACION-PROVINCIA", "scheduled_date", "scheduled_time", "status_operativo", "assigned_to", "guild_id", "Código Postal", "assigned_to_name"];
+ const skipKeys = ["Nombre Cliente", "CLIENTE", "Dirección", "DOMICILIO", "Población", "POBLACION-PROVINCIA", "scheduled_date", "scheduled_time", "status_operativo", "assigned_to", "guild_id", "Código Postal", "assigned_to_name", "Descripción", "DESCRIPCION", "Compañía", "COMPAÑIA"];
for(let key in raw) {
if(skipKeys.includes(key)) continue;
@@ -414,9 +474,9 @@
if(!val || val.trim() === "") continue;
detailsHtml += `
-
-
${key}
-
${val}
+
+ ${key}
+ ${val}
`;
}
@@ -437,6 +497,30 @@
setTimeout(() => modal.classList.add('hidden'), 300);
document.getElementById('gpsLoading').classList.remove('hidden');
document.getElementById('gpsResult').classList.add('hidden');
+ document.getElementById('extraDataBox').classList.add('hidden'); // Resetear caja extra
+ }
+
+ function callClient() {
+ const phone = document.getElementById('detPhoneRaw').value;
+ if (phone) window.location.href = `tel:+34${phone}`;
+ else alert("No hay un teléfono válido guardado.");
+ }
+
+ function openWhatsApp() {
+ const phone = document.getElementById('detPhoneRaw').value;
+ if (phone) window.open(`https://wa.me/34${phone}`, '_blank');
+ else alert("No hay un teléfono válido guardado.");
+ }
+
+ function openMaps() {
+ const address = document.getElementById('detAddress').innerText;
+ if (address) {
+ const encodedAddr = encodeURIComponent(address);
+ // Intenta abrir en la app de Apple Maps o Google Maps nativa del movil
+ window.open(`maps://?q=${encodedAddr}`, '_blank');
+ // Fallback a web si falla
+ setTimeout(() => { window.open(`https://maps.google.com/?q=${encodedAddr}`, '_blank'); }, 500);
+ }
}
async function calculateDistance(destAddress) {