feat(membership): PDF generation for declarations via WeasyPrint
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
- New route: /admin/membership/<id>/print → generates PDF - Professional A4 layout with chamber header, data sections, signatures - Button changed from window.print() to PDF link (opens in new tab) - No browser headers/footers — clean PDF output - Signature lines for applicant and reviewer Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9079610ea4
commit
86090a7d33
@ -386,6 +386,38 @@ def admin_membership():
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/membership/<int:app_id>/print')
|
||||
@login_required
|
||||
@role_required(SystemRole.OFFICE_MANAGER)
|
||||
def admin_membership_print(app_id):
|
||||
"""Generate PDF of membership declaration."""
|
||||
from flask import Response
|
||||
import weasyprint
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
application = db.query(MembershipApplication).get(app_id)
|
||||
if not application:
|
||||
flash('Nie znaleziono deklaracji.', 'error')
|
||||
return redirect(url_for('admin.admin_membership'))
|
||||
|
||||
html_content = render_template(
|
||||
'admin/membership_print.html',
|
||||
app=application,
|
||||
section_choices=MembershipApplication.SECTION_CHOICES,
|
||||
)
|
||||
pdf = weasyprint.HTML(string=html_content).write_pdf()
|
||||
return Response(
|
||||
pdf,
|
||||
mimetype='application/pdf',
|
||||
headers={
|
||||
'Content-Disposition': f'inline; filename=deklaracja-{app_id}.pdf'
|
||||
}
|
||||
)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/membership/<int:app_id>')
|
||||
@login_required
|
||||
@role_required(SystemRole.OFFICE_MANAGER)
|
||||
|
||||
@ -850,9 +850,9 @@
|
||||
<button class="btn-action btn-review" onclick="startReview()">
|
||||
Rozpocznij rozpatrywanie
|
||||
</button>
|
||||
<button class="btn-action" onclick="printDeclaration()" style="background: var(--primary); color: white; margin-top: 8px;">
|
||||
🖨 Drukuj deklarację
|
||||
</button>
|
||||
<a href="{{ url_for('admin.admin_membership_print', app_id=application.id) }}" target="_blank" class="btn-action" style="background: var(--primary); color: white; margin-top: 8px; text-decoration: none; text-align: center; display: block;">
|
||||
🖨 Drukuj deklarację (PDF)
|
||||
</a>
|
||||
</div>
|
||||
<p class="action-help">
|
||||
Zmieni status na "W trakcie rozpatrywania" i odblokuje opcje zatwierdzenia, odrzucenia lub prośby o poprawki.
|
||||
@ -898,9 +898,9 @@
|
||||
<button class="btn-action btn-reject" onclick="openRejectModal()">
|
||||
✗ Odrzuć
|
||||
</button>
|
||||
<button class="btn-action" onclick="printDeclaration()" style="background: var(--primary); color: white; margin-top: 8px;">
|
||||
🖨 Drukuj deklarację
|
||||
</button>
|
||||
<a href="{{ url_for('admin.admin_membership_print', app_id=application.id) }}" target="_blank" class="btn-action" style="background: var(--primary); color: white; margin-top: 8px; text-decoration: none; text-align: center; display: block;">
|
||||
🖨 Drukuj deklarację (PDF)
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-top: var(--spacing-lg);">
|
||||
@ -1376,15 +1376,40 @@ async function proposeChanges() {
|
||||
}
|
||||
|
||||
function printDeclaration() {
|
||||
// Hide browser headers/footers by temporarily clearing title
|
||||
var origTitle = document.title;
|
||||
document.title = ' ';
|
||||
// Also hide dev-notice via JS in case CSS didn't catch it
|
||||
var devNotice = document.getElementById('devNotice');
|
||||
if (devNotice) devNotice.style.display = 'none';
|
||||
window.print();
|
||||
// Restore after print dialog closes
|
||||
setTimeout(function() { document.title = origTitle; }, 1000);
|
||||
// Open a clean print window — no browser headers/footers
|
||||
var printHeader = document.querySelector('.print-header');
|
||||
var mainContent = document.querySelector('.main-content');
|
||||
if (!mainContent) return;
|
||||
|
||||
var win = window.open('', '_blank', 'width=800,height=600');
|
||||
win.document.write('<!DOCTYPE html><html><head><meta charset="utf-8">');
|
||||
win.document.write('<title> </title>'); // Empty title = no header
|
||||
win.document.write('<style>');
|
||||
win.document.write('body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 9pt; color: #000; margin: 0; padding: 15mm; }');
|
||||
win.document.write('.print-header { text-align: center; margin-bottom: 8pt; padding-bottom: 6pt; border-bottom: 2pt solid #2E4872; }');
|
||||
win.document.write('.print-header h2 { font-size: 13pt; color: #2E4872; margin: 0; }');
|
||||
win.document.write('.print-header p { font-size: 8.5pt; color: #444; margin: 2pt 0 0; }');
|
||||
win.document.write('.info-section { break-inside: avoid; margin: 4pt 0; border: 0.5pt solid #bbb; padding: 4pt 8pt; }');
|
||||
win.document.write('.info-section h2 { font-size: 10pt; color: #2E4872; border-bottom: 0.5pt solid #2E4872; padding-bottom: 2pt; margin: 0 0 4pt; }');
|
||||
win.document.write('.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2pt 16pt; }');
|
||||
win.document.write('.info-row { padding: 1pt 0; font-size: 8.5pt; line-height: 1.3; }');
|
||||
win.document.write('.info-label { font-weight: bold; font-size: 7.5pt; color: #666; display: block; }');
|
||||
win.document.write('.info-value { font-size: 9pt; }');
|
||||
win.document.write('.section-tag { display: inline-block; background: #e8f0fe; color: #1a56db; padding: 1pt 6pt; border-radius: 3pt; font-size: 8pt; margin: 1pt 2pt; }');
|
||||
win.document.write('.consent-item { font-size: 8pt; padding: 1pt 0; }');
|
||||
win.document.write('.consent-yes { color: #16a34a; } .consent-no { color: #dc2626; }');
|
||||
win.document.write('h2, h3, h4 { margin: 0; }');
|
||||
win.document.write('a { color: #000; text-decoration: none; }');
|
||||
win.document.write('.registry-actions, .action-buttons, .btn-action, .alert, .status-badge, .workflow-timeline { display: none; }');
|
||||
win.document.write('@page { margin: 10mm; }');
|
||||
win.document.write('@media print { body { padding: 0; } }');
|
||||
win.document.write('</style></head><body>');
|
||||
if (printHeader) win.document.write(printHeader.outerHTML.replace('display: none', 'display: block'));
|
||||
win.document.write(mainContent.innerHTML);
|
||||
win.document.write('</body></html>');
|
||||
win.document.close();
|
||||
win.focus();
|
||||
setTimeout(function() { win.print(); }, 300);
|
||||
}
|
||||
|
||||
function openApproveModal() {
|
||||
|
||||
313
templates/admin/membership_print.html
Normal file
313
templates/admin/membership_print.html
Normal file
@ -0,0 +1,313 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 18mm 15mm 15mm 15mm;
|
||||
@top-center {
|
||||
content: "";
|
||||
}
|
||||
@bottom-center {
|
||||
content: "";
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 9pt;
|
||||
color: #1a1a1a;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 12pt;
|
||||
padding-bottom: 8pt;
|
||||
border-bottom: 2pt solid #2E4872;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 15pt;
|
||||
color: #2E4872;
|
||||
margin: 0 0 2pt 0;
|
||||
letter-spacing: 0.5pt;
|
||||
}
|
||||
.header .subtitle {
|
||||
font-size: 10pt;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
}
|
||||
.header .meta {
|
||||
font-size: 8pt;
|
||||
color: #666;
|
||||
margin: 3pt 0 0;
|
||||
}
|
||||
|
||||
/* Section */
|
||||
.section {
|
||||
margin-bottom: 8pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 10pt;
|
||||
font-weight: 600;
|
||||
color: #2E4872;
|
||||
border-bottom: 1pt solid #2E4872;
|
||||
padding-bottom: 2pt;
|
||||
margin: 0 0 4pt 0;
|
||||
}
|
||||
|
||||
/* Data grid */
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 3pt 20pt;
|
||||
}
|
||||
.grid-3 {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
.field {
|
||||
margin-bottom: 2pt;
|
||||
}
|
||||
.field-label {
|
||||
font-size: 7pt;
|
||||
color: #888;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3pt;
|
||||
margin: 0;
|
||||
}
|
||||
.field-value {
|
||||
font-size: 9pt;
|
||||
font-weight: 500;
|
||||
color: #1a1a1a;
|
||||
margin: 0;
|
||||
}
|
||||
.field-value.large {
|
||||
font-size: 10pt;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Tags */
|
||||
.tag {
|
||||
display: inline-block;
|
||||
background: #e8f0fe;
|
||||
color: #1a56db;
|
||||
padding: 1pt 8pt;
|
||||
border-radius: 3pt;
|
||||
font-size: 8pt;
|
||||
margin: 1pt 2pt;
|
||||
}
|
||||
|
||||
/* Description */
|
||||
.description {
|
||||
font-size: 8.5pt;
|
||||
line-height: 1.5;
|
||||
color: #333;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
/* Consent */
|
||||
.consent-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4pt;
|
||||
font-size: 8pt;
|
||||
padding: 1pt 0;
|
||||
}
|
||||
.check-yes { color: #16a34a; font-weight: bold; }
|
||||
.check-no { color: #dc2626; font-weight: bold; }
|
||||
|
||||
/* Declaration box */
|
||||
.declaration-box {
|
||||
border: 1pt solid #2E4872;
|
||||
padding: 6pt 10pt;
|
||||
margin-top: 6pt;
|
||||
background: #f8fafc;
|
||||
font-size: 8pt;
|
||||
}
|
||||
.declaration-box .label {
|
||||
font-weight: 600;
|
||||
color: #2E4872;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.footer {
|
||||
margin-top: 20pt;
|
||||
padding-top: 8pt;
|
||||
border-top: 0.5pt solid #ccc;
|
||||
font-size: 7pt;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Signature line */
|
||||
.signature-area {
|
||||
margin-top: 30pt;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 40pt;
|
||||
}
|
||||
.signature-line {
|
||||
border-top: 0.5pt solid #666;
|
||||
padding-top: 3pt;
|
||||
text-align: center;
|
||||
font-size: 7pt;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="header">
|
||||
<h1>Izba Gospodarcza Norda Biznes</h1>
|
||||
<p class="subtitle">Deklaracja Przystapienia do Izby nr {{ app.id }}</p>
|
||||
<p class="meta">
|
||||
{{ app.company_name }}
|
||||
| Data zlozenia: {{ app.submitted_at.strftime('%d.%m.%Y, %H:%M') if app.submitted_at else 'brak' }}
|
||||
| Status: {{ app.status_label }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">Dane firmy</h2>
|
||||
<div class="grid">
|
||||
<div class="field">
|
||||
<p class="field-label">Nazwa firmy</p>
|
||||
<p class="field-value large">{{ app.company_name }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">NIP</p>
|
||||
<p class="field-value large">{{ app.nip or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">KRS</p>
|
||||
<p class="field-value">{{ app.krs or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">REGON</p>
|
||||
<p class="field-value">{{ app.regon or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Forma prawna</p>
|
||||
<p class="field-value">{{ app.legal_form or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Zrodlo danych</p>
|
||||
<p class="field-value">{{ app.registry_source or '---' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">Adres siedziby</h2>
|
||||
<div class="grid">
|
||||
<div class="field">
|
||||
<p class="field-label">Ulica</p>
|
||||
<p class="field-value">{{ app.address_street or '---' }} {{ app.address_building or '' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Kod pocztowy i miejscowosc</p>
|
||||
<p class="field-value">{{ app.address_postal or '' }} {{ app.address_city or '---' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">Dane kontaktowe</h2>
|
||||
<div class="grid">
|
||||
<div class="field">
|
||||
<p class="field-label">Email</p>
|
||||
<p class="field-value">{{ app.contact_email or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Telefon</p>
|
||||
<p class="field-value">{{ app.contact_phone or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Strona WWW</p>
|
||||
<p class="field-value">{{ app.contact_website or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Nazwa skrocona</p>
|
||||
<p class="field-value">{{ app.short_name or '---' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">Delegaci do Walnego Zgromadzenia</h2>
|
||||
<div class="grid grid-3">
|
||||
<div class="field">
|
||||
<p class="field-label">Delegat 1 (glowny)</p>
|
||||
<p class="field-value">{{ app.delegate_1 or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Delegat 2</p>
|
||||
<p class="field-value">{{ app.delegate_2 or '---' }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="field-label">Delegat 3</p>
|
||||
<p class="field-value">{{ app.delegate_3 or '---' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if app.sections_labels %}
|
||||
<div class="section">
|
||||
<h2 class="section-title">Sekcje tematyczne</h2>
|
||||
{% for label in app.sections_labels %}
|
||||
<span class="tag">{{ label }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if app.business_description %}
|
||||
<div class="section">
|
||||
<h2 class="section-title">Opis dzialalnosci</h2>
|
||||
<p class="description">{{ app.business_description }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">Zgody i oswiadczenia</h2>
|
||||
<div class="consent-row">
|
||||
<span class="{{ 'check-yes' if app.consent_email else 'check-no' }}">{{ '✓' if app.consent_email else '✗' }}</span>
|
||||
Zgoda na komunikacje e-mail
|
||||
</div>
|
||||
<div class="consent-row">
|
||||
<span class="{{ 'check-yes' if app.consent_sms else 'check-no' }}">{{ '✓' if app.consent_sms else '✗' }}</span>
|
||||
Zgoda na komunikacje SMS
|
||||
</div>
|
||||
|
||||
{% if app.declaration_accepted %}
|
||||
<div class="declaration-box">
|
||||
<span class="label">Deklaracja przystapiena:</span> Zaakceptowana
|
||||
{% if app.declaration_accepted_at %}
|
||||
| Data: {{ app.declaration_accepted_at.strftime('%d.%m.%Y, %H:%M') }}
|
||||
{% endif %}
|
||||
{% if app.declaration_ip %}
|
||||
| IP: {{ app.declaration_ip }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="signature-area">
|
||||
<div>
|
||||
<div class="signature-line">Podpis wnioskodawcy</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="signature-line">Podpis osoby przyjmujacej</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Wygenerowano z portalu nordabiznes.pl | Izba Gospodarcza Norda Biznes, Wejherowo
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user