352 lines
18 KiB
HTML
352 lines
18 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}{% trans %}Classrooms{% endtrans %} - Edu-Space Admin{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.classroom-card {
|
|
transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
|
|
border-radius: 0.65rem;
|
|
}
|
|
.classroom-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
|
|
}
|
|
.metric-pill {
|
|
padding: 0.35rem 0.2rem;
|
|
border-radius: 0.45rem;
|
|
transition: all 0.15s ease;
|
|
cursor: pointer;
|
|
line-height: 1.2;
|
|
}
|
|
.metric-pill:hover {
|
|
transform: translateY(-1px);
|
|
filter: brightness(1.06);
|
|
}
|
|
.metric-label {
|
|
font-size: 0.65rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.3px;
|
|
margin-bottom: 2px;
|
|
}
|
|
.metric-val {
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
}
|
|
|
|
/* Semantics light */
|
|
.metric-high {
|
|
background-color: #FEE2E2;
|
|
border-color: #FCA5A5 !important;
|
|
color: #991B1B !important;
|
|
}
|
|
.metric-medium {
|
|
background-color: #FEF3C7;
|
|
border-color: #FCD34D !important;
|
|
color: #92400E !important;
|
|
}
|
|
.metric-low {
|
|
background-color: #D1FAE5;
|
|
border-color: #6EE7B7 !important;
|
|
color: #065F46 !important;
|
|
}
|
|
.metric-zero {
|
|
background-color: rgba(148, 163, 184, 0.1);
|
|
border-color: rgba(148, 163, 184, 0.25) !important;
|
|
color: #64748B !important;
|
|
}
|
|
|
|
/* Semantics dark */
|
|
[data-bs-theme="dark"] .metric-high {
|
|
background-color: rgba(239, 68, 68, 0.18);
|
|
border-color: rgba(239, 68, 68, 0.4) !important;
|
|
color: #FCA5A5 !important;
|
|
}
|
|
[data-bs-theme="dark"] .metric-medium {
|
|
background-color: rgba(245, 158, 11, 0.18);
|
|
border-color: rgba(245, 158, 11, 0.4) !important;
|
|
color: #FCD34D !important;
|
|
}
|
|
[data-bs-theme="dark"] .metric-low {
|
|
background-color: rgba(16, 185, 129, 0.18);
|
|
border-color: rgba(16, 185, 129, 0.4) !important;
|
|
color: #6EE7B7 !important;
|
|
}
|
|
[data-bs-theme="dark"] .metric-zero {
|
|
background-color: rgba(148, 163, 184, 0.08);
|
|
border-color: rgba(148, 163, 184, 0.18) !important;
|
|
color: #94A3B8 !important;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid pt-5 mt-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3">
|
|
<i class="bi bi-door-open text-primary"></i> {% trans %}Classrooms{% endtrans %}
|
|
</h1>
|
|
<div>
|
|
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-primary">
|
|
<i class="bi bi-plus-circle"></i> {% trans %}Add Classroom{% endtrans %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filters -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-body">
|
|
<form method="GET" class="row g-2 align-items-center">
|
|
<div class="col-md-3">
|
|
<div class="input-group input-group-sm">
|
|
<span class="input-group-text bg-body-tertiary"><i class="bi bi-search"></i></span>
|
|
<input type="text" name="search" class="form-control"
|
|
placeholder="{% trans %}Buscar aula, descripción...{% endtrans %}"
|
|
value="{{ search }}">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filtro por Edificio -->
|
|
<div class="col-md-3">
|
|
<div class="input-group input-group-sm">
|
|
<span class="input-group-text bg-body-tertiary"><i class="bi bi-buildings text-primary"></i></span>
|
|
<select name="building_id" class="form-select form-select-sm" onchange="this.form.submit()">
|
|
<option value="">{% trans %}Todos los edificios{% endtrans %}</option>
|
|
{% for b in buildings %}
|
|
<option value="{{ b.id }}" {% if building_filter == (b.id|string) %}selected{% endif %}>{{ b.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filtro por Piso -->
|
|
<div class="col-md-2">
|
|
<div class="input-group input-group-sm">
|
|
<span class="input-group-text bg-body-tertiary"><i class="bi bi-layers text-secondary"></i></span>
|
|
<select name="floor" class="form-select form-select-sm" onchange="this.form.submit()">
|
|
<option value="">{% trans %}Todos los pisos{% endtrans %}</option>
|
|
{% for f in floors %}
|
|
<option value="{{ f }}" {% if floor_filter == (f|string) %}selected{% endif %}>
|
|
{% if f == '0' or f == 'PB' %}{% trans %}Planta Baja{% endtrans %}{% else %}{% trans %}Piso{% endtrans %} {{ f }}{% endif %}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-2">
|
|
<div class="form-check pt-1">
|
|
<input class="form-check-input" type="checkbox" name="active_only"
|
|
id="activeOnly" {% if active_only %}checked{% endif %} onchange="this.form.submit()">
|
|
<label class="form-check-label small" for="activeOnly">
|
|
{% trans %}Solo activas{% endtrans %}
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-2 text-md-end">
|
|
<button type="submit" class="btn btn-sm btn-primary me-1">
|
|
<i class="bi bi-filter"></i> {% trans %}Filtrar{% endtrans %}
|
|
</button>
|
|
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-sm btn-outline-secondary">
|
|
<i class="bi bi-x-circle"></i> {% trans %}Limpiar{% endtrans %}
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Classrooms Grid -->
|
|
{% if classrooms and classrooms.items %}
|
|
<div class="row g-3 mt-1">
|
|
{% for classroom in classrooms.items %}
|
|
<div class="col-xxl-3 col-xl-3 col-lg-4 col-md-6 col-sm-12 mb-2">
|
|
<div class="card classroom-card border shadow-sm h-100">
|
|
<div class="card-body p-3 d-flex flex-column justify-content-between">
|
|
<div>
|
|
<!-- Encabezado con Código y Estado -->
|
|
<div class="d-flex justify-content-between align-items-start mb-2">
|
|
<div class="text-truncate me-2">
|
|
<h5 class="card-title mb-0 fw-bold text-primary text-truncate fs-6" title="{{ classroom.code }}">
|
|
<i class="bi bi-door-open me-1"></i>{{ classroom.code }}
|
|
</h5>
|
|
</div>
|
|
<span class="badge rounded-pill {% if classroom.is_active %}bg-success-subtle text-success border border-success-subtle{% else %}bg-secondary-subtle text-secondary border{% endif %}" style="font-size: 0.68rem;">
|
|
{% if classroom.is_active %}{% trans %}Activa{% endtrans %}{% else %}{% trans %}Inactiva{% endtrans %}{% endif %}
|
|
</span>
|
|
</div>
|
|
|
|
<!-- Ubicación: Edificio y Piso -->
|
|
<div class="d-flex flex-wrap gap-1 mb-2">
|
|
<span class="badge bg-primary-subtle text-primary border" style="font-size: 0.7rem;">
|
|
<i class="bi bi-buildings me-1"></i>{{ classroom.building_name }}
|
|
</span>
|
|
<span class="badge bg-secondary-subtle text-secondary border" style="font-size: 0.7rem;">
|
|
<i class="bi bi-layers me-1"></i>{{ classroom.floor_display }}
|
|
</span>
|
|
</div>
|
|
|
|
<!-- Capacidad y Recursos -->
|
|
<div class="d-flex justify-content-between align-items-center small py-1 px-2 bg-body-tertiary rounded mb-2" style="font-size: 0.75rem;">
|
|
<div>
|
|
<span class="text-muted">{% trans %}Cap:{% endtrans %}</span>
|
|
<strong>
|
|
{% if classroom.is_unlimited %}
|
|
<span class="badge bg-primary-subtle text-primary border"><i class="bi bi-infinity"></i></span>
|
|
{% else %}
|
|
{{ classroom.capacity }}
|
|
{% endif %}
|
|
</strong>
|
|
</div>
|
|
<div>
|
|
<span class="text-muted"><i class="bi bi-tools me-1"></i>{{ classroom.resources|length if classroom.resources else 0 }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Barra de Métricas de Ocupación (Día, Semana, Mes) -->
|
|
{% set metrics = occupancy_metrics.get(classroom.id, {'day_pct': 0, 'day_count': 0, 'week_pct': 0, 'week_count': 0, 'month_pct': 0, 'month_count': 0}) %}
|
|
<div class="classroom-occupancy-bar p-2 rounded bg-body-tertiary border mb-2">
|
|
<div class="d-flex justify-content-between align-items-center mb-1">
|
|
<span class="small fw-semibold text-muted" style="font-size: 0.72rem;">
|
|
<i class="bi bi-graph-up me-1 text-primary"></i>{% trans %}Ocupación{% endtrans %}
|
|
</span>
|
|
<span class="text-muted" style="font-size: 0.65rem;" title="{% trans %}Haz clic en cualquier métrica para ver las reservas de ese período{% endtrans %}">
|
|
<i class="bi bi-info-circle me-1"></i>{% trans %}Ver reservas{% endtrans %}
|
|
</span>
|
|
</div>
|
|
<div class="row g-1 text-center">
|
|
<!-- Día -->
|
|
<div class="col-4">
|
|
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.today, date_to=date_filters.today) }}"
|
|
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.day_pct > 80 %}high{% elif metrics.day_pct > 40 %}medium{% elif metrics.day_pct > 0 %}low{% else %}zero{% endif %}"
|
|
title="{% trans %}Ocupación Hoy{% endtrans %}: {{ metrics.day_count }} {% trans %}clases registradas{% endtrans %}">
|
|
<div class="metric-label">{% trans %}Hoy{% endtrans %}</div>
|
|
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.day_count }} cl.{% else %}{{ metrics.day_pct }}%{% endif %}</div>
|
|
</a>
|
|
</div>
|
|
<!-- Semana -->
|
|
<div class="col-4">
|
|
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.week_start, date_to=date_filters.week_end) }}"
|
|
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.week_pct > 80 %}high{% elif metrics.week_pct > 40 %}medium{% elif metrics.week_pct > 0 %}low{% else %}zero{% endif %}"
|
|
title="{% trans %}Ocupación Semana{% endtrans %}: {{ metrics.week_count }} {% trans %}clases registradas{% endtrans %}">
|
|
<div class="metric-label">{% trans %}Semana{% endtrans %}</div>
|
|
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.week_count }} cl.{% else %}{{ metrics.week_pct }}%{% endif %}</div>
|
|
</a>
|
|
</div>
|
|
<!-- Mes -->
|
|
<div class="col-4">
|
|
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.month_start, date_to=date_filters.month_end) }}"
|
|
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.month_pct > 80 %}high{% elif metrics.month_pct > 40 %}medium{% elif metrics.month_pct > 0 %}low{% else %}zero{% endif %}"
|
|
title="{% trans %}Ocupación Mes{% endtrans %}: {{ metrics.month_count }} {% trans %}clases registradas{% endtrans %}">
|
|
<div class="metric-label">{% trans %}Mes{% endtrans %}</div>
|
|
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.month_count }} cl.{% else %}{{ metrics.month_pct }}%{% endif %}</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer con Botones Compactos -->
|
|
<div class="pt-2 border-top d-flex justify-content-between align-items-center">
|
|
<div class="btn-group btn-group-sm">
|
|
<a href="{{ url_for('classrooms.view_classroom', id=classroom.id) }}"
|
|
class="btn btn-outline-primary py-0 px-2" title="{% trans %}Ver Ficha{% endtrans %}" style="font-size: 0.75rem;">
|
|
<i class="bi bi-eye me-1"></i>{% trans %}Ficha{% endtrans %}
|
|
</a>
|
|
<a href="{{ url_for('classrooms.edit_classroom', id=classroom.id) }}"
|
|
class="btn btn-outline-secondary py-0 px-2" title="{% trans %}Editar Aula{% endtrans %}" style="font-size: 0.75rem;">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
</div>
|
|
<form method="POST" action="{{ url_for('classrooms.toggle_classroom', id=classroom.id) }}" class="d-inline mb-0">
|
|
<button type="submit" class="btn btn-sm py-0 px-2 {% if classroom.is_active %}btn-outline-warning{% else %}btn-outline-success{% endif %}"
|
|
title="{% if classroom.is_active %}{% trans %}Desactivar{% endtrans %}{% else %}{% trans %}Activar{% endtrans %}{% endif %}" style="font-size: 0.75rem;">
|
|
{% if classroom.is_active %}
|
|
<i class="bi bi-pause"></i>
|
|
{% else %}
|
|
<i class="bi bi-play"></i>
|
|
{% endif %}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if classrooms.pages > 1 %}
|
|
<nav aria-label="Classroom pagination">
|
|
<ul class="pagination justify-content-center">
|
|
{% if classrooms.has_prev %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.prev_num, search=search, active_only=active_only) }}">
|
|
{% trans %}Previous{% endtrans %}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
{% for page_num in classrooms.iter_pages() %}
|
|
{% if page_num %}
|
|
{% if page_num != classrooms.page %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=page_num, search=search, active_only=active_only) }}">
|
|
{{ page_num }}
|
|
</a>
|
|
</li>
|
|
{% else %}
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_num }}</span>
|
|
</li>
|
|
{% endif %}
|
|
{% else %}
|
|
<li class="page-item disabled">
|
|
<span class="page-link">…</span>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if classrooms.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.next_num, search=search, active_only=active_only) }}">
|
|
{% trans %}Next{% endtrans %}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
<div class="row mt-4">
|
|
<div class="col-12">
|
|
<div class="text-center py-5">
|
|
<i class="bi bi-door-open text-muted" style="font-size: 4rem;"></i>
|
|
<h4 class="mt-3 text-muted">{% trans %}No classrooms found{% endtrans %}</h4>
|
|
<p class="text-muted">
|
|
{% if search %}
|
|
{% trans %}No classrooms match your search criteria.{% endtrans %}
|
|
{% else %}
|
|
{% trans %}No classrooms have been registered yet.{% endtrans %}
|
|
{% endif %}
|
|
</p>
|
|
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-primary">
|
|
<i class="bi bi-plus-circle"></i> {% trans %}Add First Classroom{% endtrans %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %} |