NexLab_System / templates /print_barcode.html
alisaleem97's picture
Upload folder using huggingface_hub
6ea020b verified
Raw History Blame Contribute Delete
5.1 kB
<!-- templates/print_barcode.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PrintBarcode - {{ patient.patient_id if patient else 'NexLab' }}</title>
<style>
@page {
size: {{ template_data.paper_width if template_data else '4in' }} {{ template_data.paper_height if template_data else '2in' }};
margin: 0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Arial', sans-serif;
background: #f3f4f6;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
}
.toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
background: white;
padding: 10px 20px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
z-index: 100;
}
.toolbar button {
padding: 8px 20px;
border: none;
border-radius: 6px;
font-weight: 600;
cursor: pointer;
font-size: 14px;
transition: all 0.2s;
}
.btn-print {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-print:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); }
.btn-close {
background: #f3f4f6;
color: #374151;
}
.btn-close:hover { background: #e5e7eb; }
.barcode-pages {
margin-top: 60px;
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}
.barcode-page {
background: white;
border: 1px solid #d1d5db;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
position: relative;
overflow: visible;
width: {{ template_data.paper_width if template_data else '4in' }};
height: {{ template_data.paper_height if template_data else '2in' }};
}
.barcode-page img {
width: 100%;
height: 100%;
display: block;
image-rendering: pixelated; /* crisp 1-bit barcode rendering */
}
.page-label {
font-size: 12px;
color: #6b7280;
margin-bottom: 4px;
font-weight: 500;
}
@media print {
html, body { background: white; padding: 0 !important; margin: 0 !important; width: 100%; height: 100%; }
.toolbar { display: none !important; }
.barcode-pages { margin: 0 !important; padding: 0 !important; gap: 0; display: block; }
.barcode-page {
border: none;
box-shadow: none;
page-break-after: always;
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
height: 100% !important;
position: relative;
left: 4mm;
top: -2mm;
}
.barcode-page:last-child {
page-break-after: auto;
}
.barcode-page img {
width: 100% !important;
height: 100% !important;
object-fit: fill;
}
.page-label { display: none !important; }
}
</style>
</head>
<body>
<!-- Toolbar (hidden during print) -->
<div class="toolbar">
<button class="btn-print" onclick="window.print()">🖨️ Print</button>
<button class="btn-close" onclick="window.close()">✕ Close</button>
</div>
<div class="barcode-pages">
{% if template_data and template_data.elements %}
<!-- Render one barcode page per sample type using server-generated PNG images -->
{% set page_index = namespace(val=0) %}
{% for sample_type, test_names in tests_by_sample_type.items() %}
<div class="page-label">{{ sample_type }} ({{ test_names | join(', ') }})</div>
<div class="barcode-page">
<img src="/api/print-barcode-image/{{ patient.patient_id }}?print_token={{ print_token }}&page={{ page_index.val }}"
alt="Barcode - {{ sample_type }}">
</div>
{% set page_index.val = page_index.val + 1 %}
{% endfor %}
{% else %}
<!-- Fallback: No saved design -->
<div style="padding: 40px; text-align: center; color: #ef4444;">
<h2>⚠️ No Barcode Design Found</h2>
<p>Please create and save a barcode design in the <a href="/print-barcode-designer">Barcode Designer</a> first.</p>
</div>
{% endif %}
</div>
</body>
</html>