Fix print_lost_labels compact styling and production data import

- Added compact table styling to print_lost_labels page (smaller fonts, reduced padding)
- Fixed production data import missing fields (production_order_line, line_number)
- Added better error handling and logging for Excel file imports
- Skip empty rows in production data import
- Log all columns and columns with data for debugging
This commit is contained in:
ske087
2025-11-26 21:59:03 +02:00
parent d3a0123acc
commit d070db0052
13 changed files with 649 additions and 1042 deletions

View File

@@ -7,8 +7,13 @@ def get_db_connection():
settings = {}
with open(settings_file, 'r') as f:
for line in f:
key, value = line.strip().split('=', 1)
settings[key] = value
line = line.strip()
# Skip empty lines and comments
if not line or line.startswith('#'):
continue
if '=' in line:
key, value = line.split('=', 1)
settings[key] = value
return mariadb.connect(
user=settings['username'],
password=settings['password'],
@@ -23,6 +28,10 @@ def get_unprinted_orders_data(limit=100):
Returns list of order dictionaries where printed_labels != 1
"""
try:
import sys
sys.stderr.write(f"DEBUG print_module: get_unprinted_orders_data called with limit={limit}\n")
sys.stderr.flush()
conn = get_db_connection()
cursor = conn.cursor()
@@ -30,8 +39,14 @@ def get_unprinted_orders_data(limit=100):
cursor.execute("SHOW COLUMNS FROM order_for_labels LIKE 'printed_labels'")
column_exists = cursor.fetchone()
sys.stderr.write(f"DEBUG print_module: printed_labels column exists={bool(column_exists)}\n")
sys.stderr.flush()
if column_exists:
# Use printed_labels column
sys.stderr.write(f"DEBUG print_module: Executing query with printed_labels != 1\n")
sys.stderr.flush()
cursor.execute("""
SELECT id, comanda_productie, cod_articol, descr_com_prod, cantitate,
com_achiz_client, nr_linie_com_client, customer_name,
@@ -43,6 +58,9 @@ def get_unprinted_orders_data(limit=100):
LIMIT %s
""", (limit,))
else:
sys.stderr.write(f"DEBUG print_module: Executing fallback query (no printed_labels column)\n")
sys.stderr.flush()
# Fallback: get all orders if no printed_labels column
cursor.execute("""
SELECT id, comanda_productie, cod_articol, descr_com_prod, cantitate,
@@ -55,7 +73,21 @@ def get_unprinted_orders_data(limit=100):
""", (limit,))
orders = []
for row in cursor.fetchall():
rows = cursor.fetchall()
sys.stderr.write(f"DEBUG print_module: Query returned {len(rows)} rows\n")
sys.stderr.flush()
# Also write to file for debugging
try:
with open('/app/print_module_debug.log', 'w') as f:
f.write(f"Query returned {len(rows)} rows\n")
f.write(f"Column exists: {column_exists}\n")
if rows:
f.write(f"First row: {rows[0]}\n")
except:
pass
for row in rows:
if column_exists:
orders.append({
'id': row[0],
@@ -100,6 +132,21 @@ def get_unprinted_orders_data(limit=100):
return orders
except Exception as e:
import sys
import traceback
error_trace = traceback.format_exc()
sys.stderr.write(f"ERROR in get_unprinted_orders_data: {e}\n{error_trace}\n")
sys.stderr.flush()
# Write to file
try:
with open('/app/print_module_error.log', 'w') as f:
f.write(f"ERROR: {e}\n")
f.write(f"Traceback:\n{error_trace}\n")
except:
pass
print(f"Error retrieving unprinted orders: {e}")
return []