updated correct label and collumns in te database for label

This commit is contained in:
2025-09-18 21:56:31 +03:00
parent dfc60a9725
commit 282d311e6a
7 changed files with 437 additions and 138 deletions

View File

@@ -68,6 +68,22 @@ def validate_order_row(row_data):
except ValueError:
errors.append(f"{field} must be a valid number")
# Validate data_livrare (optional date field)
data_livrare = row_data.get('data_livrare', '').strip()
if data_livrare:
try:
# Try to parse common date formats
for date_format in ['%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y', '%d.%m.%Y']:
try:
datetime.strptime(data_livrare, date_format)
break
except ValueError:
continue
else:
errors.append("data_livrare must be a valid date (YYYY-MM-DD, DD/MM/YYYY, MM/DD/YYYY, or DD.MM.YYYY)")
except Exception:
errors.append("data_livrare date format error")
# Validate string length limits
field_limits = {
'comanda_productie': 15,
@@ -96,11 +112,29 @@ def add_order_to_database(order_data):
cursor = conn.cursor()
# Prepare data with proper types and limits
# Handle date conversion for data_livrare
data_livrare_value = None
data_livrare_str = order_data.get('data_livrare', '').strip()
if data_livrare_str:
try:
# Try to parse common date formats and convert to YYYY-MM-DD
for date_format in ['%Y-%m-%d', '%d/%m/%Y', '%m/%d/%Y', '%d.%m.%Y']:
try:
parsed_date = datetime.strptime(data_livrare_str, date_format)
data_livrare_value = parsed_date.strftime('%Y-%m-%d')
break
except ValueError:
continue
except Exception:
pass # Leave as None if parsing fails
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)),
'data_livrare': data_livrare_value,
'dimensiune': order_data.get('dimensiune', '').strip()[:10] or None,
'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,
@@ -111,10 +145,10 @@ def add_order_to_database(order_data):
sql = """
INSERT INTO order_for_labels
(comanda_productie, cod_articol, descr_com_prod, cantitate,
(comanda_productie, cod_articol, descr_com_prod, cantitate, data_livrare, dimensiune,
com_achiz_client, nr_linie_com_client, customer_name,
customer_article_number, open_for_order, line_number, printed_labels)
VALUES (%(comanda_productie)s, %(cod_articol)s, %(descr_com_prod)s, %(cantitate)s,
VALUES (%(comanda_productie)s, %(cod_articol)s, %(descr_com_prod)s, %(cantitate)s, %(data_livrare)s, %(dimensiune)s,
%(com_achiz_client)s, %(nr_linie_com_client)s, %(customer_name)s,
%(customer_article_number)s, %(open_for_order)s, %(line_number)s, 0)
"""
@@ -156,6 +190,9 @@ def process_csv_file(file_path):
'cod articol': 'cod_articol',
'descr. com. prod': 'descr_com_prod',
'cantitate': 'cantitate',
'datalivrare': 'data_livrare',
'data livrare': 'data_livrare',
'dimensiune': 'dimensiune',
'com.achiz.client': 'com_achiz_client',
'nr. linie com. client': 'nr_linie_com_client',
'customer name': 'customer_name',
@@ -279,7 +316,7 @@ def upload_orders_handler():
flash(report, "success" if failed_count == 0 else "warning")
return redirect(url_for('main.upload_orders') + '#imported')
return redirect(url_for('main.view_orders'))
# Load data from session if available
elif 'orders_csv_data' in session:
@@ -304,7 +341,7 @@ def get_orders_from_database(limit=100):
cursor.execute("""
SELECT id, comanda_productie, cod_articol, descr_com_prod, cantitate,
com_achiz_client, nr_linie_com_client, customer_name,
data_livrare, dimensiune, 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
@@ -320,15 +357,17 @@ def get_orders_from_database(limit=100):
'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]
'data_livrare': row[5],
'dimensiune': row[6],
'com_achiz_client': row[7],
'nr_linie_com_client': row[8],
'customer_name': row[9],
'customer_article_number': row[10],
'open_for_order': row[11],
'line_number': row[12],
'printed_labels': row[13],
'created_at': row[14],
'updated_at': row[15]
})
conn.close()

View File

@@ -34,7 +34,7 @@ def get_unprinted_orders_data(limit=100):
# Use printed_labels column
cursor.execute("""
SELECT id, comanda_productie, cod_articol, descr_com_prod, cantitate,
com_achiz_client, nr_linie_com_client, customer_name,
data_livrare, dimensiune, 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
@@ -46,7 +46,7 @@ def get_unprinted_orders_data(limit=100):
# Fallback: get all orders if no printed_labels column
cursor.execute("""
SELECT id, comanda_productie, cod_articol, descr_com_prod, cantitate,
com_achiz_client, nr_linie_com_client, customer_name,
data_livrare, dimensiune, com_achiz_client, nr_linie_com_client, customer_name,
customer_article_number, open_for_order, line_number,
created_at, updated_at
FROM order_for_labels
@@ -63,15 +63,17 @@ def get_unprinted_orders_data(limit=100):
'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]
'data_livrare': row[5],
'dimensiune': row[6],
'com_achiz_client': row[7],
'nr_linie_com_client': row[8],
'customer_name': row[9],
'customer_article_number': row[10],
'open_for_order': row[11],
'line_number': row[12],
'printed_labels': row[13],
'created_at': row[14],
'updated_at': row[15]
})
else:
orders.append({
@@ -80,15 +82,17 @@ def get_unprinted_orders_data(limit=100):
'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],
'data_livrare': row[5],
'dimensiune': row[6],
'com_achiz_client': row[7],
'nr_linie_com_client': row[8],
'customer_name': row[9],
'customer_article_number': row[10],
'open_for_order': row[11],
'line_number': row[12],
'printed_labels': 0, # Default to not printed
'created_at': row[11],
'updated_at': row[12]
'created_at': row[13],
'updated_at': row[14]
})
conn.close()

View File

@@ -12,9 +12,12 @@
<!-- Card 1: View Orders -->
<div class="dashboard-card">
<h3>View Orders</h3>
<p>View uploaded orders and manage label data for printing.</p>
<p>Upload new orders or view existing orders and manage label data for printing.</p>
<div style="display: flex; gap: 10px; flex-wrap: wrap;">
<a href="{{ url_for('main.upload_orders') }}" class="btn">Upload Orders</a>
<a href="{{ url_for('main.view_orders') }}" class="btn">View Orders</a>
</div>
</div>
<!-- Card 2: Launch Print Module -->
<div class="dashboard-card">

View File

@@ -23,56 +23,83 @@
INNOFA RROMANIA SRL
</div>
<!-- Second row content: Customer Name -->
<!-- Row 2 content: Customer Name -->
<div id="customer-name-row" style="position: absolute; top: 32.13px; left: 0; right: 0; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #000;">
<!-- Customer name will be populated here -->
</div>
<!-- Horizontal dividing lines for 9 parts (row 6 is double height) -->
<!-- Horizontal dividing lines for 9 rows (row 6 is double height) -->
<div style="position: absolute; top: 32.13px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 67.83px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 103.53px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 139.23px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 175.23px; left: 0; right: 0; height: 1px; background: #999;"></div>
<!-- Row 6 is double height, so no line at 210.63px -->
<div style="position: absolute; top: 246.33px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 282.03px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 64.26px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 96.39px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 128.52px; left: 0; right: 0; height: 1px; background: #999;"></div>
<div style="position: absolute; top: 160.65px; left: 0; right: 0; height: 1px; background: #999;"></div>
<!-- Row 6 is double height for Description -->
<div style="position: absolute; top: 224.91px; left: 0; right: 0; height: 1px; background: #999;"></div>
<!-- Row 7 for Size -->
<div style="position: absolute; top: 257.04px; left: 0; right: 0; height: 1px; background: #999;"></div>
<!-- Row 8 for Article Code -->
<div style="position: absolute; top: 289.17px; left: 0; right: 0; height: 1px; background: #999;"></div>
<!-- Row 9 for Prod Order (final row) -->
<!-- Row 3 content: Quantity ordered -->
<div style="position: absolute; top: 67.83px; left: 0; width: 90.96px; height: 35.7px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
<div style="position: absolute; top: 64.26px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Quantity ordered
</div>
<div id="quantity-ordered-value" style="position: absolute; top: 67.83px; left: 90.96px; width: 136.44px; height: 35.7px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #000;">
<div id="quantity-ordered-value" style="position: absolute; top: 64.26px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: bold; color: #000;">
<!-- Quantity value will be populated here -->
</div>
<!-- Row 4 content: Client Order Info -->
<div id="client-order-info" style="position: absolute; top: 103.53px; left: 90.96px; width: 136.44px; height: 35.7px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #000;">
<!-- Client order info will be populated here -->
</div>
<!-- Row 4 content: Customer order -->
<div style="position: absolute; top: 103.53px; left: 0; width: 90.96px; height: 35.7px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
<div style="position: absolute; top: 96.39px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Customer order
</div>
<div id="client-order-info" style="position: absolute; top: 96.39px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #000;">
<!-- Client order info will be populated here -->
</div>
<!-- Row 5 content: Delivery date -->
<div style="position: absolute; top: 139.23px; left: 0; width: 90.96px; height: 35.7px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
<div style="position: absolute; top: 128.52px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Delivery date
</div>
<div id="delivery-date-value" style="position: absolute; top: 139.23px; left: 90.96px; width: 136.44px; height: 35.7px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #000;">
<div id="delivery-date-value" style="position: absolute; top: 128.52px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #000;">
<!-- Delivery date value will be populated here -->
</div>
<!-- Row 6 content: Description (double height row) -->
<div style="position: absolute; top: 174.93px; left: 0; width: 90.96px; height: 71.4px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
<div style="position: absolute; top: 160.65px; left: 0; width: 90.96px; height: 64.26px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Description
</div>
<div id="description-value" style="position: absolute; top: 174.93px; left: 90.96px; width: 136.44px; height: 71.4px; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #000; text-align: center; line-height: 1.2; padding: 2px; overflow: hidden; word-wrap: break-word;">
<div id="description-value" style="position: absolute; top: 160.65px; left: 90.96px; width: 136.44px; height: 64.26px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #000; text-align: center; line-height: 1.2; padding: 2px; overflow: hidden; word-wrap: break-word;">
<!-- Description value will be populated here -->
</div>
<!-- Row 7 content: Size -->
<div style="position: absolute; top: 224.91px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Size
</div>
<div id="size-value" style="position: absolute; top: 224.91px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #000;">
<!-- Size value will be populated here -->
</div>
<!-- Row 8 content: Article Code -->
<div style="position: absolute; top: 257.04px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Article Code
</div>
<div id="article-code-value" style="position: absolute; top: 257.04px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #000;">
<!-- Article code value will be populated here -->
</div>
<!-- Row 9 content: Prod Order (final row) -->
<div style="position: absolute; top: 289.17px; left: 0; width: 90.96px; height: 32.13px; display: flex; align-items: center; padding-left: 5px; font-size: 10px; color: #000;">
Prod Order
</div>
<div id="prod-order-value" style="position: absolute; top: 289.17px; left: 90.96px; width: 136.44px; height: 32.13px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: #000;">
<!-- Prod order value will be populated here -->
</div>
</div>
</div>
</div>
@@ -90,6 +117,8 @@
<th>Cod Articol</th>
<th>Descr. Com. Prod</th>
<th>Cantitate</th>
<th>Data<br>Livrare</th>
<th>Dimensiune</th>
<th>Com.Achiz.Client</th>
<th>Nr. Linie</th>
<th>Customer Name</th>
@@ -123,6 +152,10 @@ document.getElementById('check-db-btn').addEventListener('click', function() {
<td>${order.cod_articol || '-'}</td>
<td>${order.descr_com_prod}</td>
<td style="text-align: right; font-weight: 600;">${order.cantitate}</td>
<td style="text-align: center;">
${order.data_livrare ? new Date(order.data_livrare).toLocaleDateString() : '-'}
</td>
<td style="text-align: center;">${order.dimensiune || '-'}</td>
<td>${order.com_achiz_client || '-'}</td>
<td style="text-align: right;">${order.nr_linie_com_client || '-'}</td>
<td>${order.customer_name || '-'}</td>
@@ -156,19 +189,36 @@ document.getElementById('check-db-btn').addEventListener('click', function() {
const clientOrderInfo = comAchizClient && nrLinie ? `${comAchizClient}-${nrLinie}` : 'N/A';
document.getElementById('client-order-info').textContent = clientOrderInfo;
// Update delivery date (using created_at as placeholder since delivery_date column doesn't exist)
const deliveryDate = data[0].created_at ? new Date(data[0].created_at).toLocaleDateString() : 'N/A';
// Update delivery date (using data_livrare column)
const deliveryDate = data[0].data_livrare ? new Date(data[0].data_livrare).toLocaleDateString() : 'N/A';
document.getElementById('delivery-date-value').textContent = deliveryDate;
// Update size (using dimensiune column)
const size = data[0].dimensiune || 'N/A';
document.getElementById('size-value').textContent = size;
// Update description (Descr. Com. Prod)
const description = data[0].descr_com_prod || 'N/A';
document.getElementById('description-value').textContent = description;
// Update article code (using customer_article_number column)
const articleCode = data[0].customer_article_number || 'N/A';
document.getElementById('article-code-value').textContent = articleCode;
// Update prod order (comanda_productie - cantitate)
const comandaProductie = data[0].comanda_productie || '';
const cantitate = data[0].cantitate || '';
const prodOrder = comandaProductie && cantitate ? `${comandaProductie}-${cantitate}` : 'N/A';
document.getElementById('prod-order-value').textContent = prodOrder;
} else {
document.getElementById('customer-name-row').textContent = 'No data available';
document.getElementById('quantity-ordered-value').textContent = '0';
document.getElementById('client-order-info').textContent = 'N/A';
document.getElementById('delivery-date-value').textContent = 'N/A';
document.getElementById('size-value').textContent = 'N/A';
document.getElementById('description-value').textContent = 'N/A';
document.getElementById('article-code-value').textContent = 'N/A';
document.getElementById('prod-order-value').textContent = 'N/A';
}
})
.catch(error => {
@@ -177,7 +227,10 @@ document.getElementById('check-db-btn').addEventListener('click', function() {
document.getElementById('quantity-ordered-value').textContent = 'Error';
document.getElementById('client-order-info').textContent = 'Error';
document.getElementById('delivery-date-value').textContent = 'Error';
document.getElementById('size-value').textContent = 'Error';
document.getElementById('description-value').textContent = 'Error';
document.getElementById('article-code-value').textContent = 'Error';
document.getElementById('prod-order-value').textContent = 'Error';
});
});
</script>

View File

@@ -1,5 +1,136 @@
{% extends "base.html" %}
{% block title %}Upload Order Data for Labels{% endblock %}
{% block head %}
<style>
/* COMPLETE OVERRIDE FOR UPLOAD ORDERS TABLE - Maximum Specificity */
table.upload-orders-table.scan-table {
margin: 0 !important;
border-spacing: 0 !important;
border-collapse: collapse !important;
width: 100% !important;
table-layout: fixed !important;
font-size: 11px !important;
}
/* REMOVE ALL SPACING AROUND THE TABLE CARD */
.scan-table-card {
padding: 15px !important;
}
.scan-table-card h3 {
margin: 0 0 15px 0 !important;
padding: 0 !important;
}
.scan-table-card > * {
margin-top: 0 !important;
}
/* HEADER STYLES - Ultra specific to prevent overrides */
table.upload-orders-table.scan-table thead th {
height: 200px !important;
min-height: 85px !important;
max-height: 85px !important;
vertical-align: middle !important;
text-align: center !important;
white-space: normal !important;
word-wrap: break-word !important;
line-height: 1.3 !important;
padding: 6px 3px !important;
font-size: 11px !important;
background-color: #e9ecef !important;
font-weight: bold !important;
text-transform: none !important;
letter-spacing: 0 !important;
overflow: visible !important;
box-sizing: border-box !important;
border: 1px solid #ddd !important;
text-overflow: clip !important;
position: relative !important;
}
/* BODY CELL STYLES */
table.upload-orders-table.scan-table tbody td {
padding: 4px 2px !important;
font-size: 10px !important;
text-align: center !important;
border: 1px solid #ddd !important;
white-space: nowrap !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
vertical-align: middle !important;
}
/* SPECIFIC COLUMN WIDTHS - Ultra specific selectors */
table.upload-orders-table.scan-table th:nth-child(1),
table.upload-orders-table.scan-table td:nth-child(1) { width: 45px !important; } /* Comanda Productie */
table.upload-orders-table.scan-table th:nth-child(2),
table.upload-orders-table.scan-table td:nth-child(2) { width: 65px !important; } /* Cod Articol */
table.upload-orders-table.scan-table th:nth-child(3),
table.upload-orders-table.scan-table td:nth-child(3) { width: 110px !important; } /* Descr. Com. Prod */
table.upload-orders-table.scan-table th:nth-child(4),
table.upload-orders-table.scan-table td:nth-child(4) { width: 55px !important; text-align: right !important; } /* Cantitate */
table.upload-orders-table.scan-table th:nth-child(5),
table.upload-orders-table.scan-table td:nth-child(5) { width: 70px !important; } /* Data Livrare */
table.upload-orders-table.scan-table th:nth-child(6),
table.upload-orders-table.scan-table td:nth-child(6) { width: 75px !important; } /* Dimensiune */
table.upload-orders-table.scan-table th:nth-child(8),
table.upload-orders-table.scan-table td:nth-child(8) { width: 80px !important; } /* Nr. Linie com. Client */
table.upload-orders-table.scan-table th:nth-child(9),
table.upload-orders-table.scan-table td:nth-child(9) { width: 90px !important; } /* Customer Name */
table.upload-orders-table.scan-table th:nth-child(10),
table.upload-orders-table.scan-table td:nth-child(10) { width: 85px !important; } /* Customer Article Number */
table.upload-orders-table.scan-table th:nth-child(11),
table.upload-orders-table.scan-table td:nth-child(11) { width: 60px !important; } /* Open for order */
table.upload-orders-table.scan-table th:nth-child(12),
table.upload-orders-table.scan-table td:nth-child(12) { width: 40px !important; } /* Line */
/* HOVER EFFECTS */
table.upload-orders-table.scan-table tbody tr:hover td {
background-color: #f8f9fa !important;
}
/* REMOVE EMPTY ROWS */
table.upload-orders-table.scan-table tbody tr:empty {
display: none !important;
}
table.upload-orders-table.scan-table tbody tr td:empty:only-child {
display: none !important;
}
table.upload-orders-table.scan-table tbody tr:has(td:empty:only-child) {
display: none !important;
}
/* Hide rows that contain only a single empty cell */
table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
display: none !important;
}
/* REMOVE UNWANTED SPACING IN PREVIEW CARD */
.scan-table-card h3 {
margin-bottom: 10px !important;
}
.scan-table-card .scan-table {
margin-top: 0 !important;
margin-bottom: 0 !important;
}
</style>
{% endblock %}
{% block content %}
<div class="scan-container">
<!-- Upload Orders Card (first, fixed position) -->
@@ -48,29 +179,34 @@
<!-- Preview Table Card (expandable height, scrollable) -->
<div class="card scan-table-card" style="margin-bottom: 24px; max-height: 480px; overflow-y: auto;">
<h3>Preview Table</h3>
<table class="scan-table">
<table class="scan-table upload-orders-table">
<thead>
<tr>
<th>Comanda Productie</th>
<th>Cod Articol</th>
<th>Descr. Com. Prod</th>
<th>Comanda<br>Productie</th>
<th>Cod<br>Articol</th>
<th>Descr. Com.<br>Prod</th>
<th>Cantitate</th>
<th>Com.Achiz.Client</th>
<th>Nr. Linie com. Client</th>
<th>Customer Name</th>
<th>Customer Article Number</th>
<th>Open for order</th>
<th>Data<br>Livrare</th>
<th>Dimensiune</th>
<th>Com.Achiz.<br>Client</th>
<th>Nr. Linie com.<br>Client</th>
<th>Customer<br>Name</th>
<th>Customer Article<br>Number</th>
<th>Open for<br>order</th>
<th>Line</th>
</tr>
</thead>
<tbody>
{% if orders %}
{% for order in orders %}
{% if order and (order.get('comanda_productie', '') or order.get('descr_com_prod', '')) %}
<tr>
<td>{{ order.get('comanda_productie', '') }}</td>
<td>{{ order.get('cod_articol', '') }}</td>
<td>{{ order.get('descr_com_prod', '') }}</td>
<td>{{ order.get('cantitate', '') }}</td>
<td>{{ order.get('data_livrare', '') }}</td>
<td>{{ order.get('dimensiune', '') }}</td>
<td>{{ order.get('com_achiz_client', '') }}</td>
<td>{{ order.get('nr_linie_com_client', '') }}</td>
<td>{{ order.get('customer_name', '') }}</td>
@@ -78,9 +214,10 @@
<td>{{ order.get('open_for_order', '') }}</td>
<td>{{ order.get('line_number', '') }}</td>
</tr>
{% endif %}
{% endfor %}
{% else %}
<tr><td colspan="10" style="text-align:center;">No CSV file uploaded yet.</td></tr>
<tr><td colspan="12" style="text-align:center;">No CSV file uploaded yet.</td></tr>
{% endif %}
</tbody>
</table>
@@ -123,115 +260,78 @@
</div>
<style>
/* Optimize table for better content fitting */
.scan-table {
/* THESE STYLES ONLY APPLY TO OTHER TABLES, NOT UPLOAD ORDERS TABLE */
.scan-table:not(.upload-orders-table) {
font-size: 11px !important;
line-height: 1.2;
min-width: 800px;
width: 100%;
table-layout: fixed;
}
.scan-table th,
.scan-table td {
.scan-table:not(.upload-orders-table) th,
.scan-table:not(.upload-orders-table) td {
padding: 6px 4px !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.scan-table th {
.scan-table:not(.upload-orders-table) th {
font-size: 10px !important;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.3px;
}
/* Specific column width optimizations */
.scan-table th:nth-child(1), /* Comanda Productie */
.scan-table td:nth-child(1) {
max-width: 80px;
min-width: 80px;
/* Column widths for NON-upload-orders tables only */
.scan-table:not(.upload-orders-table) th:nth-child(1),
.scan-table:not(.upload-orders-table) td:nth-child(1) {
max-width: 50px;
min-width: 30px;
}
.scan-table th:nth-child(2), /* Cod Articol */
.scan-table td:nth-child(2) {
.scan-table:not(.upload-orders-table) th:nth-child(2),
.scan-table:not(.upload-orders-table) td:nth-child(2) {
max-width: 70px;
min-width: 70px;
}
.scan-table th:nth-child(3), /* Descr. Com. Prod */
.scan-table td:nth-child(3) {
.scan-table:not(.upload-orders-table) th:nth-child(3),
.scan-table:not(.upload-orders-table) td:nth-child(3) {
max-width: 120px;
min-width: 120px;
}
.scan-table th:nth-child(4), /* Cantitate */
.scan-table td:nth-child(4) {
.scan-table:not(.upload-orders-table) th:nth-child(4),
.scan-table:not(.upload-orders-table) td:nth-child(4) {
max-width: 60px;
min-width: 60px;
text-align: right;
}
.scan-table th:nth-child(5), /* Com.Achiz.Client */
.scan-table td:nth-child(5) {
.scan-table:not(.upload-orders-table) th:nth-child(5),
.scan-table:not(.upload-orders-table) td:nth-child(5) {
max-width: 90px;
min-width: 90px;
}
.scan-table th:nth-child(6), /* Nr. Linie com. Client */
.scan-table td:nth-child(6) {
max-width: 60px;
min-width: 60px;
text-align: center;
}
.scan-table th:nth-child(7), /* Customer Name */
.scan-table td:nth-child(7) {
max-width: 100px;
min-width: 100px;
}
.scan-table th:nth-child(8), /* Customer Article Number */
.scan-table td:nth-child(8) {
max-width: 80px;
min-width: 80px;
}
.scan-table th:nth-child(9), /* Open for order */
.scan-table td:nth-child(9) {
max-width: 50px;
min-width: 50px;
text-align: center;
}
.scan-table th:nth-child(10), /* Line */
.scan-table td:nth-child(10) {
max-width: 40px;
min-width: 40px;
text-align: center;
}
/* Ensure table fits in container */
/* Ensure table container fits */
.scan-table-card {
overflow-x: auto;
}
.scan-table {
min-width: 800px;
width: 100%;
table-layout: fixed;
}
/* Add hover effect for better readability */
.scan-table tbody tr:hover td {
/* Hover effects for NON-upload-orders tables */
.scan-table:not(.upload-orders-table) tbody tr:hover td {
background-color: #f8f9fa !important;
position: relative;
}
/* Tooltip on hover for truncated text */
.scan-table td {
.scan-table:not(.upload-orders-table) td {
cursor: help;
}
.scan-table td:hover {
.scan-table:not(.upload-orders-table) td:hover {
overflow: visible;
white-space: normal;
word-wrap: break-word;

View File

@@ -1,5 +1,95 @@
{% extends "base.html" %}
{% block title %}View Uploaded Orders{% endblock %}
{% block head %}
<style>
/* VIEW ORDERS TABLE - Specific styling */
table.view-orders-table.scan-table {
margin: 0 !important;
border-spacing: 0 !important;
border-collapse: collapse !important;
width: 100% !important;
table-layout: fixed !important;
font-size: 11px !important;
}
/* HEADER STYLES for 2-line text */
table.view-orders-table.scan-table thead th {
height: 85px !important;
min-height: 85px !important;
max-height: 85px !important;
vertical-align: middle !important;
text-align: center !important;
white-space: normal !important;
word-wrap: break-word !important;
line-height: 1.3 !important;
padding: 6px 3px !important;
font-size: 11px !important;
background-color: #e9ecef !important;
font-weight: bold !important;
text-transform: none !important;
letter-spacing: 0 !important;
overflow: visible !important;
box-sizing: border-box !important;
border: 1px solid #ddd !important;
text-overflow: clip !important;
position: relative !important;
}
/* BODY CELL STYLES */
table.view-orders-table.scan-table tbody td {
padding: 4px 2px !important;
font-size: 10px !important;
text-align: center !important;
border: 1px solid #ddd !important;
white-space: nowrap !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
vertical-align: middle !important;
}
/* REMOVE UNWANTED SPACING */
.report-table-card h3 {
margin: 0 0 15px 0 !important;
padding: 0 !important;
}
.report-table-card {
padding: 15px !important;
}
.report-table-card > * {
margin-top: 0 !important;
}
.report-table-container {
margin-top: 0 !important;
}
/* HOVER EFFECTS */
table.view-orders-table.scan-table tbody tr:hover td {
background-color: #f8f9fa !important;
}
/* COLUMN WIDTH SPECIFICATIONS */
table.view-orders-table.scan-table td:nth-child(1) { width: 50px !important; } /* ID */
table.view-orders-table.scan-table td:nth-child(2) { width: 80px !important; } /* Comanda Productie */
table.view-orders-table.scan-table td:nth-child(3) { width: 80px !important; } /* Cod Articol */
table.view-orders-table.scan-table td:nth-child(4) { width: 150px !important; } /* Descr Com Prod */
table.view-orders-table.scan-table td:nth-child(5) { width: 70px !important; } /* Cantitate */
table.view-orders-table.scan-table td:nth-child(6) { width: 80px !important; } /* Data Livrare */
table.view-orders-table.scan-table td:nth-child(7) { width: 75px !important; } /* Dimensiune */
table.view-orders-table.scan-table td:nth-child(8) { width: 90px !important; } /* Com Achiz Client */
table.view-orders-table.scan-table td:nth-child(9) { width: 70px !important; } /* Nr Linie */
table.view-orders-table.scan-table td:nth-child(10) { width: 100px !important; } /* Customer Name */
table.view-orders-table.scan-table td:nth-child(11) { width: 90px !important; } /* Customer Art Nr */
table.view-orders-table.scan-table td:nth-child(12) { width: 70px !important; } /* Open Order */
table.view-orders-table.scan-table td:nth-child(13) { width: 50px !important; } /* Line */
table.view-orders-table.scan-table td:nth-child(14) { width: 70px !important; } /* Printed */
table.view-orders-table.scan-table td:nth-child(15) { width: 100px !important; } /* Created */
</style>
{% endblock %}
{% block content %}
<div class="scan-container">
<!-- Orders Actions Card (first, narrower) -->
@@ -46,19 +136,21 @@
<div class="report-table-container">
{% if orders %}
<table class="scan-table">
<table class="scan-table view-orders-table">
<thead>
<tr>
<th>ID</th>
<th>Comanda Productie</th>
<th>Cod Articol</th>
<th>Descr. Com. Prod</th>
<th>Comanda<br>Productie</th>
<th>Cod<br>Articol</th>
<th>Descr. Com.<br>Prod</th>
<th>Cantitate</th>
<th>Com.Achiz.Client</th>
<th>Nr. Linie</th>
<th>Customer Name</th>
<th>Customer Art. Nr.</th>
<th>Open Order</th>
<th>Data<br>Livrare</th>
<th>Dimensiune</th>
<th>Com.Achiz.<br>Client</th>
<th>Nr.<br>Linie</th>
<th>Customer<br>Name</th>
<th>Customer<br>Art. Nr.</th>
<th>Open<br>Order</th>
<th>Line</th>
<th>Printed</th>
<th>Created</th>
@@ -72,6 +164,14 @@
<td>{{ order.cod_articol or '-' }}</td>
<td>{{ order.descr_com_prod }}</td>
<td style="text-align: right; font-weight: 600;">{{ order.cantitate }}</td>
<td style="text-align: center;">
{% if order.data_livrare %}
{{ order.data_livrare.strftime('%Y-%m-%d') if order.data_livrare is not string else order.data_livrare }}
{% else %}
-
{% endif %}
</td>
<td style="text-align: center;">{{ order.dimensiune or '-' }}</td>
<td>{{ order.com_achiz_client or '-' }}</td>
<td style="text-align: right;">{{ order.nr_linie_com_client or '-' }}</td>
<td>{{ order.customer_name or '-' }}</td>