98 lines
4.8 KiB
HTML
98 lines
4.8 KiB
HTML
{% extends "base.html" %}
|
||
|
||
{% block title %}{{ 'Редактирование' if product else 'Добавление' }} товара{% endblock %}
|
||
|
||
{% block content %}
|
||
<div class="form-container">
|
||
<h2>{{ '✏️ Редактирование товара' if product else '➕ Добавление нового товара' }}</h2>
|
||
|
||
<form method="POST">
|
||
<div class="form-group">
|
||
<label for="article">Артикул *</label>
|
||
<input type="text" id="article" name="article" value="{{ product.article if product else '' }}" required>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="name">Наименование *</label>
|
||
<input type="text" id="name" name="name" value="{{ product.name if product else '' }}" required>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="commercial_name">Коммерческое наименование</label>
|
||
<input type="text" id="commercial_name" name="commercial_name" value="{{ product.commercial_name if product else '' }}">
|
||
</div>
|
||
|
||
<div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
|
||
<div class="form-group">
|
||
<label for="unit">Единица измерения</label>
|
||
<input type="text" id="unit" name="unit" value="{{ product.unit if product else 'шт' }}">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="category_id">Категория *</label>
|
||
<select id="category_id" name="category_id" required>
|
||
<option value="">— Выберите категорию —</option>
|
||
{% for category in categories %}
|
||
<option value="{{ category.id }}" {% if product and product.category_id == category.id %}selected{% endif %}>
|
||
{{ category.name }}
|
||
</option>
|
||
{% endfor %}
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;">
|
||
<div class="form-group">
|
||
<label for="base_price">Базовая цена *</label>
|
||
<input type="number" id="base_price" name="base_price" step="0.01" min="0" value="{{ product.base_price if product else '' }}" required>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="excise_tax">Акциз (₽)</label>
|
||
<input type="number" id="excise_tax" name="excise_tax" step="0.01" min="0" value="{{ product.excise_tax if product else '0' }}">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="license_fee">Лицензионный сбор (₽)</label>
|
||
<input type="number" id="license_fee" name="license_fee" step="0.01" min="0" value="{{ product.license_fee if product else '0' }}">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label>
|
||
<input type="checkbox" name="is_alcohol" {% if product and product.is_alcohol %}checked{% endif %}>
|
||
Алкогольная продукция
|
||
</label>
|
||
</div>
|
||
|
||
<div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;" id="alcohol-fields" {% if not product or not product.is_alcohol %}style="display: none;"{% endif %}>
|
||
<div class="form-group">
|
||
<label for="alcohol_content">Крепость (%)</label>
|
||
<input type="number" id="alcohol_content" name="alcohol_content" step="0.1" min="0" max="100" value="{{ product.alcohol_content if product else '' }}">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="volume">Объём (л)</label>
|
||
<input type="number" id="volume" name="volume" step="0.001" min="0" value="{{ product.volume if product else '' }}">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-actions">
|
||
<button type="submit" class="btn btn-primary">{{ '💾 Сохранить' if product else '✅ Добавить' }}</button>
|
||
<a href="{{ url_for('products') }}" class="btn">↩️ Отмена</a>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
|
||
<script>
|
||
// Показывать/скрывать поля для алкоголя
|
||
document.querySelector('input[name="is_alcohol"]').addEventListener('change', function(e) {
|
||
const alcoholFields = document.getElementById('alcohol-fields');
|
||
if (e.target.checked) {
|
||
alcoholFields.style.display = 'grid';
|
||
} else {
|
||
alcoholFields.style.display = 'none';
|
||
}
|
||
});
|
||
</script>
|
||
{% endblock %} |