Загрузка данных
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Дети сотрудника</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.child-table td { vertical-align: middle; }
</style>
</head>
<body class="bg-light">
<div class="container mt-4">
<h2>{{ worker[0] }} {{ worker[1] }} {{ worker[2] }}</h2>
<p><strong>Таб. номер:</strong> {{ worker[3] }} | <strong>Должность:</strong> {{ worker[4] }}</p>
<form method="get" action="/employee/{{ worker[3] }}/export" id="exportForm">
<!-- Выбор формы -->
<div class="mb-3">
<label for="formSelect" class="form-label"><strong>Выберите форму для экспорта:</strong></label>
<select class="form-select" id="formSelect" name="form" style="max-width: 300px;">
<option value="blank6">BLANKS6.XLS (только работник)</option>
<option value="blank5">BLANK5_1.xlsx (работник + ребёнок)</option>
</select>
</div>
<!-- Список детей с радиокнопками -->
{% if children %}
<h4>Выберите ребёнка (для BLANK5_1)</h4>
<div class="table-responsive">
<table class="table table-bordered child-table">
<thead class="table-dark">
<tr>
<th style="width: 50px;">Выбор</th>
<th>Фамилия</th>
<th>Имя</th>
<th>Отчество</th>
<th>Дата рождения</th>
<th>Степень родства</th>
<th>Пол</th>
</tr>
</thead>
<tbody>
{% for ch in children %}
<tr>
<td class="text-center">
<input type="radio" name="child_id" value="{{ ch[0] }}" required>
</td>
<td>{{ ch[1] }}</td>
<td>{{ ch[2] }}</td>
<td>{{ ch[3] }}</td>
<td>{{ ch[4] }}</td>
<td>{{ ch[5] }}</td>
<td>{{ ch[6] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-warning">У этого сотрудника нет детей.</div>
{% endif %}
<div class="mt-3">
<button type="submit" class="btn btn-success">Экспортировать</button>
<a href="/" class="btn btn-secondary">← Назад</a>
</div>
</form>
<!-- Небольшой скрипт, чтобы сделать радиокнопки необязательными при выборе BLANK6 -->
<script>
document.getElementById('formSelect').addEventListener('change', function() {
var radios = document.querySelectorAll('input[name="child_id"]');
var required = (this.value === 'blank5');
radios.forEach(function(r) {
r.required = required;
});
// Если выбрана форма blank6, снимаем checked, чтобы не передавать лишний параметр
if (!required) {
radios.forEach(function(r) { r.checked = false; });
}
});
// При загрузке страницы сразу применить правило
window.addEventListener('DOMContentLoaded', function() {
var event = new Event('change');
document.getElementById('formSelect').dispatchEvent(event);
});
</script>
</div>
</body>
</html>