GestionTablets/templates/loan_tablet.html
ijuanes 8a8d2f02fa Initial commit: Tablet lending system with user-tablet many-to-many relationship
- Database schema: tablets, users, loans (junction table)
- CLI app: minimal_app.py
- Web apps: app.py (Flask), simple_app.py (http.server)
- Features: loan management, search, user loans view, project notes
- Git structure: CONTRIBUTING.md, .gitignore

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-03 10:43:17 +01:00

78 lines
No EOL
3 KiB
HTML

{% extends "base.html" %}
{% block content %}
<h2>Loan Tablet</h2>
<form method="POST" action="/loan_tablet">
<!-- Tablet Selection with Search -->
<div class="form-group">
<label for="tablet_id">Tablet:</label>
<input type="text" id="tablet_search" class="search-input"
placeholder="Search tablets (brand, model, or serial)..."
onkeyup="filterDropdown('tablet_search', 'tablet_id')">
<select id="tablet_id" name="tablet_id" required size="5">
<option value="">Select a tablet</option>
{% for tablet in available_tablets %}
<option value="{{ tablet.id }}"
data-search="{{ tablet.brand|lower }} {{ tablet.model|lower }} {{ tablet.serial_number|lower }}">
{{ tablet.brand }} {{ tablet.model }} ({{ tablet.serial_number }})
</option>
{% endfor %}
</select>
</div>
<!-- User Selection with Search -->
<div class="form-group">
<label for="user_id">User:</label>
<input type="text" id="user_search" class="search-input"
placeholder="Search users (name or ID)..."
onkeyup="filterDropdown('user_search', 'user_id')">
<select id="user_id" name="user_id" required size="5">
<option value="">Select a user</option>
{% for user in users %}
<option value="{{ user.id }}"
data-search="{{ user.name|lower }} {{ user.identification|lower }}">
{{ user.name }} ({{ user.identification }})
</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<button type="submit" class="btn">Loan Tablet</button>
</div>
</form>
<script>
function filterDropdown(searchId, selectId) {
const search = document.getElementById(searchId).value.toLowerCase();
const select = document.getElementById(selectId);
const options = select.options;
for (let i = 1; i < options.length; i++) {
const searchText = options[i].getAttribute('data-search') || '';
options[i].style.display = searchText.includes(search) ? '' : 'none';
}
// Show first visible option if search is empty, otherwise keep selection
if (search === '') {
select.selectedIndex = 0;
}
}
</script>
<style>
.search-input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 5px;
}
select[size] {
width: 100%;
max-height: 200px;
overflow-y: auto;
}
</style>
{% endblock %}