99 lines
4.3 KiB
HTML
99 lines
4.3 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Создание КС-2{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h2>Создание КС-2</h2>
|
|
|
|
{% if error %}
|
|
<div class="alert alert-danger" role="alert">
|
|
{{ error }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<form method="post" action="/projects/{{ project.id }}/ks2">
|
|
<div class="row mb-3">
|
|
<div class="col-md-6">
|
|
<label for="number" class="form-label">Номер КС-2</label>
|
|
<input type="text" class="form-control" id="number" name="number" required>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label for="document_date" class="form-label">Дата</label>
|
|
<input type="date" class="form-control" id="document_date" name="document_date" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="comment" class="form-label">Комментарий</label>
|
|
<textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
|
|
</div>
|
|
|
|
<h4>Выберите позиции</h4>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Наименование</th>
|
|
<th>План</th>
|
|
<th>Факт</th>
|
|
<th>Закрыто</th>
|
|
<th>Доступно</th>
|
|
<th>Количество</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for balance in balances %}
|
|
<tr>
|
|
<td>{{ balance.item.name }}</td>
|
|
<td>{{ balance.planned_quantity }}</td>
|
|
<td>{{ balance.actual_quantity }}</td>
|
|
<td>{{ balance.closed_quantity }}</td>
|
|
<td>{{ balance.available_quantity }}</td>
|
|
<td>
|
|
<input type="checkbox" class="form-check-input" id="include_{{ balance.item.id }}"
|
|
name="include_{{ balance.item.id }}" value="1"
|
|
{% if balance.item.id in selected %}checked{% endif %}>
|
|
<input type="number" class="form-control form-control-sm"
|
|
name="quantity_{{ balance.item.id }}"
|
|
value="{{ selected.get(balance.item.id, '') }}"
|
|
min="0" step="0.0001"
|
|
{% if balance.item.id not in selected %}disabled{% endif %}
|
|
placeholder="Количество">
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">Создать</button>
|
|
<a href="/projects/{{ project.id }}/ks2" class="btn btn-secondary">Отмена</a>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Обработчик изменения чекбокса
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
|
checkboxes.forEach(checkbox => {
|
|
checkbox.addEventListener('change', function() {
|
|
const quantityInput = document.querySelector(`input[name="quantity_${this.id.split('_')[1]}"]`);
|
|
if (this.checked) {
|
|
quantityInput.disabled = false;
|
|
quantityInput.focus();
|
|
} else {
|
|
quantityInput.disabled = true;
|
|
quantityInput.value = '';
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|