update
This commit is contained in:
@@ -34,6 +34,10 @@ if (urlParams.get("login") != null) {
|
||||
//location.search = "";
|
||||
}
|
||||
function open_page(params) {
|
||||
if (SUB_LOGGED_IN != true) {
|
||||
PAGES["login"].index();
|
||||
return;
|
||||
}
|
||||
if (params == "") {
|
||||
params = "index";
|
||||
}
|
||||
|
||||
@@ -215,7 +215,9 @@ function addCategory_Personas(
|
||||
options,
|
||||
defaultval,
|
||||
change_cb = () => {},
|
||||
label = "Persona"
|
||||
label = "Persona",
|
||||
open_default = false,
|
||||
default_empty_text = "- Lista Vacia -"
|
||||
) {
|
||||
var details_0 = document.createElement("details"); // children: img_0, summary_0
|
||||
//details_0.open = true;
|
||||
@@ -233,6 +235,9 @@ function addCategory_Personas(
|
||||
span_0.append(p.Nombre || "", " ", img_0);
|
||||
summary_0.append(label, span_0);
|
||||
details_0.append(summary_0, document.createElement("br"));
|
||||
if (open_default == true) {
|
||||
details_0.open = true;
|
||||
}
|
||||
details_0.style.textAlign = "center";
|
||||
details_0.style.margin = "5px";
|
||||
details_0.style.padding = "5px";
|
||||
@@ -302,6 +307,11 @@ function addCategory_Personas(
|
||||
//btn.style.fontSize="17.5px"
|
||||
details_0.append(btn);
|
||||
});
|
||||
if (Object.entries(options).length == 0) {
|
||||
var btn = document.createElement("b");
|
||||
btn.append(default_empty_text);
|
||||
details_0.append(btn);
|
||||
}
|
||||
}
|
||||
const SC_actions_icons = {
|
||||
Tamaño: "static/ico/sizes.png",
|
||||
@@ -493,23 +503,21 @@ gun
|
||||
.get("personas")
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
SC_Personas[key] = data;
|
||||
} else {
|
||||
delete SC_Personas[key];
|
||||
}
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
SC_Personas[key] = data;
|
||||
} else {
|
||||
add_row(data, key);
|
||||
delete SC_Personas[key];
|
||||
}
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
|
||||
function SC_parse(json) {
|
||||
@@ -656,7 +664,6 @@ function TS_IndexElement(
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
var tablebody_EL = document.getElementById(tablebody);
|
||||
tablebody_EL.innerHTML = "";
|
||||
Object.values(rows)
|
||||
.sort(sorter)
|
||||
@@ -675,34 +682,39 @@ function TS_IndexElement(
|
||||
config.forEach((key) => {
|
||||
switch (key.type) {
|
||||
case "raw":
|
||||
const tdRaw = document.createElement('td');
|
||||
const rawContent = (data[key.key] || key.default || "").replace(/\n/g, '<br>');
|
||||
const tdRaw = document.createElement("td");
|
||||
const rawContent = (data[key.key] || key.default || "").replace(
|
||||
/\n/g,
|
||||
"<br>"
|
||||
);
|
||||
tdRaw.innerHTML = rawContent;
|
||||
new_tr.appendChild(tdRaw);
|
||||
break;
|
||||
case "comanda":
|
||||
const tdComanda = document.createElement('td');
|
||||
const tdComanda = document.createElement("td");
|
||||
const parsedComanda = JSON.parse(data.Comanda);
|
||||
const precio = SC_priceCalc(parsedComanda)[0];
|
||||
|
||||
// Create a temporary div to parse the HTML from setLayeredImages
|
||||
const tempDiv = document.createElement('div');
|
||||
const tempDiv = document.createElement("div");
|
||||
tempDiv.innerHTML = setLayeredImages(parsedComanda, data._key);
|
||||
tdComanda.appendChild(tempDiv.firstChild);
|
||||
|
||||
const pre = document.createElement('pre');
|
||||
pre.style.fontSize = '15px';
|
||||
pre.style.display = 'inline-block';
|
||||
const pre = document.createElement("pre");
|
||||
pre.style.fontSize = "15px";
|
||||
pre.style.display = "inline-block";
|
||||
|
||||
const spanPrecio = document.createElement('span');
|
||||
spanPrecio.style.fontSize = '20px';
|
||||
spanPrecio.innerHTML = SC_Personas[data.Persona].Puntos >= 10 ?
|
||||
`Total: Gratis!(${precio}c)` :
|
||||
`Total: ${precio}c`;
|
||||
const spanPrecio = document.createElement("span");
|
||||
spanPrecio.style.fontSize = "20px";
|
||||
spanPrecio.innerHTML =
|
||||
SC_Personas[data.Persona].Puntos >= 10
|
||||
? `Total: Gratis!(${precio}c)`
|
||||
: `Total: ${precio}c`;
|
||||
|
||||
pre.appendChild(spanPrecio);
|
||||
pre.appendChild(document.createTextNode('\n'));
|
||||
pre.innerHTML += SC_parse_short(parsedComanda) + "<hr>" + data.Notas;
|
||||
pre.appendChild(document.createTextNode("\n"));
|
||||
pre.innerHTML +=
|
||||
SC_parse_short(parsedComanda) + "<hr>" + data.Notas;
|
||||
|
||||
tdComanda.appendChild(pre);
|
||||
new_tr.appendChild(tdComanda);
|
||||
@@ -712,19 +724,19 @@ function TS_IndexElement(
|
||||
if (urlParams.get("sc_nobtn") == "yes") {
|
||||
sc_nobtn = "pointer-events: none; opacity: 0.5";
|
||||
}
|
||||
const td = document.createElement('td');
|
||||
td.style.fontSize = '17px';
|
||||
const td = document.createElement("td");
|
||||
td.style.fontSize = "17px";
|
||||
if (sc_nobtn) {
|
||||
td.style.pointerEvents = 'none';
|
||||
td.style.opacity = '0.5';
|
||||
td.style.pointerEvents = "none";
|
||||
td.style.opacity = "0.5";
|
||||
}
|
||||
|
||||
// Create buttons
|
||||
const createButton = (text, state) => {
|
||||
const button = document.createElement('button');
|
||||
const button = document.createElement("button");
|
||||
button.textContent = text;
|
||||
if (data.Estado === state) {
|
||||
button.className = 'rojo';
|
||||
button.className = "rojo";
|
||||
}
|
||||
button.onclick = (event) => {
|
||||
event.preventDefault();
|
||||
@@ -741,20 +753,24 @@ function TS_IndexElement(
|
||||
|
||||
// Create all buttons
|
||||
const buttons = [
|
||||
createButton('Pedido', 'Pedido'),
|
||||
createButton('En preparación', 'En preparación'),
|
||||
createButton('Listo', 'Listo'),
|
||||
createButton('Entregado', 'Entregado'),
|
||||
createButton('Deuda', 'Deuda')
|
||||
createButton("Pedido", "Pedido"),
|
||||
createButton("En preparación", "En preparación"),
|
||||
createButton("Listo", "Listo"),
|
||||
createButton("Entregado", "Entregado"),
|
||||
createButton("Deuda", "Deuda"),
|
||||
];
|
||||
|
||||
// Create paid button separately due to different behavior
|
||||
const paidButton = document.createElement('button');
|
||||
paidButton.textContent = 'Pagado';
|
||||
const paidButton = document.createElement("button");
|
||||
paidButton.textContent = "Pagado";
|
||||
paidButton.onclick = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!confirm("¿Quieres marcar como pagado? - Se borrara la comanda y se actualizarán los puntos.")) {
|
||||
if (
|
||||
!confirm(
|
||||
"¿Quieres marcar como pagado? - Se borrara la comanda y se actualizarán los puntos."
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
data.Estado = "Pagado";
|
||||
@@ -762,22 +778,33 @@ function TS_IndexElement(
|
||||
toastr.success("Guardado!");
|
||||
if (SC_Personas[data.Persona].Puntos >= 10) {
|
||||
SC_Personas[data.Persona].Puntos -= 10;
|
||||
toastr.success("¡Comada gratis para " + SC_Personas[data.Persona].Nombre + "!");
|
||||
toastr.success("¡Comada gratis para " + SC_Personas[data.Persona].Nombre + "!");
|
||||
toastr.success(
|
||||
"¡Comada gratis para " +
|
||||
SC_Personas[data.Persona].Nombre +
|
||||
"!"
|
||||
);
|
||||
toastr.success(
|
||||
"¡Comada gratis para " +
|
||||
SC_Personas[data.Persona].Nombre +
|
||||
"!"
|
||||
);
|
||||
} else {
|
||||
SC_Personas[data.Persona].Puntos += 1;
|
||||
toastr.success("¡Comada DE PAGO!");
|
||||
}
|
||||
SEA.encrypt(SC_Personas[data.Persona], SECRET, (encrypted) => {
|
||||
betterGunPut(gun.get(TABLE).get("personas").get(data.Persona), encrypted);
|
||||
betterGunPut(
|
||||
gun.get(TABLE).get("personas").get(data.Persona),
|
||||
encrypted
|
||||
);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
// Add all buttons to td with line breaks between
|
||||
buttons.forEach(button => {
|
||||
buttons.forEach((button) => {
|
||||
td.appendChild(button);
|
||||
td.appendChild(document.createElement('br'));
|
||||
td.appendChild(document.createElement("br"));
|
||||
});
|
||||
td.appendChild(paidButton);
|
||||
new_tr.appendChild(td);
|
||||
@@ -786,41 +813,45 @@ function TS_IndexElement(
|
||||
break;
|
||||
case "persona":
|
||||
const persona = SC_Personas[data[key.key]];
|
||||
const regco = stringToColour((persona.Region || "?").toLowerCase());
|
||||
const regco = stringToColour(
|
||||
(persona.Region || "?").toLowerCase()
|
||||
);
|
||||
|
||||
const tdPersona = document.createElement('td');
|
||||
tdPersona.style.textAlign = 'center';
|
||||
tdPersona.style.fontSize = '20px';
|
||||
const tdPersona = document.createElement("td");
|
||||
tdPersona.style.textAlign = "center";
|
||||
tdPersona.style.fontSize = "20px";
|
||||
tdPersona.style.backgroundColor = regco;
|
||||
tdPersona.style.color = colorIsDarkAdvanced(regco);
|
||||
|
||||
const regionSpan = document.createElement('span');
|
||||
regionSpan.style.fontSize = '40px';
|
||||
regionSpan.style.textTransform = 'capitalize';
|
||||
const regionSpan = document.createElement("span");
|
||||
regionSpan.style.fontSize = "40px";
|
||||
regionSpan.style.textTransform = "capitalize";
|
||||
regionSpan.textContent = (persona.Region || "?").toLowerCase();
|
||||
tdPersona.appendChild(regionSpan);
|
||||
|
||||
tdPersona.appendChild(document.createElement('br'));
|
||||
tdPersona.appendChild(document.createElement("br"));
|
||||
|
||||
const infoSpan = document.createElement('span');
|
||||
infoSpan.style.backgroundColor = 'white';
|
||||
infoSpan.style.border = '2px solid black';
|
||||
infoSpan.style.borderRadius = '5px';
|
||||
infoSpan.style.display = 'inline-block';
|
||||
infoSpan.style.padding = '5px';
|
||||
infoSpan.style.color = 'black';
|
||||
const infoSpan = document.createElement("span");
|
||||
infoSpan.style.backgroundColor = "white";
|
||||
infoSpan.style.border = "2px solid black";
|
||||
infoSpan.style.borderRadius = "5px";
|
||||
infoSpan.style.display = "inline-block";
|
||||
infoSpan.style.padding = "5px";
|
||||
infoSpan.style.color = "black";
|
||||
|
||||
const img = document.createElement('img');
|
||||
const img = document.createElement("img");
|
||||
img.src = persona.Foto || "static/ico/user_generic.png";
|
||||
img.height = 70;
|
||||
infoSpan.appendChild(img);
|
||||
|
||||
infoSpan.appendChild(document.createElement('br'));
|
||||
infoSpan.appendChild(document.createTextNode(persona.Nombre || ""));
|
||||
infoSpan.appendChild(document.createElement("br"));
|
||||
infoSpan.appendChild(
|
||||
document.createTextNode(persona.Nombre || "")
|
||||
);
|
||||
|
||||
infoSpan.appendChild(document.createElement('br'));
|
||||
const pointsSpan = document.createElement('span');
|
||||
pointsSpan.style.fontSize = '17px';
|
||||
infoSpan.appendChild(document.createElement("br"));
|
||||
const pointsSpan = document.createElement("span");
|
||||
pointsSpan.style.fontSize = "17px";
|
||||
pointsSpan.textContent = (persona.Puntos || "0") + " puntos.";
|
||||
infoSpan.appendChild(pointsSpan);
|
||||
|
||||
@@ -839,23 +870,21 @@ function TS_IndexElement(
|
||||
}
|
||||
ref.map().on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER = _ev;
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
add_row(data, key);
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -863,6 +892,9 @@ function TS_IndexElement(
|
||||
const PAGES = {};
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
Object.keys(PAGES).forEach((key) => {
|
||||
if (PAGES[key].Esconder == true) {
|
||||
return;
|
||||
}
|
||||
var a = document.createElement("a");
|
||||
a.className = "button " + PAGES[key].navcss;
|
||||
a.href = "#" + key;
|
||||
|
||||
@@ -20,3 +20,6 @@ const RELAYS = [
|
||||
"https://gun.defucc.me/gun",
|
||||
];
|
||||
var SECRET = "";
|
||||
var SUB_LOGGED_IN = false;
|
||||
var SUB_LOGGED_IN_DETAILS = false;
|
||||
var SUB_LOGGED_IN_ID = false;
|
||||
@@ -141,6 +141,7 @@
|
||||
<script src="gun_init.js"></script>
|
||||
<script src="app_logic.js"></script>
|
||||
<script src="app_modules.js"></script>
|
||||
<script src="page__login.js"></script>
|
||||
<script src="page__index.js"></script>
|
||||
<script src="page__importar.js"></script>
|
||||
<script src="page__exportar.js"></script>
|
||||
|
||||
50
src/page__login.js
Normal file
50
src/page__login.js
Normal file
@@ -0,0 +1,50 @@
|
||||
PAGES.login = {
|
||||
Esconder: true,
|
||||
Title: "Login",
|
||||
index: function (mid) {
|
||||
var field_persona = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_reload = safeuuid();
|
||||
var div_actions = safeuuid();
|
||||
container.innerHTML = `
|
||||
<h1>Iniciar sesión</h1>
|
||||
<fieldset>
|
||||
<legend>Valores</legend>
|
||||
<input type="hidden" id="${field_persona}">
|
||||
<div id="${div_actions}"></div>
|
||||
<button class="btn5" id="${btn_guardar}">Acceder</button>
|
||||
<button class="btn1" id="${btn_reload}">Recargar lista</button>
|
||||
</fieldset>
|
||||
<a style="color: rgb(240,240,240)">Acceso sin cuenta</a>
|
||||
`;
|
||||
var divact = document.getElementById(div_actions);
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
"",
|
||||
(value) => {
|
||||
document.getElementById(field_persona).value = value;
|
||||
},
|
||||
"¿Quién eres?",
|
||||
true,
|
||||
"- Pulsa recargar -"
|
||||
);
|
||||
document.getElementById("appendApps").style.display = "none"
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
if (document.getElementById(field_persona).value == "") {
|
||||
alert("Tienes que elegir tu cuenta!");
|
||||
return;
|
||||
}
|
||||
SUB_LOGGED_IN_ID = document.getElementById(field_persona).value
|
||||
SUB_LOGGED_IN_DETAILS = SC_Personas[SUB_LOGGED_IN_ID]
|
||||
SUB_LOGGED_IN = true
|
||||
setUrlHash("index")
|
||||
document.getElementById("appendApps").style.display = "unset"
|
||||
};
|
||||
|
||||
document.getElementById(btn_reload).onclick = () => {
|
||||
setUrlHash("login," + safeuuid(""))
|
||||
};
|
||||
|
||||
},
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
PAGES.materiales = {
|
||||
navcss: "btn2",
|
||||
Title: "Materiales",
|
||||
edit: function (mid) {
|
||||
var nameh1 = safeuuid();
|
||||
var field_nombre = safeuuid();
|
||||
var field_cantidad = safeuuid();
|
||||
var field_unidad = safeuuid();
|
||||
var field_cantidad_min = safeuuid();
|
||||
var field_abierto = safeuuid();
|
||||
var field_ubicacion = safeuuid();
|
||||
var field_referencia = safeuuid();
|
||||
var field_notas = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_borrar = safeuuid();
|
||||
container.innerHTML = `
|
||||
navcss: "btn2",
|
||||
Title: "Materiales",
|
||||
edit: function (mid) {
|
||||
var nameh1 = safeuuid();
|
||||
var field_nombre = safeuuid();
|
||||
var field_cantidad = safeuuid();
|
||||
var field_unidad = safeuuid();
|
||||
var field_cantidad_min = safeuuid();
|
||||
var field_abierto = safeuuid();
|
||||
var field_ubicacion = safeuuid();
|
||||
var field_referencia = safeuuid();
|
||||
var field_notas = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_borrar = safeuuid();
|
||||
container.innerHTML = `
|
||||
<h1>Material <code id="${nameh1}"></code></h1>
|
||||
<fieldset>
|
||||
<label>
|
||||
@@ -48,67 +48,67 @@ PAGES.materiales = {
|
||||
<button class="rojo" id="${btn_borrar}">Borrar</button>
|
||||
</fieldset>
|
||||
`;
|
||||
gun
|
||||
.get(TABLE)
|
||||
.get("materiales")
|
||||
.get(mid)
|
||||
.once((data, key) => {
|
||||
function load_data(data, ENC = "") {
|
||||
document.getElementById(nameh1).innerText = key;
|
||||
document.getElementById(field_nombre).value = data["Nombre"] || "";
|
||||
document.getElementById(field_unidad).value = data["Unidad"] || "";
|
||||
document.getElementById(field_cantidad).value =
|
||||
data["Cantidad"] || "";
|
||||
document.getElementById(field_cantidad_min).value =
|
||||
data["Cantidad_Minima"] || "";
|
||||
document.getElementById(field_ubicacion).value =
|
||||
data["Ubicacion"] || "-";
|
||||
document.getElementById(field_referencia).value =
|
||||
data["Referencia"] || "?";
|
||||
document.getElementById(field_notas).value = data["Notas"] || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
} else {
|
||||
load_data(data);
|
||||
}
|
||||
});
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
var data = {
|
||||
Nombre: document.getElementById(field_nombre).value,
|
||||
Unidad: document.getElementById(field_unidad).value,
|
||||
Cantidad: document.getElementById(field_cantidad).value,
|
||||
Cantidad_Minima: document.getElementById(field_cantidad_min).value,
|
||||
Ubicacion: document.getElementById(field_ubicacion).value,
|
||||
Referencia: document.getElementById(field_referencia).value,
|
||||
Notas: document.getElementById(field_notas).value,
|
||||
};
|
||||
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
betterGunPut(gun.get(TABLE).get("materiales").get(mid), encrypted);
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("materiales");
|
||||
}, 1500);
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar este material?") == true) {
|
||||
betterGunPut(gun.get(TABLE).get("materiales").get(mid), null);
|
||||
toastr.error("Borrado!");
|
||||
setTimeout(() => {
|
||||
setUrlHash("materiales");
|
||||
}, 1500);
|
||||
gun
|
||||
.get(TABLE)
|
||||
.get("materiales")
|
||||
.get(mid)
|
||||
.once((data, key) => {
|
||||
function load_data(data, ENC = "") {
|
||||
document.getElementById(nameh1).innerText = key;
|
||||
document.getElementById(field_nombre).value = data["Nombre"] || "";
|
||||
document.getElementById(field_unidad).value = data["Unidad"] || "";
|
||||
document.getElementById(field_cantidad).value =
|
||||
data["Cantidad"] || "";
|
||||
document.getElementById(field_cantidad_min).value =
|
||||
data["Cantidad_Minima"] || "";
|
||||
document.getElementById(field_ubicacion).value =
|
||||
data["Ubicacion"] || "-";
|
||||
document.getElementById(field_referencia).value =
|
||||
data["Referencia"] || "?";
|
||||
document.getElementById(field_notas).value = data["Notas"] || "";
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
load_data(data, "%E");
|
||||
});
|
||||
} else {
|
||||
load_data(data);
|
||||
}
|
||||
});
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
var data = {
|
||||
Nombre: document.getElementById(field_nombre).value,
|
||||
Unidad: document.getElementById(field_unidad).value,
|
||||
Cantidad: document.getElementById(field_cantidad).value,
|
||||
Cantidad_Minima: document.getElementById(field_cantidad_min).value,
|
||||
Ubicacion: document.getElementById(field_ubicacion).value,
|
||||
Referencia: document.getElementById(field_referencia).value,
|
||||
Notas: document.getElementById(field_notas).value,
|
||||
};
|
||||
},
|
||||
index: function () {
|
||||
const tablebody = safeuuid();
|
||||
var btn_new = safeuuid();
|
||||
container.innerHTML = `
|
||||
var enc = SEA.encrypt(data, SECRET, (encrypted) => {
|
||||
document.getElementById("actionStatus").style.display = "block";
|
||||
betterGunPut(gun.get(TABLE).get("materiales").get(mid), encrypted);
|
||||
toastr.success("Guardado!");
|
||||
setTimeout(() => {
|
||||
document.getElementById("actionStatus").style.display = "none";
|
||||
setUrlHash("materiales");
|
||||
}, 1500);
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm("¿Quieres borrar este material?") == true) {
|
||||
betterGunPut(gun.get(TABLE).get("materiales").get(mid), null);
|
||||
toastr.error("Borrado!");
|
||||
setTimeout(() => {
|
||||
setUrlHash("materiales");
|
||||
}, 1500);
|
||||
}
|
||||
};
|
||||
},
|
||||
index: function () {
|
||||
const tablebody = safeuuid();
|
||||
var btn_new = safeuuid();
|
||||
container.innerHTML = `
|
||||
<h1>Materiales</h1>
|
||||
<button id="${btn_new}">Nuevo Material</button>
|
||||
<div id="scrolltable"><table>
|
||||
@@ -125,70 +125,68 @@ PAGES.materiales = {
|
||||
</tbody>
|
||||
</table></div>
|
||||
`;
|
||||
tableScroll("#scrolltable");
|
||||
var tablebody_EL = document.getElementById(tablebody);
|
||||
var rows = {};
|
||||
function render() {
|
||||
function sorter(a, b) {
|
||||
if (a.Nombre < b.Nombre) {
|
||||
return -1;
|
||||
}
|
||||
if (a.Nombre > b.Nombre) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
tableScroll("#scrolltable");
|
||||
var tablebody_EL = document.getElementById(tablebody);
|
||||
var rows = {};
|
||||
function render() {
|
||||
function sorter(a, b) {
|
||||
if (a.Nombre < b.Nombre) {
|
||||
return -1;
|
||||
}
|
||||
var tablebody_EL = document.getElementById(tablebody);
|
||||
tablebody_EL.innerHTML = "";
|
||||
Object.values(rows)
|
||||
.sort(sorter)
|
||||
.forEach((data) => {
|
||||
var new_tr = document.createElement("tr");
|
||||
new_tr.innerHTML = `
|
||||
if (a.Nombre > b.Nombre) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
var tablebody_EL = document.getElementById(tablebody);
|
||||
tablebody_EL.innerHTML = "";
|
||||
Object.values(rows)
|
||||
.sort(sorter)
|
||||
.forEach((data) => {
|
||||
var new_tr = document.createElement("tr");
|
||||
new_tr.innerHTML = `
|
||||
<td>${data.Referencia || "?"}</td>
|
||||
<td>${data.Nombre || "?"}</td>
|
||||
<td>${data.Ubicacion || "?"}</td>
|
||||
<td>${data.Cantidad || "?"} ${data.Unidad || "?"}</td>
|
||||
<td>${data.Notas || "?"}</td>
|
||||
`;
|
||||
var min = parseFloat(data.Cantidad_Minima);
|
||||
var act = parseFloat(data.Cantidad);
|
||||
if (act < min) {
|
||||
new_tr.style.backgroundColor = "lightcoral";
|
||||
}
|
||||
new_tr.onclick = () => {
|
||||
setUrlHash("materiales," + data._key);
|
||||
};
|
||||
tablebody_EL.append(new_tr);
|
||||
});
|
||||
}
|
||||
gun
|
||||
.get(TABLE)
|
||||
.get("materiales")
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER = _ev;
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
var min = parseFloat(data.Cantidad_Minima);
|
||||
var act = parseFloat(data.Cantidad);
|
||||
if (act < min) {
|
||||
new_tr.style.backgroundColor = "lightcoral";
|
||||
}
|
||||
new_tr.onclick = () => {
|
||||
setUrlHash("materiales," + data._key);
|
||||
};
|
||||
tablebody_EL.append(new_tr);
|
||||
});
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
setUrlHash("materiales," + safeuuid(""));
|
||||
};
|
||||
},
|
||||
}
|
||||
}
|
||||
gun
|
||||
.get(TABLE)
|
||||
.get("materiales")
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER = _ev;
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
setUrlHash("materiales," + safeuuid(""));
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -198,23 +198,21 @@ PAGES.personas = {
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER = _ev;
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
rows[key] = data;
|
||||
} else {
|
||||
add_row(data, key);
|
||||
delete rows[key];
|
||||
}
|
||||
render();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
|
||||
@@ -58,23 +58,21 @@ PAGES.resumen_diario = {
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER2 = _ev;
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
materiales_low[key] = data;
|
||||
} else {
|
||||
delete materiales_low[key];
|
||||
}
|
||||
render_materialesLow();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
materiales_low[key] = data;
|
||||
} else {
|
||||
add_row(data, key);
|
||||
delete materiales_low[key];
|
||||
}
|
||||
render_materialesLow();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
function render_personasHigh() {
|
||||
@@ -123,23 +121,21 @@ PAGES.resumen_diario = {
|
||||
.map()
|
||||
.on((data, key, _msg, _ev) => {
|
||||
EVENTLISTENER = _ev;
|
||||
if (data != null) {
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
personas_high[key] = data;
|
||||
} else {
|
||||
delete personas_high[key];
|
||||
}
|
||||
render_personasHigh();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
function add_row(data, key) {
|
||||
if (data != null) {
|
||||
data["_key"] = key;
|
||||
personas_high[key] = data;
|
||||
} else {
|
||||
add_row(data, key);
|
||||
delete personas_high[key];
|
||||
}
|
||||
render_personasHigh();
|
||||
}
|
||||
if (typeof data == "string") {
|
||||
SEA.decrypt(data, SECRET, (data) => {
|
||||
add_row(data, key);
|
||||
});
|
||||
} else {
|
||||
add_row(data, key);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user