Actualizar proveedores.html
This commit is contained in:
@@ -303,7 +303,6 @@
|
|||||||
} catch (e) { console.error("Error en loadInbox:", e); }
|
} catch (e) { console.error("Error en loadInbox:", e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== 🔥 DETECCIÓN DE URGENCIA Y GREMIO AÑADIDA AQUÍ ======
|
|
||||||
function buildServiceCard(svc) {
|
function buildServiceCard(svc) {
|
||||||
const raw = svc.raw_data || {};
|
const raw = svc.raw_data || {};
|
||||||
const isArchived = svc.status === 'archived';
|
const isArchived = svc.status === 'archived';
|
||||||
@@ -314,8 +313,14 @@
|
|||||||
const fullAddr = `${addr} ${pop}`.trim();
|
const fullAddr = `${addr} ${pop}`.trim();
|
||||||
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
|
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
|
||||||
|
|
||||||
// CORRECCIÓN: Ahora lee el guild_id del JSON interno asegurándose de que lo coja en cualquier caso.
|
// CORRECCIÓN BLINDADA DEL GREMIO
|
||||||
const guildName = allGuilds.find(g => g.id == (svc.guild_id || raw['guild_id'] || raw.guild_id))?.name || null;
|
let guildName = null;
|
||||||
|
const rawGuildId = svc.guild_id || raw['guild_id'] || raw.guild_id;
|
||||||
|
|
||||||
|
if (rawGuildId) {
|
||||||
|
const foundGuild = allGuilds.find(g => String(g.id) === String(rawGuildId));
|
||||||
|
if (foundGuild) guildName = foundGuild.name;
|
||||||
|
}
|
||||||
|
|
||||||
const opName = raw['assigned_to_name'] || null;
|
const opName = raw['assigned_to_name'] || null;
|
||||||
|
|
||||||
@@ -328,7 +333,6 @@
|
|||||||
const sysStatus = (svc.status || '').toLowerCase();
|
const sysStatus = (svc.status || '').toLowerCase();
|
||||||
const linkedStatus = (raw['estado'] || raw['status'] || '').toLowerCase();
|
const linkedStatus = (raw['estado'] || raw['status'] || '').toLowerCase();
|
||||||
|
|
||||||
// DETECCIÓN DE URGENCIA (Ya sea por la BD o por el raw_data)
|
|
||||||
const isUrgent = svc.is_urgent === true || (raw['Urgente'] && raw['Urgente'].toLowerCase() === 'sí') || (raw['URGENTE'] && raw['URGENTE'].toLowerCase() === 'si');
|
const isUrgent = svc.is_urgent === true || (raw['Urgente'] && raw['Urgente'].toLowerCase() === 'sí') || (raw['URGENTE'] && raw['URGENTE'].toLowerCase() === 'si');
|
||||||
const urgentBadge = isUrgent ? `<span class="bg-red-500 text-white px-2 py-0.5 rounded-md text-[9px] font-black uppercase shadow-sm animate-pulse ml-3">🔥 Urgente</span>` : '';
|
const urgentBadge = isUrgent ? `<span class="bg-red-500 text-white px-2 py-0.5 rounded-md text-[9px] font-black uppercase shadow-sm animate-pulse ml-3">🔥 Urgente</span>` : '';
|
||||||
|
|
||||||
@@ -535,12 +539,12 @@
|
|||||||
document.getElementById('impNotesInt').value = raw['internal_notes'] || "";
|
document.getElementById('impNotesInt').value = raw['internal_notes'] || "";
|
||||||
document.getElementById('impNotesExt').value = raw['client_notes'] || "";
|
document.getElementById('impNotesExt').value = raw['client_notes'] || "";
|
||||||
|
|
||||||
// CORRECCIÓN: Ahora lee el guild_id del JSON interno asegurándose de que lo coja en cualquier caso para rellenar el desplegable.
|
// CORRECCIÓN BLINDADA DEL SELECTOR DE GREMIOS
|
||||||
const savedGuild = svc.guild_id || raw['guild_id'] || raw.guild_id || "";
|
const rawGuildId = svc.guild_id || raw['guild_id'] || raw.guild_id;
|
||||||
document.getElementById('impGuild').value = savedGuild;
|
document.getElementById('impGuild').value = rawGuildId ? String(rawGuildId) : "";
|
||||||
|
|
||||||
if(savedGuild) {
|
if(rawGuildId) {
|
||||||
await loadOpsForGuild(savedGuild);
|
await loadOpsForGuild(rawGuildId);
|
||||||
document.getElementById('impOperator').value = raw['assigned_to'] || "";
|
document.getElementById('impOperator').value = raw['assigned_to'] || "";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
|
document.getElementById('impOperator').innerHTML = '<option value="">-- Automática --</option>';
|
||||||
|
|||||||
Reference in New Issue
Block a user