+
+
${shortProv}
${isBlocked ? 'Expediente Bloqueado' : (rawName || 'S/N')}
-
- ${isBlocked ? 'Pendiente de liberación' : (fullAddr || 'Sin dirección')}
+
+ ${isBlocked ? 'Pendiente de liberación' : (fullAddr || 'Sin dirección')}
- ${!isBlocked ? `
-
- #${svc.service_ref}
- ${cleanPhone ? `${cleanPhone}` : ''}
- ${cpOnly ? `${cpOnly}` : ''}
-
` : ''}
@@ -203,14 +186,9 @@
${!isBlocked ? `
- ${cleanPhone ? `
-
-
- ` : ''}
-
-
` : `
+
` : `
`}
@@ -232,9 +210,9 @@
const phoneVal = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || "";
const phoneMatch = phoneVal.match(/[6789]\d{8}/);
document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : "";
- document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Dato original capturado: ${phoneVal}` : "";
+ document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Capturado: ${phoneVal}` : "";
- // 2. SEPARAR CP Y POBLACIÓN DEL CAMPO CP
+ // 2. SEPARAR CP Y POBLACIÓN
const rawAddr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || "";
const rawCPField = raw[myMap.find(m => m.target_key === 'cp')?.original_key] || raw['Población_CP'] || "";
const cpMatch = rawCPField.match(/\b\d{5}\b/);
@@ -244,15 +222,17 @@
document.getElementById('imp_address').value = `${rawAddr} ${popOnly}`.trim();
document.getElementById('imp_cp').value = cpOnly;
- // 3. PROVEEDOR ACORTADO EN COMPAÑÍA
- const cia = raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['Compañía'] || "";
- const shortProv = svc.provider.toUpperCase() === 'MULTIASISTENCIA' ? 'MULTI' : 'HOME';
- document.getElementById('imp_company').value = `${shortProv} - ${cia}`;
+ // 3. DESCRIPCIÓN TÉCNICA (LIMPIEZA DE HISTORIAL)
+ let rawDesc = raw[myMap.find(m => m.target_key === 'descripcion')?.original_key] || raw['Descripción'] || "";
+ // Cortamos el texto justo antes de la primera fecha de registro (formato 00/00/0000)
+ const idxDate = rawDesc.search(/\b\d{2}\/\d{2}\/\d{4}\b/);
+ const cleanDesc = idxDate !== -1 ? rawDesc.substring(0, idxDate).trim() : rawDesc;
+ document.getElementById('imp_desc').value = cleanDesc;
+ document.getElementById('imp_company').value = `${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'} - ${raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['Compañía'] || ""}`;
document.getElementById('scrapedId').value = scrapedId;
document.getElementById('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
document.getElementById('imp_ref').value = svc.service_ref;
- document.getElementById('imp_desc').value = raw[myMap.find(m => m.target_key === 'descripcion')?.original_key] || raw['Descripción'] || "";
document.getElementById('imp_urgent').value = (raw['Urgente'] === 'Sí' || raw['Urgente'] === 'true').toString();
document.getElementById('importModal').classList.remove('hidden');