GestionTablets/templates/students.html

183 lines
10 KiB
HTML
Raw Normal View History

{% extends "base.html" %}
{% block title %}{{ gettext('Students') }}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-12">
<h1 class="page-title">{{ gettext('Students') }}</h1>
<div class="mb-4">
<div class="d-flex justify-content-between align-items-center">
<div>
<p class="text-muted">{{ gettext('Total students:') }} {{ total_students }}</p>
</div>
<div class="btn-group" role="group">
<a href="{{ url_for('add_student') }}" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> {{ gettext('Add Student') }}
</a>
<a href="{{ url_for('import_students') }}" class="btn btn-secondary">
<i class="bi bi-upload"></i> {{ gettext('Import CSV') }}
</a>
</div>
</div>
</div>
<!-- Search and Filter Form -->
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">{{ gettext('Search & Filter') }}</h5>
</div>
<div class="card-body">
<form method="get" action="{{ url_for('list_students') }}" class="row g-3">
<div class="col-md-4">
<label for="search" class="form-label">{{ gettext('Search') }}</label>
<input type="text" class="form-control" id="search" name="search"
value="{{ search }}" placeholder="{{ gettext('Name, CIAL, NIF...') }}">
</div>
<div class="col-md-2">
<label for="gender" class="form-label">{{ gettext('Gender') }}</label>
<select class="form-select" id="gender" name="gender">
<option value="">{{ gettext('All') }}</option>
{% for g in genders %}
<option value="{{ g }}" {% if gender == g %}selected{% endif %}>{{ g }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<label for="group" class="form-label">{{ gettext('Study Group') }}</label>
<select class="form-select" id="group" name="group">
<option value="">{{ gettext('All') }}</option>
{% for g in groups %}
<option value="{{ g }}" {% if group == g %}selected{% endif %}>{{ g }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2 d-flex align-items-end">
<button type="submit" class="btn btn-primary w-100">
<i class="bi bi-search"></i> {{ gettext('Search') }}
</button>
</div>
<div class="col-md-1 d-flex align-items-end">
<a href="{{ url_for('list_students') }}" class="btn btn-secondary w-100">
<i class="bi bi-x-circle"></i> {{ gettext('Clear') }}
</a>
</div>
</form>
</div>
</div>
<!-- Students Table -->
<div class="card">
<div class="card-header">
<h5 class="mb-0">{{ gettext('Student List') }}</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-striped table-hover mb-0">
<thead class="table-light">
<tr>
<th>{{ gettext('ID') }}</th>
<th>{{ gettext('Name') }}</th>
<th>{{ gettext('CIAL Code') }}</th>
<th>{{ gettext('NIF/NIE') }}</th>
<th>{{ gettext('Gender') }}</th>
<th>{{ gettext('Study Group') }}</th>
<th>{{ gettext('Birth Date') }}</th>
<th class="text-end">{{ gettext('Actions') }}</th>
</tr>
</thead>
<tbody>
{% if students %}
{% for student in students %}
<tr>
<td>{{ student.id }}</td>
<td>
<a href="{{ url_for('student_detail', student_id=student.id) }}">
{{ student.last_name }}, {{ student.first_name }}
</a>
</td>
<td>{{ student.cial_code }}</td>
<td>{{ student.nif_nie_passport or '-' }}</td>
<td>{{ student.gender or '-' }}</td>
<td>{{ student.study_group or '-' }}</td>
<td>{{ student.birth_date or '-' }}</td>
<td class="text-end">
<div class="btn-group btn-group-sm" role="group">
<a href="{{ url_for('student_detail', student_id=student.id) }}"
class="btn btn-info btn-sm" title="{{ gettext('View') }}">
<i class="bi bi-eye"></i>
</a>
<a href="{{ url_for('edit_student', student_id=student.id) }}"
class="btn btn-warning btn-sm" title="{{ gettext('Edit') }}">
<i class="bi bi-pencil"></i>
</a>
<a href="{{ url_for('delete_student', student_id=student.id) }}"
class="btn btn-danger btn-sm"
onclick="return confirm('{{ gettext('Are you sure you want to delete this student?') }}')"
title="{{ gettext('Delete') }}">
<i class="bi bi-trash"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="8" class="text-center text-muted">
{{ gettext('No students found') }}
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<!-- Pagination -->
{% if total_pages > 1 %}
<div class="card-footer">
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center mb-0">
{% if page > 1 %}
<li class="page-item">
<a class="page-link" href="?page={{ page - 1 }}&search={{ search }}&gender={{ gender }}&group={{ group }}">
{{ gettext('Previous') }}
</a>
</li>
{% endif %}
{% for p in range(1, total_pages + 1) %}
{% if p == page %}
<li class="page-item active"><span class="page-link">{{ p }}</span></li>
{% elif p <= 3 or p > total_pages - 3 or (p >= page - 2 and p <= page + 2) %}
<li class="page-item">
<a class="page-link" href="?page={{ p }}&search={{ search }}&gender={{ gender }}&group={{ group }}">{{ p }}</a>
</li>
{% elif p == 4 or p == total_pages - 3 %}
<li class="page-item disabled"><span class="page-link">...</span></li>
{% endif %}
{% endfor %}
{% if page < total_pages %}
<li class="page-item">
<a class="page-link" href="?page={{ page + 1 }}&search={{ search }}&gender={{ gender }}&group={{ group }}">
{{ gettext('Next') }}
</a>
</li>
{% endif %}
</ul>
</nav>
<div class="text-muted text-center mt-2">
{{ gettext('Showing') }} {{ (page - 1) * per_page + 1 }}-
{{ min(page * per_page, total_students) }} {{ gettext('of') }} {{ total_students }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}