This commit is contained in:
naielv
2025-09-07 15:52:00 +02:00
parent fc4170acb8
commit f11760d867
10 changed files with 337 additions and 355 deletions

View File

@@ -67,14 +67,6 @@ String.prototype.toHex = function() {
return wheelcolors[hash % wheelcolors.length]; return wheelcolors[hash % wheelcolors.length];
}; };
// Test
console.log("hello".toHex());
console.log("world".toHex());
console.log("foo".toHex());
console.log("bar".toHex());
function stringToColour(str) { function stringToColour(str) {
return str.toHex(); return str.toHex();
} }
@@ -1038,7 +1030,6 @@ function TS_IndexElement(
} }
function BuildQR(mid, label) { function BuildQR(mid, label) {
console.warn("BARCODE " + mid + " LABEL " + label)
return ` return `
<span style="border: 2px dashed black; padding: 10px; display: inline-block; background: white; border-radius: 7px; text-align: center; margin: 10px;"> <span style="border: 2px dashed black; padding: 10px; display: inline-block; background: white; border-radius: 7px; text-align: center; margin: 10px;">
<b>TeleSec AztecQR</b> <b>TeleSec AztecQR</b>

View File

@@ -95,21 +95,6 @@
<script src="static/toastr.min.js"></script> <script src="static/toastr.min.js"></script>
<script src="static/doublescroll.js"></script> <script src="static/doublescroll.js"></script>
<!--<script src="static/simplemde.min.js"></script>--> <!--<script src="static/simplemde.min.js"></script>-->
<script>
let totalSize = 0;
for (let key in localStorage) {
if (localStorage.hasOwnProperty(key)) {
let keySize = new Blob([key]).size; // Size of the key
let valueSize = new Blob([localStorage[key]]).size; // Size of the value
totalSize += keySize + valueSize;
}
}
console.log(`Total localStorage size: ${totalSize} bytes`);
console.log(`Total size in KB: ${(totalSize / 1024).toFixed(2)} KB`);
console.log(`Total size in MB: ${(totalSize / (1024 * 1024)).toFixed(2)} MB`);
</script>
<script src="pwa.js"></script> <script src="pwa.js"></script>
<script src="config.js"></script> <script src="config.js"></script>
<script src="gun_init.js"></script> <script src="gun_init.js"></script>

View File

@@ -141,7 +141,7 @@ PAGES.aulas = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {
@@ -276,7 +276,7 @@ PAGES.aulas = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {

View File

@@ -124,7 +124,7 @@ PAGES.avisos = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {

View File

@@ -44,7 +44,7 @@ PAGES.comedor = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {

View File

@@ -3,25 +3,25 @@ PAGES.dataman = {
icon: "static/appico/Cogs.svg", icon: "static/appico/Cogs.svg",
AccessControl: true, AccessControl: true,
Title: "Ajustes", Title: "Ajustes",
edit: function(mid) { edit: function (mid) {
switch (mid) { switch (mid) {
case 'export': case "export":
PAGES.dataman.__export() PAGES.dataman.__export();
break; break;
case 'import': case "import":
PAGES.dataman.__import() PAGES.dataman.__import();
break; break;
case 'config': case "config":
PAGES.dataman.__config() PAGES.dataman.__config();
break; break;
case 'labels': case "labels":
PAGES.dataman.__labels() PAGES.dataman.__labels();
break; break;
default: default:
// Tab to edit // Tab to edit
} }
}, },
__config: function() { __config: function () {
var form = safeuuid(); var form = safeuuid();
container.innerHTML = ` container.innerHTML = `
<h1>Ajustes</h1> <h1>Ajustes</h1>
@@ -33,16 +33,16 @@ PAGES.dataman = {
</label> </label>
<button type="submit">Aplicar ajustes</button> <button type="submit">Aplicar ajustes</button>
</form> </form>
` `;
document.getElementById(form).onsubmit = (ev) => { document.getElementById(form).onsubmit = (ev) => {
ev.preventDefault() ev.preventDefault();
var ford = new FormData(document.getElementById(form)) var ford = new FormData(document.getElementById(form));
if (ford.get("block_add_account") == "yes") { if (ford.get("block_add_account") == "yes") {
config["block_add_account"] = true config["block_add_account"] = true;
} }
} };
}, },
__export: function() { __export: function () {
var select_type = safeuuid(); var select_type = safeuuid();
var textarea_content = safeuuid(); var textarea_content = safeuuid();
var button_export_local = safeuuid(); var button_export_local = safeuuid();
@@ -75,16 +75,15 @@ PAGES.dataman = {
var value = entry[1]; var value = entry[1];
if (value != null) { if (value != null) {
if (typeof value == "string") { if (typeof value == "string") {
SEA.decrypt(value, SECRET, (data) => { SEA.decrypt(value, SECRET, (data) => {
output[modul][key] = data; output[modul][key] = data;
}); });
} else { } else {
output[modul][key] = value; output[modul][key] = value;
} }
} }
}); });
toastr.success("Exportado todo, descargando!"); toastr.success("Exportado todo, descargando!");
console.error(output);
download( download(
`Export TeleSec ${GROUPID}.json.txt`, `Export TeleSec ${GROUPID}.json.txt`,
JSON.stringify(output) JSON.stringify(output)
@@ -97,7 +96,6 @@ PAGES.dataman = {
document.getElementById(button_export_safe).onclick = () => { document.getElementById(button_export_safe).onclick = () => {
var download_data = (DATA) => { var download_data = (DATA) => {
toastr.success("Exportado todo, descargado!"); toastr.success("Exportado todo, descargado!");
console.error(DATA);
download( download(
`Export TeleSec Encriptado ${GROUPID}.json.txt`, `Export TeleSec Encriptado ${GROUPID}.json.txt`,
JSON.stringify(DATA) JSON.stringify(DATA)
@@ -109,14 +107,13 @@ PAGES.dataman = {
document.getElementById(button_export_safe_cloud).onclick = () => { document.getElementById(button_export_safe_cloud).onclick = () => {
var download_data = (DATA) => { var download_data = (DATA) => {
toastr.info("Exportado todo, subiendo!"); toastr.info("Exportado todo, subiendo!");
console.error(DATA);
fetch( fetch(
"https://telesec-sync.tech.eus/upload_backup.php?table=" + GROUPID, "https://telesec-sync.tech.eus/upload_backup.php?table=" + GROUPID,
{ {
method: "POST", method: "POST",
body: JSON.stringify(DATA), body: JSON.stringify(DATA),
} }
) )
.then(() => { .then(() => {
toastr.success("Subido correctamente!"); toastr.success("Subido correctamente!");
}) })
@@ -127,7 +124,7 @@ PAGES.dataman = {
gun.get(TABLE).load(download_data); gun.get(TABLE).load(download_data);
}; };
}, },
__import: function() { __import: function () {
var select_type = safeuuid(); var select_type = safeuuid();
var textarea_content = safeuuid(); var textarea_content = safeuuid();
var button_import = safeuuid(); var button_import = safeuuid();
@@ -177,29 +174,36 @@ PAGES.dataman = {
}, 5000); }, 5000);
}; };
}, },
__labels: function(mid) { __labels: function (mid) {
var div_materiales = safeuuid() var div_materiales = safeuuid();
container.innerHTML = ` container.innerHTML = `
<h1>Imprimir Etiquetas AztecQR</h1> <h1>Imprimir Etiquetas AztecQR</h1>
<button onclick="print()">Imprimir</button> <button onclick="print()">Imprimir</button>
<h2>Materiales</h2> <h2>Materiales</h2>
<div id="${div_materiales}"></div> <div id="${div_materiales}"></div>
<br><br>`; <br><br>`;
div_materiales = document.getElementById(div_materiales) div_materiales = document.getElementById(div_materiales);
gun.get(TABLE).get("materiales").map().once((data, key) => { gun
function add_row(data, key) { .get(TABLE)
if (data != null) { .get("materiales")
div_materiales.innerHTML += BuildQR("materiales," + key, data["Nombre"] || key) .map()
.once((data, key) => {
function add_row(data, key) {
if (data != null) {
div_materiales.innerHTML += BuildQR(
"materiales," + key,
data["Nombre"] || key
);
}
} }
} if (typeof data == "string") {
if (typeof data == "string") { SEA.decrypt(data, SECRET, (data) => {
SEA.decrypt(data, SECRET, (data) => { add_row(data, key);
});
} else {
add_row(data, key); add_row(data, key);
}); }
} else { });
add_row(data, key);
}
})
}, },
index: function () { index: function () {
container.innerHTML = ` container.innerHTML = `
@@ -208,6 +212,6 @@ PAGES.dataman = {
<a class="button" href="#dataman,export">Exportar datos</a> <a class="button" href="#dataman,export">Exportar datos</a>
<a class="button" href="#dataman,labels">Imprimir etiquetas</a> <a class="button" href="#dataman,labels">Imprimir etiquetas</a>
<a class="button" href="#dataman,config">Ajustes</a> <a class="button" href="#dataman,config">Ajustes</a>
` `;
} },
}; };

View File

@@ -78,7 +78,7 @@ PAGES.materiales = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {
@@ -176,7 +176,6 @@ PAGES.materiales = {
document.getElementById("tableContainer"), document.getElementById("tableContainer"),
undefined, undefined,
function(data) { function(data) {
console.log(data.Ubicacion, filtroUbicacion);
if (data.Ubicacion == filtroUbicacion) {return false} if (data.Ubicacion == filtroUbicacion) {return false}
if (filtroUbicacion == "") {return false} if (filtroUbicacion == "") {return false}
return true return true

View File

@@ -74,7 +74,7 @@ PAGES.notas = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document.getElementById(btn_guardar).onclick = () => { document.getElementById(btn_guardar).onclick = () => {

View File

@@ -98,7 +98,7 @@ PAGES.personas = {
load_data(data, "%E"); load_data(data, "%E");
}); });
} else { } else {
load_data(data); load_data(data || {});
} }
}); });
document document

View File

@@ -1,25 +1,28 @@
PERMS["supercafe"] = "SuperCafé" PERMS["supercafe"] = "SuperCafé";
PERMS["supercafe:edit"] = "&gt; Editar" PERMS["supercafe:edit"] = "&gt; Editar";
PAGES.supercafe = { PAGES.supercafe = {
navcss: "btn4", navcss: "btn4",
icon: "static/appico/Coffee.svg", icon: "static/appico/Coffee.svg",
AccessControl: true, AccessControl: true,
Title: "SuperCafé", Title: "SuperCafé",
edit: function (mid) { edit: function (mid) {
if (!checkRole("supercafe:edit")) {setUrlHash("supercafe");return} if (!checkRole("supercafe:edit")) {
var nameh1 = safeuuid(); setUrlHash("supercafe");
var field_fecha = safeuuid(); return;
var field_persona = safeuuid(); }
var field_comanda = safeuuid(); var nameh1 = safeuuid();
var field_notas = safeuuid(); var field_fecha = safeuuid();
var field_estado = safeuuid(); var field_persona = safeuuid();
var div_actions = safeuuid(); var field_comanda = safeuuid();
var btn_pagos = safeuuid(); var field_notas = safeuuid();
var btn_cocina = safeuuid(); var field_estado = safeuuid();
var btn_guardar = safeuuid(); var div_actions = safeuuid();
var btn_guardar2 = safeuuid(); var btn_pagos = safeuuid();
var btn_borrar = safeuuid(); var btn_cocina = safeuuid();
container.innerHTML = ` var btn_guardar = safeuuid();
var btn_guardar2 = safeuuid();
var btn_borrar = safeuuid();
container.innerHTML = `
<h1>Comanda <code id="${nameh1}"></code></h1> <h1>Comanda <code id="${nameh1}"></code></h1>
<button onclick="setUrlHash('supercafe');">Salir</button> <button onclick="setUrlHash('supercafe');">Salir</button>
<fieldset style="text-align: center;"> <fieldset style="text-align: center;">
@@ -53,113 +56,115 @@ PAGES.supercafe = {
<button id=${btn_borrar} class="rojo">Borrar</button> <button id=${btn_borrar} class="rojo">Borrar</button>
</fieldset> </fieldset>
`; `;
var currentData = {}; var currentData = {};
var currentPersonaID = ""; var currentPersonaID = "";
var divact = document.getElementById(div_actions); var divact = document.getElementById(div_actions);
function loadActions() { function loadActions() {
divact.innerHTML = ""; divact.innerHTML = "";
addCategory_Personas(divact, SC_Personas, currentPersonaID, (value) => { addCategory_Personas(divact, SC_Personas, currentPersonaID, (value) => {
document.getElementById(field_persona).value = value; document.getElementById(field_persona).value = value;
}); });
Object.entries(SC_actions).forEach((category) => { Object.entries(SC_actions).forEach((category) => {
addCategory( addCategory(
divact, divact,
category[0], category[0],
SC_actions_icons[category[0]], SC_actions_icons[category[0]],
category[1], category[1],
currentData, currentData,
(values) => { (values) => {
document.getElementById(field_comanda).value = SC_parse(values); document.getElementById(field_comanda).value = SC_parse(values);
} }
); );
}); });
} }
loadActions(); loadActions();
gun gun
.get(TABLE) .get(TABLE)
.get("supercafe") .get("supercafe")
.get(mid) .get(mid)
.once((data, key) => { .once((data, key) => {
function load_data(data, ENC = "") { function load_data(data, ENC = "") {
document.getElementById(nameh1).innerText = key; document.getElementById(nameh1).innerText = key;
document.getElementById(field_fecha).value = data["Fecha"]; document.getElementById(field_fecha).value = data["Fecha"];
document.getElementById(field_persona).value = document.getElementById(field_persona).value = data["Persona"] || "";
data["Persona"] || ""; currentPersonaID = data["Persona"] || "";
currentPersonaID = data["Persona"] || ""; document.getElementById(field_comanda).value =
document.getElementById(field_comanda).value = SC_parse(JSON.parse(data["Comanda"] || "{}")) || "";
SC_parse(JSON.parse(data["Comanda"] || "{}")) || ""; document.getElementById(field_notas).value = data["Notas"] || "";
document.getElementById(field_notas).value = data["Notas"] || ""; document.getElementById(field_estado).value = data["Estado"] || "";
document.getElementById(field_estado).value = data["Estado"] || ""; currentData = JSON.parse(data["Comanda"] || "{}");
currentData = JSON.parse(data["Comanda"] || "{}");
loadActions(); loadActions();
}
if (typeof data == "string") {
SEA.decrypt(data, SECRET, (data) => {
load_data(data, "%E");
});
} else {
load_data(data);
}
});
document.getElementById(btn_guardar).onclick = () => {
if (document.getElementById(field_persona).value == "") {
alert("¡Hay que elegir una persona!");
return;
} }
var data = { if (typeof data == "string") {
Fecha: document.getElementById(field_fecha).value, SEA.decrypt(data, SECRET, (data) => {
Persona: document.getElementById(field_persona).value, load_data(data, "%E");
Comanda: JSON.stringify(currentData), });
Notas: document.getElementById(field_notas).value, } else {
Estado: document load_data(data || {});
.getElementById(field_estado)
.value.replace("%%", "Pedido"),
};
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
document.getElementById("actionStatus").style.display = "block";
betterGunPut(gun.get(TABLE).get("supercafe").get(mid), encrypted);
toastr.success("Guardado!");
setTimeout(() => {
document.getElementById("actionStatus").style.display = "none";
setUrlHash("supercafe");
}, 1500);
});
};
document.getElementById(btn_borrar).onclick = () => {
if (
confirm(
"¿Quieres borrar esta comanda? - NO se actualizaran los puntos de la persona asignada."
) == true
) {
betterGunPut(gun.get(TABLE).get("supercafe").get(mid), null);
setTimeout(() => {
setUrlHash("supercafe");
}, 1500);
} }
}; });
}, document.getElementById(btn_guardar).onclick = () => {
index: function () { if (document.getElementById(field_persona).value == "") {
if (!checkRole("supercafe")) {setUrlHash("index");return} alert("¡Hay que elegir una persona!");
var tts = false; return;
var sc_nobtn = "";
if (urlParams.get("sc_nobtn") == "yes") {
sc_nobtn = "pointer-events: none; opacity: 0.5";
} }
var ev = setTimeout(() => { var data = {
tts = true; Fecha: document.getElementById(field_fecha).value,
console.log("TTS Enabled"); Persona: document.getElementById(field_persona).value,
toastr.info("Texto a voz disponible"); Comanda: JSON.stringify(currentData),
}, 6500); Notas: document.getElementById(field_notas).value,
EventListeners.Timeout.push(ev) Estado: document
const tablebody = safeuuid(); .getElementById(field_estado)
const tablebody2 = safeuuid(); .value.replace("%%", "Pedido"),
var btn_new = safeuuid(); };
var totalprecio = safeuuid(); var enc = SEA.encrypt(data, SECRET, (encrypted) => {
var tts_check = safeuuid(); document.getElementById("actionStatus").style.display = "block";
var old = {}; betterGunPut(gun.get(TABLE).get("supercafe").get(mid), encrypted);
container.innerHTML = ` toastr.success("Guardado!");
setTimeout(() => {
document.getElementById("actionStatus").style.display = "none";
setUrlHash("supercafe");
}, 1500);
});
};
document.getElementById(btn_borrar).onclick = () => {
if (
confirm(
"¿Quieres borrar esta comanda? - NO se actualizaran los puntos de la persona asignada."
) == true
) {
betterGunPut(gun.get(TABLE).get("supercafe").get(mid), null);
setTimeout(() => {
setUrlHash("supercafe");
}, 1500);
}
};
},
index: function () {
if (!checkRole("supercafe")) {
setUrlHash("index");
return;
}
var tts = false;
var sc_nobtn = "";
if (urlParams.get("sc_nobtn") == "yes") {
sc_nobtn = "pointer-events: none; opacity: 0.5";
}
var ev = setTimeout(() => {
tts = true;
console.log("TTS Enabled");
toastr.info("Texto a voz disponible");
}, 6500);
EventListeners.Timeout.push(ev);
const tablebody = safeuuid();
const tablebody2 = safeuuid();
var btn_new = safeuuid();
var totalprecio = safeuuid();
var tts_check = safeuuid();
var old = {};
container.innerHTML = `
<h1>SuperCafé - Total: <span id="${totalprecio}">0</span>c</h1> <h1>SuperCafé - Total: <span id="${totalprecio}">0</span>c</h1>
<button id="${btn_new}" style="${sc_nobtn};">Nueva comanda</button> <button id="${btn_new}" style="${sc_nobtn};">Nueva comanda</button>
<br> <br>
@@ -178,157 +183,155 @@ PAGES.supercafe = {
<div id="cont2"></div> <div id="cont2"></div>
</details> </details>
`; `;
var config = [ var config = [
{ {
key: "Persona", key: "Persona",
type: "persona", type: "persona",
default: "", default: "",
label: "Persona", label: "Persona",
}, },
{ {
key: "Estado", key: "Estado",
type: "comanda-status", type: "comanda-status",
default: "", default: "",
label: "Estado", label: "Estado",
}, },
{ {
key: "Comanda", key: "Comanda",
type: "comanda", type: "comanda",
default: "", default: "",
label: "Comanda", label: "Comanda",
}, },
] ];
if (!checkRole("supercafe:edit")) { if (!checkRole("supercafe:edit")) {
config = [ config = [
{ {
key: "Persona", key: "Persona",
type: "persona", type: "persona",
default: "", default: "",
label: "Persona", label: "Persona",
},
{
key: "Comanda",
type: "comanda",
default: "",
label: "Comanda",
},
]
}
//Todas las comandas
var comandasTot = {}
function calcPrecio() {
var tot = 0
Object.values(comandasTot).forEach(precio => {
tot += precio
});
document.getElementById(totalprecio).innerText = tot
return tot
}
TS_IndexElement(
"supercafe",
config,
gun.get(TABLE).get("supercafe"),
document.querySelector("#cont1"),
(data, new_tr) => {
// new_tr.style.backgroundColor = "#FFCCCB";
comandasTot[data._key] = SC_priceCalc(JSON.parse(data.Comanda))[0]
calcPrecio()
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
}
if (data.Estado == "En preparación") {
new_tr.style.backgroundColor = "#FFCCCB";
}
if (data.Estado == "Listo") {
new_tr.style.backgroundColor = "gold";
}
if (data.Estado == "Entregado") {
new_tr.style.backgroundColor = "lightgreen";
}
if (data.Estado == "Deuda") {
new_tr.style.backgroundColor = "#f5d3ff";
}
}, },
(data) => { {
if (data.Estado == "Deuda") { key: "Comanda",
return true; type: "comanda",
} default: "",
var key = data._key; label: "Comanda",
if (old[key] == undefined) {
old[key] = "";
}
if (old[key] != data.Estado) {
if (tts && document.getElementById(tts_check).checked) {
var msg = `Comanda de ${SC_Personas[data.Persona].Region}. - ${
JSON.parse(data.Comanda)["Selección"]
}. - ${SC_Personas[data.Persona].Nombre}. - ${data.Estado}`;
console.log("TTS: " + msg);
let utterance = new SpeechSynthesisUtterance(msg);
utterance.rate = 0.9;
// utterance.voice = speechSynthesis.getVoices()[7]
speechSynthesis.speak(utterance);
}
}
old[key] = data.Estado;
}
);
//Deudas
TS_IndexElement(
"supercafe",
config,
gun.get(TABLE).get("supercafe"),
document.querySelector("#cont2"),
(data, new_tr) => {
// new_tr.style.backgroundColor = "#FFCCCB";
comandasTot[data._key] = 0 // No mostrar comandas en deuda.
calcPrecio()
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
}
if (data.Estado == "En preparación") {
new_tr.style.backgroundColor = "#FFCCCB";
}
if (data.Estado == "Listo") {
new_tr.style.backgroundColor = "gold";
}
if (data.Estado == "Entregado") {
new_tr.style.backgroundColor = "lightgreen";
}
if (data.Estado == "Deuda") {
new_tr.style.backgroundColor = "#f5d3ff";
}
}, },
(data) => { ];
if (data.Estado != "Deuda") { }
return true; //Todas las comandas
} var comandasTot = {};
var key = data._key; function calcPrecio() {
if (old[key] == undefined) { var tot = 0;
old[key] = ""; Object.values(comandasTot).forEach((precio) => {
} tot += precio;
if (old[key] != data.Estado) { });
if (tts && document.getElementById(tts_check).checked) { document.getElementById(totalprecio).innerText = tot;
var msg = `Comanda de ${SC_Personas[data.Persona].Region}. - ${ return tot;
JSON.parse(data.Comanda)["Selección"] }
}. - ${SC_Personas[data.Persona].Nombre}. - ${data.Estado}`; TS_IndexElement(
console.log("TTS: " + msg); "supercafe",
let utterance = new SpeechSynthesisUtterance(msg); config,
utterance.rate = 0.9; gun.get(TABLE).get("supercafe"),
// utterance.voice = speechSynthesis.getVoices()[7] document.querySelector("#cont1"),
speechSynthesis.speak(utterance); (data, new_tr) => {
} // new_tr.style.backgroundColor = "#FFCCCB";
} comandasTot[data._key] = SC_priceCalc(JSON.parse(data.Comanda))[0];
old[key] = data.Estado; calcPrecio();
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
} }
); if (data.Estado == "En preparación") {
if (!checkRole("supercafe:edit")) { new_tr.style.backgroundColor = "#FFCCCB";
document.getElementById(btn_new).style.display = "none" }
} else { if (data.Estado == "Listo") {
document.getElementById(btn_new).onclick = () => { new_tr.style.backgroundColor = "gold";
setUrlHash("supercafe," + safeuuid("")); }
}; if (data.Estado == "Entregado") {
new_tr.style.backgroundColor = "lightgreen";
}
if (data.Estado == "Deuda") {
new_tr.style.backgroundColor = "#f5d3ff";
}
},
(data) => {
if (data.Estado == "Deuda") {
return true;
}
var key = data._key;
if (old[key] == undefined) {
old[key] = "";
}
if (old[key] != data.Estado) {
if (tts && document.getElementById(tts_check).checked) {
var msg = `Comanda de ${SC_Personas[data.Persona].Region}. - ${
JSON.parse(data.Comanda)["Selección"]
}. - ${SC_Personas[data.Persona].Nombre}. - ${data.Estado}`;
let utterance = new SpeechSynthesisUtterance(msg);
utterance.rate = 0.9;
// utterance.voice = speechSynthesis.getVoices()[7]
speechSynthesis.speak(utterance);
}
}
old[key] = data.Estado;
} }
}, );
}
//Deudas
TS_IndexElement(
"supercafe",
config,
gun.get(TABLE).get("supercafe"),
document.querySelector("#cont2"),
(data, new_tr) => {
// new_tr.style.backgroundColor = "#FFCCCB";
comandasTot[data._key] = 0; // No mostrar comandas en deuda.
calcPrecio();
if (data.Estado == "Pedido") {
new_tr.style.backgroundColor = "#FFFFFF";
}
if (data.Estado == "En preparación") {
new_tr.style.backgroundColor = "#FFCCCB";
}
if (data.Estado == "Listo") {
new_tr.style.backgroundColor = "gold";
}
if (data.Estado == "Entregado") {
new_tr.style.backgroundColor = "lightgreen";
}
if (data.Estado == "Deuda") {
new_tr.style.backgroundColor = "#f5d3ff";
}
},
(data) => {
if (data.Estado != "Deuda") {
return true;
}
var key = data._key;
if (old[key] == undefined) {
old[key] = "";
}
if (old[key] != data.Estado) {
if (tts && document.getElementById(tts_check).checked) {
var msg = `Comanda de ${SC_Personas[data.Persona].Region}. - ${
JSON.parse(data.Comanda)["Selección"]
}. - ${SC_Personas[data.Persona].Nombre}. - ${data.Estado}`;
let utterance = new SpeechSynthesisUtterance(msg);
utterance.rate = 0.9;
// utterance.voice = speechSynthesis.getVoices()[7]
speechSynthesis.speak(utterance);
}
}
old[key] = data.Estado;
}
);
if (!checkRole("supercafe:edit")) {
document.getElementById(btn_new).style.display = "none";
} else {
document.getElementById(btn_new).onclick = () => {
setUrlHash("supercafe," + safeuuid(""));
};
}
},
};