{% extends "base.html" %} {% block title %}Skladki Czlonkowskie - Norda Biznes Hub{% endblock %} {% block extra_css %} {% endblock %} {% block content %}

Skladki Czlonkowskie

{{ total_companies }}
Firm czlonkowskich
{{ paid_count }}
Oplaconych
{{ pending_count }}
Oczekujacych
{{ "%.2f"|format(total_paid) }} zl
Zebrano
{{ "%.2f"|format(total_due - total_paid) }} zl
Do zebrania
{% if month %} {% endif %}
{% if month %} {% endif %}

Lista firm {% if month %}({{ dict(months).get(month, month) }} {{ year }}){% else %}({{ year }}){% endif %}

{% if month %} {% endif %}
{% if month %}{% endif %} {% if month %} {% else %} {% endif %} {% for cf in companies_fees %} {% if month %} {% else %} {% for m in range(1, 13) %} {% endfor %} {% endif %} {% endfor %}
FirmaStatus Kwota Zaplacono Data platnosci AkcjeStyLutMarKwiMajCze LipSieWrzPazLisGru
{% if cf.fee %} {% endif %} {{ cf.company.name }} {% if cf.status == 'paid' %}Oplacone {% elif cf.status == 'pending' %}Oczekuje {% elif cf.status == 'overdue' %}Zalegle {% elif cf.status == 'partial' %}Czesciowe {% else %}Brak {% endif %} {% if cf.fee %}{{ cf.fee.amount }} zl{% else %}-{% endif %} {% if cf.fee and cf.fee.amount_paid %}{{ cf.fee.amount_paid }} zl{% else %}-{% endif %} {% if cf.fee and cf.fee.payment_date %}{{ cf.fee.payment_date }}{% else %}-{% endif %} {% if cf.fee and cf.status != 'paid' %} {% elif not cf.fee %} Brak rekordu {% endif %} {{ cf.company.name }} {% set fee = cf.months.get(m) %} {% if fee %} {{ m }} {% else %} - {% endif %}
{% endblock %} {% block extra_js %} function generateFees() { if (!confirm('Czy na pewno chcesz wygenerowac rekordy skladek dla wszystkich firm na wybrany miesiac?')) { return; } const formData = new FormData(); formData.append('year', {{ year }}); formData.append('month', {{ month or 'null' }}); fetch('{{ url_for("admin_fees_generate") }}', { method: 'POST', body: formData, headers: { 'X-CSRFToken': '{{ csrf_token() }}' } }) .then(response => response.json()) .then(data => { if (data.success) { alert(data.message); location.reload(); } else { alert('Blad: ' + data.error); } }) .catch(err => alert('Blad: ' + err)); } function openPaymentModal(feeId, companyName, amount) { document.getElementById('modalFeeId').value = feeId; document.getElementById('modalCompanyName').value = companyName; document.getElementById('modalAmount').value = amount; document.getElementById('modalDate').value = new Date().toISOString().split('T')[0]; document.getElementById('paymentModal').classList.add('active'); } function closePaymentModal() { document.getElementById('paymentModal').classList.remove('active'); } document.getElementById('paymentForm').addEventListener('submit', function(e) { e.preventDefault(); const feeId = document.getElementById('modalFeeId').value; const formData = new FormData(this); fetch('/admin/fees/' + feeId + '/mark-paid', { method: 'POST', body: formData, headers: { 'X-CSRFToken': '{{ csrf_token() }}' } }) .then(response => response.json()) .then(data => { if (data.success) { alert(data.message); location.reload(); } else { alert('Blad: ' + data.error); } }) .catch(err => alert('Blad: ' + err)); }); function toggleSelectAll() { const selectAll = document.getElementById('selectAll'); const checkboxes = document.querySelectorAll('.fee-checkbox:not(:disabled)'); checkboxes.forEach(cb => cb.checked = selectAll.checked); } function bulkMarkPaid() { const checkboxes = document.querySelectorAll('.fee-checkbox:checked'); if (checkboxes.length === 0) { alert('Zaznacz przynajmniej jedna skladke'); return; } if (!confirm('Czy na pewno chcesz oznaczyc ' + checkboxes.length + ' skladek jako oplacone?')) { return; } const formData = new FormData(); checkboxes.forEach(cb => formData.append('fee_ids[]', cb.value)); fetch('{{ url_for("admin_fees_bulk_mark_paid") }}', { method: 'POST', body: formData, headers: { 'X-CSRFToken': '{{ csrf_token() }}' } }) .then(response => response.json()) .then(data => { if (data.success) { alert(data.message); location.reload(); } else { alert('Blad: ' + data.error); } }) .catch(err => alert('Blad: ' + err)); } // Close modal on outside click document.getElementById('paymentModal').addEventListener('click', function(e) { if (e.target === this) { closePaymentModal(); } }); {% endblock %}