fix: update bedelia views for today and weekly reservations, available rooms and unassigned commissions

This commit is contained in:
2026-10-07 19:16:35 -03:00
parent 5764203232
commit ff6480f591
9 changed files with 449 additions and 23 deletions
+8 -1
View File
@@ -833,6 +833,7 @@ const handleCommissionsList = async (req, res) => {
const career_id = req.query.career_id || '';
const shift = req.query.shift || '';
const active = req.query.active || '';
const unassigned_room = req.query.unassigned_room || '';
const created = req.query.created === '1';
let commissions = [];
@@ -843,7 +844,7 @@ const handleCommissionsList = async (req, res) => {
try {
const [cRes, uRes] = await Promise.allSettled([
req.apiClient.get('/commissions', { params: { search, subject_id, career_id, shift, active } }),
req.apiClient.get('/commissions', { params: { search, subject_id, career_id, shift, active, unassigned_room } }),
req.apiClient.get('/users')
]);
@@ -853,6 +854,11 @@ const handleCommissionsList = async (req, res) => {
get_full_code: () => c.full_code || c.code,
career_id: c.career_id,
career_name: c.career_name || 'Carrera General',
classroom_name: c.classroom_name || 'Sin Aula Asignada',
has_classroom: Boolean(c.has_classroom),
is_virtual: Boolean(c.is_virtual),
virtual_link: c.virtual_link || '',
schedule: c.schedule || 'Sin horario',
subject: {
id: c.subject_id,
name: c.subject_name,
@@ -907,6 +913,7 @@ const handleCommissionsList = async (req, res) => {
career_filter: career_id ? parseInt(career_id, 10) : '',
shift_filter: shift,
active_filter: active,
unassigned_room_filter: unassigned_room,
created,
msg: req.query.msg || (created ? 'created' : ''),
error: req.query.error || '',
+4
View File
@@ -107,11 +107,15 @@ router.get('/', async (req, res) => {
]
};
} else if (role === 'bedelia') {
const apiWeekSchedule = Array.isArray(apiData.week_schedule_list) ? apiData.week_schedule_list : [];
role_data = {
pending_reservations: apiPending || [],
today_schedule_list: apiTodaySchedule || [],
week_schedule_list: apiWeekSchedule,
unassigned_commissions_week: bedeliaData.unassigned_commissions_week || [],
unassigned_commissions_month: bedeliaData.unassigned_commissions_month || [],
unassigned_commissions_general: bedeliaData.unassigned_commissions_general || [],
available_classrooms_today: bedeliaData.available_classrooms_today || [],
available_classrooms_week: bedeliaData.available_classrooms_week || [],
available_classrooms_month: bedeliaData.available_classrooms_month || []
};
+19 -2
View File
@@ -164,11 +164,21 @@ router.get('/list_reservations', handleReservationsList);
// 4. Vista de Hoy (Cartelera del Día)
const handleTodaySchedule = async (req, res) => {
try {
const todayStr = req.query.date || '2026-09-18';
const defaultTodayStr = new Date().toISOString().split('T')[0];
const todayStr = req.query.date || defaultTodayStr;
const hide_virtual = req.query.hide_virtual === '1' || req.query.hide_virtual === 'true';
const floor_filter = req.query.floor || '';
const shift_filter = req.query.shift || '';
// Fechas anterior y siguiente para navegación
const currentDateObj = new Date(todayStr + 'T00:00:00');
const prevDateObj = new Date(currentDateObj);
prevDateObj.setDate(prevDateObj.getDate() - 1);
const nextDateObj = new Date(currentDateObj);
nextDateObj.setDate(nextDateObj.getDate() + 1);
const prevDateStr = prevDateObj.toISOString().split('T')[0];
const nextDateStr = nextDateObj.toISOString().split('T')[0];
const params = {
start_date: todayStr,
end_date: todayStr
@@ -238,6 +248,9 @@ const handleTodaySchedule = async (req, res) => {
time_blocks,
stats,
today: todayStr,
prev_date: prevDateStr,
next_date: nextDateStr,
default_today: defaultTodayStr,
hide_virtual,
floor_filter,
shift_filter,
@@ -246,12 +259,16 @@ const handleTodaySchedule = async (req, res) => {
});
} catch (error) {
console.error('Error fetching today reservations:', error.message);
const fallbackToday = new Date().toISOString().split('T')[0];
res.render('schedule/today', {
title: 'Cartelera del Día (Offline)',
reservations: [],
time_blocks: {},
stats: { total_reservations: 0, confirmed: 0, pending: 0, occupied_classrooms: 0, total_classrooms: 59 },
today: '2026-09-18',
today: fallbackToday,
prev_date: fallbackToday,
next_date: fallbackToday,
default_today: fallbackToday,
hide_virtual: false,
floor_filter: '',
shift_filter: '',