663 lines
29 KiB
HTML
663 lines
29 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}
|
|
{% if not role or role == 'admin' %}
|
|
Panel de Administración - Edu-Space Admin
|
|
{% elif role == 'bedelia' %}
|
|
Panel Operativo de Bedelía - Edu-Space Admin
|
|
{% elif role == 'docente' %}
|
|
Panel Docente - Edu-Space Admin
|
|
{% else %}
|
|
Mi Portal de Cursada - Edu-Space Admin
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if user.is_authenticated %}
|
|
<div class="container-fluid px-0">
|
|
{% endif %}
|
|
|
|
<!-- ========================================================================= -->
|
|
<!-- 1. HEADER & ROLE PERSPECTIVE SWITCHER -->
|
|
<!-- ========================================================================= -->
|
|
{% if show_role_banner %}
|
|
<div class="dashboard-role-banner mb-3 shadow-sm">
|
|
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
|
<div>
|
|
<div class="d-flex align-items-center gap-2 mb-1 flex-wrap">
|
|
<h1 class="h4 mb-0 fw-bold">
|
|
¡Hola, {{ user.first_name or user.name }}!
|
|
</h1>
|
|
<span class="badge {{ user.role_badge_display.class }} role-pill">
|
|
<i class="bi {{ user.role_badge_display.icon }}"></i>
|
|
{{ user.role_badge_display.label }}
|
|
</span>
|
|
{% if role != actual_role %}
|
|
<span class="badge bg-warning text-dark border font-monospace small">
|
|
<i class="bi bi-eye-fill me-1"></i>Modo Vista Previa: {{ role|capitalize }}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
<p class="text-muted small mb-0">
|
|
{% if not role or role == 'admin' %}
|
|
<i class="bi bi-shield-check text-primary me-1"></i>Gestión centralizada de infraestructura, oferta académica, seguridad y trazabilidad institucional.
|
|
{% elif role == 'bedelia' %}
|
|
<i class="bi bi-building-gear text-warning me-1"></i>Control operativo de campus: asignación de aulas físicas y virtuales, cartelera del día y aprobaciones.
|
|
{% elif role == 'docente' %}
|
|
<i class="bi bi-person-video3 text-info me-1"></i>Espacio docente: gestión de cursadas, horarios de clase, solicitudes de aula y enlaces de videoconferencia.
|
|
{% else %}
|
|
<i class="bi bi-mortarboard text-success me-1"></i>Portal de cursada: consulta tu aula de hoy, cronograma semanal de clases y fechas de exámenes.
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- ========================================================================= -->
|
|
<!-- 2. ROLE SPECIFIC DASHBOARDS (MODULAR INJECTION) -->
|
|
<!-- ========================================================================= -->
|
|
|
|
{% if not role or role == 'admin' %}
|
|
<!-- [A] ADMIN DASHBOARD -->
|
|
{% include "dashboard/dashadm.html" %}
|
|
|
|
{% elif role == 'bedelia' %}
|
|
<!-- [B] BEDELÍA DASHBOARD -->
|
|
{% include "dashboard/dashbede.html" %}
|
|
|
|
{% elif role == 'docente' or role == 'profesor' %}
|
|
<!-- [C] DOCENTE DASHBOARD -->
|
|
{% include "dashboard/dashprof.html" %}
|
|
|
|
{% elif role == 'alumno' or role == 'estudiante' %}
|
|
<!-- [D] ALUMNO DASHBOARD -->
|
|
{% include "dashboard/dashalum.html" %}
|
|
|
|
{% else %}
|
|
{% include "dashboard/dashadm.html" %}
|
|
{% endif %}
|
|
|
|
{% if user.is_authenticated %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Script de datos seguros para filtrado de Aulas y Comisiones -->
|
|
<script id="filter-stats-json" type="application/json">
|
|
{{ filter_stats | dump | safe }}
|
|
</script>
|
|
<script id="floor-availability-json" type="application/json">
|
|
{{ floor_availability | dump | safe }}
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
const floorChartElem = document.getElementById('floorAvailabilityChart');
|
|
if (floorChartElem) {
|
|
let floorData = [];
|
|
try {
|
|
const rawJson = document.getElementById('floor-availability-json');
|
|
if (rawJson) {
|
|
floorData = JSON.parse(rawJson.textContent || '[]');
|
|
}
|
|
} catch (e) {
|
|
console.warn('Error leyendo floor-availability-json:', e);
|
|
}
|
|
|
|
const labels = floorData.map(f => f.floor);
|
|
const availableData = floorData.map(f => f.available);
|
|
const occupiedData = floorData.map(f => f.occupied);
|
|
|
|
const ctx = floorChartElem.getContext('2d');
|
|
new Chart(ctx, {
|
|
type: 'bar',
|
|
data: {
|
|
labels: labels.length > 0 ? labels : ['Piso 2', 'Piso 3'],
|
|
datasets: [
|
|
{
|
|
label: 'Aulas Libres (Hoy)',
|
|
data: availableData.length > 0 ? availableData : [1, 2],
|
|
backgroundColor: '#198754',
|
|
borderRadius: 6,
|
|
barThickness: 24
|
|
},
|
|
{
|
|
label: 'Aulas Asignadas con Cursada',
|
|
data: occupiedData.length > 0 ? occupiedData : [0, 0],
|
|
backgroundColor: '#B43E8E',
|
|
borderRadius: 6,
|
|
barThickness: 24
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
indexAxis: 'y',
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
resizeDelay: 100,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top',
|
|
labels: {
|
|
boxWidth: 12,
|
|
padding: 12,
|
|
font: { size: 12 }
|
|
}
|
|
},
|
|
tooltip: {
|
|
callbacks: {
|
|
label: function(context) {
|
|
return ` ${context.dataset.label}: ${context.raw} aula(s)`;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
scales: {
|
|
x: {
|
|
stacked: true,
|
|
beginAtZero: true,
|
|
ticks: {
|
|
stepSize: 1,
|
|
precision: 0
|
|
},
|
|
grid: {
|
|
color: 'rgba(0,0,0,0.06)'
|
|
}
|
|
},
|
|
y: {
|
|
stacked: true,
|
|
grid: {
|
|
display: false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Inicialización de Gráficos de Torta (Doughnut) para Aulas y Comisiones
|
|
initDoughnutCharts();
|
|
|
|
// Poblar dinámicamente opciones de carrera si faltaran en el selector
|
|
const careerSelect = document.getElementById('commCareerFilter');
|
|
if (careerSelect) {
|
|
const existingValues = new Set(Array.from(careerSelect.options).map(o => o.value));
|
|
document.querySelectorAll('tr[data-career]').forEach(function(tr) {
|
|
const cName = tr.getAttribute('data-career');
|
|
if (cName && !existingValues.has(cName)) {
|
|
existingValues.add(cName);
|
|
const opt = document.createElement('option');
|
|
opt.value = cName;
|
|
opt.textContent = cName;
|
|
careerSelect.appendChild(opt);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Inicializar la paginación y filtrado de comisiones
|
|
applyCommPaginationAndFilter();
|
|
});
|
|
|
|
// Referencias globales a los gráficos Doughnut
|
|
let classroomsPieChart = null;
|
|
let commissionsPieChart = null;
|
|
|
|
function initDoughnutCharts() {
|
|
const classCanvas = document.getElementById('bedeliaClassroomsPieChart') || document.getElementById('adminClassroomsPieChart');
|
|
const commCanvas = document.getElementById('bedeliaCommissionsPieChart') || document.getElementById('adminCommissionsPieChart');
|
|
|
|
if (classCanvas && FILTER_STATS_DATA && FILTER_STATS_DATA.today) {
|
|
const todayClass = FILTER_STATS_DATA.today.classrooms || {};
|
|
const assigned = todayClass.assigned_count || 0;
|
|
const unassigned = todayClass.unassigned_count || 0;
|
|
|
|
classroomsPieChart = new Chart(classCanvas.getContext('2d'), {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: ['Aulas Asignadas', 'Aulas Libres'],
|
|
datasets: [{
|
|
data: [assigned, unassigned],
|
|
backgroundColor: ['#198754', '#ffc107'],
|
|
borderColor: 'transparent',
|
|
borderWidth: 2,
|
|
hoverOffset: 4
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
cutout: '68%',
|
|
plugins: {
|
|
legend: { display: false },
|
|
tooltip: {
|
|
callbacks: {
|
|
label: function(ctx) {
|
|
const val = ctx.raw || 0;
|
|
const total = ctx.dataset.data.reduce((a, b) => a + b, 0);
|
|
const pct = total > 0 ? Math.round((val / total) * 100) : 0;
|
|
return ` ${ctx.label}: ${val} (${pct}%)`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
if (commCanvas && FILTER_STATS_DATA && FILTER_STATS_DATA.today) {
|
|
const todayComm = FILTER_STATS_DATA.today.commissions || {};
|
|
const assigned = todayComm.assigned_count || 0;
|
|
const unassigned = todayComm.unassigned_count || 0;
|
|
|
|
commissionsPieChart = new Chart(commCanvas.getContext('2d'), {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: ['Con Aula Asignada', 'Sin Asignar (Pendientes)'],
|
|
datasets: [{
|
|
data: [assigned, unassigned],
|
|
backgroundColor: ['#0d6efd', '#dc3545'],
|
|
borderColor: 'transparent',
|
|
borderWidth: 2,
|
|
hoverOffset: 4
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
cutout: '68%',
|
|
plugins: {
|
|
legend: { display: false },
|
|
tooltip: {
|
|
callbacks: {
|
|
label: function(ctx) {
|
|
const val = ctx.raw || 0;
|
|
const total = ctx.dataset.data.reduce((a, b) => a + b, 0);
|
|
const pct = total > 0 ? Math.round((val / total) * 100) : 0;
|
|
return ` ${ctx.label}: ${val} (${pct}%)`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function updateDoughnutCharts(period) {
|
|
if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return;
|
|
const periodData = FILTER_STATS_DATA[period];
|
|
const classData = periodData.classrooms || {};
|
|
const commData = periodData.commissions || {};
|
|
|
|
if (classroomsPieChart) {
|
|
classroomsPieChart.data.datasets[0].data = [classData.assigned_count || 0, classData.unassigned_count || 0];
|
|
classroomsPieChart.update();
|
|
}
|
|
if (commissionsPieChart) {
|
|
commissionsPieChart.data.datasets[0].data = [commData.assigned_count || 0, commData.unassigned_count || 0];
|
|
commissionsPieChart.update();
|
|
}
|
|
}
|
|
|
|
// Apply dynamic colors from data-color attributes (milestone type badges)
|
|
document.querySelectorAll('[data-color]').forEach(function(el) {
|
|
const color = el.getAttribute('data-color');
|
|
if (color) el.style.setProperty('background-color', color, 'important');
|
|
});
|
|
|
|
// Bedelía: Switcher para Cartelera y Agenda de Clases
|
|
function switchBedeliaScheduleView(view) {
|
|
const todayEl = document.getElementById('bedeliaScheduleToday');
|
|
const tomorrowEl = document.getElementById('bedeliaScheduleTomorrow');
|
|
const weekEl = document.getElementById('bedeliaScheduleWeek');
|
|
if (todayEl) todayEl.style.display = view === 'today' ? 'block' : 'none';
|
|
if (tomorrowEl) tomorrowEl.style.display = view === 'tomorrow' ? 'block' : 'none';
|
|
if (weekEl) weekEl.style.display = view === 'week' ? 'block' : 'none';
|
|
document.querySelectorAll('#bedeliaScheduleSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-view') === view);
|
|
});
|
|
}
|
|
|
|
// Cargar datos unificados de filtros desde JSON script seguro
|
|
let FILTER_STATS_DATA = {};
|
|
try {
|
|
const jsonElem = document.getElementById('filter-stats-json');
|
|
if (jsonElem) {
|
|
FILTER_STATS_DATA = JSON.parse(jsonElem.textContent || '{}');
|
|
}
|
|
} catch (e) {
|
|
console.error('Error parseando filter-stats-json:', e);
|
|
}
|
|
|
|
// Variables de estado activas para Comisiones y Aulas
|
|
let currentCommPeriod = 'today';
|
|
let currentCommStatus = 'unassigned';
|
|
let currentClassPeriod = 'today';
|
|
let currentClassStatus = 'unassigned';
|
|
|
|
// Bedelía: Switcher de Percentiles de Aulas (Día / Mañana / Semana / Mes)
|
|
function switchBedeliaPercentiles(period) {
|
|
if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return;
|
|
const periodData = FILTER_STATS_DATA[period];
|
|
const classData = periodData.classrooms || {};
|
|
const commData = periodData.commissions || {};
|
|
|
|
const dateText = document.getElementById('bedeliaPctDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const periodName = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes'));
|
|
|
|
const classPieTitle = document.getElementById('bedeliaClassPiePeriodTitle');
|
|
const commPieTitle = document.getElementById('bedeliaCommPiePeriodTitle');
|
|
if (classPieTitle) classPieTitle.innerText = periodName;
|
|
if (commPieTitle) commPieTitle.innerText = periodName;
|
|
|
|
// Tarjetas KPI Aulas
|
|
const assignedCount = document.getElementById('bedeliaPctAssignedCount');
|
|
const assignedPct = document.getElementById('bedeliaPctAssignedPct');
|
|
const unassignedCount = document.getElementById('bedeliaPctUnassignedCount');
|
|
const unassignedPct = document.getElementById('bedeliaPctUnassignedPct');
|
|
const assignedLabel = document.getElementById('bedeliaPctAssignedLabel');
|
|
|
|
if (assignedCount) assignedCount.innerText = classData.assigned_count ?? 0;
|
|
if (assignedPct) assignedPct.innerText = (classData.assigned_pct ?? 0) + '%';
|
|
if (unassignedCount) unassignedCount.innerText = classData.unassigned_count ?? 0;
|
|
if (unassignedPct) unassignedPct.innerText = (classData.unassigned_pct ?? 0) + '%';
|
|
if (assignedLabel) {
|
|
assignedLabel.innerText = period === 'today' ? 'Con cursada activa hoy' : (period === 'tomorrow' ? 'Con cursada activa mañana' : (period === 'week' ? 'Con cursada activa esta semana' : 'Con cursada activa este mes'));
|
|
}
|
|
|
|
// Tarjetas KPI Comisiones
|
|
const commUnassignedCount = document.getElementById('bedeliaPctCommUnassignedCount');
|
|
const commUnassignedPct = document.getElementById('bedeliaPctCommUnassignedPct');
|
|
const commAssignedCount = document.getElementById('bedeliaPctCommAssignedCount');
|
|
const commAssignedPct = document.getElementById('bedeliaPctCommAssignedPct');
|
|
|
|
if (commUnassignedCount) commUnassignedCount.innerText = commData.unassigned_count ?? 0;
|
|
if (commUnassignedPct) commUnassignedPct.innerText = (commData.unassigned_pct ?? 0) + '%';
|
|
if (commAssignedCount) commAssignedCount.innerText = commData.assigned_count ?? 0;
|
|
if (commAssignedPct) commAssignedPct.innerText = (commData.assigned_pct ?? 0) + '%';
|
|
|
|
// Leyendas de los gráficos de torta
|
|
const classLegendAssigned = document.getElementById('bedeliaClassPieLegendAssigned');
|
|
const classLegendUnassigned = document.getElementById('bedeliaClassPieLegendUnassigned');
|
|
const commLegendAssigned = document.getElementById('bedeliaCommPieLegendAssigned');
|
|
const commLegendUnassigned = document.getElementById('bedeliaCommPieLegendUnassigned');
|
|
|
|
if (classLegendAssigned) classLegendAssigned.innerText = 'Asignadas: ' + (classData.assigned_count ?? 0) + ' (' + (classData.assigned_pct ?? 0) + '%)';
|
|
if (classLegendUnassigned) classLegendUnassigned.innerText = 'Libres: ' + (classData.unassigned_count ?? 0) + ' (' + (classData.unassigned_pct ?? 0) + '%)';
|
|
if (commLegendAssigned) commLegendAssigned.innerText = 'Con Aula: ' + (commData.assigned_count ?? 0) + ' (' + (commData.assigned_pct ?? 0) + '%)';
|
|
if (commLegendUnassigned) commLegendUnassigned.innerText = 'Sin Asignar: ' + (commData.unassigned_count ?? 0) + ' (' + (commData.unassigned_pct ?? 0) + '%)';
|
|
|
|
// Actualizar gráficos Doughnut
|
|
updateDoughnutCharts(period);
|
|
|
|
// Botones activos
|
|
document.querySelectorAll('#bedeliaPctPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
}
|
|
|
|
// Admin: Switcher de Percentiles de Aulas (Día / Mañana / Semana / Mes)
|
|
function switchAdminPercentiles(period) {
|
|
if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return;
|
|
const periodData = FILTER_STATS_DATA[period];
|
|
const classData = periodData.classrooms || {};
|
|
const commData = periodData.commissions || {};
|
|
|
|
const dateText = document.getElementById('adminPctDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const periodName = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes'));
|
|
|
|
const classPieTitle = document.getElementById('adminClassPiePeriodTitle');
|
|
const commPieTitle = document.getElementById('adminCommPiePeriodTitle');
|
|
if (classPieTitle) classPieTitle.innerText = periodName;
|
|
if (commPieTitle) commPieTitle.innerText = periodName;
|
|
|
|
// Tarjetas KPI Aulas
|
|
const assignedCount = document.getElementById('adminPctAssignedCount');
|
|
const assignedPct = document.getElementById('adminPctAssignedPct');
|
|
const unassignedCount = document.getElementById('adminPctUnassignedCount');
|
|
const unassignedPct = document.getElementById('adminPctUnassignedPct');
|
|
|
|
if (assignedCount) assignedCount.innerText = classData.assigned_count ?? 0;
|
|
if (assignedPct) assignedPct.innerText = (classData.assigned_pct ?? 0) + '%';
|
|
if (unassignedCount) unassignedCount.innerText = classData.unassigned_count ?? 0;
|
|
if (unassignedPct) unassignedPct.innerText = (classData.unassigned_pct ?? 0) + '%';
|
|
|
|
// Tarjetas KPI Comisiones
|
|
const commUnassignedCount = document.getElementById('adminPctCommUnassignedCount');
|
|
const commUnassignedPct = document.getElementById('adminPctCommUnassignedPct');
|
|
const commAssignedCount = document.getElementById('adminPctCommAssignedCount');
|
|
const commAssignedPct = document.getElementById('adminPctCommAssignedPct');
|
|
|
|
if (commUnassignedCount) commUnassignedCount.innerText = commData.unassigned_count ?? 0;
|
|
if (commUnassignedPct) commUnassignedPct.innerText = (commData.unassigned_pct ?? 0) + '%';
|
|
if (commAssignedCount) commAssignedCount.innerText = commData.assigned_count ?? 0;
|
|
if (commAssignedPct) commAssignedPct.innerText = (commData.assigned_pct ?? 0) + '%';
|
|
|
|
// Leyendas de los gráficos de torta
|
|
const classLegendAssigned = document.getElementById('adminClassPieLegendAssigned');
|
|
const classLegendUnassigned = document.getElementById('adminClassPieLegendUnassigned');
|
|
const commLegendAssigned = document.getElementById('adminCommPieLegendAssigned');
|
|
const commLegendUnassigned = document.getElementById('adminCommPieLegendUnassigned');
|
|
|
|
if (classLegendAssigned) classLegendAssigned.innerText = 'Asignadas: ' + (classData.assigned_count ?? 0) + ' (' + (classData.assigned_pct ?? 0) + '%)';
|
|
if (classLegendUnassigned) classLegendUnassigned.innerText = 'Libres: ' + (classData.unassigned_count ?? 0) + ' (' + (classData.unassigned_pct ?? 0) + '%)';
|
|
if (commLegendAssigned) commLegendAssigned.innerText = 'Con Aula: ' + (commData.assigned_count ?? 0) + ' (' + (commData.assigned_pct ?? 0) + '%)';
|
|
if (commLegendUnassigned) commLegendUnassigned.innerText = 'Sin Asignar: ' + (commData.unassigned_count ?? 0) + ' (' + (commData.unassigned_pct ?? 0) + '%)';
|
|
|
|
// Actualizar gráficos Doughnut
|
|
updateDoughnutCharts(period);
|
|
|
|
document.querySelectorAll('#adminPctPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
}
|
|
|
|
// ======================== Paginación y Filtro de Carrera para Comisiones ========================
|
|
let commCurrentPage = 1;
|
|
const commPageSize = 10;
|
|
let commSelectedCareer = '';
|
|
|
|
function onCommCareerFilterChange(career) {
|
|
commSelectedCareer = (career || '').trim();
|
|
commCurrentPage = 1;
|
|
applyCommPaginationAndFilter();
|
|
}
|
|
|
|
function goToCommPage(page) {
|
|
commCurrentPage = page;
|
|
applyCommPaginationAndFilter();
|
|
}
|
|
|
|
function applyCommPaginationAndFilter() {
|
|
const activeBlock = document.getElementById('commBlock-' + currentCommPeriod + '-' + currentCommStatus);
|
|
const paginationContainer = document.getElementById('commPaginationContainer');
|
|
if (!activeBlock) {
|
|
if (paginationContainer) paginationContainer.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
const table = activeBlock.querySelector('table');
|
|
const tableContainer = activeBlock.querySelector('.table-responsive');
|
|
const noMatchAlert = activeBlock.querySelector('.comm-no-match-alert');
|
|
|
|
if (!table) {
|
|
if (paginationContainer) paginationContainer.style.display = 'none';
|
|
if (noMatchAlert) noMatchAlert.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
const rows = Array.from(table.querySelectorAll('tbody tr'));
|
|
if (rows.length === 0) {
|
|
if (paginationContainer) paginationContainer.style.display = 'none';
|
|
if (noMatchAlert) noMatchAlert.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
// Filtrar por carrera seleccionada
|
|
const filterLower = commSelectedCareer.toLowerCase();
|
|
const filteredRows = rows.filter(function(row) {
|
|
if (!filterLower) return true;
|
|
const career = (row.getAttribute('data-career') || '').toLowerCase();
|
|
const careerNames = (row.getAttribute('data-career-names') || '').toLowerCase();
|
|
return career.includes(filterLower) || careerNames.includes(filterLower);
|
|
});
|
|
|
|
if (filteredRows.length === 0) {
|
|
rows.forEach(function(r) { r.style.display = 'none'; });
|
|
if (tableContainer) tableContainer.style.display = 'none';
|
|
if (noMatchAlert) noMatchAlert.style.display = 'block';
|
|
if (paginationContainer) paginationContainer.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
if (noMatchAlert) noMatchAlert.style.display = 'none';
|
|
if (tableContainer) tableContainer.style.display = 'block';
|
|
|
|
// Calcular páginas
|
|
const totalItems = filteredRows.length;
|
|
const totalPages = Math.ceil(totalItems / commPageSize);
|
|
if (commCurrentPage > totalPages) commCurrentPage = totalPages;
|
|
if (commCurrentPage < 1) commCurrentPage = 1;
|
|
|
|
const startIndex = (commCurrentPage - 1) * commPageSize;
|
|
const endIndex = Math.min(startIndex + commPageSize, totalItems);
|
|
|
|
// Ocultar todas las filas
|
|
rows.forEach(function(r) { r.style.display = 'none'; });
|
|
|
|
// Mostrar únicamente las filas de la página actual
|
|
for (let i = startIndex; i < endIndex; i++) {
|
|
filteredRows[i].style.display = '';
|
|
}
|
|
|
|
// Actualizar resumen
|
|
const startEl = document.getElementById('commPageStart');
|
|
const endEl = document.getElementById('commPageEnd');
|
|
const totalEl = document.getElementById('commPageTotal');
|
|
if (startEl) startEl.innerText = startIndex + 1;
|
|
if (endEl) endEl.innerText = endIndex;
|
|
if (totalEl) totalEl.innerText = totalItems;
|
|
|
|
// Renderizar botones de paginación
|
|
const navEl = document.getElementById('commPaginationNav');
|
|
if (navEl) {
|
|
let navHtml = '';
|
|
const prevDisabled = commCurrentPage === 1 ? 'disabled' : '';
|
|
navHtml += `<li class="page-item ${prevDisabled}"><a class="page-link" href="javascript:void(0)" onclick="goToCommPage(${commCurrentPage - 1})"><i class="bi bi-chevron-left"></i></a></li>`;
|
|
|
|
for (let p = 1; p <= totalPages; p++) {
|
|
const activeClass = p === commCurrentPage ? 'active' : '';
|
|
navHtml += `<li class="page-item ${activeClass}"><a class="page-link" href="javascript:void(0)" onclick="goToCommPage(${p})">${p}</a></li>`;
|
|
}
|
|
|
|
const nextDisabled = commCurrentPage === totalPages ? 'disabled' : '';
|
|
navHtml += `<li class="page-item ${nextDisabled}"><a class="page-link" href="javascript:void(0)" onclick="goToCommPage(${commCurrentPage + 1})"><i class="bi bi-chevron-right"></i></a></li>`;
|
|
|
|
navEl.innerHTML = navHtml;
|
|
}
|
|
|
|
if (paginationContainer) {
|
|
paginationContainer.style.display = totalItems > 0 ? 'block' : 'none';
|
|
}
|
|
}
|
|
|
|
// Bedelía: Switcher de Período para Comisiones (Día / Semana / Mes)
|
|
function switchCommFilterPeriod(period) {
|
|
currentCommPeriod = period;
|
|
const periodData = FILTER_STATS_DATA[period] || {};
|
|
const commData = periodData.commissions || {};
|
|
|
|
const dateText = document.getElementById('commActiveDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const badgeUnassigned = document.getElementById('commStatusBadgeUnassigned');
|
|
const badgeAssigned = document.getElementById('commStatusBadgeAssigned');
|
|
if (badgeUnassigned) badgeUnassigned.innerText = commData.unassigned_count ?? 0;
|
|
if (badgeAssigned) badgeAssigned.innerText = commData.assigned_count ?? 0;
|
|
|
|
const summaryText = document.getElementById('commStatusSummaryText');
|
|
if (summaryText) summaryText.innerHTML = 'Período activo: <strong>' + (periodData.label || '') + '</strong>';
|
|
|
|
document.querySelectorAll('#commFilterPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
|
|
renderActiveCommBlock();
|
|
}
|
|
|
|
// Bedelía: Switcher de Estado para Comisiones (Asignadas / Sin Asignar)
|
|
function switchCommStatusTab(status) {
|
|
currentCommStatus = status;
|
|
document.querySelectorAll('#commStatusPills button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-status') === status);
|
|
});
|
|
renderActiveCommBlock();
|
|
}
|
|
|
|
function renderActiveCommBlock() {
|
|
document.querySelectorAll('.comm-block').forEach(function(block) {
|
|
block.style.display = 'none';
|
|
});
|
|
const target = document.getElementById('commBlock-' + currentCommPeriod + '-' + currentCommStatus);
|
|
if (target) target.style.display = 'block';
|
|
|
|
commCurrentPage = 1;
|
|
applyCommPaginationAndFilter();
|
|
}
|
|
|
|
// Bedelía: Switcher de Período para Aulas (Día / Semana / Mes)
|
|
function switchClassFilterPeriod(period) {
|
|
currentClassPeriod = period;
|
|
const periodData = FILTER_STATS_DATA[period] || {};
|
|
const classData = periodData.classrooms || {};
|
|
|
|
const dateText = document.getElementById('classActiveDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const badgeUnassigned = document.getElementById('classStatusBadgeUnassigned');
|
|
const badgeAssigned = document.getElementById('classStatusBadgeAssigned');
|
|
if (badgeUnassigned) badgeUnassigned.innerText = classData.unassigned_count ?? 0;
|
|
if (badgeAssigned) badgeAssigned.innerText = classData.assigned_count ?? 0;
|
|
|
|
const summaryText = document.getElementById('classStatusSummaryText');
|
|
if (summaryText) summaryText.innerHTML = 'Período activo: <strong>' + (periodData.label || '') + '</strong>';
|
|
|
|
document.querySelectorAll('#classFilterPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
|
|
renderActiveClassBlock();
|
|
}
|
|
|
|
// Bedelía: Switcher de Estado para Aulas (Asignadas / Sin Asignar / Virtual)
|
|
function switchClassStatusTab(status) {
|
|
currentClassStatus = status;
|
|
document.querySelectorAll('#classStatusPills button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-status') === status);
|
|
});
|
|
renderActiveClassBlock();
|
|
}
|
|
|
|
function renderActiveClassBlock() {
|
|
document.querySelectorAll('.class-block').forEach(function(block) {
|
|
block.style.display = 'none';
|
|
});
|
|
if (currentClassStatus === 'virtual') {
|
|
const vTarget = document.getElementById('classBlock-virtual');
|
|
if (vTarget) vTarget.style.display = 'block';
|
|
} else {
|
|
const target = document.getElementById('classBlock-' + currentClassPeriod + '-' + currentClassStatus);
|
|
if (target) target.style.display = 'block';
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %} |