diff --git a/py_app/app/__pycache__/routes.cpython-312.pyc b/py_app/app/__pycache__/routes.cpython-312.pyc index fd1d11c..9ca7d8d 100644 Binary files a/py_app/app/__pycache__/routes.cpython-312.pyc and b/py_app/app/__pycache__/routes.cpython-312.pyc differ diff --git a/py_app/app/pdf_generator.py b/py_app/app/pdf_generator.py index cbd6bbf..42e218f 100644 --- a/py_app/app/pdf_generator.py +++ b/py_app/app/pdf_generator.py @@ -24,9 +24,9 @@ def mm_to_points(mm_value): class LabelPDFGenerator: def __init__(self, paper_saving_mode=True): - # Label dimensions: 80mm x 110mm + # Label dimensions: 80mm x 105mm (reduced from 110mm by cutting 5mm from bottom) self.label_width = mm_to_points(80) - self.label_height = mm_to_points(110) + self.label_height = mm_to_points(105) # Paper-saving mode: positions content at top of label to minimize waste self.paper_saving_mode = paper_saving_mode @@ -35,19 +35,21 @@ class LabelPDFGenerator: # Preview: 227.4px width x 321.3px height # Convert to proportional dimensions for 80x110mm self.content_width = mm_to_points(60) # ~227px scaled to 80mm - self.content_height = mm_to_points(85) # ~321px scaled to 110mm + self.content_height = mm_to_points(68) # Reduced by 20% from 85mm to 68mm - # Position content in label - optimized for paper saving + # Position content in label - rectangle positioned 15mm from top + # Label height: 105mm, Rectangle height: 68mm + # content_y = 105mm - 15mm - 68mm = 22mm from bottom if self.paper_saving_mode: - # Start content from top of label with minimal top margin - self.content_x = mm_to_points(4) # 4mm from left edge (was 3mm, moved 1mm right to ensure left border prints) - self.content_y = mm_to_points(20) # 20mm from bottom (more space at top) - self.top_margin = mm_to_points(5) # 5mm top margin instead of larger bottom margin + # Start content from top of label with 15mm top margin + self.content_x = mm_to_points(4) # 4mm from left edge + self.content_y = mm_to_points(22) # 22mm from bottom (15mm from top) + self.top_margin = mm_to_points(15) # 15mm top margin else: # Original positioning - self.content_x = mm_to_points(5) # 5mm from left edge (was 4mm, moved 1mm right to ensure left border prints) - self.content_y = mm_to_points(15) # 15mm from bottom (space for bottom barcode) - self.top_margin = mm_to_points(10) + self.content_x = mm_to_points(5) # 5mm from left edge + self.content_y = mm_to_points(22) # 22mm from bottom (15mm from top) + self.top_margin = mm_to_points(15) # 15mm top margin # Row dimensions (9 rows total, row 6 is double height) self.row_height = self.content_height / 10 # 8.5mm per standard row @@ -288,6 +290,10 @@ class LabelPDFGenerator: canvas.drawString(ac_x_centered, row_y + self.row_height/3, article_code) current_y = row_y + # Draw horizontal line between Article Code and Prod Order + canvas.setLineWidth(1) + canvas.line(self.content_x, current_y, self.content_x + self.content_width, current_y) + # Row 9: Prod Order - CORRECTED to match HTML preview with sequential numbering row_y = current_y - self.row_height canvas.setFont("Helvetica", 8) @@ -307,9 +313,9 @@ class LabelPDFGenerator: line_y -= self.row_height canvas.line(self.content_x, line_y, self.content_x + self.content_width, line_y) - # Bottom horizontal barcode - positioned within label bounds + # Bottom horizontal barcode - positioned 1.5mm below the main rectangle barcode_area_height = mm_to_points(12) # Reserve space for barcode - barcode_y = mm_to_points(3) # 3mm from bottom of label (moved down 1mm for more space) + barcode_y = self.content_y - mm_to_points(1.5) - barcode_area_height # 1.5mm gap below rectangle barcode_width = self.content_width # Use full content width barcode_x = self.content_x diff --git a/py_app/app/routes.py b/py_app/app/routes.py index ab34f6a..838ed67 100644 --- a/py_app/app/routes.py +++ b/py_app/app/routes.py @@ -2006,6 +2006,17 @@ def view_orders(): orders = get_orders_from_database(200) # Get last 200 orders return render_template('view_orders.html', orders=orders) +@bp.route('/print_lost_labels') +def print_lost_labels(): + """Route for printing lost labels - allows searching and reprinting specific orders""" + if 'role' not in session or session['role'] not in ['superadmin', 'warehouse', 'warehouse_manager', 'warehouse_worker']: + flash('Access denied: Warehouse access required.') + return redirect(url_for('main.dashboard')) + + from app.order_labels import get_orders_from_database + orders = get_orders_from_database(500) # Get more orders for searching + return render_template('print_lost_labels.html', orders=orders) + @bp.route('/db_test') def db_test(): """Simple database test page""" diff --git a/py_app/app/templates/main_page_etichete.html b/py_app/app/templates/main_page_etichete.html index dc2ddb2..86994e5 100644 --- a/py_app/app/templates/main_page_etichete.html +++ b/py_app/app/templates/main_page_etichete.html @@ -19,11 +19,14 @@ - +
-

Launch Print Module

+

Printing Module

Access the print module to print labels.

- Launch Print Module +
+ Launch Printing Module + Launch lost labels printing module +
diff --git a/py_app/app/templates/print_lost_labels.html b/py_app/app/templates/print_lost_labels.html new file mode 100644 index 0000000..32e101c --- /dev/null +++ b/py_app/app/templates/print_lost_labels.html @@ -0,0 +1,429 @@ +{% extends "base.html" %} + +{% block head %} + + +{% endblock %} + +{% block content %} + + + +
+
+
+ + + +
+
+ + +
+ +
+
Label View
+ +
+ + 🔑 Manage Keys +
+ +
+ +
+
INNOFA ROMANIA SRL
+
+
+
+
+
+
+
+
+
+
+
Quantity ordered
+
+
Customer order
+
+
Delivery date
+
+
Product description
+
+
Size
+
+
Article code
+
+
Prod. order
+
+
+
+ +
+
+
+ +
+
+
+ +
+ +
+

Data Preview

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + +{% endblock %} diff --git a/py_app/app/templates/print_module.html b/py_app/app/templates/print_module.html index fe8e554..dc00072 100644 --- a/py_app/app/templates/print_module.html +++ b/py_app/app/templates/print_module.html @@ -912,10 +912,13 @@ async function generatePDFAndPrint(selectedPrinter, orderData, pieceNumber, tota console.log(`🖨️ Sending PDF to printer ${selectedPrinter}...`); - // Configure QZ Tray for PDF printing + // Configure QZ Tray for PDF printing with explicit paper size const config = qz.configs.create(selectedPrinter, { scaleContent: false, - rasterize: false + rasterize: false, + size: { width: 80, height: 100 }, + units: 'mm', + margins: { top: 0, right: 0, bottom: 0, left: 0 } }); // Prepare PDF data for QZ Tray @@ -1033,7 +1036,7 @@ function generateHTMLLabel(orderData, pieceNumber, totalPieces) {