diff --git a/instance/users.db b/instance/users.db deleted file mode 100644 index fa85049..0000000 Binary files a/instance/users.db and /dev/null differ diff --git a/py_app/app/__pycache__/order_labels.cpython-312.pyc b/py_app/app/__pycache__/order_labels.cpython-312.pyc new file mode 100644 index 0000000..767ed32 Binary files /dev/null and b/py_app/app/__pycache__/order_labels.cpython-312.pyc differ diff --git a/py_app/app/__pycache__/routes.cpython-312.pyc b/py_app/app/__pycache__/routes.cpython-312.pyc index f3b6de2..702debe 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/db_create_scripts/add_printed_labels_column.py b/py_app/app/db_create_scripts/add_printed_labels_column.py new file mode 100644 index 0000000..fe04ec4 --- /dev/null +++ b/py_app/app/db_create_scripts/add_printed_labels_column.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +""" +Database script to add the printed_labels column to the order_for_labels table +This column will track whether labels have been printed for each order (boolean: 0=false, 1=true) +Default value: 0 (false) +""" + +import sys +import os +import mariadb +from flask import Flask + +# Add the app directory to the path +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +def get_db_connection(): + """Get database connection using settings from external_server.conf""" + # Go up two levels from this script to reach py_app directory, then to instance + app_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + settings_file = os.path.join(app_root, 'instance', 'external_server.conf') + + settings = {} + with open(settings_file, 'r') as f: + for line in f: + key, value = line.strip().split('=', 1) + settings[key] = value + + return mariadb.connect( + user=settings['username'], + password=settings['password'], + host=settings['server_domain'], + port=int(settings['port']), + database=settings['database_name'] + ) + +def add_printed_labels_column(): + """ + Adds the printed_labels column to the order_for_labels table after the line_number column + Column type: TINYINT(1) (boolean: 0=false, 1=true) + Default value: 0 (false) + """ + try: + conn = get_db_connection() + cursor = conn.cursor() + + # Check if table exists + cursor.execute("SHOW TABLES LIKE 'order_for_labels'") + result = cursor.fetchone() + + if not result: + print("āŒ Table 'order_for_labels' does not exist. Please create it first.") + return False + + # Check if column already exists + cursor.execute("SHOW COLUMNS FROM order_for_labels LIKE 'printed_labels'") + column_exists = cursor.fetchone() + + if column_exists: + print("ā„¹ļø Column 'printed_labels' already exists.") + # Show current structure + cursor.execute("DESCRIBE order_for_labels") + columns = cursor.fetchall() + print("\nšŸ“‹ Current table structure:") + for col in columns: + null_info = 'NULL' if col[2] == 'YES' else 'NOT NULL' + default_info = f" DEFAULT {col[4]}" if col[4] else "" + print(f" šŸ“Œ {col[0]:<25} {col[1]:<20} {null_info}{default_info}") + else: + # Add the column after line_number + alter_table_sql = """ + ALTER TABLE order_for_labels + ADD COLUMN printed_labels TINYINT(1) NOT NULL DEFAULT 0 + COMMENT 'Boolean flag: 0=labels not printed, 1=labels printed' + AFTER line_number + """ + + cursor.execute(alter_table_sql) + conn.commit() + print("āœ… Column 'printed_labels' added successfully!") + + # Show the updated structure + cursor.execute("DESCRIBE order_for_labels") + columns = cursor.fetchall() + print("\nšŸ“‹ Updated table structure:") + for col in columns: + null_info = 'NULL' if col[2] == 'YES' else 'NOT NULL' + default_info = f" DEFAULT {col[4]}" if col[4] else "" + highlight = "šŸ†• " if col[0] == 'printed_labels' else " " + print(f"{highlight}{col[0]:<25} {col[1]:<20} {null_info}{default_info}") + + # Show count of existing records that will have printed_labels = 0 + cursor.execute("SELECT COUNT(*) FROM order_for_labels") + count = cursor.fetchone()[0] + if count > 0: + print(f"\nšŸ“Š {count} existing records now have printed_labels = 0 (false)") + + conn.close() + + except mariadb.Error as e: + print(f"āŒ Database error: {e}") + return False + except Exception as e: + print(f"āŒ Error: {e}") + return False + + return True + +def verify_column(): + """Verify the column was added correctly""" + try: + conn = get_db_connection() + cursor = conn.cursor() + + # Test the column functionality + cursor.execute("SELECT COUNT(*) as total, SUM(printed_labels) as printed FROM order_for_labels") + result = cursor.fetchone() + + if result: + total, printed = result + print(f"\nšŸ” Verification:") + print(f" šŸ“¦ Total orders: {total}") + print(f" šŸ–Øļø Printed orders: {printed or 0}") + print(f" šŸ“„ Unprinted orders: {total - (printed or 0)}") + + conn.close() + return True + + except Exception as e: + print(f"āŒ Verification failed: {e}") + return False + +if __name__ == "__main__": + print("šŸ”§ Adding printed_labels column to order_for_labels table...") + print("="*60) + + success = add_printed_labels_column() + + if success: + print("\nšŸ” Verifying column addition...") + verify_column() + print("\nāœ… Database modification completed successfully!") + print("\nšŸ“ Column Details:") + print(" • Name: printed_labels") + print(" • Type: TINYINT(1) (boolean)") + print(" • Default: 0 (false - labels not printed)") + print(" • Values: 0 = not printed, 1 = printed") + print(" • Position: After line_number column") + else: + print("\nāŒ Database modification failed!") + + print("="*60) \ No newline at end of file diff --git a/py_app/app/db_create_scripts/create_order_for_labels_table.py b/py_app/app/db_create_scripts/create_order_for_labels_table.py new file mode 100644 index 0000000..fc21e80 --- /dev/null +++ b/py_app/app/db_create_scripts/create_order_for_labels_table.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +""" +Database script to create the order_for_labels table +This table will store order information for label generation +""" + +import sys +import os +import mariadb +from flask import Flask + +# Add the app directory to the path +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +def get_db_connection(): + """Get database connection using settings from external_server.conf""" + # Go up two levels from this script to reach py_app directory, then to instance + app_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + settings_file = os.path.join(app_root, 'instance', 'external_server.conf') + + settings = {} + with open(settings_file, 'r') as f: + for line in f: + key, value = line.strip().split('=', 1) + settings[key] = value + + return mariadb.connect( + user=settings['username'], + password=settings['password'], + host=settings['server_domain'], + port=int(settings['port']), + database=settings['database_name'] + ) + +def create_order_for_labels_table(): + """ + Creates the order_for_labels table with the specified structure + """ + try: + conn = get_db_connection() + cursor = conn.cursor() + + # First check if table already exists + cursor.execute("SHOW TABLES LIKE 'order_for_labels'") + result = cursor.fetchone() + + if result: + print("Table 'order_for_labels' already exists.") + # Show current structure + cursor.execute("DESCRIBE order_for_labels") + columns = cursor.fetchall() + print("\nCurrent table structure:") + for col in columns: + print(f" {col[0]} - {col[1]} {'NULL' if col[2] == 'YES' else 'NOT NULL'}") + else: + # Create the table + create_table_sql = """ + CREATE TABLE order_for_labels ( + id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique identifier', + comanda_productie VARCHAR(15) NOT NULL COMMENT 'Production Order', + cod_articol VARCHAR(15) COMMENT 'Article Code', + descr_com_prod VARCHAR(50) NOT NULL COMMENT 'Production Order Description', + cantitate INT(3) NOT NULL COMMENT 'Quantity', + com_achiz_client VARCHAR(25) COMMENT 'Client Purchase Order', + nr_linie_com_client INT(3) COMMENT 'Client Order Line Number', + customer_name VARCHAR(50) COMMENT 'Customer Name', + customer_article_number VARCHAR(25) COMMENT 'Customer Article Number', + open_for_order VARCHAR(25) COMMENT 'Open for Order Status', + line_number INT(3) COMMENT 'Line Number', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Record creation timestamp', + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Record update timestamp' + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Table for storing order information for label generation' + """ + + cursor.execute(create_table_sql) + conn.commit() + print("āœ… Table 'order_for_labels' created successfully!") + + # Show the created structure + cursor.execute("DESCRIBE order_for_labels") + columns = cursor.fetchall() + print("\nšŸ“‹ Table structure:") + for col in columns: + null_info = 'NULL' if col[2] == 'YES' else 'NOT NULL' + default_info = f" DEFAULT {col[4]}" if col[4] else "" + print(f" šŸ“Œ {col[0]:<25} {col[1]:<20} {null_info}{default_info}") + + conn.close() + + except mariadb.Error as e: + print(f"āŒ Database error: {e}") + return False + except Exception as e: + print(f"āŒ Error: {e}") + return False + + return True + +if __name__ == "__main__": + print("šŸ—ļø Creating order_for_labels table...") + print("="*50) + + success = create_order_for_labels_table() + + if success: + print("\nāœ… Database setup completed successfully!") + else: + print("\nāŒ Database setup failed!") + + print("="*50) \ No newline at end of file diff --git a/py_app/app/order_labels.py b/py_app/app/order_labels.py new file mode 100644 index 0000000..78a3ff3 --- /dev/null +++ b/py_app/app/order_labels.py @@ -0,0 +1,339 @@ +""" +Order Labels Module - Handles CSV upload and processing for order label generation +Author: Auto-generated module for order management +""" + +import mariadb +from flask import current_app, request, render_template, session, redirect, url_for, flash +import csv +import os +import tempfile +from datetime import datetime + +def get_db_connection(): + """Get database connection using external server configuration""" + settings_file = current_app.instance_path + '/external_server.conf' + settings = {} + with open(settings_file, 'r') as f: + for line in f: + key, value = line.strip().split('=', 1) + settings[key] = value + return mariadb.connect( + user=settings['username'], + password=settings['password'], + host=settings['server_domain'], + port=int(settings['port']), + database=settings['database_name'] + ) + +def validate_order_row(row_data): + """ + Validate a single order row for required fields and data types + Required fields: Comanda Productie, Cantitate, Descr. Com. Prod + """ + errors = [] + warnings = [] + + # Check required fields + if not row_data.get('comanda_productie', '').strip(): + errors.append("Comanda Productie is required") + + if not row_data.get('descr_com_prod', '').strip(): + errors.append("Descr. Com. Prod is required") + + # Validate Cantitate (quantity) - must be integer + cantitate_str = row_data.get('cantitate', '').strip() + if not cantitate_str: + errors.append("Cantitate is required") + else: + try: + cantitate = int(cantitate_str) + if cantitate <= 0: + errors.append("Cantitate must be a positive number") + elif cantitate > 999: # INT(3) limit + warnings.append("Cantitate exceeds 999 (will be truncated)") + except ValueError: + errors.append("Cantitate must be a valid number") + + # Validate numeric fields (optional but must be valid if provided) + for field, max_val in [('nr_linie_com_client', 999), ('line_number', 999)]: + value = row_data.get(field, '').strip() + if value: + try: + num_val = int(value) + if num_val < 0: + warnings.append(f"{field} should be positive") + elif num_val > max_val: + warnings.append(f"{field} exceeds {max_val} (will be truncated)") + except ValueError: + errors.append(f"{field} must be a valid number") + + # Validate string length limits + field_limits = { + 'comanda_productie': 15, + 'cod_articol': 15, + 'descr_com_prod': 50, + 'com_achiz_client': 25, + 'customer_name': 50, + 'customer_article_number': 25, + 'open_for_order': 25 + } + + for field, max_len in field_limits.items(): + value = row_data.get(field, '').strip() + if value and len(value) > max_len: + warnings.append(f"{field} exceeds {max_len} characters (will be truncated)") + + return errors, warnings + +def add_order_to_database(order_data): + """ + Add a single order to the order_for_labels table + Returns (success: bool, message: str) + """ + try: + conn = get_db_connection() + cursor = conn.cursor() + + # Prepare data with proper types and limits + insert_data = { + 'comanda_productie': order_data.get('comanda_productie', '').strip()[:15], + 'cod_articol': order_data.get('cod_articol', '').strip()[:15] or None, + 'descr_com_prod': order_data.get('descr_com_prod', '').strip()[:50], + 'cantitate': int(order_data.get('cantitate', 0)), + 'com_achiz_client': order_data.get('com_achiz_client', '').strip()[:25] or None, + 'nr_linie_com_client': int(order_data.get('nr_linie_com_client', 0)) if order_data.get('nr_linie_com_client', '').strip() else None, + 'customer_name': order_data.get('customer_name', '').strip()[:50] or None, + 'customer_article_number': order_data.get('customer_article_number', '').strip()[:25] or None, + 'open_for_order': order_data.get('open_for_order', '').strip()[:25] or None, + 'line_number': int(order_data.get('line_number', 0)) if order_data.get('line_number', '').strip() else None + } + + sql = """ + 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) + 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) + """ + + cursor.execute(sql, insert_data) + conn.commit() + conn.close() + + return True, f"Successfully added order {insert_data['comanda_productie']}" + + except mariadb.Error as e: + return False, f"Database error: {str(e)}" + except ValueError as e: + return False, f"Data validation error: {str(e)}" + except Exception as e: + return False, f"Unexpected error: {str(e)}" + +def process_csv_file(file_path): + """ + Process uploaded CSV file and return parsed data with validation + Returns: (orders_data: list, validation_errors: list, validation_warnings: list) + """ + orders_data = [] + all_errors = [] + all_warnings = [] + + try: + with open(file_path, 'r', encoding='utf-8') as f: + # Try to detect the CSV dialect + sample = f.read(1024) + f.seek(0) + + # Create CSV reader + reader = csv.DictReader(f) + + # Map possible column names (case-insensitive) + column_mapping = { + 'comanda productie': 'comanda_productie', + 'cod articol': 'cod_articol', + 'descr. com. prod': 'descr_com_prod', + 'cantitate': 'cantitate', + 'com.achiz.client': 'com_achiz_client', + 'nr. linie com. client': 'nr_linie_com_client', + 'customer name': 'customer_name', + 'customer article number': 'customer_article_number', + 'open for order': 'open_for_order', + 'line': 'line_number' + } + + for row_num, row in enumerate(reader, start=2): # Start at 2 (row 1 is header) + # Normalize column names and create order data + normalized_row = {} + for col_name, col_value in row.items(): + if col_name: + col_key = col_name.lower().strip() + mapped_key = column_mapping.get(col_key, col_key.replace(' ', '_').replace('.', '_')) + normalized_row[mapped_key] = col_value.strip() if col_value else '' + + # Validate the row + errors, warnings = validate_order_row(normalized_row) + + if errors: + all_errors.extend([f"Row {row_num}: {error}" for error in errors]) + else: + # Only add valid rows + orders_data.append(normalized_row) + + if warnings: + all_warnings.extend([f"Row {row_num}: {warning}" for warning in warnings]) + + except UnicodeDecodeError: + # Try different encodings + try: + with open(file_path, 'r', encoding='latin-1') as f: + reader = csv.DictReader(f) + # ... repeat the same processing logic + except Exception as e: + all_errors.append(f"File encoding error: {str(e)}") + except Exception as e: + all_errors.append(f"File processing error: {str(e)}") + + return orders_data, all_errors, all_warnings + +def upload_orders_handler(): + """ + Main handler for the upload orders functionality + Handles both CSV upload/preview and database insertion + """ + report = None + orders_data = [] + validation_errors = [] + validation_warnings = [] + temp_dir = tempfile.gettempdir() + + if request.method == 'POST': + # Handle file upload + file = request.files.get('csv_file') + if file and file.filename.endswith(('.csv', '.CSV')): + try: + # Save uploaded file + temp_path = os.path.join(temp_dir, file.filename) + file.save(temp_path) + + # Store file info in session + session['csv_filename'] = file.filename + session['orders_csv_filepath'] = temp_path + + # Process the CSV file + orders_data, validation_errors, validation_warnings = process_csv_file(temp_path) + + # Store processed data in session + session['orders_csv_data'] = orders_data + session['orders_validation_errors'] = validation_errors + session['orders_validation_warnings'] = validation_warnings + + flash(f"šŸ“ File '{file.filename}' uploaded and processed successfully!", "info") + + if validation_errors: + flash(f"āš ļø Found {len(validation_errors)} validation errors. Please fix them before importing.", "warning") + + if validation_warnings: + flash(f"ā„¹ļø Found {len(validation_warnings)} warnings. Data will be adjusted automatically.", "info") + + except Exception as e: + flash(f"āŒ Error processing file: {str(e)}", "error") + + # Handle database insertion + elif request.form.get('save_to_database') and 'orders_csv_data' in session: + orders_data = session['orders_csv_data'] + + if not orders_data: + flash("āŒ No valid data to save to database.", "error") + else: + success_count = 0 + failed_count = 0 + failed_orders = [] + + for order in orders_data: + success, message = add_order_to_database(order) + if success: + success_count += 1 + else: + failed_count += 1 + failed_orders.append(f"{order.get('comanda_productie', 'Unknown')}: {message}") + + # Create report + report = f"āœ… Successfully imported {success_count} orders." + if failed_count > 0: + report += f" āŒ {failed_count} orders failed to import." + for failure in failed_orders[:5]: # Show first 5 failures + report += f"
• {failure}" + if len(failed_orders) > 5: + report += f"
• ... and {len(failed_orders) - 5} more failures." + + # Clear session data after successful import + if success_count > 0: + session.pop('orders_csv_data', None) + session.pop('csv_filename', None) + session.pop('orders_csv_filepath', None) + session.pop('orders_validation_errors', None) + session.pop('orders_validation_warnings', None) + + flash(report, "success" if failed_count == 0 else "warning") + + return redirect(url_for('main.upload_orders') + '#imported') + + # Load data from session if available + elif 'orders_csv_data' in session: + orders_data = session['orders_csv_data'] + validation_errors = session.get('orders_validation_errors', []) + validation_warnings = session.get('orders_validation_warnings', []) + + return render_template('upload_orders.html', + orders=orders_data, + validation_errors=validation_errors, + validation_warnings=validation_warnings, + report=report) + +def get_orders_from_database(limit=100): + """ + Retrieve orders from the database for display + Returns list of order dictionaries + """ + try: + conn = get_db_connection() + cursor = conn.cursor() + + cursor.execute(""" + SELECT id, 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, created_at, updated_at + FROM order_for_labels + ORDER BY created_at DESC + LIMIT %s + """, (limit,)) + + orders = [] + for row in cursor.fetchall(): + orders.append({ + 'id': row[0], + 'comanda_productie': row[1], + 'cod_articol': row[2], + 'descr_com_prod': row[3], + 'cantitate': row[4], + 'com_achiz_client': row[5], + 'nr_linie_com_client': row[6], + 'customer_name': row[7], + 'customer_article_number': row[8], + 'open_for_order': row[9], + 'line_number': row[10], + 'printed_labels': row[11], + 'created_at': row[12], + 'updated_at': row[13] + }) + + conn.close() + return orders + + except Exception as e: + print(f"Error retrieving orders: {e}") + return [] \ No newline at end of file diff --git a/py_app/app/routes.py b/py_app/app/routes.py index d72e5fb..1fc519b 100644 --- a/py_app/app/routes.py +++ b/py_app/app/routes.py @@ -1002,6 +1002,28 @@ def generate_pdf(): return jsonify({'message': 'PDF generated successfully!', 'pdf_path': f'/static/label_templates/label_template.pdf'}) +# Order Labels Upload Module Routes +@bp.route('/upload_orders', methods=['GET', 'POST']) +def upload_orders(): + """Route for uploading orders CSV files for label generation""" + if 'role' not in session or session['role'] not in ['superadmin', 'warehouse', 'warehouse_manager']: + flash('Access denied: Warehouse management permissions required.') + return redirect(url_for('main.dashboard')) + + from app.order_labels import upload_orders_handler + return upload_orders_handler() + +@bp.route('/view_orders') +def view_orders(): + """Route for viewing uploaded 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(200) # Get last 200 orders + return render_template('view_orders.html', orders=orders) + @warehouse_bp.route('/create_locations', methods=['GET', 'POST']) def create_locations(): from app.warehouse import create_locations_handler diff --git a/py_app/app/templates/main_page_etichete.html b/py_app/app/templates/main_page_etichete.html index e2c55fd..311e1fd 100644 --- a/py_app/app/templates/main_page_etichete.html +++ b/py_app/app/templates/main_page_etichete.html @@ -9,11 +9,11 @@
- +
-

Upload Data

-

Upload data into the database for label management.

- Go to Upload Data +

View Orders

+

View uploaded orders and manage label data for printing.

+ View Orders
diff --git a/py_app/app/templates/upload_data.html b/py_app/app/templates/upload_data.html deleted file mode 100644 index 7e46a4e..0000000 --- a/py_app/app/templates/upload_data.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Upload Data{% endblock %} - -{% block content %} -
-

Upload Data

-

This page will allow users to upload data into the database.

-
-{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/upload_orders.html b/py_app/app/templates/upload_orders.html new file mode 100644 index 0000000..d5b72d4 --- /dev/null +++ b/py_app/app/templates/upload_orders.html @@ -0,0 +1,244 @@ +{% extends "base.html" %} +{% block title %}Upload Order Data for Labels{% endblock %} +{% block content %} +
+ +
+

Upload Order Data for Labels

+
+ + {% if not orders %} +
+ + {% else %} +
+ + {% endif %} +
+ + + + + +
+ + +
+

Preview Table

+ + + + + + + + + + + + + + + + + {% if orders %} + {% for order in orders %} + + + + + + + + + + + + + {% endfor %} + {% else %} + + {% endif %} + +
Comanda ProductieCod ArticolDescr. Com. ProdCantitateCom.Achiz.ClientNr. Linie com. ClientCustomer NameCustomer Article NumberOpen for orderLine
{{ order.get('comanda_productie', '') }}{{ order.get('cod_articol', '') }}{{ order.get('descr_com_prod', '') }}{{ order.get('cantitate', '') }}{{ order.get('com_achiz_client', '') }}{{ order.get('nr_linie_com_client', '') }}{{ order.get('customer_name', '') }}{{ order.get('customer_article_number', '') }}{{ order.get('open_for_order', '') }}{{ order.get('line_number', '') }}
No CSV file uploaded yet.
+
+ + {% if validation_errors or validation_warnings %} +
+

Validation Results

+ + {% if validation_errors %} +
+ Errors found: +
    + {% for error in validation_errors %} +
  • {{ error }}
  • + {% endfor %} +
+
+ {% endif %} + + {% if validation_warnings %} +
+ Warnings: +
    + {% for warning in validation_warnings %} +
  • {{ warning }}
  • + {% endfor %} +
+
+ {% endif %} +
+ {% endif %} + + {% if report %} +
+

Import Report

+

{{ report }}

+
+ {% endif %} +
+ + +{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/view_orders.html b/py_app/app/templates/view_orders.html new file mode 100644 index 0000000..18c5544 --- /dev/null +++ b/py_app/app/templates/view_orders.html @@ -0,0 +1,266 @@ +{% extends "base.html" %} +{% block title %}View Uploaded Orders{% endblock %} +{% block content %} +
+ +
+

List Uploaded Orders

+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+
+ +
+ +
+
+
+
+ + +
+ {% if orders %} +

Uploaded Orders ({{ orders|length }} total)

+ {% else %} +

No orders uploaded yet

+ {% endif %} + +
+ {% if orders %} + + + + + + + + + + + + + + + + + + + + {% for order in orders %} + + + + + + + + + + + + + + + + {% endfor %} + +
IDComanda ProductieCod ArticolDescr. Com. ProdCantitateCom.Achiz.ClientNr. LinieCustomer NameCustomer Art. Nr.Open OrderLinePrintedCreated
{{ order.id }}{{ order.comanda_productie }}{{ order.cod_articol or '-' }}{{ order.descr_com_prod }}{{ order.cantitate }}{{ order.com_achiz_client or '-' }}{{ order.nr_linie_com_client or '-' }}{{ order.customer_name or '-' }}{{ order.customer_article_number or '-' }}{{ order.open_for_order or '-' }}{{ order.line_number or '-' }} + {% if order.printed_labels == 1 %} + āœ“ Yes + {% else %} + āœ— No + {% endif %} + + {% if order.created_at %} + {{ order.created_at.strftime('%Y-%m-%d %H:%M') }} + {% else %} + - + {% endif %} +
+ {% else %} +
+
šŸ“¦
+

No Orders Found

+

Upload your first CSV file to see orders here.

+ +
+ {% endif %} +
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/sample_orders.csv b/sample_orders.csv new file mode 100644 index 0000000..8480e6a --- /dev/null +++ b/sample_orders.csv @@ -0,0 +1,6 @@ +Comanda Productie,Cod Articol,Descr. Com. Prod,Cantitate,Com.Achiz.Client,Nr. Linie com. Client,Customer Name,Customer Article Number,Open for order,Line +CP001234,ART001,Sample Production Order 1,100,CLIENT-PO-001,1,ABC Company Ltd,CUST-ART-001,Yes,1 +CP001235,ART002,Sample Production Order 2,150,CLIENT-PO-002,2,XYZ Corporation,CUST-ART-002,Yes,1 +CP001236,ART003,Sample Production Order 3,75,CLIENT-PO-003,1,DEF Industries,CUST-ART-003,No,2 +CP001237,ART004,Sample Production Order 4,200,CLIENT-PO-004,3,GHI Manufacturing,CUST-ART-004,Yes,1 +CP001238,ART005,Sample Production Order 5,50,CLIENT-PO-005,1,JKL Enterprises,CUST-ART-005,Yes,3 \ No newline at end of file