diff --git a/asignados.html b/asignados.html
index 3be1d3d..ab30936 100644
--- a/asignados.html
+++ b/asignados.html
@@ -120,6 +120,7 @@
+
`;
diff --git a/calendario.html b/calendario.html
index 1664c73..5407def 100644
--- a/calendario.html
+++ b/calendario.html
@@ -169,8 +169,10 @@
Copiar y Abrir Portal
-
-
+
+
+
+
Llamar al Cliente
@@ -1010,9 +1012,16 @@
const fullAddress = `${raw["Dirección"] || ""}, ${raw["Código Postal"] || ""} ${raw["Población"] || ""}`;
document.getElementById('detAddress').innerText = fullAddress;
+ // 📞 Usamos los teléfonos ya extraídos y priorizados (móvil primero) por la API.
+ // Si por caché no vinieran, caemos al match simple de siempre.
const rawPhone = raw["Teléfono"] || raw["TELEFONOS"] || raw["TELEFONO"] || "";
const matchPhone = String(rawPhone).match(/[6789]\d{8}/);
- document.getElementById('detPhoneRaw').value = matchPhone ? matchPhone[0] : "";
+ const fallbackPhone = matchPhone ? matchPhone[0] : "";
+ const detailPhones = Array.isArray(s.phones) && s.phones.length > 0
+ ? s.phones
+ : (fallbackPhone ? [{ number: fallbackPhone, isMobile: /^[67]/.test(fallbackPhone), horario: '', contacto: '' }] : []);
+ document.getElementById('detPhoneRaw').value = detailPhones[0]?.number || "";
+ renderPhoneSelector(detailPhones);
const banner = document.getElementById('urgentBanner');
if (s.is_urgent) banner.classList.remove('hidden');
@@ -1386,13 +1395,37 @@
} else { alert("Sin teléfono"); }
}
- function openWhatsApp() {
- const p = document.getElementById('detPhoneRaw').value;
+ function openWhatsApp() {
+ const p = document.getElementById('detPhoneRaw').value;
if (p) {
sendLog("WhatsApp Abierto", "El operario ha abierto el chat de WhatsApp con el cliente.");
- window.open(`https://wa.me/34${p}`, '_blank');
+ window.open(`https://wa.me/34${p}`, '_blank');
} else { alert("Sin teléfono"); }
}
+
+ // 📞 Cuando el servicio trae más de un teléfono (típico de HomeServe), pintamos un
+ // selector de chips para que el operario elija cuál usar antes de Llamar/WhatsApp.
+ // Con un solo teléfono no mostramos nada (para no añadir ruido visual de más).
+ function renderPhoneSelector(phones) {
+ const row = document.getElementById('phoneSelectorRow');
+ if (!row) return;
+ if (!phones || phones.length <= 1) { row.innerHTML = ''; row.classList.add('hidden'); return; }
+ const active = document.getElementById('detPhoneRaw').value;
+ row.innerHTML = phones.map(p => {
+ const isActive = p.number === active;
+ return `
+
+ ${p.number}
+ `;
+ }).join('');
+ row.classList.remove('hidden');
+ lucide.createIcons();
+ }
+ function selectPhone(number) {
+ document.getElementById('detPhoneRaw').value = number;
+ const s = localServices.find(x => String(x.id) === String(document.getElementById('detId').value));
+ renderPhoneSelector(Array.isArray(s?.phones) && s.phones.length > 0 ? s.phones : [{number, isMobile:/^[67]/.test(number)}]);
+ }
async function copyAndOpenPortal() {
const btn = document.getElementById('btnPortal');