From 18a1c638e1f8ba72e55b1a6275ae39d828c86673 Mon Sep 17 00:00:00 2001 From: Scheianu Ionut Date: Wed, 17 Sep 2025 20:47:22 +0300 Subject: [PATCH] updated --- .gitignore | 1 + .../__pycache__/order_labels.cpython-312.pyc | Bin 15063 -> 15082 bytes py_app/app/__pycache__/routes.cpython-312.pyc | Bin 53335 -> 58358 bytes py_app/app/routes.py | 124 +++++ .../app/templates/create_template copy.html | 440 ++++++++++++++++++ py_app/app/templates/create_template.html | 78 ---- .../app/templates/import_locations_csv.html | 99 ---- py_app/app/templates/label_templates.html | 21 - py_app/app/templates/main_page_etichete.html | 5 - 9 files changed, 565 insertions(+), 203 deletions(-) create mode 100644 py_app/app/templates/create_template copy.html delete mode 100644 py_app/app/templates/create_template.html delete mode 100644 py_app/app/templates/import_locations_csv.html delete mode 100644 py_app/app/templates/label_templates.html diff --git a/.gitignore b/.gitignore index b7ec88f..42b08bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ recticel/ .venv/ __pycache__/ +app/__pycache__/ diff --git a/py_app/app/__pycache__/order_labels.cpython-312.pyc b/py_app/app/__pycache__/order_labels.cpython-312.pyc index 2d88b5301c98f16b856fd2200ec362d7973a0766..07c12415b7e9474b87ea5b5b5fcb5b2d9c5fc76f 100644 GIT binary patch delta 59 zcmca!`l^)oG%qg~0}vG5J(ZEYk$08|qvGThB7X#Q6bgzm^GZ@v;&T#{QgezoFA?Qt OWY$qI*t}j$Lj?eTuoO%H delta 38 tcmaD=dcBnQG%qg~0}!wTpU8;V$U94fk#F(}kw2Tah;lP-J|w200s#6;46FbE diff --git a/py_app/app/__pycache__/routes.cpython-312.pyc b/py_app/app/__pycache__/routes.cpython-312.pyc index 702debeaf34d8001cedd33278bd54033c9aa2371..b71b5fbd5ca0be304f843d29258a969639b4077d 100644 GIT binary patch delta 7510 zcmcIp3wTsTmcG@m^fR4K=S`a25R%Y&5}pwuAtoVYAc-NMqCnI1y&(-rcec7iAarPE zeFcpYtaX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K2o;4Ux% zYfAxg0hxn&kn({UY`h?Hk0aAKvWp{sI1+&4h&e*f5loI?aO|CLqkA7FhV2rf_z&`K P)Z(vY25Wn6J;DA1^6px9 diff --git a/py_app/app/routes.py b/py_app/app/routes.py index 1fc519b..d45cf74 100644 --- a/py_app/app/routes.py +++ b/py_app/app/routes.py @@ -939,6 +939,130 @@ def label_templates(): def create_template(): return render_template('create_template.html') +@bp.route('/get_database_tables', methods=['GET']) +def get_database_tables(): + """Get list of database tables for template creation""" + if 'role' not in session or session['role'] not in ['superadmin', 'warehouse_manager', 'etichete']: + return jsonify({'error': 'Access denied'}), 403 + + try: + # Get database connection using the same method as other functions + 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 + + connection = mariadb.connect( + user=settings['username'], + password=settings['password'], + host=settings['server_domain'], + port=int(settings['port']), + database=settings['database_name'] + ) + + cursor = connection.cursor() + + # Get all tables in the database + cursor.execute("SHOW TABLES") + all_tables = [table[0] for table in cursor.fetchall()] + + # Filter to show relevant tables (prioritize order_for_labels) + relevant_tables = [] + if 'order_for_labels' in all_tables: + relevant_tables.append('order_for_labels') + + # Add other potentially relevant tables + for table in all_tables: + if table not in relevant_tables and any(keyword in table.lower() for keyword in ['order', 'label', 'product', 'customer']): + relevant_tables.append(table) + + connection.close() + + return jsonify({ + 'success': True, + 'tables': relevant_tables, + 'recommended': 'order_for_labels' + }) + + except Exception as e: + return jsonify({'error': f'Database error: {str(e)}'}), 500 + +@bp.route('/get_table_columns/', methods=['GET']) +def get_table_columns(table_name): + """Get column names and descriptions for a specific table""" + if 'role' not in session or session['role'] not in ['superadmin', 'warehouse_manager', 'etichete']: + return jsonify({'error': 'Access denied'}), 403 + + try: + # Get database connection + 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 + + connection = mariadb.connect( + user=settings['username'], + password=settings['password'], + host=settings['server_domain'], + port=int(settings['port']), + database=settings['database_name'] + ) + + cursor = connection.cursor() + + # Verify table exists + cursor.execute("SHOW TABLES LIKE %s", (table_name,)) + if not cursor.fetchone(): + return jsonify({'error': f'Table {table_name} not found'}), 404 + + # Get column information + cursor.execute(f"DESCRIBE {table_name}") + columns_info = cursor.fetchall() + + columns = [] + for col_info in columns_info: + column_name = col_info[0] + column_type = col_info[1] + is_nullable = col_info[2] == 'YES' + column_default = col_info[4] + + # Get column comment if available + cursor.execute(f""" + SELECT COLUMN_COMMENT + FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_NAME = %s AND COLUMN_NAME = %s AND TABLE_SCHEMA = DATABASE() + """, (table_name, column_name)) + + comment_result = cursor.fetchone() + column_comment = comment_result[0] if comment_result and comment_result[0] else '' + + # Create user-friendly description + description = column_comment or column_name.replace('_', ' ').title() + + columns.append({ + 'name': column_name, + 'type': column_type, + 'nullable': is_nullable, + 'default': column_default, + 'description': description, + 'field_id': f"db_{column_name}" # Unique ID for template fields + }) + + connection.close() + + return jsonify({ + 'success': True, + 'table': table_name, + 'columns': columns + }) + + except Exception as e: + return jsonify({'error': f'Database error: {str(e)}'}), 500 + @bp.route('/edit_template/') def edit_template(template_id): # Logic for editing a template will go here diff --git a/py_app/app/templates/create_template copy.html b/py_app/app/templates/create_template copy.html new file mode 100644 index 0000000..7df0164 --- /dev/null +++ b/py_app/app/templates/create_template copy.html @@ -0,0 +1,440 @@ +{% extends "base.html" %} + +{% block title %}Create Template{% endblock %} + +{% block head %} + +{% endblock %} + +{% block content %} +
+ +
+
+

Template Settings

+

Set the dimensions and retrieve database headers for the label template:

+ + +
+

Dimensions

+
+
+ + +
+
+ + +
+ +
+
+ +
+ + +
+

Add Fields

+ + .big-card { + box-shadow: 0 4px 12px rgba(0,0,0,0.12); + border-radius: 10px; + padding: 30px 24px; + min-height: 600px; + background: #f5faff; + } + .small-card { + box-shadow: 0 2px 6px rgba(0,0,0,0.10); + border-radius: 10px; + padding: 18px 12px; + min-height: 300px; + background: #fff; + } + + + +
+ +
+

Get Database Headers

+

Retrieve column names from a selected database table:

+ +
+ +
+
+ +
+
+ +
+ + +
+
+ + +
+
+

Interactive Label Preview

+

Drag and drop fields to design your label:

+
+
+ +
+
+ +
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/create_template.html b/py_app/app/templates/create_template.html deleted file mode 100644 index 0802da5..0000000 --- a/py_app/app/templates/create_template.html +++ /dev/null @@ -1,78 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Create Template{% endblock %} - -{% block content %} -
- -
-
-

Template Settings

-

Set the dimensions and retrieve database headers for the label template:

- - -
-

Dimensions

-
-
- - -
-
- - -
- -
-
- -
- - -
-

Add Fields

- - - - -
- -
-

Get Database Headers

-

Retrieve column names from a selected database table:

- -
- -
-
- -
-
- -
- - -
-
- - -
-
-

Interactive Label Preview

-

Drag and drop fields to design your label:

-
-
- -
-
- -
-
-
- - - -{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/import_locations_csv.html b/py_app/app/templates/import_locations_csv.html deleted file mode 100644 index 1d287d8..0000000 --- a/py_app/app/templates/import_locations_csv.html +++ /dev/null @@ -1,99 +0,0 @@ -{% extends "base.html" %} -{% block title %}Import Warehouse Locations from CSV{% endblock %} -{% block content %} -
- -
-

Import Locations from CSV

-
- - {% if not locations %} -
- - {% else %} -
- - {% endif %} - -
-

CSV File Format

- - - - - - - - - - - - - - - - -
Location CodeSizeDescription
EX123100Zona depozitare A
-
-
- - - -
- -
-

Preview Table

- - - - - - - - - - {% if locations %} - {% for loc in locations %} - - - - - - {% endfor %} - {% else %} - - {% endif %} - -
Location CodeSizeDescription
{{ loc[0] }}{{ loc[1] }}{{ loc[2] }}
No CSV file uploaded yet.
-
- {% if report %} -
-

Import Report

-

{{ report }}

-
- {% endif %} -
-{% endblock %} diff --git a/py_app/app/templates/label_templates.html b/py_app/app/templates/label_templates.html deleted file mode 100644 index 0a167f4..0000000 --- a/py_app/app/templates/label_templates.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Label Templates{% endblock %} - -{% block content %} -
-
-

List of Label Templates

-
    - {% for template in templates %} -
  • - {{ template.name }} - - -
  • - {% endfor %} -
- -
-
-{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/main_page_etichete.html b/py_app/app/templates/main_page_etichete.html index 311e1fd..cdfd254 100644 --- a/py_app/app/templates/main_page_etichete.html +++ b/py_app/app/templates/main_page_etichete.html @@ -24,11 +24,6 @@ -
-

Manage Label Templates

-

Manage and configure label templates.

- Manage Templates -
{% endblock %} \ No newline at end of file