From d5b043c7620f91e9c5bb90d6a5c331b74a53865b Mon Sep 17 00:00:00 2001 From: Quality App Developer Date: Sun, 15 Feb 2026 12:05:20 +0200 Subject: [PATCH] Fix Docker build and add labels test data - Fix Docker build issues: * Add missing system dependencies (build-essential, python3-dev, libpq-dev) * Fix requirements.txt formatting (separate Flask-Session and openpyxl) * Update openpyxl version to 3.1.5 (3.10.0 was invalid) - Set proper folder permissions for Docker write access (app/ and data/) - Add comprehensive test data for labels module: * 8 sample orders (TEST-ORD-001 through TEST-ORD-008) * Mix of printed/unprinted orders for testing * Various product types, customers, and delivery dates * Ready for QZ Tray printing functionality testing - Include test data generation scripts for future use - Application now fully containerized and ready for labels/printing testing --- Dockerfile | 3 + app/__init__.py | 0 app/access_control.py | 0 app/auth.py | 0 app/config.py | 0 app/database.py | 0 .../add_warehouse_roles_and_bindings.sql | 0 app/db_schema_verifier.py | 0 app/models/__init__.py | 0 app/modules/labels/__init__.py | 0 app/modules/labels/import_labels.py | 0 app/modules/labels/pdf_generator.py | 0 app/modules/labels/print_module.py | 0 app/modules/labels/routes.py | 0 app/modules/quality/__init__.py | 0 app/modules/quality/quality.py | 0 app/modules/quality/routes.py | 0 app/modules/settings/__init__.py | 0 app/modules/settings/logs.py | 0 app/modules/settings/routes.py | 0 app/modules/settings/stats.py | 0 .../settings/warehouse_worker_management.py | 0 app/modules/warehouse/__init__.py | 0 app/modules/warehouse/boxes.py | 0 app/modules/warehouse/boxes_routes.py | 0 app/modules/warehouse/routes.py | 0 app/modules/warehouse/warehouse.py | 0 app/modules/warehouse/warehouse_orders.py | 0 app/routes.py | 0 app/scheduler.py | 0 app/static/css/base.css | 0 app/static/css/database_management.css | 0 app/static/css/fg_scan.css | 0 app/static/css/login.css | 0 app/static/css/print_module.css | 0 app/static/css/scan.css | 0 app/static/css/theme.css | 0 app/static/js/base.js | 0 app/static/js/qz-printer.js | 0 app/static/js/qz-tray.js | 0 app/static/js/theme.js | 0 app/static/style.css | 0 app/templates/base.html | 0 app/templates/base_print.html | 0 app/templates/dashboard.html | 0 app/templates/errors/403.html | 0 app/templates/errors/404.html | 0 app/templates/errors/500.html | 0 app/templates/login.html | 0 .../modules/labels/import_labels.html | 0 app/templates/modules/labels/index.html | 0 .../modules/labels/print_labels.html | 0 .../modules/labels/print_lost_labels.html | 0 .../modules/labels/print_lost_labels_new.html | 0 .../modules/labels/print_module.html | 0 app/templates/modules/quality/fg_reports.html | 0 app/templates/modules/quality/fg_scan.html | 0 app/templates/modules/quality/index.html | 0 .../modules/quality/inspections.html | 0 app/templates/modules/quality/reports.html | 0 app/templates/modules/settings/app_keys.html | 0 app/templates/modules/settings/database.html | 0 .../modules/settings/database_management.html | 0 app/templates/modules/settings/general.html | 0 app/templates/modules/settings/index.html | 0 .../modules/settings/logs_explorer.html | 0 .../modules/settings/search_logs.html | 0 app/templates/modules/settings/user_form.html | 0 app/templates/modules/settings/users.html | 0 app/templates/modules/settings/view_log.html | 0 app/templates/modules/warehouse/boxes.html | 0 app/templates/modules/warehouse/index.html | 0 .../modules/warehouse/inventory.html | 0 .../modules/warehouse/locations.html | 0 app/templates/modules/warehouse/reports.html | 0 .../warehouse/set_boxes_locations.html | 0 .../warehouse/set_orders_on_boxes.html | 0 .../modules/warehouse/test_barcode.html | 0 app/templates/profile.html | 0 docker-compose.yml | 2 +- documentation/add_labels_test_data.py | 260 ++++++++++++++++++ documentation/add_labels_test_data_direct.py | 149 ++++++++++ requirements.txt | 3 +- 83 files changed, 415 insertions(+), 2 deletions(-) mode change 100644 => 100755 app/__init__.py mode change 100644 => 100755 app/access_control.py mode change 100644 => 100755 app/auth.py mode change 100644 => 100755 app/config.py mode change 100644 => 100755 app/database.py mode change 100644 => 100755 app/db_migrations/add_warehouse_roles_and_bindings.sql mode change 100644 => 100755 app/db_schema_verifier.py mode change 100644 => 100755 app/models/__init__.py mode change 100644 => 100755 app/modules/labels/__init__.py mode change 100644 => 100755 app/modules/labels/import_labels.py mode change 100644 => 100755 app/modules/labels/pdf_generator.py mode change 100644 => 100755 app/modules/labels/print_module.py mode change 100644 => 100755 app/modules/labels/routes.py mode change 100644 => 100755 app/modules/quality/__init__.py mode change 100644 => 100755 app/modules/quality/quality.py mode change 100644 => 100755 app/modules/quality/routes.py mode change 100644 => 100755 app/modules/settings/__init__.py mode change 100644 => 100755 app/modules/settings/logs.py mode change 100644 => 100755 app/modules/settings/routes.py mode change 100644 => 100755 app/modules/settings/stats.py mode change 100644 => 100755 app/modules/settings/warehouse_worker_management.py mode change 100644 => 100755 app/modules/warehouse/__init__.py mode change 100644 => 100755 app/modules/warehouse/boxes.py mode change 100644 => 100755 app/modules/warehouse/boxes_routes.py mode change 100644 => 100755 app/modules/warehouse/routes.py mode change 100644 => 100755 app/modules/warehouse/warehouse.py mode change 100644 => 100755 app/modules/warehouse/warehouse_orders.py mode change 100644 => 100755 app/routes.py mode change 100644 => 100755 app/scheduler.py mode change 100644 => 100755 app/static/css/base.css mode change 100644 => 100755 app/static/css/database_management.css mode change 100644 => 100755 app/static/css/fg_scan.css mode change 100644 => 100755 app/static/css/login.css mode change 100644 => 100755 app/static/css/print_module.css mode change 100644 => 100755 app/static/css/scan.css mode change 100644 => 100755 app/static/css/theme.css mode change 100644 => 100755 app/static/js/base.js mode change 100644 => 100755 app/static/js/qz-printer.js mode change 100644 => 100755 app/static/js/qz-tray.js mode change 100644 => 100755 app/static/js/theme.js mode change 100644 => 100755 app/static/style.css mode change 100644 => 100755 app/templates/base.html mode change 100644 => 100755 app/templates/base_print.html mode change 100644 => 100755 app/templates/dashboard.html mode change 100644 => 100755 app/templates/errors/403.html mode change 100644 => 100755 app/templates/errors/404.html mode change 100644 => 100755 app/templates/errors/500.html mode change 100644 => 100755 app/templates/login.html mode change 100644 => 100755 app/templates/modules/labels/import_labels.html mode change 100644 => 100755 app/templates/modules/labels/index.html mode change 100644 => 100755 app/templates/modules/labels/print_labels.html mode change 100644 => 100755 app/templates/modules/labels/print_lost_labels.html mode change 100644 => 100755 app/templates/modules/labels/print_lost_labels_new.html mode change 100644 => 100755 app/templates/modules/labels/print_module.html mode change 100644 => 100755 app/templates/modules/quality/fg_reports.html mode change 100644 => 100755 app/templates/modules/quality/fg_scan.html mode change 100644 => 100755 app/templates/modules/quality/index.html mode change 100644 => 100755 app/templates/modules/quality/inspections.html mode change 100644 => 100755 app/templates/modules/quality/reports.html mode change 100644 => 100755 app/templates/modules/settings/app_keys.html mode change 100644 => 100755 app/templates/modules/settings/database.html mode change 100644 => 100755 app/templates/modules/settings/database_management.html mode change 100644 => 100755 app/templates/modules/settings/general.html mode change 100644 => 100755 app/templates/modules/settings/index.html mode change 100644 => 100755 app/templates/modules/settings/logs_explorer.html mode change 100644 => 100755 app/templates/modules/settings/search_logs.html mode change 100644 => 100755 app/templates/modules/settings/user_form.html mode change 100644 => 100755 app/templates/modules/settings/users.html mode change 100644 => 100755 app/templates/modules/settings/view_log.html mode change 100644 => 100755 app/templates/modules/warehouse/boxes.html mode change 100644 => 100755 app/templates/modules/warehouse/index.html mode change 100644 => 100755 app/templates/modules/warehouse/inventory.html mode change 100644 => 100755 app/templates/modules/warehouse/locations.html mode change 100644 => 100755 app/templates/modules/warehouse/reports.html mode change 100644 => 100755 app/templates/modules/warehouse/set_boxes_locations.html mode change 100644 => 100755 app/templates/modules/warehouse/set_orders_on_boxes.html mode change 100644 => 100755 app/templates/modules/warehouse/test_barcode.html mode change 100644 => 100755 app/templates/profile.html create mode 100644 documentation/add_labels_test_data.py create mode 100644 documentation/add_labels_test_data_direct.py diff --git a/Dockerfile b/Dockerfile index abe0770..2437789 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,11 @@ ENV PYTHONUNBUFFERED=1 \ # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + python3-dev \ mariadb-client \ curl \ + libpq-dev \ && rm -rf /var/lib/apt/lists/* # Create application directory diff --git a/app/__init__.py b/app/__init__.py old mode 100644 new mode 100755 diff --git a/app/access_control.py b/app/access_control.py old mode 100644 new mode 100755 diff --git a/app/auth.py b/app/auth.py old mode 100644 new mode 100755 diff --git a/app/config.py b/app/config.py old mode 100644 new mode 100755 diff --git a/app/database.py b/app/database.py old mode 100644 new mode 100755 diff --git a/app/db_migrations/add_warehouse_roles_and_bindings.sql b/app/db_migrations/add_warehouse_roles_and_bindings.sql old mode 100644 new mode 100755 diff --git a/app/db_schema_verifier.py b/app/db_schema_verifier.py old mode 100644 new mode 100755 diff --git a/app/models/__init__.py b/app/models/__init__.py old mode 100644 new mode 100755 diff --git a/app/modules/labels/__init__.py b/app/modules/labels/__init__.py old mode 100644 new mode 100755 diff --git a/app/modules/labels/import_labels.py b/app/modules/labels/import_labels.py old mode 100644 new mode 100755 diff --git a/app/modules/labels/pdf_generator.py b/app/modules/labels/pdf_generator.py old mode 100644 new mode 100755 diff --git a/app/modules/labels/print_module.py b/app/modules/labels/print_module.py old mode 100644 new mode 100755 diff --git a/app/modules/labels/routes.py b/app/modules/labels/routes.py old mode 100644 new mode 100755 diff --git a/app/modules/quality/__init__.py b/app/modules/quality/__init__.py old mode 100644 new mode 100755 diff --git a/app/modules/quality/quality.py b/app/modules/quality/quality.py old mode 100644 new mode 100755 diff --git a/app/modules/quality/routes.py b/app/modules/quality/routes.py old mode 100644 new mode 100755 diff --git a/app/modules/settings/__init__.py b/app/modules/settings/__init__.py old mode 100644 new mode 100755 diff --git a/app/modules/settings/logs.py b/app/modules/settings/logs.py old mode 100644 new mode 100755 diff --git a/app/modules/settings/routes.py b/app/modules/settings/routes.py old mode 100644 new mode 100755 diff --git a/app/modules/settings/stats.py b/app/modules/settings/stats.py old mode 100644 new mode 100755 diff --git a/app/modules/settings/warehouse_worker_management.py b/app/modules/settings/warehouse_worker_management.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/__init__.py b/app/modules/warehouse/__init__.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/boxes.py b/app/modules/warehouse/boxes.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/boxes_routes.py b/app/modules/warehouse/boxes_routes.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/routes.py b/app/modules/warehouse/routes.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/warehouse.py b/app/modules/warehouse/warehouse.py old mode 100644 new mode 100755 diff --git a/app/modules/warehouse/warehouse_orders.py b/app/modules/warehouse/warehouse_orders.py old mode 100644 new mode 100755 diff --git a/app/routes.py b/app/routes.py old mode 100644 new mode 100755 diff --git a/app/scheduler.py b/app/scheduler.py old mode 100644 new mode 100755 diff --git a/app/static/css/base.css b/app/static/css/base.css old mode 100644 new mode 100755 diff --git a/app/static/css/database_management.css b/app/static/css/database_management.css old mode 100644 new mode 100755 diff --git a/app/static/css/fg_scan.css b/app/static/css/fg_scan.css old mode 100644 new mode 100755 diff --git a/app/static/css/login.css b/app/static/css/login.css old mode 100644 new mode 100755 diff --git a/app/static/css/print_module.css b/app/static/css/print_module.css old mode 100644 new mode 100755 diff --git a/app/static/css/scan.css b/app/static/css/scan.css old mode 100644 new mode 100755 diff --git a/app/static/css/theme.css b/app/static/css/theme.css old mode 100644 new mode 100755 diff --git a/app/static/js/base.js b/app/static/js/base.js old mode 100644 new mode 100755 diff --git a/app/static/js/qz-printer.js b/app/static/js/qz-printer.js old mode 100644 new mode 100755 diff --git a/app/static/js/qz-tray.js b/app/static/js/qz-tray.js old mode 100644 new mode 100755 diff --git a/app/static/js/theme.js b/app/static/js/theme.js old mode 100644 new mode 100755 diff --git a/app/static/style.css b/app/static/style.css old mode 100644 new mode 100755 diff --git a/app/templates/base.html b/app/templates/base.html old mode 100644 new mode 100755 diff --git a/app/templates/base_print.html b/app/templates/base_print.html old mode 100644 new mode 100755 diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html old mode 100644 new mode 100755 diff --git a/app/templates/errors/403.html b/app/templates/errors/403.html old mode 100644 new mode 100755 diff --git a/app/templates/errors/404.html b/app/templates/errors/404.html old mode 100644 new mode 100755 diff --git a/app/templates/errors/500.html b/app/templates/errors/500.html old mode 100644 new mode 100755 diff --git a/app/templates/login.html b/app/templates/login.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/import_labels.html b/app/templates/modules/labels/import_labels.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/index.html b/app/templates/modules/labels/index.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/print_labels.html b/app/templates/modules/labels/print_labels.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/print_lost_labels.html b/app/templates/modules/labels/print_lost_labels.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/print_lost_labels_new.html b/app/templates/modules/labels/print_lost_labels_new.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/labels/print_module.html b/app/templates/modules/labels/print_module.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/quality/fg_reports.html b/app/templates/modules/quality/fg_reports.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/quality/fg_scan.html b/app/templates/modules/quality/fg_scan.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/quality/index.html b/app/templates/modules/quality/index.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/quality/inspections.html b/app/templates/modules/quality/inspections.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/quality/reports.html b/app/templates/modules/quality/reports.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/app_keys.html b/app/templates/modules/settings/app_keys.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/database.html b/app/templates/modules/settings/database.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/database_management.html b/app/templates/modules/settings/database_management.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/general.html b/app/templates/modules/settings/general.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/index.html b/app/templates/modules/settings/index.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/logs_explorer.html b/app/templates/modules/settings/logs_explorer.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/search_logs.html b/app/templates/modules/settings/search_logs.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/user_form.html b/app/templates/modules/settings/user_form.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/users.html b/app/templates/modules/settings/users.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/settings/view_log.html b/app/templates/modules/settings/view_log.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/boxes.html b/app/templates/modules/warehouse/boxes.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/index.html b/app/templates/modules/warehouse/index.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/inventory.html b/app/templates/modules/warehouse/inventory.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/locations.html b/app/templates/modules/warehouse/locations.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/reports.html b/app/templates/modules/warehouse/reports.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/set_boxes_locations.html b/app/templates/modules/warehouse/set_boxes_locations.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/set_orders_on_boxes.html b/app/templates/modules/warehouse/set_orders_on_boxes.html old mode 100644 new mode 100755 diff --git a/app/templates/modules/warehouse/test_barcode.html b/app/templates/modules/warehouse/test_barcode.html old mode 100644 new mode 100755 diff --git a/app/templates/profile.html b/app/templates/profile.html old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml index 4691d49..41f403a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +#version: '3.8' services: # MariaDB Database Service diff --git a/documentation/add_labels_test_data.py b/documentation/add_labels_test_data.py new file mode 100644 index 0000000..d7eb038 --- /dev/null +++ b/documentation/add_labels_test_data.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python3 +""" +Add Example/Test Data for Labels Module +Creates sample orders in order_for_labels table for testing printing functionality via QZ Tray +""" + +import sys +import os +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +from app.database import get_db +import logging +from datetime import datetime, timedelta + +# Configure logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') +logger = logging.getLogger(__name__) + +def add_sample_labels_data(): + """Add sample order data for testing labels/printing functionality""" + try: + conn = get_db() + cursor = conn.cursor() + + # Check if table exists + cursor.execute("SHOW TABLES LIKE 'order_for_labels'") + if not cursor.fetchone(): + logger.error("order_for_labels table does not exist. Please run initialize_db.py first.") + return False + + # Clear existing test data (optional - comment out if you want to keep existing data) + logger.info("Clearing existing test data...") + cursor.execute("DELETE FROM order_for_labels WHERE comanda_productie LIKE 'TEST%'") + + # Sample test data for different scenarios + test_orders = [ + { + 'comanda_productie': 'TEST-ORD-001', + 'cod_articol': 'ART001', + 'descr_com_prod': 'Electronic Component Type A - High Performance', + 'cantitate': 150, + 'com_achiz_client': 'CLIENT-PO-2024-001', + 'nr_linie_com_client': '01', + 'customer_name': 'TechCorp Industries', + 'customer_article_number': 'TC-COMP-A001', + 'open_for_order': 1, + 'line_number': 1, + 'printed_labels': 0, # Not printed - will show in unprinted list + 'data_livrara': '2024-03-15', # Fixed field name to match DB schema + 'dimensiune': 'Standard-Large' + }, + { + 'comanda_productie': 'TEST-ORD-002', + 'cod_articol': 'ART002', + 'descr_com_prod': 'Mechanical Part B - Precision Machined', + 'cantitate': 75, + 'com_achiz_client': 'CLIENT-PO-2024-002', + 'nr_linie_com_client': '02', + 'customer_name': 'MechParts Ltd', + 'customer_article_number': 'MP-PART-B002', + 'open_for_order': 1, + 'line_number': 2, + 'printed_labels': 0, # Not printed + 'data_livrara': '2024-03-18', + 'dimensiune': 'Medium' + }, + { + 'comanda_productie': 'TEST-ORD-003', + 'cod_articol': 'ART003', + 'descr_com_prod': 'Plastic Housing C - UV Resistant', + 'cantitate': 200, + 'com_achiz_client': 'CLIENT-PO-2024-003', + 'nr_linie_com_client': '03', + 'customer_name': 'PlasticWorks Inc', + 'customer_article_number': 'PW-HOUSE-C003', + 'open_for_order': 1, + 'line_number': 3, + 'printed_labels': 1, # Already printed - will show in printed list + 'data_livrara': '2024-03-20', + 'dimensiune': 'Large' + }, + { + 'comanda_productie': 'TEST-ORD-004', + 'cod_articol': 'ART004', + 'descr_com_prod': 'Metal Bracket D - Galvanized Steel', + 'cantitate': 300, + 'com_achiz_client': 'CLIENT-PO-2024-004', + 'nr_linie_com_client': '04', + 'customer_name': 'MetalCraft Solutions', + 'customer_article_number': 'MC-BRACK-D004', + 'open_for_order': 1, + 'line_number': 4, + 'printed_labels': 0, # Not printed + 'data_livrara': '2024-03-22', + 'dimensiune': 'Small' + }, + { + 'comanda_productie': 'TEST-ORD-005', + 'cod_articol': 'ART005', + 'descr_com_prod': 'Circuit Board E - Multi-layer PCB', + 'cantitate': 50, + 'com_achiz_client': 'CLIENT-PO-2024-005', + 'nr_linie_com_client': '05', + 'customer_name': 'CircuitTech Systems', + 'customer_article_number': 'CT-PCB-E005', + 'open_for_order': 1, + 'line_number': 5, + 'printed_labels': 0, # Not printed + 'data_livrara': '2024-03-25', + 'dimensiune': 'Standard' + }, + { + 'comanda_productie': 'TEST-ORD-006', + 'cod_articol': 'ART006', + 'descr_com_prod': 'Rubber Gasket F - High Temperature', + 'cantitate': 500, + 'com_achiz_client': 'CLIENT-PO-2024-006', + 'nr_linie_com_client': '06', + 'customer_name': 'RubberPro Manufacturing', + 'customer_article_number': 'RP-GASKET-F006', + 'open_for_order': 1, + 'line_number': 6, + 'printed_labels': 1, # Already printed + 'data_livrara': '2024-03-28', + 'dimensiune': 'Extra-Small' + }, + { + 'comanda_productie': 'TEST-ORD-007', + 'cod_articol': 'ART007', + 'descr_com_prod': 'Glass Panel G - Tempered Safety Glass', + 'cantitate': 25, + 'com_achiz_client': 'CLIENT-PO-2024-007', + 'nr_linie_com_client': '07', + 'customer_name': 'GlassTech Innovations', + 'customer_article_number': 'GT-PANEL-G007', + 'open_for_order': 1, + 'line_number': 7, + 'printed_labels': 0, # Not printed - urgent order + 'data_livrara': '2024-03-12', # Past due date for testing + 'dimensiune': 'Extra-Large' + }, + { + 'comanda_productie': 'TEST-ORD-008', + 'cod_articol': 'ART008', + 'descr_com_prod': 'Fabric Cover H - Water-Resistant Canvas', + 'cantitate': 120, + 'com_achiz_client': 'CLIENT-PO-2024-008', + 'nr_linie_com_client': '08', + 'customer_name': 'FabricWorks Design', + 'customer_article_number': 'FW-COVER-H008', + 'open_for_order': 0, # Not open for order - for testing + 'line_number': 8, + 'printed_labels': 0, + 'data_livrara': '2024-04-01', + 'dimensiune': 'Custom' + } + ] + + # Insert test data + logger.info(f"Inserting {len(test_orders)} test orders...") + + for order in test_orders: + cursor.execute(""" + INSERT INTO order_for_labels ( + comanda_productie, cod_articol, descr_com_prod, cantitate, + com_achiz_client, nr_linie_com_client, customer_name, + customer_article_number, open_for_order, line_number, + printed_labels, data_livrara, dimensiune + ) VALUES ( + %(comanda_productie)s, %(cod_articol)s, %(descr_com_prod)s, %(cantitate)s, + %(com_achiz_client)s, %(nr_linie_com_client)s, %(customer_name)s, + %(customer_article_number)s, %(open_for_order)s, %(line_number)s, + %(printed_labels)s, %(data_livrara)s, %(dimensiune)s + ) + """, order) + + conn.commit() + cursor.close() + conn.close() + + logger.info("āœ… Successfully added test data for labels module!") + logger.info("Test data summary:") + logger.info(f" - Total orders: {len(test_orders)}") + logger.info(f" - Unprinted orders: {sum(1 for o in test_orders if o['printed_labels'] == 0)}") + logger.info(f" - Printed orders: {sum(1 for o in test_orders if o['printed_labels'] == 1)}") + logger.info(" - Test order codes: TEST-ORD-001 through TEST-ORD-008") + logger.info("\nYou can now test:") + logger.info(" 1. Navigate to /labels/print-module") + logger.info(" 2. View unprinted orders (should show 6 orders)") + logger.info(" 3. Generate PDF labels and test QZ Tray printing") + logger.info(" 4. Mark orders as printed and verify status updates") + + return True + + except Exception as e: + logger.error(f"Error adding test data: {e}") + return False + + +def verify_test_data(): + """Verify that test data was added correctly""" + try: + conn = get_db() + cursor = conn.cursor() + + # Count total test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%'") + total_count = cursor.fetchone()[0] + + # Count unprinted test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%' AND printed_labels = 0") + unprinted_count = cursor.fetchone()[0] + + # Count printed test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%' AND printed_labels = 1") + printed_count = cursor.fetchone()[0] + + logger.info(f"\nšŸ“‹ Test Data Verification:") + logger.info(f" - Total test orders: {total_count}") + logger.info(f" - Unprinted orders: {unprinted_count}") + logger.info(f" - Printed orders: {printed_count}") + + # List some sample orders + cursor.execute(""" + SELECT comanda_productie, descr_com_prod, cantitate, printed_labels, data_livrara + FROM order_for_labels + WHERE comanda_productie LIKE 'TEST%' + ORDER BY comanda_productie + LIMIT 5 + """) + + orders = cursor.fetchall() + if orders: + logger.info(f"\nšŸ·ļø Sample Test Orders:") + for order in orders: + status = "āœ… Printed" if order[3] else "ā³ Unprinted" + logger.info(f" - {order[0]}: {order[1][:50]}... (Qty: {order[2]}, {status})") + + cursor.close() + conn.close() + return True + + except Exception as e: + logger.error(f"Error verifying test data: {e}") + return False + + +if __name__ == "__main__": + logger.info("šŸ·ļø Adding Labels Module Test Data...") + + if add_sample_labels_data(): + verify_test_data() + logger.info("\nšŸŽ‰ Test data successfully added!") + logger.info("\nNext steps:") + logger.info("1. Start the application: docker compose up -d") + logger.info("2. Navigate to: http://localhost:8080/labels/print-module") + logger.info("3. Test QZ Tray printing functionality") + else: + logger.error("āŒ Failed to add test data") + sys.exit(1) \ No newline at end of file diff --git a/documentation/add_labels_test_data_direct.py b/documentation/add_labels_test_data_direct.py new file mode 100644 index 0000000..5dcb688 --- /dev/null +++ b/documentation/add_labels_test_data_direct.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python3 +""" +Add Example/Test Data for Labels Module - Direct Database Version +Creates sample orders in order_for_labels table for testing printing functionality via QZ Tray +""" + +import pymysql +import logging +from datetime import datetime + +# Configure logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') +logger = logging.getLogger(__name__) + +# Database connection parameters +DB_CONFIG = { + 'host': 'localhost', + 'port': 3306, + 'user': 'quality_user', + 'password': 'qualitypass', + 'database': 'quality_db', + 'charset': 'utf8mb4' +} + +def add_sample_labels_data(): + """Add sample order data for testing labels/printing functionality""" + try: + # Connect to database + conn = pymysql.connect(**DB_CONFIG) + cursor = conn.cursor() + + # Check if table exists + cursor.execute("SHOW TABLES LIKE 'order_for_labels'") + if not cursor.fetchone(): + logger.error("order_for_labels table does not exist. Please run initialize_db.py first.") + return False + + # Clear existing test data (optional - comment out if you want to keep existing data) + logger.info("Clearing existing test data...") + cursor.execute("DELETE FROM order_for_labels WHERE comanda_productie LIKE 'TEST%'") + + # Sample test data for different scenarios + test_orders = [ + ('TEST-ORD-001', 'ART001', 'Electronic Component Type A - High Performance', 150, 'CLIENT-PO-2024-001', '01', 'TechCorp Industries', 'TC-COMP-A001', 1, 1, 0, '2024-03-15', 'Standard-Large'), + ('TEST-ORD-002', 'ART002', 'Mechanical Part B - Precision Machined', 75, 'CLIENT-PO-2024-002', '02', 'MechParts Ltd', 'MP-PART-B002', 1, 2, 0, '2024-03-18', 'Medium'), + ('TEST-ORD-003', 'ART003', 'Plastic Housing C - UV Resistant', 200, 'CLIENT-PO-2024-003', '03', 'PlasticWorks Inc', 'PW-HOUSE-C003', 1, 3, 1, '2024-03-20', 'Large'), + ('TEST-ORD-004', 'ART004', 'Metal Bracket D - Galvanized Steel', 300, 'CLIENT-PO-2024-004', '04', 'MetalCraft Solutions', 'MC-BRACK-D004', 1, 4, 0, '2024-03-22', 'Small'), + ('TEST-ORD-005', 'ART005', 'Circuit Board E - Multi-layer PCB', 50, 'CLIENT-PO-2024-005', '05', 'CircuitTech Systems', 'CT-PCB-E005', 1, 5, 0, '2024-03-25', 'Standard'), + ('TEST-ORD-006', 'ART006', 'Rubber Gasket F - High Temperature', 500, 'CLIENT-PO-2024-006', '06', 'RubberPro Manufacturing', 'RP-GASKET-F006', 1, 6, 1, '2024-03-28', 'Extra-Small'), + ('TEST-ORD-007', 'ART007', 'Glass Panel G - Tempered Safety Glass', 25, 'CLIENT-PO-2024-007', '07', 'GlassTech Innovations', 'GT-PANEL-G007', 1, 7, 0, '2024-03-12', 'Extra-Large'), + ('TEST-ORD-008', 'ART008', 'Fabric Cover H - Water-Resistant Canvas', 120, 'CLIENT-PO-2024-008', '08', 'FabricWorks Design', 'FW-COVER-H008', 0, 8, 0, '2024-04-01', 'Custom'), + ] + + # Insert test data + logger.info(f"Inserting {len(test_orders)} test orders...") + + cursor.executemany(""" + INSERT INTO order_for_labels ( + comanda_productie, cod_articol, descr_com_prod, cantitate, + com_achiz_client, nr_linie_com_client, customer_name, + customer_article_number, open_for_order, line_number, + printed_labels, data_livrara, dimensiune + ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) + """, test_orders) + + conn.commit() + cursor.close() + conn.close() + + logger.info("āœ… Successfully added test data for labels module!") + logger.info("Test data summary:") + logger.info(f" - Total orders: {len(test_orders)}") + logger.info(f" - Unprinted orders: {sum(1 for o in test_orders if o[10] == 0)}") # printed_labels is index 10 + logger.info(f" - Printed orders: {sum(1 for o in test_orders if o[10] == 1)}") + logger.info(" - Test order codes: TEST-ORD-001 through TEST-ORD-008") + logger.info("\nYou can now test:") + logger.info(" 1. Navigate to /labels/print-module") + logger.info(" 2. View unprinted orders (should show 6 orders)") + logger.info(" 3. Generate PDF labels and test QZ Tray printing") + logger.info(" 4. Mark orders as printed and verify status updates") + + return True + + except Exception as e: + logger.error(f"Error adding test data: {e}") + return False + + +def verify_test_data(): + """Verify that test data was added correctly""" + try: + conn = pymysql.connect(**DB_CONFIG) + cursor = conn.cursor() + + # Count total test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%'") + total_count = cursor.fetchone()[0] + + # Count unprinted test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%' AND printed_labels = 0") + unprinted_count = cursor.fetchone()[0] + + # Count printed test orders + cursor.execute("SELECT COUNT(*) FROM order_for_labels WHERE comanda_productie LIKE 'TEST%' AND printed_labels = 1") + printed_count = cursor.fetchone()[0] + + logger.info(f"\nšŸ“‹ Test Data Verification:") + logger.info(f" - Total test orders: {total_count}") + logger.info(f" - Unprinted orders: {unprinted_count}") + logger.info(f" - Printed orders: {printed_count}") + + # List some sample orders + cursor.execute(""" + SELECT comanda_productie, descr_com_prod, cantitate, printed_labels, data_livrara + FROM order_for_labels + WHERE comanda_productie LIKE 'TEST%' + ORDER BY comanda_productie + LIMIT 5 + """) + + orders = cursor.fetchall() + if orders: + logger.info(f"\nšŸ·ļø Sample Test Orders:") + for order in orders: + status = "āœ… Printed" if order[3] else "ā³ Unprinted" + desc = order[1][:50] + "..." if len(order[1]) > 50 else order[1] + logger.info(f" - {order[0]}: {desc} (Qty: {order[2]}, {status})") + + cursor.close() + conn.close() + return True + + except Exception as e: + logger.error(f"Error verifying test data: {e}") + return False + + +if __name__ == "__main__": + logger.info("šŸ·ļø Adding Labels Module Test Data...") + + if add_sample_labels_data(): + verify_test_data() + logger.info("\nšŸŽ‰ Test data successfully added!") + logger.info("\nNext steps:") + logger.info("1. Navigate to: http://localhost:8781/labels/print-module") + logger.info("2. Test QZ Tray printing functionality") + logger.info("3. Use test orders TEST-ORD-001 through TEST-ORD-008") + else: + logger.error("āŒ Failed to add test data") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2ad8c5f..0d348c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,5 @@ Markdown==3.5.1 APScheduler==3.10.4 reportlab==4.0.7 python-barcode==0.15.1 -Flask-Session==0.8.0openpyxl==3.10.0 \ No newline at end of file +Flask-Session==0.8.0 +openpyxl==3.1.5 \ No newline at end of file