finished
This commit is contained in:
@@ -73,9 +73,9 @@ PAGES.aulas = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'comedor', CurrentISODate());
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
@@ -93,9 +93,9 @@ PAGES.aulas = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'notas', 'tareas');
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
@@ -113,9 +113,9 @@ PAGES.aulas = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'aulas_informes', 'diario-' + CurrentISODate());
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
@@ -191,9 +191,9 @@ PAGES.aulas = {
|
||||
document.getElementById(field_autor).value = data["Solicitante"] || SUB_LOGGED_IN_ID || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'aulas_solicitudes', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
@@ -204,16 +204,14 @@ PAGES.aulas = {
|
||||
Contenido: document.getElementById(field_contenido).value,
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('aulas_solicitudes', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("aulas,solicitudes");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('aulas_solicitudes', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("aulas,solicitudes");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar esta solicitud?") == true) {
|
||||
@@ -338,16 +336,14 @@ PAGES.aulas = {
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
Fecha: document.getElementById(field_fecha).value || CurrentISODate(),
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('aulas_informes', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("aulas,informes");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('aulas_informes', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("aulas,informes");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar este informe?") == true) {
|
||||
|
||||
@@ -114,9 +114,9 @@ PAGES.avisos = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'notificaciones', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
@@ -141,16 +141,14 @@ PAGES.avisos = {
|
||||
.getElementById(field_estado)
|
||||
.value.replace("%%", "por_leer"),
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('notificaciones', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("avisos");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('notificaciones', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("avisos");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar esta notificación?") == true) {
|
||||
|
||||
@@ -36,9 +36,9 @@ PAGES.comedor = {
|
||||
data["Platos"] || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'comedor', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
@@ -55,16 +55,14 @@ PAGES.comedor = {
|
||||
DB.del('comedor', mid);
|
||||
}
|
||||
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('comedor', newDate, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("comedor");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('comedor', newDate, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("comedor");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar esta entrada?") == true) {
|
||||
|
||||
@@ -75,9 +75,9 @@ PAGES.dataman = {
|
||||
const value = entry.data;
|
||||
if (value != null) {
|
||||
if (typeof value == 'string') {
|
||||
TS_decrypt(value, SECRET, (data) => {
|
||||
TS_decrypt(value, SECRET, (data, wasEncrypted) => {
|
||||
output.materiales[key] = data;
|
||||
});
|
||||
}, 'materiales', key);
|
||||
} else {
|
||||
output.materiales[key] = value;
|
||||
}
|
||||
@@ -89,9 +89,9 @@ PAGES.dataman = {
|
||||
const value = entry.data;
|
||||
if (value != null) {
|
||||
if (typeof value == 'string') {
|
||||
TS_decrypt(value, SECRET, (data) => {
|
||||
TS_decrypt(value, SECRET, (data, wasEncrypted) => {
|
||||
output.personas[key] = data;
|
||||
});
|
||||
}, 'personas', key);
|
||||
} else {
|
||||
output.personas[key] = value;
|
||||
}
|
||||
@@ -168,12 +168,18 @@ PAGES.dataman = {
|
||||
var sel = document.getElementById(select_type).value;
|
||||
if (sel == "%telesec") {
|
||||
// legacy import, store entire payload as-is
|
||||
DB.put('%telesec', 'export_' + Date.now(), JSON.parse(val));
|
||||
// for each top-level key, store their items in DB
|
||||
var parsed = JSON.parse(val);
|
||||
Object.entries(parsed).forEach((section) => {
|
||||
const sectionName = section[0];
|
||||
const sectionData = section[1];
|
||||
Object.entries(sectionData).forEach((entry) => {
|
||||
DB.put(sectionName, entry[0], entry[1]).catch((e) => { console.warn('DB.put error', e); });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Object.entries(JSON.parse(val)["data"]).forEach((entry) => {
|
||||
var enc = TS_encrypt(entry[1], SECRET, (encrypted) => {
|
||||
DB.put(sel, entry[0], encrypted);
|
||||
});
|
||||
DB.put(sel, entry[0], entry[1]).catch((e) => { console.warn('DB.put error', e); });
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -101,10 +101,9 @@ PAGES.login = {
|
||||
document.getElementById(btn_bypass_create).onclick = () => {
|
||||
var name = prompt("Nombre de la persona (ej: Admin):");
|
||||
if (!name) return;
|
||||
var id = 'bypass-' + Date.now();
|
||||
var persona = { Nombre: name, Roles: 'ADMIN,' };
|
||||
TS_encrypt(persona, SECRET, (encrypted) => {
|
||||
DB.put('personas', id, encrypted).then(() => {
|
||||
var id = 'bypass-' + Date.now();
|
||||
var persona = { Nombre: name, Roles: 'ADMIN,' };
|
||||
DB.put('personas', id, persona).then(() => {
|
||||
toastr.success('Persona creada: ' + id);
|
||||
localStorage.setItem('TELESEC_BYPASS_ID', id);
|
||||
SUB_LOGGED_IN_ID = id;
|
||||
@@ -115,7 +114,6 @@ PAGES.login = {
|
||||
}).catch((e) => {
|
||||
toastr.error('Error creando persona: ' + (e && e.message ? e.message : e));
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ PAGES.materiales = {
|
||||
document.getElementById(field_notas).value = data["Notas"] || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'materiales', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
@@ -91,16 +91,14 @@ PAGES.materiales = {
|
||||
Revision: document.getElementById(field_revision).value,
|
||||
Notas: document.getElementById(field_notas).value,
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('materiales', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("materiales");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('materiales', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("materiales");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar este material?") == true) {
|
||||
@@ -184,11 +182,11 @@ PAGES.materiales = {
|
||||
}
|
||||
|
||||
if (typeof data === "string") {
|
||||
TS_decrypt(data, SECRET, (dec) => {
|
||||
TS_decrypt(data, SECRET, (dec, wasEncrypted) => {
|
||||
if (dec && typeof dec === "object") {
|
||||
addUbicacion(dec);
|
||||
}
|
||||
});
|
||||
}, 'materiales', key);
|
||||
} else {
|
||||
addUbicacion(data);
|
||||
}
|
||||
|
||||
@@ -79,16 +79,14 @@ PAGES.notas = {
|
||||
Contenido: document.getElementById(field_contenido).value,
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('notas', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("notas");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('notas', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("notas");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar esta nota?") == true) {
|
||||
|
||||
@@ -476,37 +476,32 @@ PAGES.pagos = {
|
||||
}
|
||||
|
||||
persona.Monedero_Balance = fixfloat(newBalance);
|
||||
|
||||
TS_encrypt(persona, SECRET, (encrypted) => {
|
||||
DB.put('personas', personaId, encrypted).then(() => {
|
||||
if (callback) callback();
|
||||
});
|
||||
});
|
||||
DB.put('personas', personaId, persona).then(() => {
|
||||
if (callback) callback();
|
||||
}).catch((e) => { console.warn('DB.put error', e); if (callback) callback(); });
|
||||
}
|
||||
|
||||
function saveTransaction(ticketId, data) {
|
||||
TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('pagos', ticketId, encrypted).then(() => {
|
||||
// If this is from SuperCafé, update the order
|
||||
if (data.Origen === "SuperCafé" && data.OrigenID) {
|
||||
handleSuperCafePayment(data);
|
||||
}
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('pagos', ticketId, data).then(() => {
|
||||
// If this is from SuperCafé, update the order
|
||||
if (data.Origen === "SuperCafé" && data.OrigenID) {
|
||||
handleSuperCafePayment(data);
|
||||
}
|
||||
|
||||
// Check for promotional bonus on Ingreso transactions (Efectivo only)
|
||||
if (data.Tipo === "Ingreso" && data.Metodo === "Efectivo") {
|
||||
var bonusAmount = calculatePromoBonus(data.Monto);
|
||||
if (bonusAmount > 0) {
|
||||
createPromoBonusTransaction(data.Persona, bonusAmount, data.Monto);
|
||||
}
|
||||
// Check for promotional bonus on Ingreso transactions (Efectivo only)
|
||||
if (data.Tipo === "Ingreso" && data.Metodo === "Efectivo") {
|
||||
var bonusAmount = calculatePromoBonus(data.Monto);
|
||||
if (bonusAmount > 0) {
|
||||
createPromoBonusTransaction(data.Persona, bonusAmount, data.Monto);
|
||||
}
|
||||
}
|
||||
|
||||
toastr.success("¡Transacción completada!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("pagos," + ticketId);
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
toastr.success("¡Transacción completada!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("pagos," + ticketId);
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -555,16 +550,11 @@ PAGES.pagos = {
|
||||
var currentBalance = parseFloat(persona.Monedero_Balance || 0);
|
||||
var newBalance = currentBalance + bonusAmount;
|
||||
persona.Monedero_Balance = fixfloat(newBalance);
|
||||
|
||||
TS_encrypt(persona, SECRET, (encrypted) => {
|
||||
DB.put('personas', personaId, encrypted);
|
||||
});
|
||||
DB.put('personas', personaId, persona).catch((e) => { console.warn('DB.put error', e); });
|
||||
}
|
||||
|
||||
// Save bonus transaction
|
||||
TS_encrypt(bonusData, SECRET, (encrypted) => {
|
||||
DB.put('pagos', bonusTicketId, encrypted);
|
||||
});
|
||||
DB.put('pagos', bonusTicketId, bonusData).catch((e) => { console.warn('DB.put error', e); });
|
||||
|
||||
toastr.success(
|
||||
"🎉 ¡Promo Bono aplicado! +" + bonusAmount.toFixed(2) + "€ extra"
|
||||
@@ -580,9 +570,7 @@ PAGES.pagos = {
|
||||
var persona = SC_Personas[transactionData.Persona];
|
||||
if (!persona) return;
|
||||
|
||||
TS_encrypt(persona, SECRET, (encrypted) => {
|
||||
DB.put('personas', transactionData.Persona, encrypted);
|
||||
});
|
||||
DB.put('personas', transactionData.Persona, persona).catch((e) => { console.warn('DB.put error', e); });
|
||||
}
|
||||
|
||||
// Pre-fill if data provided
|
||||
@@ -847,12 +835,9 @@ PAGES.pagos = {
|
||||
}
|
||||
|
||||
persona.Monedero_Balance = fixfloat(newBalance);
|
||||
|
||||
TS_encrypt(persona, SECRET, (encrypted) => {
|
||||
DB.put('personas', personaId, encrypted).then(() => {
|
||||
if (callback) callback();
|
||||
});
|
||||
});
|
||||
DB.put('personas', personaId, persona).then(() => {
|
||||
if (callback) callback();
|
||||
}).catch((e) => { console.warn('DB.put error', e); if (callback) callback(); });
|
||||
}
|
||||
|
||||
function deleteTransaction(transactionKey) {
|
||||
@@ -1383,16 +1368,14 @@ PAGES.pagos = {
|
||||
delete updatedData.PersonaDestino;
|
||||
}
|
||||
|
||||
TS_encrypt(updatedData, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('pagos', transactionId, encrypted).then(() => {
|
||||
toastr.success("¡Transacción actualizada!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("pagos," + transactionId);
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('pagos', transactionId, updatedData).then(() => {
|
||||
toastr.success("¡Transacción actualizada!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("pagos," + transactionId);
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
|
||||
// Cancel button
|
||||
|
||||
@@ -66,7 +66,7 @@ PAGES.personas = {
|
||||
<button type="button" id="${btn_ver_monedero}" class="btn5">Ver Transacciones del Monedero</button>
|
||||
</div>
|
||||
</details>
|
||||
<details style="background: #e3fde3ff; border: 2px solid #21f328ff; border-radius: 8px; padding: 10px; margin: 15px 0;">
|
||||
<details style="background: #e3fde3ff; border: 2px solid #21f328ff; border-radius: 8px; padding: 10px; margin: 15px 0; display: none;">
|
||||
<summary style="cursor: pointer; font-weight: bold; color: rgba(26, 141, 3, 1);">🔗 Generar enlaces</summary>
|
||||
<div style="padding: 15px;">
|
||||
<label>
|
||||
@@ -110,9 +110,16 @@ PAGES.personas = {
|
||||
document.getElementById(field_nombre).value = data["Nombre"] || "";
|
||||
document.getElementById(field_zona).value = data["Region"] || "";
|
||||
document.getElementById(field_anilla).value = data["SC_Anilla"] || "";
|
||||
document.getElementById(render_foto).src =
|
||||
data["Foto"] || "static/ico/user_generic.png";
|
||||
// set fallback image immediately
|
||||
document.getElementById(render_foto).src = data["Foto"] || "static/ico/user_generic.png";
|
||||
resized = data["Foto"] || "static/ico/user_generic.png";
|
||||
// try to load attachment 'foto' if present (preferred storage)
|
||||
DB.getAttachment('personas', mid, 'foto').then((durl) => {
|
||||
if (durl) {
|
||||
document.getElementById(render_foto).src = durl;
|
||||
resized = durl;
|
||||
}
|
||||
}).catch(() => {});
|
||||
document.getElementById(field_notas).value = data["markdown"] || "";
|
||||
document.getElementById(field_monedero_balance).value =
|
||||
data["Monedero_Balance"] || 0;
|
||||
@@ -120,29 +127,25 @@ PAGES.personas = {
|
||||
data["Monedero_Notas"] || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'personas', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
});
|
||||
document
|
||||
.getElementById(field_foto)
|
||||
.addEventListener("change", function (e) {
|
||||
const file = e.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
resizeInputImage(
|
||||
file,
|
||||
function (url) {
|
||||
document.getElementById(render_foto).src = url;
|
||||
resized = url;
|
||||
},
|
||||
256,
|
||||
0.7
|
||||
);
|
||||
});
|
||||
document.getElementById(field_foto).addEventListener("change", function (e) {
|
||||
const file = e.target.files[0];
|
||||
if (!file) return;
|
||||
// Do NOT resize — keep original uploaded image
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (ev) {
|
||||
const url = ev.target.result;
|
||||
document.getElementById(render_foto).src = url;
|
||||
resized = url;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
var dt = new FormData(pdel);
|
||||
var data = {
|
||||
@@ -150,23 +153,28 @@ PAGES.personas = {
|
||||
Region: document.getElementById(field_zona).value,
|
||||
Roles: dt.getAll("perm").join(",") + ",",
|
||||
SC_Anilla: document.getElementById(field_anilla).value,
|
||||
Foto: resized,
|
||||
// Foto moved to PouchDB attachment named 'foto'
|
||||
markdown: document.getElementById(field_notas).value,
|
||||
Monedero_Balance:
|
||||
parseFloat(document.getElementById(field_monedero_balance).value) ||
|
||||
0,
|
||||
Monedero_Notas: document.getElementById(field_monedero_notas).value,
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('personas', mid, encrypted).then(() => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('personas', mid, data).then(() => {
|
||||
// if resized is a data URL (new/updated image), save as attachment
|
||||
var attachPromise = Promise.resolve(true);
|
||||
if (typeof resized === 'string' && resized.indexOf('data:') === 0) {
|
||||
attachPromise = DB.putAttachment('personas', mid, 'foto', resized, 'image/png');
|
||||
}
|
||||
attachPromise.then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("personas");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
}).catch((e) => { console.warn('putAttachment error', e); document.getElementById("actionStatus").style.display = "none"; });
|
||||
}).catch((e) => { console.warn('DB.put error', e); document.getElementById("actionStatus").style.display = "none"; });
|
||||
};
|
||||
document.getElementById(btn_ver_monedero).onclick = () => {
|
||||
setUrlHash("pagos"); // Navigate to pagos and show transactions for this person
|
||||
|
||||
@@ -51,9 +51,9 @@ PAGES.resumen_diario = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'comedor', CurrentISODate());
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
@@ -71,9 +71,9 @@ PAGES.resumen_diario = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'notas', 'tareas');
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
@@ -91,9 +91,9 @@ PAGES.resumen_diario = {
|
||||
);
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
});
|
||||
}, 'aulas_informes', 'diario-' + CurrentISODate());
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ PAGES.supercafe = {
|
||||
loadActions();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
TS_decrypt(data, SECRET, (data, wasEncrypted) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
}, 'supercafe', mid);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
@@ -112,16 +112,14 @@ PAGES.supercafe = {
|
||||
.getElementById(field_estado)
|
||||
.value.replace("%%", "Pedido"),
|
||||
};
|
||||
var enc = TS_encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('supercafe', mid, encrypted).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("supercafe");
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
});
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
DB.put('supercafe', mid, data).then(() => {
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("supercafe");
|
||||
}, SAVE_WAIT);
|
||||
}).catch((e) => { console.warn('DB.put error', e); });
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user