Mejoras generales, rediseño de Gest-Aula, borrado de modulos sin usar y Mensajes, movido el resumen diario a gest-aula.
This commit is contained in:
@@ -65,7 +65,8 @@ a:hover {
|
||||
@media print {
|
||||
.supermesh-indicator,
|
||||
.no_print,
|
||||
.no_print * {
|
||||
.no_print *,
|
||||
.saveico, .delico, .opicon {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,15 +85,11 @@
|
||||
<script src="page/dataman.js"></script>
|
||||
<script src="page/aulas.js"></script>
|
||||
<script src="page/materiales.js"></script>
|
||||
<script src="page/resumen_diario.js"></script>
|
||||
<script src="page/personas.js"></script>
|
||||
<script src="page/supercafe.js"></script>
|
||||
<!-- <script src="page/avisos.js"></script> -->
|
||||
<script src="page/comedor.js"></script>
|
||||
<script src="page/notas.js"></script>
|
||||
<script src="page/mensajes.js"></script>
|
||||
<script src="page/panel.js"></script>
|
||||
<!-- <script src="page/chat.js"></script> -->
|
||||
<script src="page/buscar.js"></script>
|
||||
<script src="page/pagos.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
PERMS['aulas'] = 'Aulas (Solo docentes!)';
|
||||
PERMS['aulas:resumen_diario'] = '> Resumen diario';
|
||||
PAGES.aulas = {
|
||||
//navcss: "btn1",
|
||||
Title: 'Gest-Aula',
|
||||
@@ -13,168 +14,98 @@ PAGES.aulas = {
|
||||
var data_Tareas = safeuuid();
|
||||
var data_Diario = safeuuid();
|
||||
var data_Weather = safeuuid();
|
||||
var link_alertas = safeuuid();
|
||||
var link_diario = safeuuid();
|
||||
var link_actividades = safeuuid();
|
||||
container.innerHTML = html`
|
||||
<h1>Gestión del Aula</h1>
|
||||
<div>
|
||||
<fieldset style="float: left;">
|
||||
<legend><img src="${PAGES.notas.icon}" height="20" /> Notas esenciales</legend>
|
||||
<a class="button" style="font-size: 25px;" href="#notas,inicio_dia"
|
||||
>Como iniciar el día</a
|
||||
>
|
||||
<a class="button" style="font-size: 25px;" href="#notas,realizacion_cafe"
|
||||
>Como realizar el café</a
|
||||
>
|
||||
<a class="button" style="font-size: 25px;" href="#notas,fin_dia">Como acabar el día</a>
|
||||
<a class="button" style="font-size: 25px;" href="#notas,horario">Horario</a>
|
||||
<a class="button" style="font-size: 25px;" href="#notas,tareas">Tareas</a>
|
||||
<legend>Atajos de hoy</legend>
|
||||
<a class="button" id="${link_alertas}" href="#notas,alertas">
|
||||
Alertas
|
||||
</a>
|
||||
<a class="button btn2" href="#aulas,solicitudes,${safeuuid('')}">
|
||||
Solicitar material
|
||||
</a>
|
||||
<a class="button" id="${link_diario}" href="#aulas,informes,diario-${CurrentISODate()}">
|
||||
Informe
|
||||
</a>
|
||||
<a class="button" id="${link_actividades}" href="#aulas,informes,actividades-${CurrentISODate()}">
|
||||
Actividades
|
||||
</a>
|
||||
<a class="button btn5" href="#aulas,ordenadores">
|
||||
Ordenadores
|
||||
</a>
|
||||
<a class="button btn6" href="#aulas,resumen_diario">
|
||||
Resumen Diario
|
||||
</a>
|
||||
</fieldset>
|
||||
<fieldset style="float: left;">
|
||||
<legend>Acciones</legend>
|
||||
<a class="button" style="font-size: 25px;" href="#aulas,solicitudes"
|
||||
><img src="${PAGES.materiales.icon}" height="20" /> Solicitudes de material</a
|
||||
>
|
||||
<a
|
||||
class="button"
|
||||
style="font-size: 25px;"
|
||||
href="#aulas,informes,diario-${CurrentISODate()}"
|
||||
>Diario de hoy</a
|
||||
>
|
||||
<a class="button rojo" style="font-size: 25px;" href="#notas,alertas"
|
||||
><img src="${PAGES.notas.icon}" height="20" /> Ver Alertas</a
|
||||
>
|
||||
<a class="button" style="font-size: 25px;" href="#aulas,informes"
|
||||
><img src="${PAGES.aulas.icon}" height="20" /> Informes y diarios</a
|
||||
>
|
||||
<a class="button btn4" style="font-size: 25px;" href="#supercafe"
|
||||
><img src="${PAGES.supercafe.icon}" height="20" /> Ver comandas</a
|
||||
>
|
||||
<a class="button btn8" style="font-size: 25px;" href="#aulas,ordenadores"
|
||||
><img src="${PAGES.aulas.icon}" height="20" /> Control de ordenadores</a
|
||||
>
|
||||
</fieldset>
|
||||
<fieldset style="float: left;">
|
||||
<legend>Datos de hoy</legend>
|
||||
|
||||
<span
|
||||
class="btn7"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black; max-width: 25rem;"
|
||||
><b>Menú Comedor:</b> <br /><span id="${data_Comedor}">Cargando...</span></span
|
||||
>
|
||||
<span
|
||||
class="btn6"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black; max-width: 25rem;"
|
||||
><b>Tareas:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Tareas}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
class="btn5"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black; max-width: 25rem;"
|
||||
><b>Diario:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Diario}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
class="btn4"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black; max-width: 25rem;"
|
||||
><b>Clima:</b> <br /><img
|
||||
loading="lazy"
|
||||
style="padding: 15px; background-color: white; width: 245px;"
|
||||
id="${data_Weather}"
|
||||
/></span>
|
||||
<a class="button" style="font-size: 25px;" href="#aulas,solicitudes">
|
||||
Solicitudes de materiales
|
||||
</a>
|
||||
<a class="button" style="font-size: 25px;" href="#aulas,informes">
|
||||
Informes
|
||||
</a>
|
||||
</fieldset>
|
||||
</div>
|
||||
`;
|
||||
|
||||
//#region Cargar Clima
|
||||
// Get location from DB settings.weather_location; if missing ask user and save it
|
||||
// url format: https://wttr.in/<loc>?F0m
|
||||
DB.get('settings', 'weather_location').then((loc) => {
|
||||
if (!loc) {
|
||||
loc = prompt('Introduce tu ubicación para el clima (ciudad, país):', 'Madrid, Spain');
|
||||
if (loc) {
|
||||
DB.put('settings', 'weather_location', loc);
|
||||
|
||||
//#region Contar alertas activas y mostrarlas en el botón
|
||||
DB.get('notas', 'alertas')
|
||||
.then((res) => TS_decrypt(res, SECRET, (data) => {
|
||||
var count = 0;
|
||||
// Sumar el total de alertas activas, cada linea de "Contenido"
|
||||
// es una alerta, aunque podrían hacerse varias por nota.
|
||||
// Ignora lineas que no empiezen por > (por si el profesor escribe algo que no es una alerta)
|
||||
data.Contenido.split('\n').forEach((line) => {
|
||||
if (line.trim().startsWith('>')) count++;
|
||||
});
|
||||
if (count > 0) {
|
||||
document.getElementById(link_alertas).innerText = `Alertas (${count})`;
|
||||
document.getElementById(link_alertas).classList.add('rojo');
|
||||
} else {
|
||||
document.getElementById(link_alertas).innerText = 'Alertas';
|
||||
document.getElementById(link_alertas).classList.remove('rojo');
|
||||
}
|
||||
}
|
||||
if (loc) {
|
||||
document.getElementById(data_Weather).src =
|
||||
'https://wttr.in/' + encodeURIComponent(loc) + '_IF0m_background=FFFFFF.png';
|
||||
}))
|
||||
.catch((e) => {
|
||||
console.warn('Error contando alertas activas', e);
|
||||
});
|
||||
//#endregion Contar alertas activas
|
||||
//#region Comprobar si hay un diario para hoy y marcar el botón
|
||||
DB.get('aulas_informes', 'diario-' + CurrentISODate())
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
document.getElementById(link_diario).classList.add('btn2');
|
||||
} else {
|
||||
document.getElementById(link_diario).classList.remove('btn2');
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('Error comprobando diario de hoy', e);
|
||||
});
|
||||
//#endregion Comprobar diario
|
||||
//#region Comprobar si hay un informe de actividades para hoy y contar las actividades (mismo formato que alertas)
|
||||
DB.get('aulas_informes', 'actividades-' + CurrentISODate()).then((res) => TS_decrypt(res, SECRET, (data) => {
|
||||
var count = 0;
|
||||
data.Contenido.split('\n').forEach((line) => {
|
||||
if (line.trim().startsWith('>')) count++;
|
||||
});
|
||||
if (count > 0) {
|
||||
document.getElementById(link_actividades).innerText = `Actividades (${count})`;
|
||||
document.getElementById(link_actividades).classList.add('btn4');
|
||||
} else {
|
||||
document.getElementById(data_Weather).src = 'https://wttr.in/_IF0m_background=FFFFFF.png';
|
||||
document.getElementById(link_actividades).innerText = 'Actividades';
|
||||
document.getElementById(link_actividades).classList.remove('btn4');
|
||||
}
|
||||
}))
|
||||
.catch((e) => {
|
||||
console.warn('Error comprobando actividades de hoy', e);
|
||||
});
|
||||
//#endregion Cargar Clima
|
||||
//#region Cargar Comedor
|
||||
DB.get('comedor', CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Platos = data.Platos || 'No hay platos registrados para hoy.';
|
||||
// Display platos
|
||||
document.getElementById(data_Comedor).innerHTML = data.Platos.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'comedor',
|
||||
CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Comedor
|
||||
//#region Cargar Tareas
|
||||
DB.get('notas', 'tareas').then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay tareas.';
|
||||
// Display platos
|
||||
document.getElementById(data_Tareas).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'notas',
|
||||
'tareas'
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Tareas
|
||||
//#region Cargar Diario
|
||||
DB.get('aulas_informes', 'diario-' + CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay un diario.';
|
||||
// Display platos
|
||||
document.getElementById(data_Diario).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'aulas_informes',
|
||||
'diario-' + CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Diario
|
||||
//#endregion Comprobar actividades
|
||||
},
|
||||
_solicitudes: function () {
|
||||
const tablebody = safeuuid();
|
||||
@@ -190,7 +121,7 @@ Cargando...</pre
|
||||
[
|
||||
{
|
||||
key: 'Solicitante',
|
||||
type: 'persona',
|
||||
type: 'persona-nombre',
|
||||
default: '',
|
||||
label: 'Solicitante',
|
||||
},
|
||||
@@ -233,8 +164,14 @@ Cargando...</pre
|
||||
><br /><br />
|
||||
</label>
|
||||
<hr />
|
||||
<button class="btn5" id="${btn_guardar}">Guardar</button>
|
||||
<button class="rojo" id="${btn_borrar}">Borrar</button>
|
||||
<button class="saveico" id="${btn_guardar}">
|
||||
<img src="static/floppy_disk_green.png" />
|
||||
<br>Guardar
|
||||
</button>
|
||||
<button class="delico" id="${btn_borrar}">
|
||||
<img src="static/garbage.png" />
|
||||
<br>Borrar
|
||||
</button>
|
||||
</fieldset>
|
||||
`;
|
||||
(async () => {
|
||||
@@ -311,7 +248,7 @@ Cargando...</pre
|
||||
<div
|
||||
style="display: inline-block; border: 2px solid black; padding: 5px; border-radius: 5px;"
|
||||
>
|
||||
<b>Diario:</b><br />
|
||||
<b>Por fecha:</b><br />
|
||||
<input type="date" id="${field_new_byday}" value="${CurrentISODate()}" />
|
||||
<button id="${btn_new_byday}">Abrir / Nuevo</button>
|
||||
</div>
|
||||
@@ -324,7 +261,7 @@ Cargando...</pre
|
||||
[
|
||||
{
|
||||
key: 'Autor',
|
||||
type: 'persona',
|
||||
type: 'persona-nombre',
|
||||
default: '',
|
||||
label: 'Autor',
|
||||
},
|
||||
@@ -367,7 +304,10 @@ Cargando...</pre
|
||||
var title = '';
|
||||
if (mid.startsWith('diario-')) {
|
||||
var date = mid.replace('diario-', '').split('-');
|
||||
title = 'Diario ' + date[2] + '/' + date[1] + '/' + date[0];
|
||||
title = 'Informe del ' + date[2] + '/' + date[1] + '/' + date[0];
|
||||
} else if (mid.startsWith('actividades-')) {
|
||||
var date = mid.replace('actividades-', '').split('-');
|
||||
title = 'Actividades para el ' + date[2] + '/' + date[1] + '/' + date[0];
|
||||
}
|
||||
container.innerHTML = html`
|
||||
<a class="button" href="#aulas,informes">← Volver a informes</a>
|
||||
@@ -388,8 +328,14 @@ Cargando...</pre
|
||||
><br /><br />
|
||||
</label>
|
||||
<hr />
|
||||
<button class="btn5" id="${btn_guardar}">Guardar</button>
|
||||
<button class="rojo" id="${btn_borrar}">Borrar</button>
|
||||
<button class="saveico" id="${btn_guardar}">
|
||||
<img src="static/floppy_disk_green.png" />
|
||||
<br>Guardar
|
||||
</button>
|
||||
<button class="delico" id="${btn_borrar}">
|
||||
<img src="static/garbage.png" />
|
||||
<br>Borrar
|
||||
</button>
|
||||
</fieldset>
|
||||
`;
|
||||
(async () => {
|
||||
@@ -659,6 +605,141 @@ Cargando...</pre
|
||||
await loadData();
|
||||
};
|
||||
},
|
||||
_resumen_diario: function () {
|
||||
var data_Comedor = safeuuid();
|
||||
var data_Tareas = safeuuid();
|
||||
var data_Diario = safeuuid();
|
||||
var data_Weather = safeuuid();
|
||||
if (!checkRole('aulas:resumen_diario')) {
|
||||
setUrlHash('index');
|
||||
return;
|
||||
}
|
||||
container.innerHTML = html`
|
||||
<h1>Resumen Diario ${CurrentISODate()}</h1>
|
||||
<button onclick="print()" class="no_print">Imprimir</button>
|
||||
<a class="button no_print" href="#aulas">← Volver a Gestión de Aulas</a>
|
||||
<br /><span
|
||||
class="btn7"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Menú Comedor:</b> <br /><span id="${data_Comedor}">Cargando...</span></span
|
||||
>
|
||||
<br /><span
|
||||
class="btn6"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Tareas:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Tareas}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<br /><span
|
||||
class="btn5"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Informe:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Diario}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<br /><span
|
||||
class="btn4"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Clima:</b> <br /><img
|
||||
loading="lazy"
|
||||
style="padding: 15px; background-color: white; height: 75px;"
|
||||
id="${data_Weather}"
|
||||
/></span>
|
||||
`;
|
||||
|
||||
//#region Cargar Clima
|
||||
// Get location from DB settings.weather_location; if missing ask user and save it
|
||||
// url format: https://wttr.in/<loc>?F0m
|
||||
DB.get('settings', 'weather_location').then((loc) => {
|
||||
if (!loc) {
|
||||
loc = prompt('Introduce tu ubicación para el clima (ciudad, país):', 'Madrid, Spain');
|
||||
if (loc) {
|
||||
DB.put('settings', 'weather_location', loc);
|
||||
}
|
||||
}
|
||||
if (loc) {
|
||||
document.getElementById(data_Weather).src =
|
||||
'https://wttr.in/' + encodeURIComponent(loc) + '_IF0m_background=FFFFFF.png';
|
||||
} else {
|
||||
document.getElementById(data_Weather).src = 'https://wttr.in/_IF0m_background=FFFFFF.png';
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Clima
|
||||
//#region Cargar Comedor
|
||||
DB.get('comedor', CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
if (!data.Primero) {
|
||||
var result = 'No hay información del comedor para hoy.';
|
||||
} else {
|
||||
var result = data.Primero + "<br>" + data.Segundo + "<br>" + data.Postre;
|
||||
}
|
||||
// Display platos
|
||||
document.getElementById(data_Comedor).innerHTML = result;
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'comedor',
|
||||
CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Comedor
|
||||
//#region Cargar Tareas
|
||||
DB.get('notas', 'tareas').then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay tareas.';
|
||||
// Display tareas
|
||||
document.getElementById(data_Tareas).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'notas',
|
||||
'tareas'
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Tareas
|
||||
//#region Cargar Diario
|
||||
DB.get('aulas_informes', 'diario-' + CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay un diario.';
|
||||
// Display platos
|
||||
document.getElementById(data_Diario).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'aulas_informes',
|
||||
'diario-' + CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Diario
|
||||
},
|
||||
edit: function (fsection) {
|
||||
if (!checkRole('aulas')) {
|
||||
setUrlHash('index');
|
||||
@@ -678,6 +759,9 @@ Cargando...</pre
|
||||
case 'ordenadores':
|
||||
this._ordenadores();
|
||||
break;
|
||||
case 'resumen_diario':
|
||||
this._resumen_diario();
|
||||
break;
|
||||
default:
|
||||
this.index();
|
||||
break;
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
PERMS['avisos'] = 'Avisos';
|
||||
PERMS['avisos:edit'] = '> Editar';
|
||||
PAGES.avisos = {
|
||||
navcss: 'btn5',
|
||||
icon: 'static/appico/File_Plugin.svg',
|
||||
AccessControl: true,
|
||||
Title: 'Avisos',
|
||||
edit: function (mid) {
|
||||
if (!checkRole('avisos:edit')) {
|
||||
setUrlHash('avisos');
|
||||
return;
|
||||
}
|
||||
var nameh1 = safeuuid();
|
||||
var field_fecha = safeuuid();
|
||||
var field_asunto = safeuuid();
|
||||
var field_origen = safeuuid();
|
||||
var field_destino = safeuuid();
|
||||
var field_estado = safeuuid();
|
||||
var field_mensaje = safeuuid();
|
||||
var field_respuesta = safeuuid();
|
||||
var btn_leer = safeuuid();
|
||||
var btn_desleer = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_borrar = safeuuid();
|
||||
var div_actions = safeuuid();
|
||||
container.innerHTML = html`
|
||||
<h1>Aviso <code id="${nameh1}"></code></h1>
|
||||
<fieldset style="float: left;">
|
||||
<legend>Valores</legend>
|
||||
<label>
|
||||
Fecha<br />
|
||||
<input readonly disabled type="text" id="${field_fecha}" value="" /><br /><br />
|
||||
</label>
|
||||
<label>
|
||||
Asunto<br />
|
||||
<input type="text" id="${field_asunto}" value="" /><br /><br />
|
||||
</label>
|
||||
<input type="hidden" id="${field_origen}" />
|
||||
<input type="hidden" id="${field_destino}" />
|
||||
<div id="${div_actions}"></div>
|
||||
<label>
|
||||
Mensaje<br />
|
||||
<textarea id="${field_mensaje}"></textarea><br /><br />
|
||||
</label>
|
||||
<label>
|
||||
Respuesta<br />
|
||||
<textarea id="${field_respuesta}"></textarea><br /><br />
|
||||
</label>
|
||||
<label>
|
||||
Estado<br />
|
||||
<input readonly disabled type="text" id="${field_estado}" value="" />
|
||||
<br />
|
||||
<button id="${btn_leer}">Leido</button>
|
||||
<button id="${btn_desleer}">No leido</button>
|
||||
<br />
|
||||
</label>
|
||||
<hr />
|
||||
<button class="btn5" id="${btn_guardar}">Guardar</button>
|
||||
<button class="rojo" id="${btn_borrar}">Borrar</button>
|
||||
</fieldset>
|
||||
`;
|
||||
document.getElementById(btn_leer).onclick = () => {
|
||||
document.getElementById(field_estado).value = 'leido';
|
||||
};
|
||||
document.getElementById(btn_desleer).onclick = () => {
|
||||
document.getElementById(field_estado).value = 'por_leer';
|
||||
};
|
||||
var divact = document.getElementById(div_actions);
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
'',
|
||||
(value) => {
|
||||
document.getElementById(field_origen).value = value;
|
||||
},
|
||||
'Origen'
|
||||
);
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
'',
|
||||
(value) => {
|
||||
document.getElementById(field_destino).value = value;
|
||||
},
|
||||
'Destino'
|
||||
);
|
||||
(async () => {
|
||||
const data = await DB.get('notificaciones', mid);
|
||||
function load_data(data, ENC = '') {
|
||||
document.getElementById(nameh1).innerText = mid;
|
||||
document.getElementById(field_fecha).value = data['Fecha'] || CurrentISODate() || '';
|
||||
document.getElementById(field_asunto).value = data['Asunto'] || '';
|
||||
document.getElementById(field_mensaje).value = data['Mensaje'] || '';
|
||||
document.getElementById(field_origen).value = data['Origen'] || SUB_LOGGED_IN_ID || '';
|
||||
document.getElementById(field_destino).value = data['Destino'] || '';
|
||||
document.getElementById(field_estado).value = data['Estado'] || '%%' || '';
|
||||
document.getElementById(field_respuesta).value = data['Respuesta'] || '';
|
||||
|
||||
// Persona select
|
||||
divact.innerHTML = '';
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
data['Origen'] || '',
|
||||
(value) => {
|
||||
document.getElementById(field_origen).value = value;
|
||||
},
|
||||
'Origen'
|
||||
);
|
||||
addCategory_Personas(
|
||||
divact,
|
||||
SC_Personas,
|
||||
data['Destino'] || '',
|
||||
(value) => {
|
||||
document.getElementById(field_destino).value = value;
|
||||
},
|
||||
'Destino'
|
||||
);
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
load_data(data, '%E');
|
||||
},
|
||||
'notificaciones',
|
||||
mid
|
||||
);
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
})();
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
// Check if button is already disabled to prevent double-clicking
|
||||
var guardarBtn = document.getElementById(btn_guardar);
|
||||
if (guardarBtn.disabled) return;
|
||||
|
||||
// Validate before disabling button
|
||||
if (document.getElementById(field_origen).value == '') {
|
||||
alert('¡Hay que elegir una persona de origen!');
|
||||
return;
|
||||
}
|
||||
if (document.getElementById(field_destino).value == '') {
|
||||
alert('¡Hay que elegir una persona de origen!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable button after validation passes
|
||||
guardarBtn.disabled = true;
|
||||
guardarBtn.style.opacity = '0.5';
|
||||
|
||||
var data = {
|
||||
Fecha: document.getElementById(field_fecha).value,
|
||||
Origen: document.getElementById(field_origen).value,
|
||||
Destino: document.getElementById(field_destino).value,
|
||||
Mensaje: document.getElementById(field_mensaje).value,
|
||||
Respuesta: document.getElementById(field_respuesta).value,
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
Estado: document.getElementById(field_estado).value.replace('%%', 'por_leer'),
|
||||
};
|
||||
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);
|
||||
guardarBtn.disabled = false;
|
||||
guardarBtn.style.opacity = '1';
|
||||
document.getElementById('actionStatus').style.display = 'none';
|
||||
toastr.error('Error al guardar la notificación');
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm('¿Quieres borrar esta notificación?') == true) {
|
||||
DB.del('notificaciones', mid).then(() => {
|
||||
toastr.error('Borrado!');
|
||||
setTimeout(() => {
|
||||
setUrlHash('avisos');
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
index: function () {
|
||||
if (!checkRole('avisos')) {
|
||||
setUrlHash('index');
|
||||
return;
|
||||
}
|
||||
const tablebody = safeuuid();
|
||||
var btn_new = safeuuid();
|
||||
container.innerHTML = html`
|
||||
<h1>Avisos</h1>
|
||||
<button id="${btn_new}">Nuevo aviso</button>
|
||||
<div id="cont"></div>
|
||||
`;
|
||||
TS_IndexElement(
|
||||
'avisos',
|
||||
[
|
||||
{
|
||||
key: 'Origen',
|
||||
type: 'persona',
|
||||
default: '',
|
||||
label: 'Origen',
|
||||
},
|
||||
{
|
||||
key: 'Destino',
|
||||
type: 'persona',
|
||||
default: '',
|
||||
label: 'Destino',
|
||||
},
|
||||
{
|
||||
key: 'Asunto',
|
||||
type: 'raw',
|
||||
default: '',
|
||||
label: 'Asunto',
|
||||
},
|
||||
{
|
||||
key: 'Estado',
|
||||
type: 'raw',
|
||||
default: '',
|
||||
label: 'Estado',
|
||||
},
|
||||
],
|
||||
'notificaciones',
|
||||
document.querySelector('#cont'),
|
||||
(data, new_tr) => {
|
||||
new_tr.style.backgroundColor = '#FFCCCB';
|
||||
if (data.Estado == 'leido') {
|
||||
new_tr.style.backgroundColor = 'lightgreen';
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!checkRole('avisos:edit')) {
|
||||
document.getElementById(btn_new).style.display = 'none';
|
||||
} else {
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
setUrlHash('avisos,' + safeuuid(''));
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -285,9 +285,9 @@ PAGES.materiales = {
|
||||
<div style="display: flex;flex-direction: column;align-items: stretch;gap: 6px;min-width: 180px;flex: 1 1 220px;">
|
||||
<label for="${mov_tipo}">Tipo</label>
|
||||
<select id="${mov_tipo}" style="flex: 1;">
|
||||
<option value="Entrada">Entrada</option>
|
||||
<option value="Salida">Salida</option>
|
||||
<option value="Ajuste">Ajuste</option>
|
||||
<option value="Entrada">Entrada - Meter al almacen</option>
|
||||
<option value="Salida">Salida - Sacar del almacen</option>
|
||||
<option value="Ajuste">Ajuste - Existencias actuales</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="display: flex;flex-direction: column;align-items: stretch;gap: 6px;min-width: 180px;flex: 1 1 220px;">
|
||||
@@ -424,7 +424,7 @@ PAGES.materiales = {
|
||||
var nota = document.getElementById(mov_nota).value || '';
|
||||
var actual = parseNum(document.getElementById(field_cantidad).value, 0);
|
||||
|
||||
if (!Number.isFinite(cantidadMov) || cantidadMov <= 0) {
|
||||
if ((!Number.isFinite(cantidadMov) || cantidadMov <= 0) && tipo !== 'Ajuste') {
|
||||
toastr.warning('Indica una cantidad válida para el movimiento');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
PERMS['mensajes'] = 'Mensajes';
|
||||
PERMS['mensajes:edit'] = '> Editar';
|
||||
PAGES.mensajes = {
|
||||
navcss: 'btn5',
|
||||
icon: 'static/appico/message.png',
|
||||
AccessControl: true,
|
||||
// AccessControlRole is not needed.
|
||||
Title: 'Mensajes',
|
||||
edit: function (mid) {
|
||||
if (!checkRole('mensajes:edit')) {
|
||||
setUrlHash('mensajes');
|
||||
return;
|
||||
}
|
||||
var nameh1 = safeuuid();
|
||||
var field_asunto = safeuuid();
|
||||
var field_contenido = safeuuid();
|
||||
var field_autor = safeuuid();
|
||||
var field_files = safeuuid();
|
||||
var attachments_list = safeuuid();
|
||||
var btn_guardar = safeuuid();
|
||||
var btn_borrar = safeuuid();
|
||||
var div_actions = safeuuid();
|
||||
container.innerHTML = html`
|
||||
<h1>Mensaje <code id="${nameh1}"></code></h1>
|
||||
<fieldset style="float: none; width: calc(100% - 40px);max-width: none;">
|
||||
<legend>Valores</legend>
|
||||
<div style="max-width: 400px;">
|
||||
<label>
|
||||
Asunto<br />
|
||||
<input type="text" id="${field_asunto}" value="" /><br /><br />
|
||||
</label>
|
||||
<label>
|
||||
Origen<br />
|
||||
<input type="text" id="${field_autor}" value="" /><br /><br />
|
||||
</label>
|
||||
</div>
|
||||
<label>
|
||||
Contenido<br />
|
||||
<textarea
|
||||
id="${field_contenido}"
|
||||
style="width: calc(100% - 15px); height: 400px;"
|
||||
></textarea
|
||||
><br /><br />
|
||||
</label>
|
||||
<label>
|
||||
Adjuntos (Fotos o archivos)<br />
|
||||
<input type="file" id="${field_files}" multiple /><br /><br />
|
||||
<div id="${attachments_list}"></div>
|
||||
</label>
|
||||
<hr />
|
||||
<button class="saveico" id="${btn_guardar}">
|
||||
<img src="static/floppy_disk_green.png" />
|
||||
<br>Guardar
|
||||
</button>
|
||||
<button class="delico" id="${btn_borrar}">
|
||||
<img src="static/garbage.png" />
|
||||
<br>Borrar
|
||||
</button>
|
||||
<button class="opicon" onclick="setUrlHash('mensajes')" style="float: right;"> <!-- Align to the right -->
|
||||
<img src="static/exit.png" />
|
||||
<br>Salir
|
||||
</button>
|
||||
<button class="opicon" onclick="window.print()" style="float: right;"> <!-- Align to the right -->
|
||||
<img src="static/printer2.png" />
|
||||
<br>Imprimir
|
||||
</button>
|
||||
</fieldset>
|
||||
`;
|
||||
DB.get('mensajes', mid).then((data) => {
|
||||
function load_data(data, ENC = '') {
|
||||
document.getElementById(nameh1).innerText = mid;
|
||||
document.getElementById(field_asunto).value = data['Asunto'] || '';
|
||||
document.getElementById(field_contenido).value = data['Contenido'] || '';
|
||||
document.getElementById(field_autor).value = data['Autor'] || SUB_LOGGED_IN_DETAILS["Nombre"] || '';
|
||||
|
||||
// Mostrar adjuntos existentes (si los hay).
|
||||
// No confiar en `data._attachments` porque `DB.get` devuelve solo `doc.data`.
|
||||
const attachContainer = document.getElementById(attachments_list);
|
||||
attachContainer.innerHTML = '';
|
||||
// Usar API de DB para listar attachments (no acceder a internals desde la UI)
|
||||
DB.listAttachments('mensajes', mid)
|
||||
.then((list) => {
|
||||
if (!list || !Array.isArray(list)) return;
|
||||
list.forEach((att) => {
|
||||
addAttachmentRow(att.name, att.dataUrl);
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('listAttachments error', e);
|
||||
});
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(data, SECRET, (data) => {
|
||||
load_data(data, '%E');
|
||||
});
|
||||
} else {
|
||||
load_data(data || {});
|
||||
}
|
||||
});
|
||||
// gestión de archivos seleccionados antes de guardar
|
||||
const attachmentsToUpload = [];
|
||||
function addAttachmentRow(name, url) {
|
||||
const attachContainer = document.getElementById(attachments_list);
|
||||
const idRow = safeuuid();
|
||||
const isImage = url && url.indexOf('data:image') === 0;
|
||||
const preview = isImage
|
||||
? `<img src="${url}" height="80" style="margin-right:8px;">`
|
||||
: `<a href="${url}" target="_blank">${name}</a>`;
|
||||
const html = `
|
||||
<div id="${idRow}" style="display:flex;align-items:center;margin:6px 0;border:1px solid #ddd;padding:6px;border-radius:6px;">
|
||||
<div style="flex:1">${preview}<strong style="margin-left:8px">${name}</strong></div>
|
||||
<div><button type="button" class="rojo" data-name="${name}">Borrar</button></div>
|
||||
</div>`;
|
||||
attachContainer.insertAdjacentHTML('beforeend', html);
|
||||
attachContainer.querySelectorAll(`button[data-name="${name}"]`).forEach((btn) => {
|
||||
btn.onclick = () => {
|
||||
if (!confirm('¿Borrar este adjunto?')) return;
|
||||
// Usar API pública en DB para borrar metadata del attachment
|
||||
DB.deleteAttachment('mensajes', mid, name)
|
||||
.then((ok) => {
|
||||
if (ok) {
|
||||
document.getElementById(idRow).remove();
|
||||
toastr.error('Adjunto borrado');
|
||||
} else {
|
||||
toastr.error('No se pudo borrar el adjunto');
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('deleteAttachment error', e);
|
||||
toastr.error('Error borrando adjunto');
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById(field_files).addEventListener('change', function (e) {
|
||||
const files = Array.from(e.target.files || []);
|
||||
files.forEach((file) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (ev) {
|
||||
const dataUrl = ev.target.result;
|
||||
attachmentsToUpload.push({
|
||||
name: file.name,
|
||||
data: dataUrl,
|
||||
type: file.type || 'application/octet-stream',
|
||||
});
|
||||
// mostrar preview temporal
|
||||
addAttachmentRow(file.name, dataUrl);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
// limpiar input para permitir re-subidas del mismo archivo
|
||||
e.target.value = '';
|
||||
});
|
||||
document.getElementById(btn_guardar).onclick = () => {
|
||||
// Disable button to prevent double-clicking
|
||||
var guardarBtn = document.getElementById(btn_guardar);
|
||||
if (guardarBtn.disabled) return;
|
||||
|
||||
guardarBtn.disabled = true;
|
||||
guardarBtn.style.opacity = '0.5';
|
||||
|
||||
var data = {
|
||||
Autor: document.getElementById(field_autor).value,
|
||||
Contenido: document.getElementById(field_contenido).value,
|
||||
Asunto: document.getElementById(field_asunto).value,
|
||||
};
|
||||
document.getElementById('actionStatus').style.display = 'block';
|
||||
DB.put('mensajes', mid, data)
|
||||
.then(() => {
|
||||
// subir attachments si los hay
|
||||
const uploadPromises = [];
|
||||
attachmentsToUpload.forEach((att) => {
|
||||
if (DB.putAttachment) {
|
||||
uploadPromises.push(
|
||||
DB.putAttachment('mensajes', mid, att.name, att.data, att.type).catch((e) => {
|
||||
console.warn('putAttachment error', e);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
Promise.all(uploadPromises)
|
||||
.then(() => {
|
||||
// limpiar lista temporal y recargar attachments
|
||||
attachmentsToUpload.length = 0;
|
||||
try {
|
||||
// recargar lista actual sin salir
|
||||
const pouchId = 'mensajes:' + mid;
|
||||
if (DB && DB._internal && DB._internal.local) {
|
||||
DB._internal.local
|
||||
.get(pouchId, { attachments: true })
|
||||
.then((doc) => {
|
||||
const attachContainer = document.getElementById(attachments_list);
|
||||
attachContainer.innerHTML = '';
|
||||
if (doc && doc._attachments) {
|
||||
Object.keys(doc._attachments).forEach((name) => {
|
||||
try {
|
||||
const att = doc._attachments[name];
|
||||
if (att && att.data) {
|
||||
const durl =
|
||||
'data:' +
|
||||
(att.content_type || 'application/octet-stream') +
|
||||
';base64,' +
|
||||
att.data;
|
||||
addAttachmentRow(name, durl);
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
DB.getAttachment('mensajes', mid, name)
|
||||
.then((durl) => {
|
||||
addAttachmentRow(name, durl);
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
/* ignore reload errors */
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
toastr.success('Guardado!');
|
||||
setTimeout(() => {
|
||||
document.getElementById('actionStatus').style.display = 'none';
|
||||
setUrlHash('mensajes');
|
||||
}, SAVE_WAIT);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('Attachment upload error', e);
|
||||
document.getElementById('actionStatus').style.display = 'none';
|
||||
guardarBtn.disabled = false;
|
||||
guardarBtn.style.opacity = '1';
|
||||
toastr.error('Error al guardar los adjuntos');
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.warn('DB.put error', e);
|
||||
document.getElementById('actionStatus').style.display = 'none';
|
||||
guardarBtn.disabled = false;
|
||||
guardarBtn.style.opacity = '1';
|
||||
toastr.error('Error al guardar el mensaje');
|
||||
});
|
||||
};
|
||||
document.getElementById(btn_borrar).onclick = () => {
|
||||
if (confirm('¿Quieres borrar este mensaje?') == true) {
|
||||
DB.del('mensajes', mid).then(() => {
|
||||
toastr.error('Borrado!');
|
||||
setTimeout(() => {
|
||||
setUrlHash('mensajes');
|
||||
}, SAVE_WAIT);
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
index: function () {
|
||||
if (!checkRole('mensajes')) {
|
||||
setUrlHash('index');
|
||||
return;
|
||||
}
|
||||
const tablebody = safeuuid();
|
||||
var btn_new = safeuuid();
|
||||
container.innerHTML = html`
|
||||
<h1>Mensajes</h1>
|
||||
<button id="${btn_new}">Nuevo mensaje</button>
|
||||
<div id="cont"></div>
|
||||
`;
|
||||
TS_IndexElement(
|
||||
'mensajes',
|
||||
[
|
||||
{
|
||||
key: 'Autor',
|
||||
type: 'raw',
|
||||
default: '',
|
||||
label: 'Origen',
|
||||
},
|
||||
{
|
||||
key: 'Asunto',
|
||||
type: 'raw',
|
||||
default: '',
|
||||
label: 'Asunto',
|
||||
},
|
||||
],
|
||||
'mensajes',
|
||||
document.querySelector('#cont')
|
||||
);
|
||||
if (!checkRole('mensajes:edit')) {
|
||||
document.getElementById(btn_new).style.display = 'none';
|
||||
} else {
|
||||
document.getElementById(btn_new).onclick = () => {
|
||||
setUrlHash('mensajes,' + safeuuid(''));
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,138 +0,0 @@
|
||||
PERMS['resumen_diario'] = 'Resumen diario (Solo docentes!)';
|
||||
PAGES.resumen_diario = {
|
||||
icon: 'static/appico/calendar.png',
|
||||
navcss: 'btn3',
|
||||
AccessControl: true,
|
||||
Title: 'Resumen Diario',
|
||||
index: function () {
|
||||
var data_Comedor = safeuuid();
|
||||
var data_Tareas = safeuuid();
|
||||
var data_Diario = safeuuid();
|
||||
var data_Weather = safeuuid();
|
||||
if (!checkRole('resumen_diario')) {
|
||||
setUrlHash('index');
|
||||
return;
|
||||
}
|
||||
container.innerHTML = html`
|
||||
<h1>Resumen Diario ${CurrentISODate()}</h1>
|
||||
<button onclick="print()">Imprimir</button>
|
||||
<br /><span
|
||||
class="btn7"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Menú Comedor:</b> <br /><span id="${data_Comedor}">Cargando...</span></span
|
||||
>
|
||||
<br /><span
|
||||
class="btn6"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Tareas:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Tareas}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<br /><span
|
||||
class="btn5"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Diario:</b> <br />
|
||||
<pre style="overflow-wrap: break-word;white-space:pre-wrap;" id="${data_Diario}">
|
||||
Cargando...</pre
|
||||
>
|
||||
</span>
|
||||
<br /><span
|
||||
class="btn4"
|
||||
style="display: inline-block; margin: 5px; padding: 5px; border-radius: 5px; border: 2px solid black;"
|
||||
><b>Clima:</b> <br /><img
|
||||
loading="lazy"
|
||||
style="padding: 15px; background-color: white; height: 75px;"
|
||||
id="${data_Weather}"
|
||||
/></span>
|
||||
`;
|
||||
|
||||
//#region Cargar Clima
|
||||
// Get location from DB settings.weather_location; if missing ask user and save it
|
||||
// url format: https://wttr.in/<loc>?F0m
|
||||
DB.get('settings', 'weather_location').then((loc) => {
|
||||
if (!loc) {
|
||||
loc = prompt('Introduce tu ubicación para el clima (ciudad, país):', 'Madrid, Spain');
|
||||
if (loc) {
|
||||
DB.put('settings', 'weather_location', loc);
|
||||
}
|
||||
}
|
||||
if (loc) {
|
||||
document.getElementById(data_Weather).src =
|
||||
'https://wttr.in/' + encodeURIComponent(loc) + '_IF0m_background=FFFFFF.png';
|
||||
} else {
|
||||
document.getElementById(data_Weather).src = 'https://wttr.in/_IF0m_background=FFFFFF.png';
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Clima
|
||||
//#region Cargar Comedor
|
||||
DB.get('comedor', CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Platos = data.Platos || 'No hay platos registrados para hoy.';
|
||||
// Display platos
|
||||
document.getElementById(data_Comedor).innerHTML = data.Platos.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'comedor',
|
||||
CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Comedor
|
||||
//#region Cargar Tareas
|
||||
DB.get('notas', 'tareas').then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay tareas.';
|
||||
// Display platos
|
||||
document.getElementById(data_Tareas).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'notas',
|
||||
'tareas'
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Tareas
|
||||
//#region Cargar Diario
|
||||
DB.get('aulas_informes', 'diario-' + CurrentISODate()).then((data) => {
|
||||
function add_row(data) {
|
||||
// Fix newlines
|
||||
data.Contenido = data.Contenido || 'No hay un diario.';
|
||||
// Display platos
|
||||
document.getElementById(data_Diario).innerHTML = data.Contenido.replace(/\n/g, '<br>');
|
||||
}
|
||||
if (typeof data == 'string') {
|
||||
TS_decrypt(
|
||||
data,
|
||||
SECRET,
|
||||
(data, wasEncrypted) => {
|
||||
add_row(data || {});
|
||||
},
|
||||
'aulas_informes',
|
||||
'diario-' + CurrentISODate()
|
||||
);
|
||||
} else {
|
||||
add_row(data || {});
|
||||
}
|
||||
});
|
||||
//#endregion Cargar Diario
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user