wylaczenie sposob platnosci i porpawki ux

This commit is contained in:
Mateusz Gruszczyński
2025-10-10 13:30:13 +02:00
parent 1c69295b9b
commit f9406a46cf
7 changed files with 332 additions and 260 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE zbiorka ALTER COLUMN numer_konta DROP NOT NULL;
ALTER TABLE zbiorka ALTER COLUMN numer_telefonu_blik DROP NOT NULL;

153
app.py
View File

@@ -82,8 +82,8 @@ class Zbiorka(db.Model):
id = db.Column(db.Integer, primary_key=True)
nazwa = db.Column(db.String(100), nullable=False)
opis = db.Column(db.Text, nullable=False)
numer_konta = db.Column(db.String(50), nullable=False)
numer_telefonu_blik = db.Column(db.String(50), nullable=False)
numer_konta = db.Column(db.String(50), nullable=True)
numer_telefonu_blik = db.Column(db.String(50), nullable=True)
cel = db.Column(Numeric(12, 2), nullable=False, default=0)
stan = db.Column(Numeric(12, 2), default=0)
ukryta = db.Column(db.Boolean, default=False)
@@ -92,6 +92,8 @@ class Zbiorka(db.Model):
pokaz_postep_finanse = db.Column(db.Boolean, default=True, nullable=False)
pokaz_postep_pozycje = db.Column(db.Boolean, default=True, nullable=False)
pokaz_postep_kwotowo = db.Column(db.Boolean, default=True, nullable=False)
uzyj_konta = db.Column(db.Boolean, default=True, nullable=False)
uzyj_blik = db.Column(db.Boolean, default=True, nullable=False)
wplaty = db.relationship(
"Wplata",
@@ -386,88 +388,69 @@ def formularz_zbiorek(zbiorka_id=None):
return redirect(url_for("index"))
is_edit = zbiorka_id is not None
zb = None
if is_edit:
zb = db.session.get(Zbiorka, zbiorka_id)
if zb is None:
zb = db.session.get(Zbiorka, zbiorka_id) if is_edit else None
if is_edit and zb is None:
abort(404)
global_settings = UstawieniaGlobalne.query.first()
def _temp_obj():
t = zb or Zbiorka()
t.nazwa = (request.form.get("nazwa", "") or "").strip()
t.opis = (request.form.get("opis", "") or "").strip()
t.numer_konta = (request.form.get("numer_konta", "") or "").strip()
t.numer_telefonu_blik = (request.form.get("numer_telefonu_blik", "") or "").strip()
t.ukryj_kwote = "ukryj_kwote" in request.form
t.pokaz_postep_finanse = "pokaz_postep_finanse" in request.form
t.pokaz_postep_pozycje = "pokaz_postep_pozycje" in request.form
t.pokaz_postep_kwotowo = "pokaz_postep_kwotowo" in request.form
t.uzyj_konta = "uzyj_konta" in request.form
t.uzyj_blik = "uzyj_blik" in request.form
return t
if request.method == "POST":
# Pola wspólne
# Pola
nazwa = (request.form.get("nazwa", "") or "").strip()
opis = (request.form.get("opis", "") or "").strip()
numer_konta = (request.form.get("numer_konta", "") or "").strip()
numer_telefonu_blik = (request.form.get("numer_telefonu_blik", "") or "").strip()
# Widoczność kwot i poszczególnych pasków postępu
# Przełączniki płatności
uzyj_konta = "uzyj_konta" in request.form
uzyj_blik = "uzyj_blik" in request.form
# Widoczność/metryki
ukryj_kwote = "ukryj_kwote" in request.form
pokaz_postep_finanse = "pokaz_postep_finanse" in request.form
pokaz_postep_pozycje = "pokaz_postep_pozycje" in request.form
pokaz_postep_kwotowo = "pokaz_postep_kwotowo" in request.form
# Walidacja wymaganych pól tekstowych (zanim uderzymy w bazę)
# Walidacje
if not nazwa:
flash("Nazwa jest wymagana", "danger")
temp_zb = zb or Zbiorka()
temp_zb.nazwa = nazwa
temp_zb.opis = opis
temp_zb.numer_konta = numer_konta
temp_zb.numer_telefonu_blik = numer_telefonu_blik
temp_zb.ukryj_kwote = ukryj_kwote
temp_zb.pokaz_postep_finanse = pokaz_postep_finanse
temp_zb.pokaz_postep_pozycje = pokaz_postep_pozycje
temp_zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
return render_template("admin/formularz_zbiorek.html", zbiorka=temp_zb, global_settings=global_settings)
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
if not opis:
flash("Opis jest wymagany", "danger")
temp_zb = zb or Zbiorka()
temp_zb.nazwa = nazwa
temp_zb.opis = opis
temp_zb.numer_konta = numer_konta
temp_zb.numer_telefonu_blik = numer_telefonu_blik
temp_zb.ukryj_kwote = ukryj_kwote
temp_zb.pokaz_postep_finanse = pokaz_postep_finanse
temp_zb.pokaz_postep_pozycje = pokaz_postep_pozycje
temp_zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
return render_template("admin/formularz_zbiorek.html", zbiorka=temp_zb, global_settings=global_settings)
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
if not numer_konta:
flash("Numer konta jest wymagany", "danger")
temp_zb = zb or Zbiorka()
temp_zb.nazwa = nazwa
temp_zb.opis = opis
temp_zb.numer_konta = numer_konta
temp_zb.numer_telefonu_blik = numer_telefonu_blik
temp_zb.ukryj_kwote = ukryj_kwote
temp_zb.pokaz_postep_finanse = pokaz_postep_finanse
temp_zb.pokaz_postep_pozycje = pokaz_postep_pozycje
temp_zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
return render_template("admin/formularz_zbiorek.html", zbiorka=temp_zb, global_settings=global_settings)
# Co najmniej jeden kanał
if not (uzyj_konta or uzyj_blik):
flash("Włącz co najmniej jeden kanał wpłat (konto lub BLIK).", "danger")
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
if not numer_telefonu_blik:
flash("Numer telefonu BLIK jest wymagany", "danger")
temp_zb = zb or Zbiorka()
temp_zb.nazwa = nazwa
temp_zb.opis = opis
temp_zb.numer_konta = numer_konta
temp_zb.numer_telefonu_blik = numer_telefonu_blik
temp_zb.ukryj_kwote = ukryj_kwote
temp_zb.pokaz_postep_finanse = pokaz_postep_finanse
temp_zb.pokaz_postep_pozycje = pokaz_postep_pozycje
temp_zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
return render_template("admin/formularz_zbiorek.html", zbiorka=temp_zb, global_settings=global_settings)
# Warunkowe wartości
if uzyj_konta and not numer_konta:
flash("Numer konta jest wymagany (kanał przelewu włączony).", "danger")
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
# Cel — Decimal, > 0; akceptuj przecinek i usuń spacje/nbsp
if uzyj_blik and not numer_telefonu_blik:
flash("Numer telefonu BLIK jest wymagany (kanał BLIK włączony).", "danger")
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
# Cel > 0
cel_raw = (request.form.get("cel", "") or "")
cel_norm = (
cel_raw.replace(" ", "")
.replace("\u00A0", "")
.replace(",", ".")
.strip()
)
cel_norm = cel_raw.replace(" ", "").replace("\u00A0", "").replace(",", ".").strip()
try:
if not cel_norm:
raise InvalidOperation
@@ -476,51 +459,41 @@ def formularz_zbiorek(zbiorka_id=None):
raise InvalidOperation
except (InvalidOperation, ValueError):
flash("Podano nieprawidłową wartość dla celu zbiórki", "danger")
# Odtwórz stan formularza, ale nie używaj zbiorka.id w szablonie
temp_zb = zb or Zbiorka()
temp_zb.nazwa = nazwa
temp_zb.opis = opis
temp_zb.numer_konta = numer_konta
temp_zb.numer_telefonu_blik = numer_telefonu_blik
# cel pozostaw niewypełniony przy błędzie, aby input pokazał to co wpisał użytkownik
temp_zb.ukryj_kwote = ukryj_kwote
temp_zb.pokaz_postep_finanse = pokaz_postep_finanse
temp_zb.pokaz_postep_pozycje = pokaz_postep_pozycje
temp_zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
return render_template("admin/formularz_zbiorek.html", zbiorka=temp_zb, global_settings=global_settings)
return render_template("admin/formularz_zbiorek.html", zbiorka=_temp_obj(), global_settings=global_settings)
# Lista produktów
# Produkty
names = request.form.getlist("item_nazwa[]")
links = request.form.getlist("item_link[]")
prices = request.form.getlist("item_cena[]")
def _read_price(val):
"""Zwraca Decimal(>=0) albo None; akceptuje przecinek jako separator dziesiętny."""
def _read_price(val: str):
if not val or not val.strip():
return None
try:
d = Decimal(val.replace(",", "."))
if d < 0:
return None
return d
return d if d >= 0 else None
except Exception:
return None
# --- ZAPIS ZBIÓRKI + PRODUKTÓW ---
# Zapis
if is_edit:
# Aktualizacja istniejącej zbiórki
zb.nazwa = nazwa
zb.opis = opis
zb.numer_konta = numer_konta
zb.numer_telefonu_blik = numer_telefonu_blik
# NOT NULL-safe: puste stringi gdy wyłączone
zb.uzyj_konta = uzyj_konta
zb.uzyj_blik = uzyj_blik
zb.numer_konta = numer_konta if uzyj_konta else ""
zb.numer_telefonu_blik = numer_telefonu_blik if uzyj_blik else ""
zb.cel = cel
zb.ukryj_kwote = ukryj_kwote
zb.pokaz_postep_finanse = pokaz_postep_finanse
zb.pokaz_postep_pozycje = pokaz_postep_pozycje
zb.pokaz_postep_kwotowo = pokaz_postep_kwotowo
db.session.commit() # zapisz bazowe pola
db.session.commit()
# Nadpisz listę produktów
# Nadpisz pozycje
zb.przedmioty.clear()
for i, raw_name in enumerate(names):
name = (raw_name or "").strip()
@@ -529,7 +502,6 @@ def formularz_zbiorek(zbiorka_id=None):
link = (links[i] if i < len(links) else "").strip() or None
cena_val = _read_price(prices[i] if i < len(prices) else "")
kupione_val = request.form.get(f"item_kupione_val_{i}") == "1"
db.session.add(Przedmiot(
zbiorka_id=zb.id,
nazwa=name,
@@ -537,17 +509,17 @@ def formularz_zbiorek(zbiorka_id=None):
cena=cena_val,
kupione=kupione_val
))
db.session.commit()
flash("Zbiórka została zaktualizowana", "success")
else:
# Utworzenie nowej zbiórki
nowa = Zbiorka(
nazwa=nazwa,
opis=opis,
numer_konta=numer_konta,
numer_telefonu_blik=numer_telefonu_blik,
uzyj_konta=uzyj_konta,
uzyj_blik=uzyj_blik,
numer_konta=(numer_konta if uzyj_konta else ""),
numer_telefonu_blik=(numer_telefonu_blik if uzyj_blik else ""),
cel=cel,
ukryj_kwote=ukryj_kwote,
pokaz_postep_finanse=pokaz_postep_finanse,
@@ -557,7 +529,6 @@ def formularz_zbiorek(zbiorka_id=None):
db.session.add(nowa)
db.session.commit() # potrzebne ID
# Dodaj produkty do nowej zbiórki
for i, raw_name in enumerate(names):
name = (raw_name or "").strip()
if not name:
@@ -565,7 +536,6 @@ def formularz_zbiorek(zbiorka_id=None):
link = (links[i] if i < len(links) else "").strip() or None
cena_val = _read_price(prices[i] if i < len(prices) else "")
kupione_val = request.form.get(f"item_kupione_val_{i}") == "1"
db.session.add(Przedmiot(
zbiorka_id=nowa.id,
nazwa=name,
@@ -573,7 +543,6 @@ def formularz_zbiorek(zbiorka_id=None):
cena=cena_val,
kupione=kupione_val
))
db.session.commit()
flash("Zbiórka została dodana", "success")

View File

@@ -422,3 +422,19 @@ select.form-select:focus {
background-color: #141414;
border-color: color-mix(in srgb, var(--accent) 24%, #ffffff);
}
#kanalyWarning,
#postepyWarning {
border: 1px solid #ffc107;
background-color: #2c2c2c;
color: #fff;
}
input:disabled,
textarea:disabled,
select:disabled {
background-color: #2b2b2b !important;
color: #bbb !important;
opacity: 1 !important;
cursor: not-allowed;
}

View File

@@ -0,0 +1,88 @@
(function () {
const form = document.getElementById('form-edit-zbiorka') || document.getElementById('form-add-zbiorka') || document.querySelector('form');
const map = [
['uzyj_konta', 'numer_konta'],
['uzyj_blik', 'numer_telefonu_blik']
];
const warnBox = document.getElementById('kanalyWarning');
function showWarn(show) {
if (!warnBox) return;
warnBox.classList.toggle('d-none', !show);
}
function getEl(id) { return document.getElementById(id); }
function toggleField(chkId, inputId) {
const chk = getEl(chkId);
const inp = getEl(inputId);
if (!inp || !chk) return;
const on = chk.checked;
inp.disabled = !on;
if (on) inp.setAttribute('required', '');
else inp.removeAttribute('required');
}
function atLeastOneOn() {
return map.some(([c]) => getEl(c)?.checked);
}
function blinkInvalid(el) {
if (!el) return;
el.classList.add('is-invalid');
setTimeout(() => el.classList.remove('is-invalid'), 400);
}
function preventUncheckLast(e) {
const target = e.target;
if (target.checked) return;
const after = map.map(([c]) => c === target.id ? false : !!getEl(c)?.checked);
if (!after.some(Boolean)) {
e.preventDefault();
target.checked = true;
showWarn(true);
blinkInvalid(target);
} else {
showWarn(false);
}
}
function onToggle(chkId, inputId) {
toggleField(chkId, inputId);
showWarn(!atLeastOneOn());
}
map.forEach(([chkId, inputId]) => {
const chk = getEl(chkId);
if (!chk) return;
chk.addEventListener('click', preventUncheckLast);
chk.addEventListener('change', () => onToggle(chkId, inputId));
toggleField(chkId, inputId);
});
showWarn(!atLeastOneOn());
if (form) {
form.addEventListener('submit', function (e) {
if (!atLeastOneOn()) {
e.preventDefault();
showWarn(true);
blinkInvalid(getEl('uzyj_konta') || getEl('uzyj_blik'));
(getEl('uzyj_konta') || getEl('uzyj_blik'))?.focus();
return;
}
for (const [chkId, inputId] of map) {
const chk = getEl(chkId), inp = getEl(inputId);
if (chk?.checked && inp && !inp.value.trim()) {
e.preventDefault();
showWarn(true);
blinkInvalid(inp);
inp.focus();
return;
}
}
});
}
})();

View File

@@ -17,14 +17,16 @@
<!-- Nawigacja / powrót -->
<div class="d-flex align-items-center gap-2 mb-3">
{% if is_edit and zbiorka and zbiorka.id %}
<a href="{{ url_for('zbiorka', zbiorka_id=zbiorka.id) }}" class="btn btn-sm btn-outline-light">← Szczegóły zbiórki</a>
<a href="{{ url_for('zbiorka', zbiorka_id=zbiorka.id) }}" class="btn btn-sm btn-outline-light">← Szczegóły
zbiórki</a>
{% else %}
<a href="{{ url_for('admin_dashboard') }}" class="btn btn-sm btn-outline-light">← Panel Admina</a>
{% endif %}
</div>
<div class="card shadow-sm">
<div class="card-header bg-secondary text-white d-flex flex-wrap align-items-center justify-content-between gap-2">
<div
class="card-header bg-secondary text-white d-flex flex-wrap align-items-center justify-content-between gap-2">
<h3 class="card-title mb-0">
{{ 'Edytuj zbiórkę' if is_edit else 'Dodaj nową zbiórkę' }}
</h3>
@@ -48,8 +50,7 @@
<span class="badge bg-dark border" style="border-color: var(--border);">
Brakuje: {{ delta|round(2) }} PLN
</span>
{% elif delta < 0 %}
<span class="badge bg-dark border" style="border-color: var(--border);">
{% elif delta < 0 %} <span class="badge bg-dark border" style="border-color: var(--border);">
Nadwyżka: {{ (-delta)|round(2) }} PLN
</span>
{% endif %}
@@ -77,30 +78,17 @@
<div class="row g-3">
<div class="col-12">
<label for="nazwa" class="form-label">Nazwa zbiórki</label>
<input
type="text"
class="form-control"
id="nazwa"
name="nazwa"
maxlength="120"
<input type="text" class="form-control" id="nazwa" name="nazwa" maxlength="120"
placeholder="{{ 'Krótki, zrozumiały tytuł' if is_edit else 'Np. Wsparcie dla schroniska Azor' }}"
value="{{ (zbiorka.nazwa if zbiorka else request.form.get('nazwa','')) }}"
required
aria-describedby="nazwaHelp"
>
value="{{ (zbiorka.nazwa if zbiorka else request.form.get('nazwa','')) }}" required
aria-describedby="nazwaHelp">
<div id="nazwaHelp" class="form-text">Krótki, zrozumiały tytuł. Max 120 znaków.</div>
</div>
<div class="col-12">
<label for="opis" class="form-label">Opis (Markdown)</label>
<textarea
class="form-control"
id="opis"
name="opis"
rows="8"
required
aria-describedby="opisHelp"
>{{ (zbiorka.opis if zbiorka else request.form.get('opis','')) }}</textarea>
<textarea class="form-control" id="opis" name="opis" rows="8" required
aria-describedby="opisHelp">{{ (zbiorka.opis if zbiorka else request.form.get('opis','')) }}</textarea>
<div class="d-flex justify-content-between">
<small id="opisHelp" class="form-text text-muted">
Możesz używać Markdown (nagłówki, listy, linki). W edytorze włącz podgląd 👁️.
@@ -139,32 +127,44 @@
{% set i = loop.index0 %}
<tr>
<td>
<input type="text" class="form-control" name="item_nazwa[]" value="{{ it.nazwa }}" placeholder="np. Karma Brit 10kg" required>
<input type="text" class="form-control" name="item_nazwa[]"
value="{{ it.nazwa }}" placeholder="np. Karma Brit 10kg" required>
</td>
<td>
<input type="url" class="form-control" name="item_link[]" value="{{ it.link or '' }}" placeholder="https://...">
<input type="url" class="form-control" name="item_link[]"
value="{{ it.link or '' }}" placeholder="https://...">
</td>
<td>
<input type="text" inputmode="decimal" class="form-control text-end" name="item_cena[]" value="{{ (it.cena|round(2)) if it.cena is not none else '' }}" placeholder="0,00">
<input type="text" inputmode="decimal" class="form-control text-end"
name="item_cena[]"
value="{{ (it.cena|round(2)) if it.cena is not none else '' }}"
placeholder="0,00">
</td>
<td>
<div class="form-check form-switch">
<input class="form-check-input kupione-switch" type="checkbox" {% if it.kupione %}checked{% endif %}>
<input type="hidden" name="item_kupione_val_{{ i }}" value="{{ 1 if it.kupione else 0 }}">
<label class="form-check-label small">{{ 'Kupione' if it.kupione else 'Do kupienia' }}</label>
<input class="form-check-input kupione-switch" type="checkbox" {% if
it.kupione %}checked{% endif %}>
<input type="hidden" name="item_kupione_val_{{ i }}"
value="{{ 1 if it.kupione else 0 }}">
<label class="form-check-label small">{{ 'Kupione' if it.kupione else 'Do
kupienia' }}</label>
</div>
</td>
<td class="text-end">
<button type="button" class="btn btn-sm btn-outline-light remove-row" title="Usuń wiersz"></button>
<button type="button" class="btn btn-sm btn-outline-light remove-row"
title="Usuń wiersz"></button>
</td>
</tr>
{% endfor %}
{% else %}
<!-- pusty wiersz startowy -->
<tr>
<td><input type="text" class="form-control" name="item_nazwa[]" placeholder="np. Karma Brit 10kg" required></td>
<td><input type="url" class="form-control" name="item_link[]" placeholder="https://..."></td>
<td><input type="text" inputmode="decimal" class="form-control text-end" name="item_cena[]" placeholder="0,00"></td>
<td><input type="text" class="form-control" name="item_nazwa[]"
placeholder="np. Karma Brit 10kg" required></td>
<td><input type="url" class="form-control" name="item_link[]"
placeholder="https://..."></td>
<td><input type="text" inputmode="decimal" class="form-control text-end"
name="item_cena[]" placeholder="0,00"></td>
<td>
<div class="form-check form-switch">
<input class="form-check-input kupione-switch" type="checkbox">
@@ -173,7 +173,8 @@
</div>
</td>
<td class="text-end">
<button type="button" class="btn btn-sm btn-outline-light remove-row" title="Usuń wiersz"></button>
<button type="button" class="btn btn-sm btn-outline-light remove-row"
title="Usuń wiersz"></button>
</td>
</tr>
{% endif %}
@@ -183,7 +184,8 @@
<div class="d-flex gap-2">
<button type="button" class="btn btn-sm btn-outline-light" id="add-row">+ Dodaj pozycję</button>
<button type="button" class="btn btn-sm btn-outline-light" id="clear-empty">Usuń puste wiersze</button>
<button type="button" class="btn btn-sm btn-outline-light" id="clear-empty">Usuń puste
wiersze</button>
</div>
</div>
@@ -192,56 +194,68 @@
<!-- SEKCJA: Dane płatności -->
<div class="mb-4">
<h6 class="text-muted mb-2">Dane płatności</h6>
<div class="row g-3">
<div class="col-12">
<label for="numer_konta" class="form-label">Numer konta (IBAN)</label>
<div class="input-group">
<span class="input-group-text">PL</span>
<input
type="text"
class="form-control"
id="numer_konta"
name="numer_konta"
inputmode="numeric"
autocomplete="off"
placeholder="12 3456 7890 1234 5678 9012 3456"
required
aria-describedby="ibanHelp"
value="{% if zbiorka and zbiorka.numer_konta %}{{ zbiorka.numer_konta }}{% elif global_settings %}{{ global_settings.numer_konta }}{% else %}{{ request.form.get('numer_konta','') }}{% endif %}"
>
<!-- Przełączniki kanałów -->
<div class="col-12 col-md-6">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="uzyj_konta" name="uzyj_konta" {% if
zbiorka is none or zbiorka.uzyj_konta %}checked{% endif %}>
<label class="form-check-label" for="uzyj_konta">Przelew na konto</label>
</div>
<div id="ibanHelp" class="form-text">Wpisz ciąg cyfr; spacje dodadzą się automatycznie dla czytelności.</div>
</div>
<div class="col-12 col-md-6">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="uzyj_blik" name="uzyj_blik" {% if
zbiorka is none or zbiorka.uzyj_blik %}checked{% endif %}>
<label class="form-check-label" for="uzyj_blik">BLIK</label>
</div>
</div>
<br>
<div id="kanalyWarning" class="alert alert-warning d-none mt-2" role="alert">
Musi być włączony co najmniej jeden kanał wpłat (konto lub BLIK).
</div>
<!-- IBAN -->
<div class="col-12" id="pole_konto">
<label for="numer_konta" class="form-label">Numer konta (IBAN)</label>
<div class="input-group">
<span class="input-group-text">PL</span>
<input type="text" class="form-control" id="numer_konta" name="numer_konta"
inputmode="numeric" autocomplete="off"
placeholder="12 3456 7890 1234 5678 9012 3456" {% if zbiorka and not
zbiorka.uzyj_konta %}disabled{% endif %} {% if zbiorka is none or zbiorka.uzyj_konta
%}required{% endif %} aria-describedby="ibanHelp"
value="{% if zbiorka and zbiorka.numer_konta %}{{ zbiorka.numer_konta }}{% elif global_settings %}{{ global_settings.numer_konta }}{% else %}{{ request.form.get('numer_konta','') }}{% endif %}">
</div>
<div id="ibanHelp" class="form-text">Wpisz ciąg cyfr; spacje dodadzą się automatycznie dla
czytelności.</div>
</div>
<!-- BLIK -->
<div class="col-12 col-md-6" id="pole_blik">
<label for="numer_telefonu_blik" class="form-label">Numer telefonu BLIK</label>
<div class="input-group">
<span class="input-group-text">+48</span>
<input
type="tel"
class="form-control"
id="numer_telefonu_blik"
name="numer_telefonu_blik"
inputmode="tel"
pattern="[0-9 ]{9,13}"
placeholder="123 456 789"
required
<input type="tel" class="form-control" id="numer_telefonu_blik"
name="numer_telefonu_blik" inputmode="tel" pattern="[0-9 ]{9,13}"
placeholder="123 456 789" {% if zbiorka and not zbiorka.uzyj_blik %}disabled{% endif
%} {% if zbiorka is none or zbiorka.uzyj_blik %}required{% endif %}
aria-describedby="blikHelp"
value="{% if zbiorka and zbiorka.numer_telefonu_blik %}{{ zbiorka.numer_telefonu_blik }}{% elif global_settings %}{{ global_settings.numer_telefonu_blik }}{% else %}{{ request.form.get('numer_telefonu_blik','') }}{% endif %}"
>
value="{% if zbiorka and zbiorka.numer_telefonu_blik %}{{ zbiorka.numer_telefonu_blik }}{% elif global_settings %}{{ global_settings.numer_telefonu_blik }}{% else %}{{ request.form.get('numer_telefonu_blik','') }}{% endif %}">
</div>
<div id="blikHelp" class="form-text">Dziewięć cyfr telefonu powiązanego z BLIK. Spacje opcjonalne.</div>
<div id="blikHelp" class="form-text">Dziewięć cyfr telefonu powiązanego z BLIK. Spacje
opcjonalne.</div>
</div>
{% if is_edit %}
<div class="col-12 col-md-12 d-flex align-items-end">
<button type="button" class="btn btn-sm btn-outline-light" id="ustaw-globalne"
title="Wstaw wartości z ustawień globalnych"
{% if global_settings %}
title="Wstaw wartości z ustawień globalnych" {% if global_settings %}
data-iban="{{ global_settings.numer_konta }}"
data-blik="{{ global_settings.numer_telefonu_blik }}"
{% endif %}
>
data-blik="{{ global_settings.numer_telefonu_blik }}" {% endif %}>
Wstaw globalne ustawienia
</button>
</div>
@@ -258,7 +272,8 @@
<div id="celSyncBox" class="alert d-none py-2 px-3 mb-3" role="alert">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2">
<div id="celSyncMsg" class="small"></div>
<button type="button" id="btnApplyCelFromSum" class="btn btn-sm btn-outline-light d-none"></button>
<button type="button" id="btnApplyCelFromSum"
class="btn btn-sm btn-outline-light d-none"></button>
</div>
</div>
@@ -267,30 +282,17 @@
<label for="cel" class="form-label">Cel zbiórki</label>
<div class="input-group">
<span class="input-group-text">PLN</span>
<input
type="text"
inputmode="decimal"
class="form-control"
id="cel"
name="cel"
placeholder="0,00"
required
aria-describedby="celHelp"
value="{% if zbiorka and zbiorka.cel is not none %}{{ zbiorka.cel }}{% else %}{{ request.form.get('cel','') }}{% endif %}"
>
<input type="text" inputmode="decimal" class="form-control" id="cel" name="cel"
placeholder="0,00" required aria-describedby="celHelp"
value="{% if zbiorka and zbiorka.cel is not none %}{{ zbiorka.cel }}{% else %}{{ request.form.get('cel','') }}{% endif %}">
</div>
<div id="celHelp" class="form-text">Minimalnie 0,01 PLN. Można później edytować.</div>
</div>
<div class="col-12 col-md-12 d-flex align-items-end">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
id="ukryj_kwote"
name="ukryj_kwote"
{% if zbiorka %}{% if zbiorka.ukryj_kwote %}checked{% endif %}{% endif %}
>
<input class="form-check-input" type="checkbox" id="ukryj_kwote" name="ukryj_kwote" {%
if zbiorka %}{% if zbiorka.ukryj_kwote %}checked{% endif %}{% endif %}>
<label class="form-check-label" for="ukryj_kwote">Ukryj kwoty (cel i stan)</label>
</div>
</div>
@@ -299,43 +301,30 @@
<div class="row g-3 mt-2">
<div class="col-12 col-md-4">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
id="pokaz_postep_finanse"
name="pokaz_postep_finanse"
data-group="postepy"
{% if zbiorka %}{% if zbiorka.pokaz_postep_finanse %}checked{% endif %}{% else %}checked{% endif %}
>
<input class="form-check-input" type="checkbox" id="pokaz_postep_finanse"
name="pokaz_postep_finanse" data-group="postepy" {% if zbiorka %}{% if
zbiorka.pokaz_postep_finanse %}checked{% endif %}{% else %}checked{% endif %}>
<label class="form-check-label" for="pokaz_postep_finanse">Pokaż postęp: Finanse</label>
</div>
</div>
<div class="col-12 col-md-4">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
id="pokaz_postep_pozycje"
name="pokaz_postep_pozycje"
data-group="postepy"
{% if zbiorka %}{% if zbiorka.pokaz_postep_pozycje %}checked{% endif %}{% else %}checked{% endif %}
>
<label class="form-check-label" for="pokaz_postep_pozycje">Pokaż postęp: Zakupy (liczba)</label>
<input class="form-check-input" type="checkbox" id="pokaz_postep_pozycje"
name="pokaz_postep_pozycje" data-group="postepy" {% if zbiorka %}{% if
zbiorka.pokaz_postep_pozycje %}checked{% endif %}{% else %}checked{% endif %}>
<label class="form-check-label" for="pokaz_postep_pozycje">Pokaż postęp: Zakupy
(liczba)</label>
</div>
</div>
<div class="col-12 col-md-4">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
id="pokaz_postep_kwotowo"
name="pokaz_postep_kwotowo"
data-group="postepy"
{% if zbiorka %}{% if zbiorka.pokaz_postep_kwotowo %}checked{% endif %}{% else %}checked{% endif %}
>
<label class="form-check-label" for="pokaz_postep_kwotowo">Pokaż postęp: Zakupy (kwotowo)</label>
<input class="form-check-input" type="checkbox" id="pokaz_postep_kwotowo"
name="pokaz_postep_kwotowo" data-group="postepy" {% if zbiorka %}{% if
zbiorka.pokaz_postep_kwotowo %}checked{% endif %}{% else %}checked{% endif %}>
<label class="form-check-label" for="pokaz_postep_kwotowo">Pokaż postęp: Zakupy
(kwotowo)</label>
</div>
</div>
</div><br>
@@ -365,4 +354,5 @@
<script src="{{ url_for('static', filename='js/produkty_formularz.js') }}?v={{ APP_VERSION }}"></script>
<script src="{{ url_for('static', filename='js/kwoty_formularz.js') }}?v={{ APP_VERSION }}"></script>
<script src="{{ url_for('static', filename='js/przelaczniki_zabezpieczenie.js') }}?v={{ APP_VERSION }}"></script>
<script src="{{ url_for('static', filename='js/sposoby_wplat.js') }}?v={{ APP_VERSION }}"></script>
{% endblock %}

View File

@@ -24,7 +24,7 @@ zbiórki{% endif %}{% endblock %}
</div>
{% if zbiorki and zbiorki|length > 0 %}
<div class="row g-4">
<div class="row g-4 pb-5">
{% for z in zbiorki %}
{% set progress = (z.stan / z.cel * 100) if z.cel > 0 else 0 %}
{% set progress_clamped = 100 if progress > 100 else (0 if progress < 0 else progress) %} <div
@@ -88,7 +88,8 @@ zbiórki{% endif %}{% endblock %}
<!-- <a href="{{ url_for('zbiorka', zbiorka_id=z.id) }}" class="stretched-link"></a> -->
<div class="d-grid">
<a href="{{ url_for('zbiorka', zbiorka_id=z.id) }}" class="btn btn-outline-light btn-sm w-100 btn-opis">
<a href="{{ url_for('zbiorka', zbiorka_id=z.id) }}"
class="btn btn-outline-light btn-sm w-100 btn-opis">
Otwórz opis
</a>
</div>

View File

@@ -62,8 +62,8 @@
{% endif %}
<span class="fw-semibold">{{ it.nazwa }}</span>
{% if it.link %}
<a href="{{ it.link }}" target="_blank" rel="noopener"
class="btn btn-sm btn-outline-light ms-2">Sklep </a>
<a href="{{ it.link }}" target="_blank" rel="noopener" class="btn btn-sm btn-outline-light ms-2">Sklep
</a>
{% endif %}
</div>
<div>
@@ -165,6 +165,9 @@
</div>
{% set show_iban = zbiorka.uzyj_konta and zbiorka.numer_konta %}
{% set show_blik = zbiorka.uzyj_blik and zbiorka.numer_telefonu_blik %}
<!-- Kolumna prawa: płatności (sticky) -->
<div class="col-md-4">
<div class="card shadow-sm wspomoz-card sticky-md" style="top: var(--sticky-offset, 1rem);">
@@ -175,17 +178,15 @@
{% if has_cel and not zbiorka.ukryj_kwote %}
{% set brak = (zbiorka.cel - zbiorka.stan) %}
{% if brak > 0 %}
<span class="badge bg-warning text-dark border border-warning">
Brakuje: {{ brak|round(2) }} PLN
</span>
<span class="badge bg-warning text-dark border border-warning">Brakuje: {{ brak|round(2) }} PLN</span>
{% else %}
<span class="badge rounded-pill" style="background: var(--accent); color:#111;">
Zrealizowana
</span>
<span class="badge rounded-pill" style="background: var(--accent); color:#111;">Zrealizowana</span>
{% endif %}
{% endif %}
</div>
{% if show_iban or show_blik %}
{% if show_iban %}
<!-- Numer konta -->
<div>
<label for="ibanInput" class="form-label fw-semibold mb-1">Numer konta</label>
@@ -198,7 +199,9 @@
aria-label="Kopiuj numer konta">Kopiuj</button>
</div>
</div>
{% endif %}
{% if show_blik %}
<!-- Telefon BLIK -->
<div>
<label for="blikInput" class="form-label fw-semibold mb-1">Telefon BLIK</label>
@@ -211,6 +214,12 @@
aria-label="Kopiuj numer BLIK">Kopiuj</button>
</div>
</div>
{% endif %}
{% else %}
<div class="alert alert-secondary mb-0">
Kanały płatności są wyłączone dla tej zbiórki.
</div>
{% endif %}
{% if not zbiorka.ukryj_kwote %}
<ul class="list-group list-group-flush small">
@@ -243,7 +252,6 @@
</ul>
{% endif %}
{% if current_user.is_authenticated and current_user.czy_admin %}
<hr>
<div class="d-grid gap-2 mt-2">
@@ -271,8 +279,7 @@
<small class="text-muted">Łącznie pozycji: {{ aktywnosci|length }}</small>
{% endif %}
{% if current_user.is_authenticated and current_user.czy_admin %}
<a href="{{ url_for('transakcje_zbiorki', zbiorka_id=zbiorka.id) }}"
class="btn btn-sm btn-outline-light">
<a href="{{ url_for('transakcje_zbiorki', zbiorka_id=zbiorka.id) }}" class="btn btn-sm btn-outline-light">
Zarządzaj
</a>
{% endif %}
@@ -324,5 +331,4 @@
{{ super() }}
<script src="{{ url_for('static', filename='js/zbiorka.js') }}?v={{ APP_VERSION }}"></script>
<script src="{{ url_for('static', filename='js/progress.js') }}?v={{ APP_VERSION }}"></script>
<script src="{{ url_for('static', filename='js/progress.js') }}?v={{ APP_VERSION }}"></script>
{% endblock %}