diff --git a/src/wwwroot/js/site.js b/src/wwwroot/js/site.js
index 0937657..a4e7ae9 100644
--- a/src/wwwroot/js/site.js
+++ b/src/wwwroot/js/site.js
@@ -1,4 +1,91 @@
-// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
-// for details on configuring this project to bundle and minify static web assets.
+function createToastContainer() {
+ const container = document.createElement('div');
+ container.id = 'toastContainer';
+ container.className = 'toast-container position-fixed bottom-0 end-0 p-3';
+ document.body.appendChild(container);
+ return container;
+}
-// Write your JavaScript code.
+// Simple toast helper
+function showToast(message, type) {
+ const toastContainer = document.getElementById('toastContainer') || createToastContainer();
+ const toast = document.createElement('div');
+ toast.className = `toast align-items-center text-white bg-${type} border-0`;
+ toast.role = 'alert';
+ toast.innerHTML = `
+
+ `;
+ toastContainer.appendChild(toast);
+ const bsToast = new bootstrap.Toast(toast, { delay: 3000 });
+ bsToast.show();
+ toast.addEventListener('hidden.bs.toast', () => toast.remove());
+}
+
+function downloadBarcode(svgId, filename = "barcode.png") {
+ const svg = document.getElementById(svgId);
+ const serializer = new XMLSerializer();
+ const svgString = serializer.serializeToString(svg);
+
+ const canvas = document.createElement("canvas");
+ const ctx = canvas.getContext("2d");
+
+ // Optionally set canvas size
+ const bbox = svg.getBBox();
+ canvas.width = bbox.width + 20; // padding
+ canvas.height = bbox.height + 20;
+
+ const img = new Image();
+ const svgBlob = new Blob([svgString], { type: "image/svg+xml;charset=utf-8" });
+ const url = URL.createObjectURL(svgBlob);
+
+ img.onload = () => {
+ ctx.drawImage(img, 0, 0);
+ URL.revokeObjectURL(url);
+
+ const pngUrl = canvas.toDataURL("image/png");
+ const a = document.createElement("a");
+ a.href = pngUrl;
+ a.download = filename;
+ a.click();
+ };
+
+ img.src = url;
+}
+
+function printBarcode(svgId) {
+ const svg = document.getElementById(svgId);
+ if (!svg) return;
+
+ // Serialize the SVG
+ const serializer = new XMLSerializer();
+ const svgString = serializer.serializeToString(svg);
+
+ // Open a new window for printing
+ const printWindow = window.open('', '_blank');
+ printWindow.document.write(`
+
+
+ Print Barcode
+
+
+
+ ${svgString}
+
+
+ `);
+ printWindow.document.close();
+ printWindow.focus();
+ printWindow.print();
+ printWindow.close();
+}
+
+function idToEAN13(id) {
+ const padded = id.toString().padStart(12, "0"); // 12 digits
+ return padded;
+}