Actualización
This commit is contained in:
704
js/auditoría.js
704
js/auditoría.js
@@ -1,352 +1,352 @@
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
$('div.modal#cargando').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
show: false,
|
||||
});
|
||||
const store = reactive({
|
||||
loading: false,
|
||||
perido: null,
|
||||
current: {
|
||||
comentario: '',
|
||||
clase_vista: null,
|
||||
empty: '',
|
||||
page: 1,
|
||||
maxPages: 10,
|
||||
perPage: 10,
|
||||
modal_state: "Cargando datos...",
|
||||
justificada: null,
|
||||
fechas_clicked: false,
|
||||
observaciones: false,
|
||||
},
|
||||
facultades: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_facultad.php');
|
||||
this.data = await res.json();
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
facultad_id: null,
|
||||
fecha: null,
|
||||
fecha_inicio: null,
|
||||
fecha_fin: null,
|
||||
profesor: null,
|
||||
periodo_id: null,
|
||||
bloque_horario: null,
|
||||
estados: [],
|
||||
switchFecha: false,
|
||||
async switchFechas() {
|
||||
const periodo = await fetch('action/periodo_datos.php');
|
||||
const periodo_data = await periodo.json();
|
||||
if (!store.filters.switchFecha) {
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch();
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
$(function () {
|
||||
store.filters.fecha_inicio = store.filters.fecha_fin = store.filters.fecha = null;
|
||||
$("#fecha, #fecha_inicio, #fecha_fin").datepicker({
|
||||
minDate: new Date(`${periodo_data.periodo_fecha_inicio}:00:00:00`),
|
||||
maxDate: new Date(`${periodo_data.fecha_final}:00:00:00`),
|
||||
dateFormat: "yy-mm-dd",
|
||||
showAnim: "slide",
|
||||
beforeShowDay: (date) => [(date.getDay() != 0), ""]
|
||||
});
|
||||
const fecha = $("#fecha"), inicio = $("#fecha_inicio"), fin = $("#fecha_fin");
|
||||
fecha.datepicker("setDate", new Date(`${periodo_data.fecha_final}:00:00:00`));
|
||||
inicio.on("change", function () {
|
||||
store.current.fechas_clicked = false;
|
||||
store.filters.fecha_inicio = inicio.val();
|
||||
fin.datepicker("option", "minDate", inicio.val());
|
||||
});
|
||||
fin.on("change", function () {
|
||||
store.current.fechas_clicked = false;
|
||||
store.filters.fecha_fin = fin.val();
|
||||
inicio.datepicker("option", "maxDate", fin.val());
|
||||
});
|
||||
fecha.on("change", async function () {
|
||||
store.filters.fecha = fecha.val();
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch(store.filters.fecha);
|
||||
$('div.modal#cargando').modal('hide');
|
||||
});
|
||||
});
|
||||
},
|
||||
async fetchByDate() {
|
||||
store.current.fechas_clicked = true;
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch(undefined, store.filters.fecha_inicio, store.filters.fecha_fin);
|
||||
store.current.page = 1;
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
estados: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_estado_supervisor.php');
|
||||
this.data = await res.json();
|
||||
},
|
||||
getEstado(id) {
|
||||
return this.data.find((estado) => estado.estado_supervisor_id === id) ?? {
|
||||
estado_color: 'dark',
|
||||
estado_icon: 'ing-cancelar',
|
||||
nombre: 'Sin registro',
|
||||
estado_supervisor_id: -1,
|
||||
};
|
||||
},
|
||||
printEstados() {
|
||||
if (store.filters.estados.length > 0)
|
||||
document.querySelector('#estados').innerHTML = store.filters.estados.map((estado) => `<span class="mx-2 badge badge-${store.estados.getEstado(estado).estado_color}">
|
||||
<i class="${store.estados.getEstado(estado).estado_icon}"></i> ${store.estados.getEstado(estado).nombre}
|
||||
</span>`).join('');
|
||||
else
|
||||
document.querySelector('#estados').innerHTML = `Todos los registros`;
|
||||
}
|
||||
},
|
||||
bloques_horario: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_grupo_horario.php');
|
||||
this.data = await res.json();
|
||||
if (this.data.every((bloque) => !bloque.selected))
|
||||
this.data[0].selected = true;
|
||||
},
|
||||
},
|
||||
toggle(arr, element) {
|
||||
const newArray = arr.includes(element) ? arr.filter((item) => item !== element) : [...arr, element];
|
||||
// if all are selected, then unselect all
|
||||
if (newArray.length === (this.estados.data.length + 1)) {
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('#dlAsistencia>ul>li.selected').forEach(element => element.classList.remove('selected'));
|
||||
}, 100);
|
||||
return [];
|
||||
}
|
||||
return newArray;
|
||||
},
|
||||
async justificar() {
|
||||
if (!store.current.justificada)
|
||||
return;
|
||||
store.current.justificada.registro_justificada = true;
|
||||
let data;
|
||||
try {
|
||||
const res = await fetch('action/justificar.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(store.current.justificada)
|
||||
});
|
||||
data = await res.json();
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al justificar');
|
||||
store.current.justificada = store.current.clone_justificada;
|
||||
}
|
||||
finally {
|
||||
delete store.current.clone_justificada;
|
||||
}
|
||||
store.current.justificada.justificador_nombre = data.justificador_nombre;
|
||||
store.current.justificada.justificador_clave = data.justificador_clave;
|
||||
store.current.justificada.justificador_facultad = data.justificador_facultad;
|
||||
store.current.justificada.justificador_rol = data.justificador_rol;
|
||||
store.current.justificada.registro_fecha_justificacion = data.registro_fecha_justificacion;
|
||||
},
|
||||
async justificarBloque(fecha, bloques, justificacion) {
|
||||
if (bloques.length === 0) {
|
||||
alert('No se ha seleccionado ningún bloque');
|
||||
return;
|
||||
}
|
||||
if (!justificacion) {
|
||||
alert('No se ha ingresado ninguna observación');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch('action/action_justificar.php', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fecha,
|
||||
bloques,
|
||||
justificacion,
|
||||
})
|
||||
});
|
||||
const resData = await res.json();
|
||||
if (resData.status === 'success') {
|
||||
alert('Se ha justificado el bloque');
|
||||
store.current.modal_state = 'Cargando datos...';
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch();
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
else {
|
||||
alert('No se ha podido justificar el bloque');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al justificar');
|
||||
}
|
||||
},
|
||||
registros: {
|
||||
data: [],
|
||||
async fetch(fecha, fecha_inicio, fecha_fin) {
|
||||
// if (!store.filters.facultad_id || !store.filters.periodo_id) return
|
||||
this.loading = true;
|
||||
this.data = [];
|
||||
const params = {};
|
||||
if (fecha)
|
||||
params['fecha'] = fecha;
|
||||
if (fecha_inicio)
|
||||
params['fecha_inicio'] = fecha_inicio;
|
||||
if (fecha_fin)
|
||||
params['fecha_fin'] = fecha_fin;
|
||||
params['periodo_id'] = store.filters.todos_los_periodos ? 0 : store.periodo.periodo_id;
|
||||
console.log(store.periodo);
|
||||
const paramsUrl = new URLSearchParams(params).toString();
|
||||
try {
|
||||
const res = await fetch(`action/action_auditoria.php?${paramsUrl}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
this.data = await res.json();
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al cargar los datos');
|
||||
}
|
||||
this.loading = false;
|
||||
store.current.page = 1;
|
||||
},
|
||||
invertir() {
|
||||
this.data = this.data.reverse();
|
||||
},
|
||||
mostrarComentario(registro_id) {
|
||||
const registro = this.data.find((registro) => registro.registro_id === registro_id);
|
||||
store.current.comentario = registro.comentario;
|
||||
$('#ver-comentario').modal('show');
|
||||
},
|
||||
get relevant() {
|
||||
/*
|
||||
facultad_id: null,
|
||||
fecha: null,
|
||||
fecha_inicio: null,
|
||||
fecha_fin: null,
|
||||
profesor: null,
|
||||
asistencia: null,
|
||||
estado_id: null,
|
||||
if one of the filters is null, then it is not relevant
|
||||
|
||||
*/
|
||||
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0);
|
||||
return this.data.filter((registro) => {
|
||||
return filters.every((filtro) => {
|
||||
switch (filtro) {
|
||||
case 'fecha':
|
||||
return registro.registro_fecha_ideal === store.filters[filtro];
|
||||
case 'fecha_inicio':
|
||||
return registro.registro_fecha_ideal >= store.filters[filtro];
|
||||
case 'fecha_fin':
|
||||
return registro.registro_fecha_ideal <= store.filters[filtro];
|
||||
case 'profesor':
|
||||
const textoFiltro = store.filters[filtro].toLowerCase();
|
||||
if (/^\([^)]+\)\s[\s\S]+$/.test(textoFiltro)) {
|
||||
const clave = registro.profesor_clave.toLowerCase();
|
||||
const filtroClave = textoFiltro.match(/\((.*?)\)/)?.[1];
|
||||
// console.log(clave, filtroClave);
|
||||
return clave.includes(filtroClave);
|
||||
}
|
||||
else {
|
||||
const nombre = registro.profesor_nombre.toLowerCase();
|
||||
return nombre.includes(textoFiltro);
|
||||
}
|
||||
case 'facultad_id':
|
||||
return registro.facultad_id === store.filters[filtro];
|
||||
case 'estados':
|
||||
if (store.filters[filtro].length === 0)
|
||||
return true;
|
||||
else if (store.filters[filtro].includes(-1) && registro.estado_supervisor_id === null)
|
||||
return true;
|
||||
return store.filters[filtro].includes(registro.estado_supervisor_id);
|
||||
case 'bloque_horario':
|
||||
const bloque = store.bloques_horario.data.find((bloque) => bloque.id === store.filters[filtro]);
|
||||
return registro.horario_hora < bloque.hora_fin && registro.horario_fin > bloque.hora_inicio;
|
||||
default: return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
async descargar() {
|
||||
store.current.modal_state = 'Generando reporte en Excel...';
|
||||
$('div.modal#cargando').modal('show');
|
||||
this.loading = true;
|
||||
if (this.relevant.length === 0)
|
||||
return;
|
||||
try {
|
||||
const res = await fetch('export/supervisor_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.relevant)
|
||||
});
|
||||
const blob = await res.blob();
|
||||
window.saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.response && error.response.status === 413) {
|
||||
alert('Your request is too large! Please reduce the data size and try again.');
|
||||
}
|
||||
else {
|
||||
alert('An error occurred: ' + error.message);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
loading: false,
|
||||
get pages() {
|
||||
return Math.ceil(this.relevant.length / store.current.perPage);
|
||||
}
|
||||
},
|
||||
});
|
||||
createApp({
|
||||
store,
|
||||
messages: [],
|
||||
get clase_vista() {
|
||||
return store.current.clase_vista;
|
||||
},
|
||||
set_justificar(horario_id, profesor_id, registro_fecha_ideal) {
|
||||
store.current.justificada = store.registros.relevant.find((registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal);
|
||||
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada));
|
||||
store.current.observaciones = false;
|
||||
},
|
||||
cancelar_justificacion() {
|
||||
Object.assign(store.current.justificada, store.current.clone_justificada);
|
||||
delete store.current.clone_justificada;
|
||||
},
|
||||
profesores: [],
|
||||
async mounted() {
|
||||
$('div.modal#cargando').modal('show');
|
||||
try {
|
||||
store.periodo = await fetch('action/periodo_datos.php').then(res => res.json());
|
||||
// await store.registros.fetch()
|
||||
await store.facultades.fetch();
|
||||
await store.estados.fetch();
|
||||
await store.bloques_horario.fetch();
|
||||
await store.filters.switchFechas();
|
||||
this.profesores = await (await fetch('action/action_profesor.php')).json();
|
||||
this.messages.push({ title: 'Datos cargados', text: 'Los datos se han cargado correctamente', type: 'success', timestamp: new Date() });
|
||||
}
|
||||
catch (error) {
|
||||
this.messages.push({ title: 'Error al cargar datos', text: 'No se pudieron cargar los datos', type: 'danger', timestamp: new Date() });
|
||||
}
|
||||
finally {
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
$('div.modal#cargando').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
show: false,
|
||||
});
|
||||
const store = reactive({
|
||||
loading: false,
|
||||
perido: null,
|
||||
current: {
|
||||
comentario: '',
|
||||
clase_vista: null,
|
||||
empty: '',
|
||||
page: 1,
|
||||
maxPages: 10,
|
||||
perPage: 10,
|
||||
modal_state: "Cargando datos...",
|
||||
justificada: null,
|
||||
fechas_clicked: false,
|
||||
observaciones: false,
|
||||
},
|
||||
facultades: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_facultad.php');
|
||||
this.data = await res.json();
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
facultad_id: null,
|
||||
fecha: null,
|
||||
fecha_inicio: null,
|
||||
fecha_fin: null,
|
||||
profesor: null,
|
||||
periodo_id: null,
|
||||
bloque_horario: null,
|
||||
estados: [],
|
||||
switchFecha: false,
|
||||
async switchFechas() {
|
||||
const periodo = await fetch('action/periodo_datos.php');
|
||||
const periodo_data = await periodo.json();
|
||||
if (!store.filters.switchFecha) {
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch();
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
$(function () {
|
||||
store.filters.fecha_inicio = store.filters.fecha_fin = store.filters.fecha = null;
|
||||
$("#fecha, #fecha_inicio, #fecha_fin").datepicker({
|
||||
minDate: new Date(`${periodo_data.periodo_fecha_inicio}:00:00:00`),
|
||||
maxDate: new Date(`${periodo_data.fecha_final}:00:00:00`),
|
||||
dateFormat: "yy-mm-dd",
|
||||
showAnim: "slide",
|
||||
beforeShowDay: (date) => [(date.getDay() != 0), ""]
|
||||
});
|
||||
const fecha = $("#fecha"), inicio = $("#fecha_inicio"), fin = $("#fecha_fin");
|
||||
fecha.datepicker("setDate", new Date(`${periodo_data.fecha_final}:00:00:00`));
|
||||
inicio.on("change", function () {
|
||||
store.current.fechas_clicked = false;
|
||||
store.filters.fecha_inicio = inicio.val();
|
||||
fin.datepicker("option", "minDate", inicio.val());
|
||||
});
|
||||
fin.on("change", function () {
|
||||
store.current.fechas_clicked = false;
|
||||
store.filters.fecha_fin = fin.val();
|
||||
inicio.datepicker("option", "maxDate", fin.val());
|
||||
});
|
||||
fecha.on("change", async function () {
|
||||
store.filters.fecha = fecha.val();
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch(store.filters.fecha);
|
||||
$('div.modal#cargando').modal('hide');
|
||||
});
|
||||
});
|
||||
},
|
||||
async fetchByDate() {
|
||||
store.current.fechas_clicked = true;
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch(undefined, store.filters.fecha_inicio, store.filters.fecha_fin);
|
||||
store.current.page = 1;
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
estados: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_estado_supervisor.php');
|
||||
this.data = await res.json();
|
||||
},
|
||||
getEstado(id) {
|
||||
return this.data.find((estado) => estado.estado_supervisor_id === id) ?? {
|
||||
estado_color: 'dark',
|
||||
estado_icon: 'ing-cancelar',
|
||||
nombre: 'Sin registro',
|
||||
estado_supervisor_id: -1,
|
||||
};
|
||||
},
|
||||
printEstados() {
|
||||
if (store.filters.estados.length > 0)
|
||||
document.querySelector('#estados').innerHTML = store.filters.estados.map((estado) => `<span class="mx-2 badge badge-${store.estados.getEstado(estado).estado_color}">
|
||||
<i class="${store.estados.getEstado(estado).estado_icon}"></i> ${store.estados.getEstado(estado).nombre}
|
||||
</span>`).join('');
|
||||
else
|
||||
document.querySelector('#estados').innerHTML = `Todos los registros`;
|
||||
}
|
||||
},
|
||||
bloques_horario: {
|
||||
data: [],
|
||||
async fetch() {
|
||||
this.data = [];
|
||||
const res = await fetch('action/action_grupo_horario.php');
|
||||
this.data = await res.json();
|
||||
if (this.data.every((bloque) => !bloque.selected))
|
||||
this.data[0].selected = true;
|
||||
},
|
||||
},
|
||||
toggle(arr, element) {
|
||||
const newArray = arr.includes(element) ? arr.filter((item) => item !== element) : [...arr, element];
|
||||
// if all are selected, then unselect all
|
||||
if (newArray.length === (this.estados.data.length + 1)) {
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('#dlAsistencia>ul>li.selected').forEach(element => element.classList.remove('selected'));
|
||||
}, 100);
|
||||
return [];
|
||||
}
|
||||
return newArray;
|
||||
},
|
||||
async justificar() {
|
||||
if (!store.current.justificada)
|
||||
return;
|
||||
store.current.justificada.registro_justificada = true;
|
||||
let data;
|
||||
try {
|
||||
const res = await fetch('action/justificar.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(store.current.justificada)
|
||||
});
|
||||
data = await res.json();
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al justificar');
|
||||
store.current.justificada = store.current.clone_justificada;
|
||||
}
|
||||
finally {
|
||||
delete store.current.clone_justificada;
|
||||
}
|
||||
store.current.justificada.justificador_nombre = data.justificador_nombre;
|
||||
store.current.justificada.justificador_clave = data.justificador_clave;
|
||||
store.current.justificada.justificador_facultad = data.justificador_facultad;
|
||||
store.current.justificada.justificador_rol = data.justificador_rol;
|
||||
store.current.justificada.registro_fecha_justificacion = data.registro_fecha_justificacion;
|
||||
},
|
||||
async justificarBloque(fecha, bloques, justificacion) {
|
||||
if (bloques.length === 0) {
|
||||
alert('No se ha seleccionado ningún bloque');
|
||||
return;
|
||||
}
|
||||
if (!justificacion) {
|
||||
alert('No se ha ingresado ninguna observación');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch('action/action_justificar.php', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fecha,
|
||||
bloques,
|
||||
justificacion,
|
||||
})
|
||||
});
|
||||
const resData = await res.json();
|
||||
if (resData.status === 'success') {
|
||||
alert('Se ha justificado el bloque');
|
||||
store.current.modal_state = 'Cargando datos...';
|
||||
$('div.modal#cargando').modal('show');
|
||||
await store.registros.fetch();
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
else {
|
||||
alert('No se ha podido justificar el bloque');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al justificar');
|
||||
}
|
||||
},
|
||||
registros: {
|
||||
data: [],
|
||||
async fetch(fecha, fecha_inicio, fecha_fin) {
|
||||
// if (!store.filters.facultad_id || !store.filters.periodo_id) return
|
||||
this.loading = true;
|
||||
this.data = [];
|
||||
const params = {};
|
||||
if (fecha)
|
||||
params['fecha'] = fecha;
|
||||
if (fecha_inicio)
|
||||
params['fecha_inicio'] = fecha_inicio;
|
||||
if (fecha_fin)
|
||||
params['fecha_fin'] = fecha_fin;
|
||||
params['periodo_id'] = store.filters.todos_los_periodos ? 0 : store.periodo.periodo_id;
|
||||
console.log(store.periodo);
|
||||
const paramsUrl = new URLSearchParams(params).toString();
|
||||
try {
|
||||
const res = await fetch(`action/action_auditoria.php?${paramsUrl}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
this.data = await res.json();
|
||||
}
|
||||
catch (error) {
|
||||
alert('Error al cargar los datos');
|
||||
}
|
||||
this.loading = false;
|
||||
store.current.page = 1;
|
||||
},
|
||||
invertir() {
|
||||
this.data = this.data.reverse();
|
||||
},
|
||||
mostrarComentario(registro_id) {
|
||||
const registro = this.data.find((registro) => registro.registro_id === registro_id);
|
||||
store.current.comentario = registro.comentario;
|
||||
$('#ver-comentario').modal('show');
|
||||
},
|
||||
get relevant() {
|
||||
/*
|
||||
facultad_id: null,
|
||||
fecha: null,
|
||||
fecha_inicio: null,
|
||||
fecha_fin: null,
|
||||
profesor: null,
|
||||
asistencia: null,
|
||||
estado_id: null,
|
||||
if one of the filters is null, then it is not relevant
|
||||
|
||||
*/
|
||||
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0);
|
||||
return this.data.filter((registro) => {
|
||||
return filters.every((filtro) => {
|
||||
switch (filtro) {
|
||||
case 'fecha':
|
||||
return registro.registro_fecha_ideal === store.filters[filtro];
|
||||
case 'fecha_inicio':
|
||||
return registro.registro_fecha_ideal >= store.filters[filtro];
|
||||
case 'fecha_fin':
|
||||
return registro.registro_fecha_ideal <= store.filters[filtro];
|
||||
case 'profesor':
|
||||
const textoFiltro = store.filters[filtro].toLowerCase();
|
||||
if (/^\([^)]+\)\s[\s\S]+$/.test(textoFiltro)) {
|
||||
const clave = registro.profesor_clave.toLowerCase();
|
||||
const filtroClave = textoFiltro.match(/\((.*?)\)/)?.[1];
|
||||
// console.log(clave, filtroClave);
|
||||
return clave.includes(filtroClave);
|
||||
}
|
||||
else {
|
||||
const nombre = registro.profesor_nombre.toLowerCase();
|
||||
return nombre.includes(textoFiltro);
|
||||
}
|
||||
case 'facultad_id':
|
||||
return registro.facultad_id === store.filters[filtro];
|
||||
case 'estados':
|
||||
if (store.filters[filtro].length === 0)
|
||||
return true;
|
||||
else if (store.filters[filtro].includes(-1) && registro.estado_supervisor_id === null)
|
||||
return true;
|
||||
return store.filters[filtro].includes(registro.estado_supervisor_id);
|
||||
case 'bloque_horario':
|
||||
const bloque = store.bloques_horario.data.find((bloque) => bloque.id === store.filters[filtro]);
|
||||
return registro.horario_hora < bloque.hora_fin && registro.horario_fin > bloque.hora_inicio;
|
||||
default: return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
async descargar() {
|
||||
store.current.modal_state = 'Generando reporte en Excel...';
|
||||
$('div.modal#cargando').modal('show');
|
||||
this.loading = true;
|
||||
if (this.relevant.length === 0)
|
||||
return;
|
||||
try {
|
||||
const res = await fetch('export/supervisor_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.relevant)
|
||||
});
|
||||
const blob = await res.blob();
|
||||
window.saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.response && error.response.status === 413) {
|
||||
alert('Your request is too large! Please reduce the data size and try again.');
|
||||
}
|
||||
else {
|
||||
alert('An error occurred: ' + error.message);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
loading: false,
|
||||
get pages() {
|
||||
return Math.ceil(this.relevant.length / store.current.perPage);
|
||||
}
|
||||
},
|
||||
});
|
||||
createApp({
|
||||
store,
|
||||
messages: [],
|
||||
get clase_vista() {
|
||||
return store.current.clase_vista;
|
||||
},
|
||||
set_justificar(horario_id, profesor_id, registro_fecha_ideal) {
|
||||
store.current.justificada = store.registros.relevant.find((registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal);
|
||||
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada));
|
||||
store.current.observaciones = false;
|
||||
},
|
||||
cancelar_justificacion() {
|
||||
Object.assign(store.current.justificada, store.current.clone_justificada);
|
||||
delete store.current.clone_justificada;
|
||||
},
|
||||
profesores: [],
|
||||
async mounted() {
|
||||
$('div.modal#cargando').modal('show');
|
||||
try {
|
||||
store.periodo = await fetch('action/periodo_datos.php').then(res => res.json());
|
||||
// await store.registros.fetch()
|
||||
await store.facultades.fetch();
|
||||
await store.estados.fetch();
|
||||
await store.bloques_horario.fetch();
|
||||
await store.filters.switchFechas();
|
||||
this.profesores = await (await fetch('action/action_profesor.php')).json();
|
||||
this.messages.push({ title: 'Datos cargados', text: 'Los datos se han cargado correctamente', type: 'success', timestamp: new Date() });
|
||||
}
|
||||
catch (error) {
|
||||
this.messages.push({ title: 'Error al cargar datos', text: 'No se pudieron cargar los datos', type: 'danger', timestamp: new Date() });
|
||||
}
|
||||
finally {
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
296
js/avisos.js
296
js/avisos.js
@@ -1,148 +1,148 @@
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const new_aviso = reactive({
|
||||
titulo: '',
|
||||
descripcion: '',
|
||||
fechaInicio: '',
|
||||
fechaFin: '',
|
||||
profesores: [],
|
||||
carreras: [],
|
||||
reset() {
|
||||
this.titulo = '';
|
||||
this.descripcion = '';
|
||||
this.fechaInicio = '';
|
||||
this.fechaFin = '';
|
||||
this.profesores = [];
|
||||
this.carreras = [];
|
||||
},
|
||||
get isValid() {
|
||||
return this.titulo !== '' && this.descripcion !== '' && this.fechaInicio !== '' && this.fechaFin !== '' && (this.profesores.length > 0 || this.carreras.length > 0) && this.facultad_id !== null;
|
||||
},
|
||||
});
|
||||
// define datepicker method
|
||||
const app = createApp({
|
||||
new_aviso,
|
||||
profesores: [],
|
||||
carreras: [],
|
||||
avisos: [],
|
||||
profesor: null,
|
||||
formatProfesor(profesor) {
|
||||
return `(${profesor.profesor_clave}) ${profesor.profesor_nombre}`;
|
||||
},
|
||||
addProfesor() {
|
||||
const profesorObj = this.profesores.find((profesor) => this.profesor === this.formatProfesor(profesor));
|
||||
if (profesorObj) {
|
||||
this.new_aviso.profesores.push(profesorObj);
|
||||
this.profesor = null;
|
||||
}
|
||||
},
|
||||
aviso_shown: null,
|
||||
// int?
|
||||
aviso_suspendido: null,
|
||||
suspenderAviso() {
|
||||
if (this.aviso_suspendido) {
|
||||
const aviso = this.avisos.find((aviso) => aviso.aviso_id === this.aviso_suspendido);
|
||||
if (aviso) {
|
||||
this.deleteAviso(aviso);
|
||||
}
|
||||
}
|
||||
},
|
||||
get relevant_profesores() {
|
||||
// not in array new_aviso.profesores
|
||||
const relevant = this.profesores.filter((profesor) => !this.new_aviso.profesores.map((profesor) => profesor.profesor_id).includes(profesor.profesor_id));
|
||||
// console.log('profesores:', this.profesores.map((profesor: Profesor) => profesor.profesor_nombre), 'relevant:', relevant.map((profesor: Profesor) => profesor.profesor_nombre), 'new_aviso:', this.new_aviso.profesores.map((profesor: Profesor) => profesor.profesor_nombre))
|
||||
return relevant;
|
||||
},
|
||||
get relevant_carreras() {
|
||||
// not in array new_aviso.carreras
|
||||
return this.carreras.filter((carrera) => !this.new_aviso.carreras.includes(carrera));
|
||||
},
|
||||
createAviso() {
|
||||
const data = {
|
||||
aviso_titulo: this.new_aviso.titulo,
|
||||
aviso_texto: this.new_aviso.descripcion,
|
||||
aviso_fecha_inicial: this.new_aviso.fechaInicio,
|
||||
aviso_fecha_final: this.new_aviso.fechaFin,
|
||||
profesores: this.new_aviso.profesores.map((profesor) => profesor.profesor_id),
|
||||
carreras: this.new_aviso.carreras.map((carrera) => carrera.carrera_id),
|
||||
};
|
||||
fetch('/action/avisos.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
// hydrate with carreras and profesores
|
||||
this.avisos.push({
|
||||
...data,
|
||||
carreras: this.carreras.filter((carrera) => data.carreras.includes(carrera.carrera_id)),
|
||||
profesores: this.profesores.filter((profesor) => data.profesores.includes(profesor.profesor_id)),
|
||||
aviso_estado: true,
|
||||
aviso_id: res.aviso_id,
|
||||
});
|
||||
this.new_aviso.reset();
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteAviso(aviso) {
|
||||
fetch(`/action/avisos.php`, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({ aviso_id: aviso.aviso_id })
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
this.avisos = this.avisos.filter((aviso) => aviso.aviso_id !== this.aviso_suspendido);
|
||||
this.aviso_suspendido = null;
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
updateAviso() {
|
||||
fetch(`/action/avisos.php`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
aviso_id: this.aviso_shown.aviso_id,
|
||||
aviso_fecha_final: this.aviso_shown.aviso_fecha_final,
|
||||
})
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
async initializeDatepickers($el) {
|
||||
const periodo = await fetch('action/periodo_datos.php');
|
||||
const periodo_data = await periodo.json();
|
||||
$('.date-picker').datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
maxDate: periodo_data.periodo_fecha_fin,
|
||||
minDate: 0,
|
||||
});
|
||||
$($el).on('change', () => {
|
||||
this.aviso_shown.aviso_fecha_final = $($el).val();
|
||||
});
|
||||
},
|
||||
async mounted() {
|
||||
this.avisos = await fetch("/action/avisos.php").then(res => res.json());
|
||||
this.profesores = await fetch('/action/action_profesor.php').then(res => res.json());
|
||||
this.carreras = await fetch('/action/action_carreras.php').then(res => res.json());
|
||||
await this.initializeDatepickers();
|
||||
const fechaInicio = $('#fechaInicio.date-picker');
|
||||
const fechaFin = $('#fechaFin.date-picker');
|
||||
fechaInicio.on("change", function () {
|
||||
new_aviso.fechaInicio = fechaInicio.val();
|
||||
fechaFin.datepicker("option", "minDate", fechaInicio.val());
|
||||
});
|
||||
fechaFin.on("change", function () {
|
||||
new_aviso.fechaFin = fechaFin.val();
|
||||
fechaInicio.datepicker("option", "maxDate", fechaFin.val());
|
||||
});
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const new_aviso = reactive({
|
||||
titulo: '',
|
||||
descripcion: '',
|
||||
fechaInicio: '',
|
||||
fechaFin: '',
|
||||
profesores: [],
|
||||
carreras: [],
|
||||
reset() {
|
||||
this.titulo = '';
|
||||
this.descripcion = '';
|
||||
this.fechaInicio = '';
|
||||
this.fechaFin = '';
|
||||
this.profesores = [];
|
||||
this.carreras = [];
|
||||
},
|
||||
get isValid() {
|
||||
return this.titulo !== '' && this.descripcion !== '' && this.fechaInicio !== '' && this.fechaFin !== '' && (this.profesores.length > 0 || this.carreras.length > 0) && this.facultad_id !== null;
|
||||
},
|
||||
});
|
||||
// define datepicker method
|
||||
const app = createApp({
|
||||
new_aviso,
|
||||
profesores: [],
|
||||
carreras: [],
|
||||
avisos: [],
|
||||
profesor: null,
|
||||
formatProfesor(profesor) {
|
||||
return `(${profesor.profesor_clave}) ${profesor.profesor_nombre}`;
|
||||
},
|
||||
addProfesor() {
|
||||
const profesorObj = this.profesores.find((profesor) => this.profesor === this.formatProfesor(profesor));
|
||||
if (profesorObj) {
|
||||
this.new_aviso.profesores.push(profesorObj);
|
||||
this.profesor = null;
|
||||
}
|
||||
},
|
||||
aviso_shown: null,
|
||||
// int?
|
||||
aviso_suspendido: null,
|
||||
suspenderAviso() {
|
||||
if (this.aviso_suspendido) {
|
||||
const aviso = this.avisos.find((aviso) => aviso.aviso_id === this.aviso_suspendido);
|
||||
if (aviso) {
|
||||
this.deleteAviso(aviso);
|
||||
}
|
||||
}
|
||||
},
|
||||
get relevant_profesores() {
|
||||
// not in array new_aviso.profesores
|
||||
const relevant = this.profesores.filter((profesor) => !this.new_aviso.profesores.map((profesor) => profesor.profesor_id).includes(profesor.profesor_id));
|
||||
// console.log('profesores:', this.profesores.map((profesor: Profesor) => profesor.profesor_nombre), 'relevant:', relevant.map((profesor: Profesor) => profesor.profesor_nombre), 'new_aviso:', this.new_aviso.profesores.map((profesor: Profesor) => profesor.profesor_nombre))
|
||||
return relevant;
|
||||
},
|
||||
get relevant_carreras() {
|
||||
// not in array new_aviso.carreras
|
||||
return this.carreras.filter((carrera) => !this.new_aviso.carreras.includes(carrera));
|
||||
},
|
||||
createAviso() {
|
||||
const data = {
|
||||
aviso_titulo: this.new_aviso.titulo,
|
||||
aviso_texto: this.new_aviso.descripcion,
|
||||
aviso_fecha_inicial: this.new_aviso.fechaInicio,
|
||||
aviso_fecha_final: this.new_aviso.fechaFin,
|
||||
profesores: this.new_aviso.profesores.map((profesor) => profesor.profesor_id),
|
||||
carreras: this.new_aviso.carreras.map((carrera) => carrera.carrera_id),
|
||||
};
|
||||
fetch('/action/avisos.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
// hydrate with carreras and profesores
|
||||
this.avisos.push({
|
||||
...data,
|
||||
carreras: this.carreras.filter((carrera) => data.carreras.includes(carrera.carrera_id)),
|
||||
profesores: this.profesores.filter((profesor) => data.profesores.includes(profesor.profesor_id)),
|
||||
aviso_estado: true,
|
||||
aviso_id: res.aviso_id,
|
||||
});
|
||||
this.new_aviso.reset();
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteAviso(aviso) {
|
||||
fetch(`/action/avisos.php`, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({ aviso_id: aviso.aviso_id })
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
this.avisos = this.avisos.filter((aviso) => aviso.aviso_id !== this.aviso_suspendido);
|
||||
this.aviso_suspendido = null;
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
updateAviso() {
|
||||
fetch(`/action/avisos.php`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
aviso_id: this.aviso_shown.aviso_id,
|
||||
aviso_fecha_final: this.aviso_shown.aviso_fecha_final,
|
||||
})
|
||||
}).then(res => res.json()).then(res => {
|
||||
if (res.success) {
|
||||
}
|
||||
else {
|
||||
alert(res.error);
|
||||
console.log(res.errors);
|
||||
}
|
||||
});
|
||||
},
|
||||
async initializeDatepickers($el) {
|
||||
const periodo = await fetch('action/periodo_datos.php');
|
||||
const periodo_data = await periodo.json();
|
||||
$('.date-picker').datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
maxDate: periodo_data.periodo_fecha_fin,
|
||||
minDate: 0,
|
||||
});
|
||||
$($el).on('change', () => {
|
||||
this.aviso_shown.aviso_fecha_final = $($el).val();
|
||||
});
|
||||
},
|
||||
async mounted() {
|
||||
this.avisos = await fetch("/action/avisos.php").then(res => res.json());
|
||||
this.profesores = await fetch('/action/action_profesor.php').then(res => res.json());
|
||||
this.carreras = await fetch('/action/action_carreras.php').then(res => res.json());
|
||||
await this.initializeDatepickers();
|
||||
const fechaInicio = $('#fechaInicio.date-picker');
|
||||
const fechaFin = $('#fechaFin.date-picker');
|
||||
fechaInicio.on("change", function () {
|
||||
new_aviso.fechaInicio = fechaInicio.val();
|
||||
fechaFin.datepicker("option", "minDate", fechaInicio.val());
|
||||
});
|
||||
fechaFin.on("change", function () {
|
||||
new_aviso.fechaFin = fechaFin.val();
|
||||
fechaInicio.datepicker("option", "maxDate", fechaFin.val());
|
||||
});
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
12
js/bootstrap/bootstrap.bundle.min.js
vendored
12
js/bootstrap/bootstrap.bundle.min.js
vendored
File diff suppressed because one or more lines are too long
12
js/bootstrap/bootstrap.min.js
vendored
12
js/bootstrap/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
10
js/bootstrap/popper.min.js
vendored
10
js/bootstrap/popper.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,44 +1,44 @@
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
const app = createApp({
|
||||
carreras: [],
|
||||
niveles: [],
|
||||
message: {},
|
||||
async setNivel(carrera, nivel) {
|
||||
if (carrera.nivel_id === nivel.nivel_id) {
|
||||
return;
|
||||
}
|
||||
carrera.nivel_id = nivel.nivel_id;
|
||||
carrera.nivel_nombre = nivel.nivel_nombre;
|
||||
await fetch('action/carrera.php', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
carrera_id: carrera.carrera_id,
|
||||
nivel_id: nivel.nivel_id
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
this.message.title = "Actualización";
|
||||
this.message.text = res.error ?? res.success;
|
||||
this.message.type = res.error ? 'danger' : 'success';
|
||||
this.message.timestamp = new Date().toLocaleTimeString();
|
||||
});
|
||||
},
|
||||
async mounted() {
|
||||
this.carreras = await fetch('action/carrera.php').then(res => res.json());
|
||||
this.niveles = await fetch('action/nivel.php').then(res => res.json());
|
||||
// group by facultad_id
|
||||
const carreras = this.carreras.reduce((acc, cur) => {
|
||||
const { facultad_nombre } = cur;
|
||||
if (!acc[facultad_nombre]) {
|
||||
acc[facultad_nombre] = [];
|
||||
}
|
||||
acc[facultad_nombre].push(cur);
|
||||
return acc;
|
||||
}, {});
|
||||
this.carreras = Object.entries(carreras).map(([facultad_nombre, carreras]) => ({
|
||||
facultad_nombre: facultad_nombre,
|
||||
carreras
|
||||
}));
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
const app = createApp({
|
||||
carreras: [],
|
||||
niveles: [],
|
||||
message: {},
|
||||
async setNivel(carrera, nivel) {
|
||||
if (carrera.nivel_id === nivel.nivel_id) {
|
||||
return;
|
||||
}
|
||||
carrera.nivel_id = nivel.nivel_id;
|
||||
carrera.nivel_nombre = nivel.nivel_nombre;
|
||||
await fetch('action/carrera.php', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
carrera_id: carrera.carrera_id,
|
||||
nivel_id: nivel.nivel_id
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
this.message.title = "Actualización";
|
||||
this.message.text = res.error ?? res.success;
|
||||
this.message.type = res.error ? 'danger' : 'success';
|
||||
this.message.timestamp = new Date().toLocaleTimeString();
|
||||
});
|
||||
},
|
||||
async mounted() {
|
||||
this.carreras = await fetch('action/carrera.php').then(res => res.json());
|
||||
this.niveles = await fetch('action/nivel.php').then(res => res.json());
|
||||
// group by facultad_id
|
||||
const carreras = this.carreras.reduce((acc, cur) => {
|
||||
const { facultad_nombre } = cur;
|
||||
if (!acc[facultad_nombre]) {
|
||||
acc[facultad_nombre] = [];
|
||||
}
|
||||
acc[facultad_nombre].push(cur);
|
||||
return acc;
|
||||
}, {});
|
||||
this.carreras = Object.entries(carreras).map(([facultad_nombre, carreras]) => ({
|
||||
facultad_nombre: facultad_nombre,
|
||||
carreras
|
||||
}));
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
240
js/client.js
240
js/client.js
@@ -1,120 +1,120 @@
|
||||
// @ts-ignore Import module
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const webServices = {
|
||||
getPeriodosV1: async () => {
|
||||
try {
|
||||
const response = await fetch('periodos.v1.php');
|
||||
return await response.json();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
getPeriodosV2: async () => {
|
||||
try {
|
||||
const response = await fetch('periodos.v2.php');
|
||||
return await response.json();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
const store = reactive({
|
||||
periodosV1: [],
|
||||
periodosV2: [],
|
||||
errors: [],
|
||||
fechas(idPeriodo) {
|
||||
const periodo = this.periodosV2.find((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
return {
|
||||
inicio: periodo ? periodo.FechaInicio : '',
|
||||
fin: periodo ? periodo.FechaFin : ''
|
||||
};
|
||||
},
|
||||
periodov1(idPeriodo) {
|
||||
return this.periodosV1.find((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
},
|
||||
periodov2(idPeriodo) {
|
||||
return this.periodosV2.filter((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
},
|
||||
async addPeriodo(periodo) {
|
||||
try {
|
||||
const result = await fetch('backend/periodos.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
...periodo,
|
||||
...this.fechas(periodo.IdPeriodo)
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
if (result.success) {
|
||||
this.periodosV1 = this.periodosV1.map((periodoV1) => {
|
||||
if (periodoV1.IdPeriodo === periodo.IdPeriodo) {
|
||||
periodoV1.in_db = true;
|
||||
}
|
||||
return periodoV1;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
this.errors.push(result.message);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.errors.push(error);
|
||||
}
|
||||
},
|
||||
async addCarreras(idPeriodo) {
|
||||
try {
|
||||
const periodoV1 = this.periodov1(idPeriodo);
|
||||
const periodoV2 = this.periodov2(idPeriodo);
|
||||
const data = periodoV2.map(({ ClaveCarrera, NombreCarrera }) => ({
|
||||
ClaveCarrera: ClaveCarrera,
|
||||
NombreCarrera: NombreCarrera,
|
||||
IdNivel: periodoV1.IdNivel,
|
||||
}));
|
||||
const result = await fetch('backend/carreras.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
if (result.success) {
|
||||
await webServices.getPeriodosV1().then((periodosV1) => {
|
||||
this.periodosV1 = periodosV1;
|
||||
});
|
||||
await webServices.getPeriodosV2().then((periodosV2) => {
|
||||
this.periodosV2 = periodosV2;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.errors.push(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
createApp({
|
||||
store,
|
||||
info(IdPeriodo) {
|
||||
const periodo = store.periodosV2.find((periodo) => periodo.IdPeriodo === IdPeriodo &&
|
||||
periodo.FechaInicio != '' && periodo.FechaFin != '');
|
||||
return periodo;
|
||||
},
|
||||
complete(IdPeriodo) {
|
||||
const info = this.info(IdPeriodo);
|
||||
return info !== undefined;
|
||||
},
|
||||
mounted: async () => {
|
||||
await webServices.getPeriodosV1().then((periodosV1) => {
|
||||
store.periodosV1 = periodosV1;
|
||||
});
|
||||
await webServices.getPeriodosV2().then((periodosV2) => {
|
||||
store.periodosV2 = periodosV2;
|
||||
});
|
||||
}
|
||||
}).mount();
|
||||
// @ts-ignore Import module
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const webServices = {
|
||||
getPeriodosV1: async () => {
|
||||
try {
|
||||
const response = await fetch('periodos.v1.php');
|
||||
return await response.json();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
getPeriodosV2: async () => {
|
||||
try {
|
||||
const response = await fetch('periodos.v2.php');
|
||||
return await response.json();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
const store = reactive({
|
||||
periodosV1: [],
|
||||
periodosV2: [],
|
||||
errors: [],
|
||||
fechas(idPeriodo) {
|
||||
const periodo = this.periodosV2.find((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
return {
|
||||
inicio: periodo ? periodo.FechaInicio : '',
|
||||
fin: periodo ? periodo.FechaFin : ''
|
||||
};
|
||||
},
|
||||
periodov1(idPeriodo) {
|
||||
return this.periodosV1.find((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
},
|
||||
periodov2(idPeriodo) {
|
||||
return this.periodosV2.filter((periodo) => periodo.IdPeriodo === idPeriodo);
|
||||
},
|
||||
async addPeriodo(periodo) {
|
||||
try {
|
||||
const result = await fetch('backend/periodos.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
...periodo,
|
||||
...this.fechas(periodo.IdPeriodo)
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
if (result.success) {
|
||||
this.periodosV1 = this.periodosV1.map((periodoV1) => {
|
||||
if (periodoV1.IdPeriodo === periodo.IdPeriodo) {
|
||||
periodoV1.in_db = true;
|
||||
}
|
||||
return periodoV1;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
this.errors.push(result.message);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.errors.push(error);
|
||||
}
|
||||
},
|
||||
async addCarreras(idPeriodo) {
|
||||
try {
|
||||
const periodoV1 = this.periodov1(idPeriodo);
|
||||
const periodoV2 = this.periodov2(idPeriodo);
|
||||
const data = periodoV2.map(({ ClaveCarrera, NombreCarrera }) => ({
|
||||
ClaveCarrera: ClaveCarrera,
|
||||
NombreCarrera: NombreCarrera,
|
||||
IdNivel: periodoV1.IdNivel,
|
||||
}));
|
||||
const result = await fetch('backend/carreras.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
if (result.success) {
|
||||
await webServices.getPeriodosV1().then((periodosV1) => {
|
||||
this.periodosV1 = periodosV1;
|
||||
});
|
||||
await webServices.getPeriodosV2().then((periodosV2) => {
|
||||
this.periodosV2 = periodosV2;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
this.errors.push(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
createApp({
|
||||
store,
|
||||
info(IdPeriodo) {
|
||||
const periodo = store.periodosV2.find((periodo) => periodo.IdPeriodo === IdPeriodo &&
|
||||
periodo.FechaInicio != '' && periodo.FechaFin != '');
|
||||
return periodo;
|
||||
},
|
||||
complete(IdPeriodo) {
|
||||
const info = this.info(IdPeriodo);
|
||||
return info !== undefined;
|
||||
},
|
||||
mounted: async () => {
|
||||
await webServices.getPeriodosV1().then((periodosV1) => {
|
||||
store.periodosV1 = periodosV1;
|
||||
});
|
||||
await webServices.getPeriodosV2().then((periodosV2) => {
|
||||
store.periodosV2 = periodosV2;
|
||||
});
|
||||
}
|
||||
}).mount();
|
||||
|
||||
1462
js/clockpicker.js
1462
js/clockpicker.js
File diff suppressed because it is too large
Load Diff
212
js/datalist.js
212
js/datalist.js
@@ -1,106 +1,106 @@
|
||||
$(function () {
|
||||
const toggleIcon = (el, fromClass, toClass) => $(el).removeClass(fromClass).addClass(toClass);
|
||||
|
||||
const ocultaTodos = () => {
|
||||
toggleIcon('.datalist .icono', 'ing-cancelar iconoAzul pointer', 'ing-buscar');
|
||||
$('.datalist ul').hide();
|
||||
};
|
||||
|
||||
$(document)
|
||||
.on('click', '.datalist-input,.icono', function () {
|
||||
const parent = $(this).parent();
|
||||
$(".datalist ul:visible").not(parent.find('ul')).siblings('.datalist-input').trigger('click');
|
||||
if (parent.find('ul').is(':visible') || parent.hasClass("disabled")) return ocultaTodos();
|
||||
|
||||
parent.find('ul, .datalist-input').show();
|
||||
toggleIcon(parent.find('.icono'), 'ing-buscar', 'ing-cancelar iconoAzul pointer');
|
||||
})
|
||||
.on('click', '.datalist-select > ul li:not(.not-selectable)', function () {
|
||||
const parent = $(this).closest('.datalist');
|
||||
parent.find('.datalist-input').text($(this).text().trim());
|
||||
parent.find("input[type=hidden]").val($(this).data('id'));
|
||||
$('.datalist li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
parent.removeClass("datalist-invalid");
|
||||
ocultaTodos();
|
||||
})
|
||||
.on('click', (e) => {
|
||||
if (!$(e.target).closest('.datalist').length) ocultaTodos();
|
||||
});
|
||||
|
||||
$('.modal').on('hide.bs.modal', ocultaTodos);
|
||||
});
|
||||
const setDatalist = (selector, value = -1) => {
|
||||
const parent = $(selector).closest('.datalist');
|
||||
parent.find('ul li:not(.not-selectable)').each(function () {
|
||||
if ($(this).data("id") !== value) return;
|
||||
parent.find('.datalist-input').text($(this).text().trim());
|
||||
$(selector).val(value);
|
||||
$('.datalist li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
$(this).click();
|
||||
});
|
||||
}
|
||||
const makeRequiredDatalist = (selector, required = true) => $(selector).closest('.datalist').toggleClass("required", required);
|
||||
|
||||
//---------
|
||||
|
||||
function setDatalistFirst(selector) {
|
||||
var index = 1;
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
var num = elementRoot.find('ul li:not(.not-selectable)').length;
|
||||
if (index <= num) {
|
||||
while (elementRoot.find('ul li:nth-child(' + index + ')').hasClass("not-selectable") && index <= num) {
|
||||
index++;
|
||||
}
|
||||
var element = elementRoot.find('ul li:nth-child(' + index + ')');
|
||||
elementRoot.find('.datalist-input').text(element.html().replace(/[\t\n]+/g, ' ').trim());
|
||||
$(selector).val(element.data("id"));
|
||||
elementRoot.find("li").removeClass("selected");
|
||||
element.addClass("selected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function disableDatalist(selector, disabled = true) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
if (disabled) {
|
||||
elementRoot.addClass("disabled");
|
||||
elementRoot.find('.icono').removeClass('ing-cancelar iconoAzul pointer').addClass('ing-buscar');
|
||||
elementRoot.find('ul').hide();
|
||||
} else
|
||||
elementRoot.removeClass("disabled");
|
||||
}
|
||||
|
||||
function invalidDatalist(selector, invalid = true) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
if (invalid) {
|
||||
elementRoot.addClass("datalist-invalid");
|
||||
} else
|
||||
elementRoot.removeClass("datalist-invalid");
|
||||
}
|
||||
|
||||
//¿Se usa?
|
||||
function buscaDatalist(selector, valor) {
|
||||
selector.find('ul li').each(function () {
|
||||
var elem = $(this);
|
||||
if ($(this).parent().is('li'))
|
||||
elem = $(this).parent();
|
||||
if (!$(this).html().toUpperCase().includes(valor.toUpperCase())) {
|
||||
$(elem).hide();
|
||||
selector.find('.datalist-input').val("");
|
||||
selector.find("input[type=hidden]").val("");
|
||||
} else
|
||||
$(elem).show();
|
||||
});
|
||||
}
|
||||
function getDatalistText(selector, valor) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
var text = "";
|
||||
$.each(elementRoot.find('ul li:not(.not-selectable)'), function () {
|
||||
if ($(this).data("id") == valor) {
|
||||
text = $(this).html();
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
$(function () {
|
||||
const toggleIcon = (el, fromClass, toClass) => $(el).removeClass(fromClass).addClass(toClass);
|
||||
|
||||
const ocultaTodos = () => {
|
||||
toggleIcon('.datalist .icono', 'ing-cancelar iconoAzul pointer', 'ing-buscar');
|
||||
$('.datalist ul').hide();
|
||||
};
|
||||
|
||||
$(document)
|
||||
.on('click', '.datalist-input,.icono', function () {
|
||||
const parent = $(this).parent();
|
||||
$(".datalist ul:visible").not(parent.find('ul')).siblings('.datalist-input').trigger('click');
|
||||
if (parent.find('ul').is(':visible') || parent.hasClass("disabled")) return ocultaTodos();
|
||||
|
||||
parent.find('ul, .datalist-input').show();
|
||||
toggleIcon(parent.find('.icono'), 'ing-buscar', 'ing-cancelar iconoAzul pointer');
|
||||
})
|
||||
.on('click', '.datalist-select > ul li:not(.not-selectable)', function () {
|
||||
const parent = $(this).closest('.datalist');
|
||||
parent.find('.datalist-input').text($(this).text().trim());
|
||||
parent.find("input[type=hidden]").val($(this).data('id'));
|
||||
$('.datalist li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
parent.removeClass("datalist-invalid");
|
||||
ocultaTodos();
|
||||
})
|
||||
.on('click', (e) => {
|
||||
if (!$(e.target).closest('.datalist').length) ocultaTodos();
|
||||
});
|
||||
|
||||
$('.modal').on('hide.bs.modal', ocultaTodos);
|
||||
});
|
||||
const setDatalist = (selector, value = -1) => {
|
||||
const parent = $(selector).closest('.datalist');
|
||||
parent.find('ul li:not(.not-selectable)').each(function () {
|
||||
if ($(this).data("id") !== value) return;
|
||||
parent.find('.datalist-input').text($(this).text().trim());
|
||||
$(selector).val(value);
|
||||
$('.datalist li').removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
$(this).click();
|
||||
});
|
||||
}
|
||||
const makeRequiredDatalist = (selector, required = true) => $(selector).closest('.datalist').toggleClass("required", required);
|
||||
|
||||
//---------
|
||||
|
||||
function setDatalistFirst(selector) {
|
||||
var index = 1;
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
var num = elementRoot.find('ul li:not(.not-selectable)').length;
|
||||
if (index <= num) {
|
||||
while (elementRoot.find('ul li:nth-child(' + index + ')').hasClass("not-selectable") && index <= num) {
|
||||
index++;
|
||||
}
|
||||
var element = elementRoot.find('ul li:nth-child(' + index + ')');
|
||||
elementRoot.find('.datalist-input').text(element.html().replace(/[\t\n]+/g, ' ').trim());
|
||||
$(selector).val(element.data("id"));
|
||||
elementRoot.find("li").removeClass("selected");
|
||||
element.addClass("selected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function disableDatalist(selector, disabled = true) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
if (disabled) {
|
||||
elementRoot.addClass("disabled");
|
||||
elementRoot.find('.icono').removeClass('ing-cancelar iconoAzul pointer').addClass('ing-buscar');
|
||||
elementRoot.find('ul').hide();
|
||||
} else
|
||||
elementRoot.removeClass("disabled");
|
||||
}
|
||||
|
||||
function invalidDatalist(selector, invalid = true) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
if (invalid) {
|
||||
elementRoot.addClass("datalist-invalid");
|
||||
} else
|
||||
elementRoot.removeClass("datalist-invalid");
|
||||
}
|
||||
|
||||
//¿Se usa?
|
||||
function buscaDatalist(selector, valor) {
|
||||
selector.find('ul li').each(function () {
|
||||
var elem = $(this);
|
||||
if ($(this).parent().is('li'))
|
||||
elem = $(this).parent();
|
||||
if (!$(this).html().toUpperCase().includes(valor.toUpperCase())) {
|
||||
$(elem).hide();
|
||||
selector.find('.datalist-input').val("");
|
||||
selector.find("input[type=hidden]").val("");
|
||||
} else
|
||||
$(elem).show();
|
||||
});
|
||||
}
|
||||
function getDatalistText(selector, valor) {
|
||||
var elementRoot = $(selector).parents('.datalist');
|
||||
var text = "";
|
||||
$.each(elementRoot.find('ul li:not(.not-selectable)'), function () {
|
||||
if ($(this).data("id") == valor) {
|
||||
text = $(this).html();
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/* Inicialización en español para la extensión 'UI date picker' para jQuery. */
|
||||
/* Traducido por Vester (xvester@gmail.com). */
|
||||
( function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [ "../widgets/datepicker" ], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery.datepicker );
|
||||
}
|
||||
}( function( datepicker ) {
|
||||
|
||||
datepicker.regional.es = {
|
||||
closeText: "Cerrar",
|
||||
prevText: "<Ant",
|
||||
nextText: "Sig>",
|
||||
currentText: "Hoy",
|
||||
monthNames: [ "enero","febrero","marzo","abril","mayo","junio",
|
||||
"julio","agosto","septiembre","octubre","noviembre","diciembre" ],
|
||||
monthNamesShort: [ "ene","feb","mar","abr","may","jun",
|
||||
"jul","ago","sep","oct","nov","dic" ],
|
||||
dayNames: [ "domingo","lunes","martes","miércoles","jueves","viernes","sábado" ],
|
||||
dayNamesShort: [ "dom","lun","mar","mié","jue","vie","sáb" ],
|
||||
dayNamesMin: [ "D","L","M","X","J","V","S" ],
|
||||
weekHeader: "Sm",
|
||||
dateFormat: "dd/mm/yy",
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: "" };
|
||||
datepicker.setDefaults( datepicker.regional.es );
|
||||
|
||||
return datepicker.regional.es;
|
||||
|
||||
} ) );
|
||||
/* Inicialización en español para la extensión 'UI date picker' para jQuery. */
|
||||
/* Traducido por Vester (xvester@gmail.com). */
|
||||
( function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [ "../widgets/datepicker" ], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery.datepicker );
|
||||
}
|
||||
}( function( datepicker ) {
|
||||
|
||||
datepicker.regional.es = {
|
||||
closeText: "Cerrar",
|
||||
prevText: "<Ant",
|
||||
nextText: "Sig>",
|
||||
currentText: "Hoy",
|
||||
monthNames: [ "enero","febrero","marzo","abril","mayo","junio",
|
||||
"julio","agosto","septiembre","octubre","noviembre","diciembre" ],
|
||||
monthNamesShort: [ "ene","feb","mar","abr","may","jun",
|
||||
"jul","ago","sep","oct","nov","dic" ],
|
||||
dayNames: [ "domingo","lunes","martes","miércoles","jueves","viernes","sábado" ],
|
||||
dayNamesShort: [ "dom","lun","mar","mié","jue","vie","sáb" ],
|
||||
dayNamesMin: [ "D","L","M","X","J","V","S" ],
|
||||
weekHeader: "Sm",
|
||||
dateFormat: "dd/mm/yy",
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: "" };
|
||||
datepicker.setDefaults( datepicker.regional.es );
|
||||
|
||||
return datepicker.regional.es;
|
||||
|
||||
} ) );
|
||||
|
||||
168
js/faltas.js
168
js/faltas.js
@@ -1,84 +1,84 @@
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const filter = reactive({
|
||||
facultad: -1,
|
||||
profesor: '',
|
||||
porcentaje: 0,
|
||||
faltas: 0,
|
||||
tipoFaltas: true,
|
||||
});
|
||||
|
||||
const app = createApp({
|
||||
filter,
|
||||
facultades: [],
|
||||
profesores: [],
|
||||
faltas: [],
|
||||
mensaje: {
|
||||
titulo: '',
|
||||
texto: '',
|
||||
},
|
||||
async refresh() {
|
||||
if (filter.facultad == -1 || (filter.porcentaje < 10 && filter.faltas < 1)) {
|
||||
console.log('Facultad: ', filter.facultad, 'Porcentaje: ', filter.porcentaje, 'Faltas: ', filter.faltas);
|
||||
return;
|
||||
}
|
||||
$('#cargando').modal('show');
|
||||
try {
|
||||
|
||||
this.faltas = await fetch(`action/profesor_faltas.php?facultad=${this.filter.facultad}&${this.filter.tipoFaltas ? 'supervisor' : 'profesor'}&${this.filter.faltas > 0 ? 'faltas' : 'porcentaje'}=${this.filter.faltas > 0 ? this.filter.faltas : this.filter.porcentaje}`).then(res => res.json());
|
||||
if (this.faltas.error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Información';
|
||||
this.mensaje.texto = this.faltas.error;
|
||||
}
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
|
||||
async toExcel() {
|
||||
if (filter.facultad == -1 || filter.porcentaje < 10) {
|
||||
return;
|
||||
}
|
||||
$('#cargando').modal('show');
|
||||
try {
|
||||
const response = await fetch(`export/faltas_excel.php`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(this.faltas.map(falta => ({
|
||||
'profesor_clave': falta.profesor.profesor_clave,
|
||||
'profesor_correo': falta.profesor.profesor_correo,
|
||||
'profesor_nombre': falta.profesor.profesor_nombre,
|
||||
'faltas': falta.faltas,
|
||||
'porcentaje': `${falta.porcentaje}%`,
|
||||
'total': falta.total,
|
||||
}))),
|
||||
})
|
||||
|
||||
const blob = await response.blob();
|
||||
window.saveAs(blob, `faltas_${this.facultades.find(facultad => facultad.facultad_id == filter.facultad).facultad_nombre}_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
console.log('Error: ', error);
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
this.facultades = await fetch('action/action_facultad.php').then(res => res.json());
|
||||
this.profesores = await fetch('action/action_profesor.php').then(res => res.json());
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
console.log('Error: ', error);
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const filter = reactive({
|
||||
facultad: -1,
|
||||
profesor: '',
|
||||
porcentaje: 0,
|
||||
faltas: 0,
|
||||
tipoFaltas: true,
|
||||
});
|
||||
|
||||
const app = createApp({
|
||||
filter,
|
||||
facultades: [],
|
||||
profesores: [],
|
||||
faltas: [],
|
||||
mensaje: {
|
||||
titulo: '',
|
||||
texto: '',
|
||||
},
|
||||
async refresh() {
|
||||
if (filter.facultad == -1 || (filter.porcentaje < 10 && filter.faltas < 1)) {
|
||||
console.log('Facultad: ', filter.facultad, 'Porcentaje: ', filter.porcentaje, 'Faltas: ', filter.faltas);
|
||||
return;
|
||||
}
|
||||
$('#cargando').modal('show');
|
||||
try {
|
||||
|
||||
this.faltas = await fetch(`action/profesor_faltas.php?facultad=${this.filter.facultad}&${this.filter.tipoFaltas ? 'supervisor' : 'profesor'}&${this.filter.faltas > 0 ? 'faltas' : 'porcentaje'}=${this.filter.faltas > 0 ? this.filter.faltas : this.filter.porcentaje}`).then(res => res.json());
|
||||
if (this.faltas.error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Información';
|
||||
this.mensaje.texto = this.faltas.error;
|
||||
}
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
|
||||
async toExcel() {
|
||||
if (filter.facultad == -1 || filter.porcentaje < 10) {
|
||||
return;
|
||||
}
|
||||
$('#cargando').modal('show');
|
||||
try {
|
||||
const response = await fetch(`export/faltas_excel.php`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(this.faltas.map(falta => ({
|
||||
'profesor_clave': falta.profesor.profesor_clave,
|
||||
'profesor_correo': falta.profesor.profesor_correo,
|
||||
'profesor_nombre': falta.profesor.profesor_nombre,
|
||||
'faltas': falta.faltas,
|
||||
'porcentaje': `${falta.porcentaje}%`,
|
||||
'total': falta.total,
|
||||
}))),
|
||||
})
|
||||
|
||||
const blob = await response.blob();
|
||||
window.saveAs(blob, `faltas_${this.facultades.find(facultad => facultad.facultad_id == filter.facultad).facultad_nombre}_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
console.log('Error: ', error);
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
this.facultades = await fetch('action/action_facultad.php').then(res => res.json());
|
||||
this.profesores = await fetch('action/action_profesor.php').then(res => res.json());
|
||||
} catch (error) {
|
||||
$('.modal#mensaje').modal('show');
|
||||
this.mensaje.titulo = 'Error';
|
||||
this.mensaje.texto = 'No se pudo cargar los datos';
|
||||
console.log('Error: ', error);
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
212
js/horario.js
212
js/horario.js
@@ -1,106 +1,106 @@
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const profesores = reactive({
|
||||
data: [],
|
||||
search: null,
|
||||
fetch: async function () {
|
||||
const response = await fetch('action/action_profesor.php');
|
||||
this.data = await response.json();
|
||||
},
|
||||
get clave() {
|
||||
const match = this.search.match(/^\((.+)\)/);
|
||||
return match ? match[1] : '';
|
||||
},
|
||||
get current() {
|
||||
return this.data.find((profesor) => profesor.profesor_clave === profesores.clave);
|
||||
},
|
||||
});
|
||||
const facultades = reactive({
|
||||
data: [],
|
||||
fetch: async function () {
|
||||
const facultades = await fetch('action/action_facultad.php').then(response => response.json());
|
||||
const carreras = await fetch(`action/carrera.php`).then(response => response.json());
|
||||
this.data = await Promise.all(facultades.map(async (facultad) => ({
|
||||
...facultad,
|
||||
carreras: await Promise.all(carreras.filter((carrera) => carrera.facultad_id === facultad.facultad_id).map(async (carrera) => {
|
||||
const grupos = await fetch(`action/action_grupo.php?carrera_id=${carrera.carrera_id}`).then(response => response.json());
|
||||
return {
|
||||
...carrera,
|
||||
grupos,
|
||||
};
|
||||
})),
|
||||
})));
|
||||
this.data = this.data.filter((facultad) => facultad.carreras.length > 0);
|
||||
}
|
||||
});
|
||||
const horarios = reactive({
|
||||
data: [],
|
||||
fetch: async function (grupo = null, carrera_id = null) {
|
||||
if (grupo && carrera_id) {
|
||||
const response = await fetch(`action/action_horario.php?grupo=${grupo}&carrera_id=${carrera_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
else if (profesores.current) {
|
||||
const response = await fetch(`action/action_horario.php?profesor_id=${profesores.current.profesor_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
},
|
||||
get structure() {
|
||||
if (this.data.length === 0)
|
||||
return null;
|
||||
const structure = {
|
||||
sábado: this.data.some((horario) => horario.horario_dia === 6),
|
||||
hora_mínima: Math.min(...this.data.map((horario) => parseInt(horario.horario_hora.split(':')[0]))),
|
||||
hora_máxima: Math.max(...this.data.map((horario) => {
|
||||
const [hour, minute] = horario.horario_fin.split(':').map(Number);
|
||||
return hour + Math.ceil(minute / 60);
|
||||
})),
|
||||
horas_totales: 0
|
||||
};
|
||||
structure.horas_totales = structure.hora_máxima - structure.hora_mínima;
|
||||
return structure;
|
||||
},
|
||||
get blocks() {
|
||||
if (this.data.length === 0)
|
||||
return null;
|
||||
return [...Array(this.structure.horas_totales).keys()].flatMap(hora => {
|
||||
const baseHour = hora + this.structure.hora_mínima;
|
||||
return [0, 15, 30, 45].map(block => ({ hour: baseHour, block }));
|
||||
});
|
||||
},
|
||||
getHorarioData(hour, block, día) {
|
||||
const foundHorario = this.data.find((horario) => parseInt(horario.horario_hora.split(':')[0]) === hour &&
|
||||
parseInt(horario.horario_hora.split(':')[1]) === block &&
|
||||
horario.horario_dia === día);
|
||||
return foundHorario;
|
||||
},
|
||||
isOccupied(hora, bloque, day) {
|
||||
if (this.getHorarioData(hora, bloque, day)) {
|
||||
return false;
|
||||
}
|
||||
const currentTimeInMinutes = hora * 60 + bloque;
|
||||
for (const item of this.data) {
|
||||
if (item.horario_dia !== day) {
|
||||
continue; // Skip items that are not on the specified day
|
||||
}
|
||||
// Split the hour and minute from horario_hora
|
||||
const [startHour, startMinute] = item.horario_hora.split(":").map(Number);
|
||||
const startTimeInMinutes = startHour * 60 + startMinute;
|
||||
// Calculate end time using duracion
|
||||
const [durationHours, durationMinutes] = item.duracion.split(":").map(Number);
|
||||
const endTimeInMinutes = startTimeInMinutes + (durationHours * 60) + durationMinutes;
|
||||
if (currentTimeInMinutes >= startTimeInMinutes && currentTimeInMinutes < endTimeInMinutes) {
|
||||
return true; // The block is occupied
|
||||
}
|
||||
}
|
||||
return false; // The block is not occupied by any class
|
||||
}
|
||||
});
|
||||
const app = createApp({
|
||||
profesores,
|
||||
horarios,
|
||||
facultades,
|
||||
mounted: async function () {
|
||||
await profesores.fetch();
|
||||
await facultades.fetch();
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
|
||||
const profesores = reactive({
|
||||
data: [],
|
||||
search: null,
|
||||
fetch: async function () {
|
||||
const response = await fetch('action/action_profesor.php');
|
||||
this.data = await response.json();
|
||||
},
|
||||
get clave() {
|
||||
const match = this.search.match(/^\((.+)\)/);
|
||||
return match ? match[1] : '';
|
||||
},
|
||||
get current() {
|
||||
return this.data.find((profesor) => profesor.profesor_clave === profesores.clave);
|
||||
},
|
||||
});
|
||||
const facultades = reactive({
|
||||
data: [],
|
||||
fetch: async function () {
|
||||
const facultades = await fetch('action/action_facultad.php').then(response => response.json());
|
||||
const carreras = await fetch(`action/carrera.php`).then(response => response.json());
|
||||
this.data = await Promise.all(facultades.map(async (facultad) => ({
|
||||
...facultad,
|
||||
carreras: await Promise.all(carreras.filter((carrera) => carrera.facultad_id === facultad.facultad_id).map(async (carrera) => {
|
||||
const grupos = await fetch(`action/action_grupo.php?carrera_id=${carrera.carrera_id}`).then(response => response.json());
|
||||
return {
|
||||
...carrera,
|
||||
grupos,
|
||||
};
|
||||
})),
|
||||
})));
|
||||
this.data = this.data.filter((facultad) => facultad.carreras.length > 0);
|
||||
}
|
||||
});
|
||||
const horarios = reactive({
|
||||
data: [],
|
||||
fetch: async function (grupo = null, carrera_id = null) {
|
||||
if (grupo && carrera_id) {
|
||||
const response = await fetch(`action/action_horario.php?grupo=${grupo}&carrera_id=${carrera_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
else if (profesores.current) {
|
||||
const response = await fetch(`action/action_horario.php?profesor_id=${profesores.current.profesor_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
},
|
||||
get structure() {
|
||||
if (this.data.length === 0)
|
||||
return null;
|
||||
const structure = {
|
||||
sábado: this.data.some((horario) => horario.horario_dia === 6),
|
||||
hora_mínima: Math.min(...this.data.map((horario) => parseInt(horario.horario_hora.split(':')[0]))),
|
||||
hora_máxima: Math.max(...this.data.map((horario) => {
|
||||
const [hour, minute] = horario.horario_fin.split(':').map(Number);
|
||||
return hour + Math.ceil(minute / 60);
|
||||
})),
|
||||
horas_totales: 0
|
||||
};
|
||||
structure.horas_totales = structure.hora_máxima - structure.hora_mínima;
|
||||
return structure;
|
||||
},
|
||||
get blocks() {
|
||||
if (this.data.length === 0)
|
||||
return null;
|
||||
return [...Array(this.structure.horas_totales).keys()].flatMap(hora => {
|
||||
const baseHour = hora + this.structure.hora_mínima;
|
||||
return [0, 15, 30, 45].map(block => ({ hour: baseHour, block }));
|
||||
});
|
||||
},
|
||||
getHorarioData(hour, block, día) {
|
||||
const foundHorario = this.data.find((horario) => parseInt(horario.horario_hora.split(':')[0]) === hour &&
|
||||
parseInt(horario.horario_hora.split(':')[1]) === block &&
|
||||
horario.horario_dia === día);
|
||||
return foundHorario;
|
||||
},
|
||||
isOccupied(hora, bloque, day) {
|
||||
if (this.getHorarioData(hora, bloque, day)) {
|
||||
return false;
|
||||
}
|
||||
const currentTimeInMinutes = hora * 60 + bloque;
|
||||
for (const item of this.data) {
|
||||
if (item.horario_dia !== day) {
|
||||
continue; // Skip items that are not on the specified day
|
||||
}
|
||||
// Split the hour and minute from horario_hora
|
||||
const [startHour, startMinute] = item.horario_hora.split(":").map(Number);
|
||||
const startTimeInMinutes = startHour * 60 + startMinute;
|
||||
// Calculate end time using duracion
|
||||
const [durationHours, durationMinutes] = item.duracion.split(":").map(Number);
|
||||
const endTimeInMinutes = startTimeInMinutes + (durationHours * 60) + durationMinutes;
|
||||
if (currentTimeInMinutes >= startTimeInMinutes && currentTimeInMinutes < endTimeInMinutes) {
|
||||
return true; // The block is occupied
|
||||
}
|
||||
}
|
||||
return false; // The block is not occupied by any class
|
||||
}
|
||||
});
|
||||
const app = createApp({
|
||||
profesores,
|
||||
horarios,
|
||||
facultades,
|
||||
mounted: async function () {
|
||||
await profesores.fetch();
|
||||
await facultades.fetch();
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
24
js/jquery-ui.js
vendored
24
js/jquery-ui.js
vendored
File diff suppressed because one or more lines are too long
4
js/jquery.min.js
vendored
4
js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
230
js/periodos.js
230
js/periodos.js
@@ -1,115 +1,115 @@
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
const app = createApp({
|
||||
periodos: [],
|
||||
niveles: [],
|
||||
messages: [],
|
||||
addMessage(title, text, type) {
|
||||
this.messages.push({ title, text, type, timestamp: new Date() });
|
||||
},
|
||||
async sendRequest(action, periodo_id, data) {
|
||||
const response = await fetch('action/periodos.php', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
action: action,
|
||||
periodo_id: periodo_id,
|
||||
...data
|
||||
})
|
||||
});
|
||||
return await response.json();
|
||||
},
|
||||
async changeNivel(periodo, nivel_id) {
|
||||
if (periodo.nivel_id === nivel_id)
|
||||
return;
|
||||
const result = await this.sendRequest('changeNivel', periodo.periodo_id, { nivel_id: nivel_id });
|
||||
if (result.success) {
|
||||
this.addMessage('Nivel cambiado', `El nivel del periodo ${periodo.periodo_nombre} ha sido cambiado a ${this.niveles.find((nivel) => nivel.nivel_id === nivel_id)?.nivel_nombre}`, 'success');
|
||||
periodo.nivel_id = nivel_id;
|
||||
periodo.nivel = this.niveles.find((nivel) => nivel.nivel_id === nivel_id)?.nivel_nombre || '';
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar nivel', `No se pudo cambiar el nivel del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async changeFechaInicio(periodo, fecha_inicio) {
|
||||
const result = await this.sendRequest('changeFechaInicio', periodo.periodo_id, { periodo_fecha_inicio: fecha_inicio });
|
||||
if (result.success) {
|
||||
this.addMessage('Fecha de inicio cambiada', `La fecha de inicio del periodo ${periodo.periodo_nombre} ha sido cambiada a ${fecha_inicio}`, 'success');
|
||||
periodo.periodo_fecha_inicio = fecha_inicio;
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar fecha de inicio', `No se pudo cambiar la fecha de inicio del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async changeFechaFin(periodo, fecha_fin) {
|
||||
const result = await this.sendRequest('changeFechaFin', periodo.periodo_id, { periodo_fecha_fin: fecha_fin });
|
||||
if (result.success) {
|
||||
this.addMessage('Fecha de fin cambiada', `La fecha de fin del periodo ${periodo.periodo_nombre} ha sido cambiada a ${fecha_fin}`, 'success');
|
||||
periodo.periodo_fecha_fin = fecha_fin;
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar fecha de fin', `No se pudo cambiar la fecha de fin del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async updatePeriodo(periodo) {
|
||||
const result = await this.sendRequest('updatePeriodo', periodo.periodo_id, {
|
||||
periodo_nombre: periodo.periodo_nombre,
|
||||
id_periodo_sgu: periodo.id_periodo_sgu,
|
||||
periodo_clave: periodo.periodo_clave,
|
||||
});
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo actualizado', `El periodo ${periodo.periodo_nombre} ha sido actualizado`, 'success');
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al actualizar periodo', `No se pudo actualizar el periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async createPeriodo(newPeriodo) {
|
||||
if (newPeriodo.periodo_nombre === null || newPeriodo.nivel_id === null || newPeriodo.periodo_fecha_inicio === null || newPeriodo.periodo_fecha_fin === null) {
|
||||
this.addMessage('Error al crear periodo', `No se pudo crear el periodo ${newPeriodo.periodo_nombre}`, 'danger');
|
||||
return;
|
||||
}
|
||||
const result = await fetch('action/periodos.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(newPeriodo)
|
||||
}).then(res => res.json());
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo creado', `El periodo ${newPeriodo.periodo_nombre} ha sido creado`, 'success');
|
||||
this.periodos;
|
||||
Object.keys(newPeriodo).forEach(key => newPeriodo[key] = null);
|
||||
newPeriodo.nivel_id = '';
|
||||
this.periodos = await fetch('action/periodos.php').then(res => res.json());
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al crear periodo', `No se pudo crear el periodo ${newPeriodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async deletePeriodo(periodo) {
|
||||
const response = await fetch('action/periodos.php', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
periodo_id: periodo.periodo_id,
|
||||
})
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo eliminado', `El periodo ${periodo.periodo_nombre} ha sido eliminado`, 'success');
|
||||
this.periodos = this.periodos.filter((p) => p.periodo_id !== periodo.periodo_id);
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al eliminar periodo', `No se pudo eliminar el periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.periodos = await fetch('action/periodos.php').then(res => res.json());
|
||||
this.niveles = await fetch('action/nivel.php').then(res => res.json());
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
const app = createApp({
|
||||
periodos: [],
|
||||
niveles: [],
|
||||
messages: [],
|
||||
addMessage(title, text, type) {
|
||||
this.messages.push({ title, text, type, timestamp: new Date() });
|
||||
},
|
||||
async sendRequest(action, periodo_id, data) {
|
||||
const response = await fetch('action/periodos.php', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
action: action,
|
||||
periodo_id: periodo_id,
|
||||
...data
|
||||
})
|
||||
});
|
||||
return await response.json();
|
||||
},
|
||||
async changeNivel(periodo, nivel_id) {
|
||||
if (periodo.nivel_id === nivel_id)
|
||||
return;
|
||||
const result = await this.sendRequest('changeNivel', periodo.periodo_id, { nivel_id: nivel_id });
|
||||
if (result.success) {
|
||||
this.addMessage('Nivel cambiado', `El nivel del periodo ${periodo.periodo_nombre} ha sido cambiado a ${this.niveles.find((nivel) => nivel.nivel_id === nivel_id)?.nivel_nombre}`, 'success');
|
||||
periodo.nivel_id = nivel_id;
|
||||
periodo.nivel = this.niveles.find((nivel) => nivel.nivel_id === nivel_id)?.nivel_nombre || '';
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar nivel', `No se pudo cambiar el nivel del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async changeFechaInicio(periodo, fecha_inicio) {
|
||||
const result = await this.sendRequest('changeFechaInicio', periodo.periodo_id, { periodo_fecha_inicio: fecha_inicio });
|
||||
if (result.success) {
|
||||
this.addMessage('Fecha de inicio cambiada', `La fecha de inicio del periodo ${periodo.periodo_nombre} ha sido cambiada a ${fecha_inicio}`, 'success');
|
||||
periodo.periodo_fecha_inicio = fecha_inicio;
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar fecha de inicio', `No se pudo cambiar la fecha de inicio del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async changeFechaFin(periodo, fecha_fin) {
|
||||
const result = await this.sendRequest('changeFechaFin', periodo.periodo_id, { periodo_fecha_fin: fecha_fin });
|
||||
if (result.success) {
|
||||
this.addMessage('Fecha de fin cambiada', `La fecha de fin del periodo ${periodo.periodo_nombre} ha sido cambiada a ${fecha_fin}`, 'success');
|
||||
periodo.periodo_fecha_fin = fecha_fin;
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al cambiar fecha de fin', `No se pudo cambiar la fecha de fin del periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async updatePeriodo(periodo) {
|
||||
const result = await this.sendRequest('updatePeriodo', periodo.periodo_id, {
|
||||
periodo_nombre: periodo.periodo_nombre,
|
||||
id_periodo_sgu: periodo.id_periodo_sgu,
|
||||
periodo_clave: periodo.periodo_clave,
|
||||
});
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo actualizado', `El periodo ${periodo.periodo_nombre} ha sido actualizado`, 'success');
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al actualizar periodo', `No se pudo actualizar el periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async createPeriodo(newPeriodo) {
|
||||
if (newPeriodo.periodo_nombre === null || newPeriodo.nivel_id === null || newPeriodo.periodo_fecha_inicio === null || newPeriodo.periodo_fecha_fin === null) {
|
||||
this.addMessage('Error al crear periodo', `No se pudo crear el periodo ${newPeriodo.periodo_nombre}`, 'danger');
|
||||
return;
|
||||
}
|
||||
const result = await fetch('action/periodos.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(newPeriodo)
|
||||
}).then(res => res.json());
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo creado', `El periodo ${newPeriodo.periodo_nombre} ha sido creado`, 'success');
|
||||
this.periodos;
|
||||
Object.keys(newPeriodo).forEach(key => newPeriodo[key] = null);
|
||||
newPeriodo.nivel_id = '';
|
||||
this.periodos = await fetch('action/periodos.php').then(res => res.json());
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al crear periodo', `No se pudo crear el periodo ${newPeriodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async deletePeriodo(periodo) {
|
||||
const response = await fetch('action/periodos.php', {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
periodo_id: periodo.periodo_id,
|
||||
})
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
this.addMessage('Periodo eliminado', `El periodo ${periodo.periodo_nombre} ha sido eliminado`, 'success');
|
||||
this.periodos = this.periodos.filter((p) => p.periodo_id !== periodo.periodo_id);
|
||||
}
|
||||
else {
|
||||
this.addMessage('Error al eliminar periodo', `No se pudo eliminar el periodo ${periodo.periodo_nombre}`, 'danger');
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.periodos = await fetch('action/periodos.php').then(res => res.json());
|
||||
this.niveles = await fetch('action/nivel.php').then(res => res.json());
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
212
js/puestos.js
212
js/puestos.js
@@ -1,106 +1,106 @@
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
|
||||
// añade una ventana de confirmación al intentar cambiar de página
|
||||
const app = createApp({
|
||||
message: null,
|
||||
puestos: [],
|
||||
carreras: [],
|
||||
materias: [],
|
||||
usuarios: [],
|
||||
async nuevoPuesto(nuevoPuesto) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
puesto_nombre: nuevoPuesto
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.puestos.push(data);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
to_delete: null,
|
||||
async eliminarPuesto(puesto_id) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({
|
||||
puesto_id
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
}, 3000);
|
||||
this.puestos = this.puestos.filter((p) => p.puesto_id !== puesto_id);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
async actualizarPuesto(puesto_id, materias, usuario_id) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
puesto_id,
|
||||
materias: materias.map(m => m.materia_id),
|
||||
usuario_id
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
|
||||
modificado = false;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
}, 3000);
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
async descargar() {
|
||||
$('div.modal#cargando').modal('show');
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await fetch('action/action_puestos_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
});
|
||||
const blob = await res.blob();
|
||||
window.saveAs(blob, `puestos_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.response && error.response.status === 413) {
|
||||
alert('Your request is too large! Please reduce the data size and try again.');
|
||||
}
|
||||
else {
|
||||
alert('An error occurred: ' + error.message);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
this.puestos = await fetch('action/puesto.php').then(res => res.json());
|
||||
this.carreras = await fetch('action/action_carreras.php').then(res => res.json());
|
||||
this.materias = await fetch('action/action_materias.php').then(res => res.json());
|
||||
this.usuarios = await fetch('action/usuarios.php').then(res => res.json());
|
||||
}
|
||||
}).mount('#app');
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
|
||||
// añade una ventana de confirmación al intentar cambiar de página
|
||||
const app = createApp({
|
||||
message: null,
|
||||
puestos: [],
|
||||
carreras: [],
|
||||
materias: [],
|
||||
usuarios: [],
|
||||
async nuevoPuesto(nuevoPuesto) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
puesto_nombre: nuevoPuesto
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.puestos.push(data);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
to_delete: null,
|
||||
async eliminarPuesto(puesto_id) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({
|
||||
puesto_id
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
}, 3000);
|
||||
this.puestos = this.puestos.filter((p) => p.puesto_id !== puesto_id);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
async actualizarPuesto(puesto_id, materias, usuario_id) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
puesto_id,
|
||||
materias: materias.map(m => m.materia_id),
|
||||
usuario_id
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
|
||||
modificado = false;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
}, 3000);
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
async descargar() {
|
||||
$('div.modal#cargando').modal('show');
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await fetch('action/action_puestos_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
});
|
||||
const blob = await res.blob();
|
||||
window.saveAs(blob, `puestos_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.response && error.response.status === 413) {
|
||||
alert('Your request is too large! Please reduce the data size and try again.');
|
||||
}
|
||||
else {
|
||||
alert('An error occurred: ' + error.message);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
this.puestos = await fetch('action/puesto.php').then(res => res.json());
|
||||
this.carreras = await fetch('action/action_carreras.php').then(res => res.json());
|
||||
this.materias = await fetch('action/action_materias.php').then(res => res.json());
|
||||
this.usuarios = await fetch('action/usuarios.php').then(res => res.json());
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
@@ -1,178 +1,178 @@
|
||||
// Get references to the HTML elements
|
||||
const form = document.getElementById('form');
|
||||
const steps = Array.from(form.querySelectorAll('.step'));
|
||||
const nextButton = document.getElementById('next-button');
|
||||
const prevButton = document.getElementById('prev-button');
|
||||
let currentStep = 0;
|
||||
// #clave_profesor on change => show step 2
|
||||
const clave_profesor = document.getElementById('clave_profesor');
|
||||
const horario_reponer = document.getElementById('horario_reponer');
|
||||
const fechas_clase = document.getElementById('fechas_clase');
|
||||
const fecha_reponer = $('#fecha_reponer');
|
||||
const hora_reponer = $('#hora_reponer');
|
||||
const minutos_reponer = $('#minutos_reponer');
|
||||
clave_profesor.addEventListener('change', async () => {
|
||||
const step2 = document.getElementById('step-2');
|
||||
clave_profesor.disabled = true;
|
||||
// get option which value is the same as clave_profesor.value
|
||||
const option = document.querySelector(`option[value="${clave_profesor.value}"]`);
|
||||
// make a form data with #form
|
||||
const profesor_id = document.getElementById('profesor_id');
|
||||
profesor_id.value = option.dataset.id;
|
||||
const formData = new FormData(form);
|
||||
const response = await fetch(`./action/action_horario_profesor.php`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data['success'] === false) {
|
||||
const message = "Hubo un error al obtener los horarios del profesor.";
|
||||
const title = 'Error';
|
||||
const color = 'danger';
|
||||
triggerMessage(message, title, color);
|
||||
return;
|
||||
}
|
||||
const horarios = data.data;
|
||||
const initial = document.createElement('option');
|
||||
initial.value = '';
|
||||
initial.textContent = 'Seleccione un horario';
|
||||
initial.selected = true;
|
||||
initial.disabled = true;
|
||||
horario_reponer.innerHTML = '';
|
||||
horario_reponer.appendChild(initial);
|
||||
horarios.forEach((horario) => {
|
||||
const dias = ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo'];
|
||||
const option = document.createElement('option');
|
||||
option.value = `${horario.id}`;
|
||||
// materia máx 25 caracteres, if materia.length > 25 then slice(0, 20)
|
||||
const max = 25;
|
||||
option.textContent = `${horario.materia.slice(0, max) + (horario.materia.length > max ? '...' : '')} - Grupo: ${horario.grupo} - ${horario.hora.slice(0, 5)}-${horario.hora_final.slice(0, 5)} - Salon: ${horario.salon} - ${horario.dia}`;
|
||||
option.dataset.materia = `${horario.materia}`;
|
||||
option.dataset.grupo = `${horario.grupo}`;
|
||||
option.dataset.hora = `${horario.hora.slice(0, 5)}`; // slice(0, 5) => HH:MM
|
||||
option.dataset.hora_final = `${horario.hora_final.slice(0, 5)}`;
|
||||
option.dataset.salon = `${horario.salon}`;
|
||||
option.dataset.dia = `${horario.dia}`;
|
||||
option.dataset.id = `${horario.id}`;
|
||||
horario_reponer.appendChild(option);
|
||||
});
|
||||
currentStep = 1;
|
||||
step2.style.display = 'block';
|
||||
prevButton.disabled = false;
|
||||
});
|
||||
// disable clave_profesor
|
||||
// from second step to first step
|
||||
prevButton.addEventListener('click', () => {
|
||||
const inputs = [clave_profesor, horario_reponer, fechas_clase, fecha_reponer, hora_reponer];
|
||||
switch (currentStep) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
const step = document.getElementById(`step-${currentStep + 1}`);
|
||||
step.style.display = 'none';
|
||||
inputs[currentStep - 1].disabled = false;
|
||||
inputs[currentStep - 1].value = '';
|
||||
if (--currentStep === 0) {
|
||||
prevButton.disabled = true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
const step5 = document.getElementById('step-5');
|
||||
step5.style.display = 'none';
|
||||
fecha_reponer.prop('disabled', false);
|
||||
fecha_reponer.val('');
|
||||
hora_reponer.parent().removeClass('disabled');
|
||||
hora_reponer.siblings('.datalist-input').text('hh');
|
||||
hora_reponer.val('');
|
||||
minutos_reponer.parent().removeClass('disabled');
|
||||
minutos_reponer.siblings('.datalist-input').text('mm');
|
||||
minutos_reponer.val('');
|
||||
currentStep--;
|
||||
break;
|
||||
}
|
||||
nextButton.disabled = true;
|
||||
});
|
||||
// #horario_reponer on change => show step 3
|
||||
horario_reponer.addEventListener('change', async () => {
|
||||
const selected = horario_reponer.querySelector(`option[value="${horario_reponer.value}"]`);
|
||||
horario_reponer.title = `Materia: ${selected.dataset.materia} - Grupo: ${selected.dataset.grupo} - Horario: ${selected.dataset.hora}-${selected.dataset.hora_final} - Salon: ${selected.dataset.salon} - Día: ${selected.dataset.dia}`;
|
||||
const step3 = document.getElementById('step-3');
|
||||
horario_reponer.disabled = true;
|
||||
// make a form data with #form
|
||||
const response = await fetch(`./action/action_fechas_clase.php?horario_id=${horario_reponer.value}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data['success'] === false) {
|
||||
const message = "Hubo un error al obtener las fechas de clase.";
|
||||
const title = 'Error';
|
||||
const color = 'danger';
|
||||
triggerMessage(message, title, color);
|
||||
return;
|
||||
}
|
||||
const meses = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
|
||||
const fechas = data.data;
|
||||
const initial = document.createElement('option');
|
||||
initial.value = '';
|
||||
initial.textContent = 'Seleccione la fecha de la falta';
|
||||
initial.selected = true;
|
||||
initial.disabled = true;
|
||||
fechas_clase.innerHTML = '';
|
||||
fechas_clase.appendChild(initial);
|
||||
fechas_clase.title = 'Seleccione la fecha de la falta';
|
||||
fechas.forEach((fecha) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = `${fecha}`;
|
||||
option.textContent = `${fecha.dia_mes} de ${meses[fecha.month - 1]} de ${fecha.year}`;
|
||||
fechas_clase.appendChild(option);
|
||||
});
|
||||
step3.style.display = 'block';
|
||||
currentStep = 2;
|
||||
});
|
||||
// #fechas_clase on change => show step 4
|
||||
fechas_clase.addEventListener('change', () => {
|
||||
const step4 = document.getElementById('step-4');
|
||||
step4.style.display = 'block';
|
||||
fechas_clase.disabled = true;
|
||||
currentStep = 3;
|
||||
});
|
||||
// when both #fecha_reponer and #hora_reponer are selected => show step 5
|
||||
const lastStep = () => {
|
||||
// timeout to wait for the value to be set
|
||||
setTimeout(() => {
|
||||
if (fecha_reponer.val() !== '' && hora_reponer.val() !== '' && minutos_reponer.val() !== '') {
|
||||
const step5 = document.getElementById('step-5');
|
||||
step5.style.display = 'block';
|
||||
// disable both
|
||||
fecha_reponer.prop('disabled', true);
|
||||
hora_reponer.parent().addClass('disabled');
|
||||
minutos_reponer.parent().addClass('disabled');
|
||||
const nextButton = document.getElementById('next-button');
|
||||
// remove property disabled
|
||||
nextButton.removeAttribute('disabled');
|
||||
currentStep = 4;
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
fecha_reponer.on('change', lastStep);
|
||||
// on click on the sibling ul>li of #hora_reponer and #minutos_reponer
|
||||
hora_reponer.siblings('ul').children('li').on('click', lastStep);
|
||||
minutos_reponer.siblings('ul').children('li').on('click', lastStep);
|
||||
// Initialize the form
|
||||
hideSteps();
|
||||
showCurrentStep();
|
||||
function hideSteps() {
|
||||
steps.forEach((step) => {
|
||||
step.style.display = 'none';
|
||||
});
|
||||
}
|
||||
function showCurrentStep() {
|
||||
steps[currentStep].style.display = 'block';
|
||||
prevButton.disabled = currentStep === 0;
|
||||
}
|
||||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
// Handle form submission
|
||||
// You can access the form data using the FormData API or serialize it manually
|
||||
}
|
||||
export {};
|
||||
// Get references to the HTML elements
|
||||
const form = document.getElementById('form');
|
||||
const steps = Array.from(form.querySelectorAll('.step'));
|
||||
const nextButton = document.getElementById('next-button');
|
||||
const prevButton = document.getElementById('prev-button');
|
||||
let currentStep = 0;
|
||||
// #clave_profesor on change => show step 2
|
||||
const clave_profesor = document.getElementById('clave_profesor');
|
||||
const horario_reponer = document.getElementById('horario_reponer');
|
||||
const fechas_clase = document.getElementById('fechas_clase');
|
||||
const fecha_reponer = $('#fecha_reponer');
|
||||
const hora_reponer = $('#hora_reponer');
|
||||
const minutos_reponer = $('#minutos_reponer');
|
||||
clave_profesor.addEventListener('change', async () => {
|
||||
const step2 = document.getElementById('step-2');
|
||||
clave_profesor.disabled = true;
|
||||
// get option which value is the same as clave_profesor.value
|
||||
const option = document.querySelector(`option[value="${clave_profesor.value}"]`);
|
||||
// make a form data with #form
|
||||
const profesor_id = document.getElementById('profesor_id');
|
||||
profesor_id.value = option.dataset.id;
|
||||
const formData = new FormData(form);
|
||||
const response = await fetch(`./action/action_horario_profesor.php`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data['success'] === false) {
|
||||
const message = "Hubo un error al obtener los horarios del profesor.";
|
||||
const title = 'Error';
|
||||
const color = 'danger';
|
||||
triggerMessage(message, title, color);
|
||||
return;
|
||||
}
|
||||
const horarios = data.data;
|
||||
const initial = document.createElement('option');
|
||||
initial.value = '';
|
||||
initial.textContent = 'Seleccione un horario';
|
||||
initial.selected = true;
|
||||
initial.disabled = true;
|
||||
horario_reponer.innerHTML = '';
|
||||
horario_reponer.appendChild(initial);
|
||||
horarios.forEach((horario) => {
|
||||
const dias = ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo'];
|
||||
const option = document.createElement('option');
|
||||
option.value = `${horario.id}`;
|
||||
// materia máx 25 caracteres, if materia.length > 25 then slice(0, 20)
|
||||
const max = 25;
|
||||
option.textContent = `${horario.materia.slice(0, max) + (horario.materia.length > max ? '...' : '')} - Grupo: ${horario.grupo} - ${horario.hora.slice(0, 5)}-${horario.hora_final.slice(0, 5)} - Salon: ${horario.salon} - ${horario.dia}`;
|
||||
option.dataset.materia = `${horario.materia}`;
|
||||
option.dataset.grupo = `${horario.grupo}`;
|
||||
option.dataset.hora = `${horario.hora.slice(0, 5)}`; // slice(0, 5) => HH:MM
|
||||
option.dataset.hora_final = `${horario.hora_final.slice(0, 5)}`;
|
||||
option.dataset.salon = `${horario.salon}`;
|
||||
option.dataset.dia = `${horario.dia}`;
|
||||
option.dataset.id = `${horario.id}`;
|
||||
horario_reponer.appendChild(option);
|
||||
});
|
||||
currentStep = 1;
|
||||
step2.style.display = 'block';
|
||||
prevButton.disabled = false;
|
||||
});
|
||||
// disable clave_profesor
|
||||
// from second step to first step
|
||||
prevButton.addEventListener('click', () => {
|
||||
const inputs = [clave_profesor, horario_reponer, fechas_clase, fecha_reponer, hora_reponer];
|
||||
switch (currentStep) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
const step = document.getElementById(`step-${currentStep + 1}`);
|
||||
step.style.display = 'none';
|
||||
inputs[currentStep - 1].disabled = false;
|
||||
inputs[currentStep - 1].value = '';
|
||||
if (--currentStep === 0) {
|
||||
prevButton.disabled = true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
const step5 = document.getElementById('step-5');
|
||||
step5.style.display = 'none';
|
||||
fecha_reponer.prop('disabled', false);
|
||||
fecha_reponer.val('');
|
||||
hora_reponer.parent().removeClass('disabled');
|
||||
hora_reponer.siblings('.datalist-input').text('hh');
|
||||
hora_reponer.val('');
|
||||
minutos_reponer.parent().removeClass('disabled');
|
||||
minutos_reponer.siblings('.datalist-input').text('mm');
|
||||
minutos_reponer.val('');
|
||||
currentStep--;
|
||||
break;
|
||||
}
|
||||
nextButton.disabled = true;
|
||||
});
|
||||
// #horario_reponer on change => show step 3
|
||||
horario_reponer.addEventListener('change', async () => {
|
||||
const selected = horario_reponer.querySelector(`option[value="${horario_reponer.value}"]`);
|
||||
horario_reponer.title = `Materia: ${selected.dataset.materia} - Grupo: ${selected.dataset.grupo} - Horario: ${selected.dataset.hora}-${selected.dataset.hora_final} - Salon: ${selected.dataset.salon} - Día: ${selected.dataset.dia}`;
|
||||
const step3 = document.getElementById('step-3');
|
||||
horario_reponer.disabled = true;
|
||||
// make a form data with #form
|
||||
const response = await fetch(`./action/action_fechas_clase.php?horario_id=${horario_reponer.value}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data['success'] === false) {
|
||||
const message = "Hubo un error al obtener las fechas de clase.";
|
||||
const title = 'Error';
|
||||
const color = 'danger';
|
||||
triggerMessage(message, title, color);
|
||||
return;
|
||||
}
|
||||
const meses = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
|
||||
const fechas = data.data;
|
||||
const initial = document.createElement('option');
|
||||
initial.value = '';
|
||||
initial.textContent = 'Seleccione la fecha de la falta';
|
||||
initial.selected = true;
|
||||
initial.disabled = true;
|
||||
fechas_clase.innerHTML = '';
|
||||
fechas_clase.appendChild(initial);
|
||||
fechas_clase.title = 'Seleccione la fecha de la falta';
|
||||
fechas.forEach((fecha) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = `${fecha}`;
|
||||
option.textContent = `${fecha.dia_mes} de ${meses[fecha.month - 1]} de ${fecha.year}`;
|
||||
fechas_clase.appendChild(option);
|
||||
});
|
||||
step3.style.display = 'block';
|
||||
currentStep = 2;
|
||||
});
|
||||
// #fechas_clase on change => show step 4
|
||||
fechas_clase.addEventListener('change', () => {
|
||||
const step4 = document.getElementById('step-4');
|
||||
step4.style.display = 'block';
|
||||
fechas_clase.disabled = true;
|
||||
currentStep = 3;
|
||||
});
|
||||
// when both #fecha_reponer and #hora_reponer are selected => show step 5
|
||||
const lastStep = () => {
|
||||
// timeout to wait for the value to be set
|
||||
setTimeout(() => {
|
||||
if (fecha_reponer.val() !== '' && hora_reponer.val() !== '' && minutos_reponer.val() !== '') {
|
||||
const step5 = document.getElementById('step-5');
|
||||
step5.style.display = 'block';
|
||||
// disable both
|
||||
fecha_reponer.prop('disabled', true);
|
||||
hora_reponer.parent().addClass('disabled');
|
||||
minutos_reponer.parent().addClass('disabled');
|
||||
const nextButton = document.getElementById('next-button');
|
||||
// remove property disabled
|
||||
nextButton.removeAttribute('disabled');
|
||||
currentStep = 4;
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
fecha_reponer.on('change', lastStep);
|
||||
// on click on the sibling ul>li of #hora_reponer and #minutos_reponer
|
||||
hora_reponer.siblings('ul').children('li').on('click', lastStep);
|
||||
minutos_reponer.siblings('ul').children('li').on('click', lastStep);
|
||||
// Initialize the form
|
||||
hideSteps();
|
||||
showCurrentStep();
|
||||
function hideSteps() {
|
||||
steps.forEach((step) => {
|
||||
step.style.display = 'none';
|
||||
});
|
||||
}
|
||||
function showCurrentStep() {
|
||||
steps[currentStep].style.display = 'block';
|
||||
prevButton.disabled = currentStep === 0;
|
||||
}
|
||||
function handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
// Handle form submission
|
||||
// You can access the form data using the FormData API or serialize it manually
|
||||
}
|
||||
export {};
|
||||
|
||||
3892
js/richtext.js
3892
js/richtext.js
File diff suppressed because it is too large
Load Diff
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
* JQuery para el manejo de menu
|
||||
*/
|
||||
|
||||
$('#dismiss, .overlay').on('click', function () {
|
||||
// hide sidebar
|
||||
$('#sidebar').removeClass('active');
|
||||
// hide overlay
|
||||
$('.overlay').removeClass('active');
|
||||
$('.menu').css('visibility', 'visible');
|
||||
});
|
||||
|
||||
$('#sidebarCollapse').on('click', function () {
|
||||
// open sidebar
|
||||
$('#sidebar').addClass('active');
|
||||
// fade in the overlay
|
||||
$('.overlay').addClass('active');
|
||||
$('.menu').css('visibility', 'hidden');
|
||||
//$('.collapse.in').toggleClass('in');
|
||||
$('a[aria-expanded=true]').attr('aria-expanded', 'false');
|
||||
});
|
||||
|
||||
/*
|
||||
var Nightly = new Nightly(true, {
|
||||
//body: "backgorund color", // Default: #282828
|
||||
//texts: "texts color", // Default: #f5f5f5
|
||||
//inputs: {
|
||||
// color: "text color inside inputs", // Default: #f5f5f5
|
||||
// backgroundColor: "background color" // Default #313131
|
||||
//},
|
||||
//buttons: {
|
||||
// color: "button's text color", // Default: #f5f5f5
|
||||
// backgroundColor: "button's backgournd color" // #757575
|
||||
//},
|
||||
links: "#ffffff", // Default: #009688
|
||||
classes: [// Classes to apply when enabling the dark mode on certain elements
|
||||
{ apply: 'bg-head-dark', to: 'bg-head', },
|
||||
{ apply: 'form-control-dark', to: 'form-control', },
|
||||
{ apply: 'subMenu-dark', to: 'subMenu', },
|
||||
{ apply: 'sistema.text-white', to: 'sistema.text-secondary', },
|
||||
]
|
||||
});
|
||||
|
||||
if($(".fa-adjust")){
|
||||
$(".fa-adjust").click(function(){
|
||||
Nightly.toggle();
|
||||
});
|
||||
}*/
|
||||
|
||||
/*
|
||||
* JQuery para el manejo de menu
|
||||
*/
|
||||
|
||||
$('#dismiss, .overlay').on('click', function () {
|
||||
// hide sidebar
|
||||
$('#sidebar').removeClass('active');
|
||||
// hide overlay
|
||||
$('.overlay').removeClass('active');
|
||||
$('.menu').css('visibility', 'visible');
|
||||
});
|
||||
|
||||
$('#sidebarCollapse').on('click', function () {
|
||||
// open sidebar
|
||||
$('#sidebar').addClass('active');
|
||||
// fade in the overlay
|
||||
$('.overlay').addClass('active');
|
||||
$('.menu').css('visibility', 'hidden');
|
||||
//$('.collapse.in').toggleClass('in');
|
||||
$('a[aria-expanded=true]').attr('aria-expanded', 'false');
|
||||
});
|
||||
|
||||
/*
|
||||
var Nightly = new Nightly(true, {
|
||||
//body: "backgorund color", // Default: #282828
|
||||
//texts: "texts color", // Default: #f5f5f5
|
||||
//inputs: {
|
||||
// color: "text color inside inputs", // Default: #f5f5f5
|
||||
// backgroundColor: "background color" // Default #313131
|
||||
//},
|
||||
//buttons: {
|
||||
// color: "button's text color", // Default: #f5f5f5
|
||||
// backgroundColor: "button's backgournd color" // #757575
|
||||
//},
|
||||
links: "#ffffff", // Default: #009688
|
||||
classes: [// Classes to apply when enabling the dark mode on certain elements
|
||||
{ apply: 'bg-head-dark', to: 'bg-head', },
|
||||
{ apply: 'form-control-dark', to: 'form-control', },
|
||||
{ apply: 'subMenu-dark', to: 'subMenu', },
|
||||
{ apply: 'sistema.text-white', to: 'sistema.text-secondary', },
|
||||
]
|
||||
});
|
||||
|
||||
if($(".fa-adjust")){
|
||||
$(".fa-adjust").click(function(){
|
||||
Nightly.toggle();
|
||||
});
|
||||
}*/
|
||||
|
||||
|
||||
374
js/toggle.js
374
js/toggle.js
@@ -1,187 +1,187 @@
|
||||
/*\
|
||||
|*| ========================================================================
|
||||
|*| Bootstrap Toggle: bootstrap4-toggle.js v3.6.1
|
||||
|*| https://gitbrent.github.io/bootstrap4-toggle/
|
||||
|*| ========================================================================
|
||||
|*| Copyright 2018-2019 Brent Ely
|
||||
|*| Licensed under MIT
|
||||
|*| ========================================================================
|
||||
\*/
|
||||
|
||||
+function ($) {
|
||||
'use strict';
|
||||
|
||||
// TOGGLE PUBLIC CLASS DEFINITION
|
||||
// ==============================
|
||||
|
||||
var Toggle = function (element, options) {
|
||||
this.$element = $(element)
|
||||
this.options = $.extend({}, this.defaults(), options)
|
||||
this.render()
|
||||
}
|
||||
|
||||
Toggle.VERSION = '3.7.0-beta'
|
||||
|
||||
Toggle.DEFAULTS = {
|
||||
on: 'On',
|
||||
off: 'Off',
|
||||
onstyle: 'primary',
|
||||
offstyle: 'light',
|
||||
size: 'normal',
|
||||
style: '',
|
||||
width: null,
|
||||
height: null
|
||||
}
|
||||
|
||||
Toggle.prototype.defaults = function() {
|
||||
return {
|
||||
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
|
||||
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
|
||||
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
|
||||
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
|
||||
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
||||
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
||||
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
||||
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
|
||||
}
|
||||
}
|
||||
|
||||
Toggle.prototype.render = function () {
|
||||
this._onstyle = 'btn-' + this.options.onstyle
|
||||
this._offstyle = 'btn-' + this.options.offstyle
|
||||
var size
|
||||
= this.options.size === 'large' || this.options.size === 'lg' ? 'btn-lg'
|
||||
: this.options.size === 'small' || this.options.size === 'sm' ? 'btn-sm'
|
||||
: this.options.size === 'mini' || this.options.size === 'xs' ? 'btn-xs'
|
||||
: ''
|
||||
var $toggleOn = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.on)
|
||||
.addClass(this._onstyle + ' ' + size)
|
||||
var $toggleOff = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.off)
|
||||
.addClass(this._offstyle + ' ' + size)
|
||||
var $toggleHandle = $('<span class="toggle-handle btn btn-light">')
|
||||
.addClass(size)
|
||||
var $toggleGroup = $('<div class="toggle-group">')
|
||||
.append($toggleOn, $toggleOff, $toggleHandle)
|
||||
var $toggle = $('<div class="toggle btn" data-toggle="toggle" role="button">')
|
||||
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
|
||||
.addClass(size).addClass(this.options.style)
|
||||
|
||||
this.$element.wrap($toggle)
|
||||
$.extend(this, {
|
||||
$toggle: this.$element.parent(),
|
||||
$toggleOn: $toggleOn,
|
||||
$toggleOff: $toggleOff,
|
||||
$toggleGroup: $toggleGroup
|
||||
})
|
||||
this.$toggle.append($toggleGroup)
|
||||
|
||||
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
|
||||
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
|
||||
$toggleOn.addClass('toggle-on')
|
||||
$toggleOff.addClass('toggle-off')
|
||||
this.$toggle.css({ width: width, height: height })
|
||||
if (this.options.height) {
|
||||
$toggleOn.css('line-height', $toggleOn.height() + 'px')
|
||||
$toggleOff.css('line-height', $toggleOff.height() + 'px')
|
||||
}
|
||||
this.update(true)
|
||||
this.trigger(true)
|
||||
}
|
||||
|
||||
Toggle.prototype.toggle = function () {
|
||||
if (this.$element.prop('checked')) this.off()
|
||||
else this.on()
|
||||
}
|
||||
|
||||
Toggle.prototype.on = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
|
||||
this.$element.prop('checked', true)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.off = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
|
||||
this.$element.prop('checked', false)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.enable = function () {
|
||||
this.$toggle.removeClass('disabled')
|
||||
this.$toggle.removeAttr('disabled')
|
||||
this.$element.prop('disabled', false)
|
||||
}
|
||||
|
||||
Toggle.prototype.disable = function () {
|
||||
this.$toggle.addClass('disabled')
|
||||
this.$toggle.attr('disabled', 'disabled')
|
||||
this.$element.prop('disabled', true)
|
||||
}
|
||||
|
||||
Toggle.prototype.update = function (silent) {
|
||||
if (this.$element.prop('disabled')) this.disable()
|
||||
else this.enable()
|
||||
if (this.$element.prop('checked')) this.on(silent)
|
||||
else this.off(silent)
|
||||
}
|
||||
|
||||
Toggle.prototype.trigger = function (silent) {
|
||||
this.$element.off('change.bs.toggle')
|
||||
if (!silent) this.$element.change()
|
||||
this.$element.on('change.bs.toggle', $.proxy(function() {
|
||||
this.update()
|
||||
}, this))
|
||||
}
|
||||
|
||||
Toggle.prototype.destroy = function() {
|
||||
this.$element.off('change.bs.toggle')
|
||||
this.$toggleGroup.remove()
|
||||
this.$element.removeData('bs.toggle')
|
||||
this.$element.unwrap()
|
||||
}
|
||||
|
||||
// TOGGLE PLUGIN DEFINITION
|
||||
// ========================
|
||||
|
||||
function Plugin(option) {
|
||||
var optArg = Array.prototype.slice.call( arguments, 1 )[0]
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
var data = $this.data('bs.toggle')
|
||||
var options = typeof option == 'object' && option
|
||||
|
||||
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
|
||||
if (typeof option === 'string' && data[option] && typeof optArg === 'boolean') data[option](optArg)
|
||||
else if (typeof option === 'string' && data[option]) data[option]()
|
||||
//else if (option && !data[option]) console.log('bootstrap-toggle: error: method `'+ option +'` does not exist!');
|
||||
})
|
||||
}
|
||||
|
||||
var old = $.fn.bootstrapToggle
|
||||
|
||||
$.fn.bootstrapToggle = Plugin
|
||||
$.fn.bootstrapToggle.Constructor = Toggle
|
||||
|
||||
// TOGGLE NO CONFLICT
|
||||
// ==================
|
||||
|
||||
$.fn.toggle.noConflict = function () {
|
||||
$.fn.bootstrapToggle = old
|
||||
return this
|
||||
}
|
||||
|
||||
// TOGGLE DATA-API
|
||||
// ===============
|
||||
|
||||
$(function() {
|
||||
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
|
||||
})
|
||||
|
||||
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
|
||||
var $checkbox = $(this).find('input[type=checkbox]')
|
||||
$checkbox.bootstrapToggle('toggle')
|
||||
e.preventDefault()
|
||||
})
|
||||
}(jQuery);
|
||||
/*\
|
||||
|*| ========================================================================
|
||||
|*| Bootstrap Toggle: bootstrap4-toggle.js v3.6.1
|
||||
|*| https://gitbrent.github.io/bootstrap4-toggle/
|
||||
|*| ========================================================================
|
||||
|*| Copyright 2018-2019 Brent Ely
|
||||
|*| Licensed under MIT
|
||||
|*| ========================================================================
|
||||
\*/
|
||||
|
||||
+function ($) {
|
||||
'use strict';
|
||||
|
||||
// TOGGLE PUBLIC CLASS DEFINITION
|
||||
// ==============================
|
||||
|
||||
var Toggle = function (element, options) {
|
||||
this.$element = $(element)
|
||||
this.options = $.extend({}, this.defaults(), options)
|
||||
this.render()
|
||||
}
|
||||
|
||||
Toggle.VERSION = '3.7.0-beta'
|
||||
|
||||
Toggle.DEFAULTS = {
|
||||
on: 'On',
|
||||
off: 'Off',
|
||||
onstyle: 'primary',
|
||||
offstyle: 'light',
|
||||
size: 'normal',
|
||||
style: '',
|
||||
width: null,
|
||||
height: null
|
||||
}
|
||||
|
||||
Toggle.prototype.defaults = function() {
|
||||
return {
|
||||
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
|
||||
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
|
||||
onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle,
|
||||
offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle,
|
||||
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
||||
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
||||
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
||||
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
|
||||
}
|
||||
}
|
||||
|
||||
Toggle.prototype.render = function () {
|
||||
this._onstyle = 'btn-' + this.options.onstyle
|
||||
this._offstyle = 'btn-' + this.options.offstyle
|
||||
var size
|
||||
= this.options.size === 'large' || this.options.size === 'lg' ? 'btn-lg'
|
||||
: this.options.size === 'small' || this.options.size === 'sm' ? 'btn-sm'
|
||||
: this.options.size === 'mini' || this.options.size === 'xs' ? 'btn-xs'
|
||||
: ''
|
||||
var $toggleOn = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.on)
|
||||
.addClass(this._onstyle + ' ' + size)
|
||||
var $toggleOff = $('<label for="'+ this.$element.prop('id') +'" class="btn">').html(this.options.off)
|
||||
.addClass(this._offstyle + ' ' + size)
|
||||
var $toggleHandle = $('<span class="toggle-handle btn btn-light">')
|
||||
.addClass(size)
|
||||
var $toggleGroup = $('<div class="toggle-group">')
|
||||
.append($toggleOn, $toggleOff, $toggleHandle)
|
||||
var $toggle = $('<div class="toggle btn" data-toggle="toggle" role="button">')
|
||||
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
|
||||
.addClass(size).addClass(this.options.style)
|
||||
|
||||
this.$element.wrap($toggle)
|
||||
$.extend(this, {
|
||||
$toggle: this.$element.parent(),
|
||||
$toggleOn: $toggleOn,
|
||||
$toggleOff: $toggleOff,
|
||||
$toggleGroup: $toggleGroup
|
||||
})
|
||||
this.$toggle.append($toggleGroup)
|
||||
|
||||
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
|
||||
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
|
||||
$toggleOn.addClass('toggle-on')
|
||||
$toggleOff.addClass('toggle-off')
|
||||
this.$toggle.css({ width: width, height: height })
|
||||
if (this.options.height) {
|
||||
$toggleOn.css('line-height', $toggleOn.height() + 'px')
|
||||
$toggleOff.css('line-height', $toggleOff.height() + 'px')
|
||||
}
|
||||
this.update(true)
|
||||
this.trigger(true)
|
||||
}
|
||||
|
||||
Toggle.prototype.toggle = function () {
|
||||
if (this.$element.prop('checked')) this.off()
|
||||
else this.on()
|
||||
}
|
||||
|
||||
Toggle.prototype.on = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
|
||||
this.$element.prop('checked', true)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.off = function (silent) {
|
||||
if (this.$element.prop('disabled')) return false
|
||||
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
|
||||
this.$element.prop('checked', false)
|
||||
if (!silent) this.trigger()
|
||||
}
|
||||
|
||||
Toggle.prototype.enable = function () {
|
||||
this.$toggle.removeClass('disabled')
|
||||
this.$toggle.removeAttr('disabled')
|
||||
this.$element.prop('disabled', false)
|
||||
}
|
||||
|
||||
Toggle.prototype.disable = function () {
|
||||
this.$toggle.addClass('disabled')
|
||||
this.$toggle.attr('disabled', 'disabled')
|
||||
this.$element.prop('disabled', true)
|
||||
}
|
||||
|
||||
Toggle.prototype.update = function (silent) {
|
||||
if (this.$element.prop('disabled')) this.disable()
|
||||
else this.enable()
|
||||
if (this.$element.prop('checked')) this.on(silent)
|
||||
else this.off(silent)
|
||||
}
|
||||
|
||||
Toggle.prototype.trigger = function (silent) {
|
||||
this.$element.off('change.bs.toggle')
|
||||
if (!silent) this.$element.change()
|
||||
this.$element.on('change.bs.toggle', $.proxy(function() {
|
||||
this.update()
|
||||
}, this))
|
||||
}
|
||||
|
||||
Toggle.prototype.destroy = function() {
|
||||
this.$element.off('change.bs.toggle')
|
||||
this.$toggleGroup.remove()
|
||||
this.$element.removeData('bs.toggle')
|
||||
this.$element.unwrap()
|
||||
}
|
||||
|
||||
// TOGGLE PLUGIN DEFINITION
|
||||
// ========================
|
||||
|
||||
function Plugin(option) {
|
||||
var optArg = Array.prototype.slice.call( arguments, 1 )[0]
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
var data = $this.data('bs.toggle')
|
||||
var options = typeof option == 'object' && option
|
||||
|
||||
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
|
||||
if (typeof option === 'string' && data[option] && typeof optArg === 'boolean') data[option](optArg)
|
||||
else if (typeof option === 'string' && data[option]) data[option]()
|
||||
//else if (option && !data[option]) console.log('bootstrap-toggle: error: method `'+ option +'` does not exist!');
|
||||
})
|
||||
}
|
||||
|
||||
var old = $.fn.bootstrapToggle
|
||||
|
||||
$.fn.bootstrapToggle = Plugin
|
||||
$.fn.bootstrapToggle.Constructor = Toggle
|
||||
|
||||
// TOGGLE NO CONFLICT
|
||||
// ==================
|
||||
|
||||
$.fn.toggle.noConflict = function () {
|
||||
$.fn.bootstrapToggle = old
|
||||
return this
|
||||
}
|
||||
|
||||
// TOGGLE DATA-API
|
||||
// ===============
|
||||
|
||||
$(function() {
|
||||
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
|
||||
})
|
||||
|
||||
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
|
||||
var $checkbox = $(this).find('input[type=checkbox]')
|
||||
$checkbox.bootstrapToggle('toggle')
|
||||
e.preventDefault()
|
||||
})
|
||||
}(jQuery);
|
||||
|
||||
208
js/util.js
208
js/util.js
@@ -1,105 +1,105 @@
|
||||
/*
|
||||
* utilidades js
|
||||
*/
|
||||
|
||||
function trim(cadena){
|
||||
for(i=0; i<cadena.length; ){
|
||||
if(cadena.charAt(i)==" ")
|
||||
cadena=cadena.substring(i+1, cadena.length);
|
||||
else
|
||||
break;
|
||||
}
|
||||
for(i=cadena.length-1; i>=0; i=cadena.length-1){
|
||||
if(cadena.charAt(i)==" ")
|
||||
cadena=cadena.substring(0,i);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return cadena;
|
||||
}
|
||||
|
||||
function getDiaNombre(num){
|
||||
switch(parseInt(num)){
|
||||
case 0: return "Domingo";
|
||||
case 1: return "Lunes";
|
||||
case 2: return "Martes";
|
||||
case 3: return "Miércoles";
|
||||
case 4: return "Jueves";
|
||||
case 5: return "Viernes";
|
||||
case 6: return "Sábado";
|
||||
}
|
||||
}
|
||||
|
||||
function fechaGuion(fechaTxt){//de dd/mm/aaaa a aaaa-mm-dd
|
||||
fechaTxt = trim(fechaTxt);
|
||||
if(fechaTxt.substr(2,1) == "/" && fechaTxt.substr(5,1) == "/"){// dd/mm/aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
return fechaArr[2]+"-"+fechaArr[1]+"-"+fechaArr[0];
|
||||
}
|
||||
if(fechaTxt.substr(4,1) == "-" && fechaTxt.substr(7,1) == "-")// aaaa-mm-dd
|
||||
return fechaTxt;
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
function fechaObjeto(fechaTxt){//de dd/mm/aaaa a aaaa-mm-dd
|
||||
fechaTxt = trim(fechaTxt);
|
||||
if(fechaTxt.substr(2,1) == "/" && fechaTxt.substr(5,1) == "/"){// dd/mm/aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
return new Date(parseInt(fechaArr[2]), parseInt(fechaArr[1])-1, parseInt(fechaArr[0]) );
|
||||
}
|
||||
if(fechaTxt.substr(4,1) == "-" && fechaTxt.substr(7,1) == "-"){// aaaa-mm-dd
|
||||
var fechaArr = fechaTxt.split("-");
|
||||
return new Date(parseInt(fechaArr[0]), parseInt(fechaArr[1])-1, parseInt(fechaArr[2]) );
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function validaFecha(fechaTxt){
|
||||
if(fechaTxt.charAt(4) == "-" && fechaTxt.charAt(7) == "-"){//yyyy-mm-dd
|
||||
var fechaArr = fechaTxt.split("-");
|
||||
var ano= fechaArr[0];
|
||||
var mes= fechaArr[1];
|
||||
var dia= fechaArr[2];
|
||||
}
|
||||
if(fechaTxt.charAt(2) == "/" && fechaTxt.charAt(5) == "/"){//dd-mm-aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
var ano= fechaArr[2];
|
||||
var mes= fechaArr[1];
|
||||
var dia= fechaArr[0];
|
||||
}
|
||||
|
||||
var d = new Date();
|
||||
var anoActual = d.getFullYear();
|
||||
if (isNaN(ano) || ano.length < 4 || parseInt(ano, 10) < (anoActual-1)){ return false; }
|
||||
if (isNaN(mes) || parseInt(mes, 10) < 1 || parseInt(mes, 10) > 12){ return false; }
|
||||
if (isNaN(dia) || parseInt(dia, 10) < 1 || parseInt(dia, 10) > 31){ return false; }
|
||||
if (mes == 4 || mes == 6 || mes == 9 || mes== 11) {
|
||||
if (dia > 30) { return false; }
|
||||
} else{
|
||||
if (mes == 2) {
|
||||
if(dia <= 28 )
|
||||
return true;
|
||||
else{
|
||||
if ((ano % 4 == 0) && dia == 29) return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function validaPass(str, vacio = false){
|
||||
if(vacio && str == "") return true;
|
||||
return str.match(/\S*(?=\S{5,})(?=\S*[a-zA-Z])(?=\S*[\d])(?=\S*[\W])\S*$/);
|
||||
}
|
||||
/*
|
||||
$('.toggle-password').click(function(){
|
||||
var campo = $(this).parents(".form-group").find(".toggle-field");
|
||||
if (campo.prop('type') === "password") {
|
||||
campo.prop('type', 'text');
|
||||
} else {
|
||||
campo.prop('type', 'password');
|
||||
}
|
||||
/*
|
||||
* utilidades js
|
||||
*/
|
||||
|
||||
function trim(cadena){
|
||||
for(i=0; i<cadena.length; ){
|
||||
if(cadena.charAt(i)==" ")
|
||||
cadena=cadena.substring(i+1, cadena.length);
|
||||
else
|
||||
break;
|
||||
}
|
||||
for(i=cadena.length-1; i>=0; i=cadena.length-1){
|
||||
if(cadena.charAt(i)==" ")
|
||||
cadena=cadena.substring(0,i);
|
||||
else
|
||||
break;
|
||||
}
|
||||
return cadena;
|
||||
}
|
||||
|
||||
function getDiaNombre(num){
|
||||
switch(parseInt(num)){
|
||||
case 0: return "Domingo";
|
||||
case 1: return "Lunes";
|
||||
case 2: return "Martes";
|
||||
case 3: return "Miércoles";
|
||||
case 4: return "Jueves";
|
||||
case 5: return "Viernes";
|
||||
case 6: return "Sábado";
|
||||
}
|
||||
}
|
||||
|
||||
function fechaGuion(fechaTxt){//de dd/mm/aaaa a aaaa-mm-dd
|
||||
fechaTxt = trim(fechaTxt);
|
||||
if(fechaTxt.substr(2,1) == "/" && fechaTxt.substr(5,1) == "/"){// dd/mm/aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
return fechaArr[2]+"-"+fechaArr[1]+"-"+fechaArr[0];
|
||||
}
|
||||
if(fechaTxt.substr(4,1) == "-" && fechaTxt.substr(7,1) == "-")// aaaa-mm-dd
|
||||
return fechaTxt;
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
function fechaObjeto(fechaTxt){//de dd/mm/aaaa a aaaa-mm-dd
|
||||
fechaTxt = trim(fechaTxt);
|
||||
if(fechaTxt.substr(2,1) == "/" && fechaTxt.substr(5,1) == "/"){// dd/mm/aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
return new Date(parseInt(fechaArr[2]), parseInt(fechaArr[1])-1, parseInt(fechaArr[0]) );
|
||||
}
|
||||
if(fechaTxt.substr(4,1) == "-" && fechaTxt.substr(7,1) == "-"){// aaaa-mm-dd
|
||||
var fechaArr = fechaTxt.split("-");
|
||||
return new Date(parseInt(fechaArr[0]), parseInt(fechaArr[1])-1, parseInt(fechaArr[2]) );
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function validaFecha(fechaTxt){
|
||||
if(fechaTxt.charAt(4) == "-" && fechaTxt.charAt(7) == "-"){//yyyy-mm-dd
|
||||
var fechaArr = fechaTxt.split("-");
|
||||
var ano= fechaArr[0];
|
||||
var mes= fechaArr[1];
|
||||
var dia= fechaArr[2];
|
||||
}
|
||||
if(fechaTxt.charAt(2) == "/" && fechaTxt.charAt(5) == "/"){//dd-mm-aaaa
|
||||
var fechaArr = fechaTxt.split("/");
|
||||
var ano= fechaArr[2];
|
||||
var mes= fechaArr[1];
|
||||
var dia= fechaArr[0];
|
||||
}
|
||||
|
||||
var d = new Date();
|
||||
var anoActual = d.getFullYear();
|
||||
if (isNaN(ano) || ano.length < 4 || parseInt(ano, 10) < (anoActual-1)){ return false; }
|
||||
if (isNaN(mes) || parseInt(mes, 10) < 1 || parseInt(mes, 10) > 12){ return false; }
|
||||
if (isNaN(dia) || parseInt(dia, 10) < 1 || parseInt(dia, 10) > 31){ return false; }
|
||||
if (mes == 4 || mes == 6 || mes == 9 || mes== 11) {
|
||||
if (dia > 30) { return false; }
|
||||
} else{
|
||||
if (mes == 2) {
|
||||
if(dia <= 28 )
|
||||
return true;
|
||||
else{
|
||||
if ((ano % 4 == 0) && dia == 29) return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function validaPass(str, vacio = false){
|
||||
if(vacio && str == "") return true;
|
||||
return str.match(/\S*(?=\S{5,})(?=\S*[a-zA-Z])(?=\S*[\d])(?=\S*[\W])\S*$/);
|
||||
}
|
||||
/*
|
||||
$('.toggle-password').click(function(){
|
||||
var campo = $(this).parents(".form-group").find(".toggle-field");
|
||||
if (campo.prop('type') === "password") {
|
||||
campo.prop('type', 'text');
|
||||
} else {
|
||||
campo.prop('type', 'password');
|
||||
}
|
||||
});*/
|
||||
Reference in New Issue
Block a user