Jul 8 - Implement Regenerate token and buik print QR codes

This commit is contained in:
2026-07-08 13:27:49 -04:00
parent ff3c76c0d8
commit 39feaa4704
5 changed files with 145 additions and 4 deletions
+6
View File
@@ -8,6 +8,12 @@
<h2><i class="bi bi-building"></i> Facilities</h2>
</div>
<div class="col-md-6 text-end">
{% if current_user.role != 'customer' %}
<a href="{{ url_for('facilities.facility_qr_print_all') }}"
class="btn btn-outline-dark" title="Printable sheet of every facility's QR code">
<i class="bi bi-qr-code"></i> Print All QR Codes
</a>
{% endif %}
{% if current_user.role in ['admin', 'director'] %}
<a href="{{ url_for('facilities.create_facility') }}" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> Add Facility
+16 -3
View File
@@ -16,9 +16,22 @@
class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left"></i> Back to Facility
</a>
<button onclick="window.print()" class="btn btn-primary btn-sm">
<i class="bi bi-printer"></i> Print
</button>
<div class="d-flex gap-2">
{% if current_user.role in ['admin', 'director'] %}
<form method="POST"
action="{{ url_for('facilities.facility_qr_regenerate', facility_id=facility.id) }}"
onsubmit="return confirm('Regenerate this QR code? Any codes already printed and posted for {{ facility.name }} will STOP working and must be reprinted.');">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-outline-danger btn-sm"
title="Invalidate the current code and generate a new one">
<i class="bi bi-arrow-repeat"></i> Regenerate
</button>
</form>
{% endif %}
<button onclick="window.print()" class="btn btn-primary btn-sm">
<i class="bi bi-printer"></i> Print
</button>
</div>
</div>
<div class="card shadow-sm qr-card">
@@ -0,0 +1,62 @@
{% extends "base.html" %}
{% block title %}Print QR Codes{% endblock %}
{% block content %}
<style>
.qr-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.qr-item { break-inside: avoid; page-break-inside: avoid; text-align: center; }
.qr-item img { width: 220px; height: 220px; max-width: 100%; }
@media print {
.no-print { display: none !important; }
.navbar, nav, footer { display: none !important; }
.qr-item { border: 1px dashed #bbb !important; }
/* Two per row, comfortable for cutting/posting */
.qr-grid { gap: 8px; }
}
</style>
<div class="d-flex justify-content-between align-items-center mb-3 no-print">
<div>
<h2 class="h4 mb-0"><i class="bi bi-qr-code"></i> Facility QR Codes</h2>
<div class="text-muted small">
{% if selected_contract %}Contract: {{ selected_contract.name }} — {% endif %}
{{ facilities|length }} facilit{{ 'y' if facilities|length == 1 else 'ies' }}
</div>
</div>
<div class="d-flex gap-2">
<a href="{{ url_for('facilities.list_facilities') }}" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left"></i> Back
</a>
<button onclick="window.print()" class="btn btn-primary btn-sm">
<i class="bi bi-printer"></i> Print All
</button>
</div>
</div>
{% if facilities %}
<div class="qr-grid">
{% for f in facilities %}
<div class="qr-item card shadow-sm p-3">
<div class="text-muted text-uppercase" style="font-size:.7rem;letter-spacing:.08em;">
Scan for Facility Status
</div>
<div class="fw-bold">{{ f.name }}</div>
{% if f.project %}
<div class="text-muted small mb-1">{{ f.project.name }}</div>
{% endif %}
<div>
<img src="{{ url_for('facilities.facility_qr_png', facility_id=f.id) }}"
alt="QR code for {{ f.name }}" loading="lazy">
</div>
<div class="small">Report a problem &amp; view recent quality</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="alert alert-info">No active facilities to print QR codes for.</div>
{% endif %}
<p class="text-muted small mt-3 no-print">
Tip: print, cut along the dashed lines, and post each code at its facility.
</p>
{% endblock %}