jewelry_inventory/templates/partner_form.html
2026-03-27 12:02:41 +05:00

87 lines
3.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block content %}
<h1>{% if partner %}✏️ Редактирование партнера{% else %}➕ Добавление партнера{% endif %}</h1>
<form method="post" class="form-card">
<div class="form-group">
<label>Название компании *</label>
<input type="text" name="company_name" value="{{ partner.company_name if partner else '' }}" required>
<small>Минимум 2 символа</small>
</div>
<div class="form-group">
<label>ФИО директора *</label>
<input type="text" name="director_name" value="{{ partner.director_name if partner else '' }}" required>
<small>Полное имя (фамилия и имя, минимум 5 символов)</small>
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" value="{{ partner.email if partner else '' }}" required>
<small>example@domain.ru</small>
</div>
<div class="form-group">
<label>Телефон *</label>
<input type="text" name="phone" id="phone" value="{{ partner.phone if partner else '' }}" required>
<small>Формат: +7 (999) 123-45-67 или 89123456789 (минимум 10 цифр)</small>
<div id="phone-hint" style="font-size: 12px; margin-top: 5px;"></div>
</div>
<div class="form-group">
<label>Юридический адрес *</label>
<input type="text" name="legal_address" value="{{ partner.legal_address if partner else '' }}" required>
<small>Полный адрес, минимум 5 символов</small>
</div>
<div class="form-group">
<label>ИНН *</label>
<input type="text" name="inn" value="{{ partner.inn if partner else '' }}" required>
<small>10 или 12 цифр, только цифры</small>
</div>
{% if partner %}
<div class="form-group">
<label>Накопленный объем продаж (₽)</label>
<input type="number" step="0.01" name="total_sales" value="{{ partner.total_sales }}">
<small>Изменение этой суммы повлияет на скидку партнера</small>
</div>
{% endif %}
<div style="display: flex; gap: 10px;">
<button type="submit" class="btn btn-primary">💾 Сохранить</button>
<a href="/partners" class="btn btn-secondary">❌ Отмена</a>
</div>
</form>
<script>
function countPhoneDigits() {
const phoneInput = document.getElementById('phone');
const hintDiv = document.getElementById('phone-hint');
if (phoneInput && hintDiv) {
const digits = phoneInput.value.replace(/\\D/g, '');
const digitCount = digits.length;
if (digitCount > 0 && digitCount < 10) {
hintDiv.innerHTML = '⚠️ Найдено ' + digitCount + ' цифр. Требуется минимум 10 цифр.';
hintDiv.style.color = '#f44336';
} else if (digitCount >= 10 && digitCount <= 15) {
hintDiv.innerHTML = '✓ ' + digitCount + ' цифр. OK';
hintDiv.style.color = '#4caf50';
} else if (digitCount > 15) {
hintDiv.innerHTML = '⚠️ Слишком много цифр (' + digitCount + '). Максимум 15.';
hintDiv.style.color = '#f44336';
} else {
hintDiv.innerHTML = '';
}
}
}
const phoneInput = document.getElementById('phone');
if (phoneInput) {
phoneInput.addEventListener('input', countPhoneDigits);
countPhoneDigits();
}
</script>
{% endblock %}
EOF