print.html

47 Zeilen · 3,1 KB · HTML
Rohdatei
{% extends 'base.html' %}
{% block title %}Etiketten drucken{% endblock %}
{% block head %}
{% set w, h = fmt.w, fmt.h %}
{% set tall = h > w %}
{% set qr = (w - 6) if tall else (h - 4) %}
<style>
  @page { {% if fmt.sheet %}size: A4; margin: 0;{% else %}size: {{ w }}mm {{ h }}mm; margin: 0;{% endif %} }
  .sheet { {% if fmt.sheet %}width: 210mm; padding-top: {{ fmt.top }}mm; padding-left: {{ fmt.left }}mm; display: grid;
           grid-template-columns: repeat({{ fmt.cols }}, {{ w }}mm); grid-auto-rows: {{ h }}mm;{% else %}display: flex; flex-wrap: wrap; gap: 4mm;{% endif %} }
  .qlabel { width: {{ w }}mm; height: {{ h }}mm; padding: 2mm; box-sizing: border-box; display: flex; gap: 2.2mm; overflow: hidden;
            font-family: Arial, Helvetica, sans-serif; color: #000; background: #fff; {% if tall %}flex-direction: column; align-items: center; text-align: center;{% else %}align-items: center;{% endif %} }
  .qlabel svg { width: {{ qr }}mm; height: {{ qr }}mm; flex: none; }
  .qlabel .t { overflow-wrap: anywhere; hyphens: auto; font-weight: 700; font-size: {{ '13pt' if tall else ('8.5pt' if h < 28 else '9.5pt') }}; line-height: 1.15; margin-bottom: .6mm;
               display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .qlabel .l { font-size: {{ '9pt' if tall else ('6.5pt' if h < 28 else '7.2pt') }}; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qlabel .c { font-size: 6pt; color: #444; margin-top: .6mm; }
  .qlabel .txt { min-width: 0; {% if tall %}width: 100%;{% endif %} }
  .skip { visibility: hidden; }
  @media screen { .qlabel { outline: 1px dashed #b5c0c2; } .sheet { background: #fff; padding: 4mm; width: fit-content; box-shadow: var(--shadow); } }
  @media print {
    body { margin: 0; }
    main.content { padding: 0 !important; }
    {% if not fmt.sheet %}.sheet { display: block; } .qlabel { page-break-after: always; break-after: page; }{% endif %}
    {% if fmt.sheet %}.sheet { padding: {{ fmt.top }}mm 0 0 {{ fmt.left }}mm; box-shadow: none; }{% endif %}
  }
</style>
{% endblock %}
{% block content %}
<div class="page-head no-print"><div><div class="crumb"><a href="{{ back }}">QR-Etiketten</a></div><h1>{{ labels|length }} Etikett{{ 'en' if labels|length != 1 }}</h1>
  <small>{{ fmt.w }} × {{ fmt.h }} mm · Im Druckdialog: Ränder „keine“, Skalierung 100 %{% if not fmt.sheet %}, Papierformat = Etikettengröße{% endif %}</small></div>
  <div class="actions"><button class="primary" type="button" onclick="window.print()">Drucken</button></div></div>
{% if not labels %}<div class="callout no-print">Nichts ausgewählt. <a href="{{ back }}">Zurück zur Auswahl</a></div>{% endif %}
<div class="sheet">
  {% for i in range(skip) %}<div class="qlabel skip"></div>{% endfor %}
  {% for l in labels %}
  <div class="qlabel">
    {{ l.qr }}
    <div class="txt">
      <div class="t">{{ l.title }}</div>
      {% for line in l.lines[:3] %}<div class="l">{{ line }}</div>{% endfor %}
      <div class="c">{{ praxis_name|truncate(30, True, '') }} · {{ l.code }}</div>
    </div>
  </div>
  {% endfor %}
</div>
{% endblock %}