update views and orders

This commit is contained in:
2025-10-04 09:37:10 +03:00
parent 395433d4c3
commit e1438a476b
6 changed files with 228 additions and 3001 deletions

View File

@@ -3,8 +3,8 @@
{% block head %}
<style>
/* COMPLETE OVERRIDE FOR UPLOAD ORDERS TABLE - Maximum Specificity */
table.upload-orders-table.scan-table {
/* VIEW ORDERS TABLE - Specific styling (copied from view_orders.html) */
table.view-orders-table.scan-table {
margin: 0 !important;
border-spacing: 0 !important;
border-collapse: collapse !important;
@@ -12,24 +12,8 @@ table.upload-orders-table.scan-table {
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;
table.view-orders-table.scan-table thead th {
height: 85px !important;
min-height: 85px !important;
max-height: 85px !important;
vertical-align: middle !important;
@@ -49,9 +33,7 @@ table.upload-orders-table.scan-table thead th {
text-overflow: clip !important;
position: relative !important;
}
/* BODY CELL STYLES */
table.upload-orders-table.scan-table tbody td {
table.view-orders-table.scan-table tbody td {
padding: 4px 2px !important;
font-size: 10px !important;
text-align: center !important;
@@ -61,72 +43,30 @@ table.upload-orders-table.scan-table tbody td {
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 {
table.view-orders-table.scan-table td:nth-child(1) { width: 50px !important; }
table.view-orders-table.scan-table td:nth-child(2) { width: 80px !important; }
table.view-orders-table.scan-table td:nth-child(3) { width: 80px !important; }
table.view-orders-table.scan-table td:nth-child(4) { width: 150px !important; }
table.view-orders-table.scan-table td:nth-child(5) { width: 70px !important; }
table.view-orders-table.scan-table td:nth-child(6) { width: 80px !important; }
table.view-orders-table.scan-table td:nth-child(7) { width: 75px !important; }
table.view-orders-table.scan-table td:nth-child(8) { width: 90px !important; }
table.view-orders-table.scan-table td:nth-child(9) { width: 70px !important; }
table.view-orders-table.scan-table td:nth-child(10) { width: 100px !important; }
table.view-orders-table.scan-table td:nth-child(11) { width: 90px !important; }
table.view-orders-table.scan-table td:nth-child(12) { width: 70px !important; }
table.view-orders-table.scan-table td:nth-child(13) { width: 50px !important; }
table.view-orders-table.scan-table td:nth-child(14) { width: 70px !important; }
table.view-orders-table.scan-table td:nth-child(15) { width: 100px !important; }
table.view-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;
.report-table-card h3 {
margin: 0 0 15px 0 !important;
padding: 0 !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;
.report-table-card {
padding: 15px !important;
}
</style>
{% endblock %}
@@ -135,15 +75,22 @@ table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
<div class="scan-container">
<!-- Upload Orders Card (first, fixed position) -->
<div class="card scan-form-card" style="margin-bottom: 24px;">
<h3>Upload Order Data for Labels</h3>
{% if leftover_description %}
<h3>Left over orders</h3>
<div style="color: #dc3545; font-weight: bold; margin-bottom: 10px;">{{ leftover_description }}</div>
{% else %}
<h3>Upload Order Data for Labels</h3>
{% endif %}
<form method="POST" enctype="multipart/form-data" class="form-centered" id="csv-upload-form">
<label for="csv_file">Choose CSV file:</label>
{% if not orders %}
{% if leftover_description %}
<button type="submit" class="btn btn-danger" name="clear_table" value="1">Clear Table</button>
{% elif not orders %}
<input type="file" name="csv_file" accept=".csv" required><br>
<button type="submit" class="btn">Upload & Preview</button>
<button type="submit" class="btn">Upload & Review</button>
{% else %}
<label style="font-weight: bold;">Selected file: {{ session['csv_filename'] if session['csv_filename'] else 'Unknown' }}</label><br>
<button type="button" class="btn" onclick="showPopupAndSubmit()">Save to Database</button>
<button type="button" class="btn" onclick="showPopupAndSubmit()">Upload to Database</button>
{% endif %}
</form>
@@ -177,11 +124,16 @@ table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
</div>
<!-- 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 upload-orders-table">
<div class="card scan-table-card{% if leftover_description %} leftover-table-card{% endif %}" style="margin-bottom: 24px; max-height: 480px; overflow-y: auto;">
{% if leftover_description %}
<h3>Left over orders</h3>
{% else %}
<h3>Preview Table</h3>
{% endif %}
<table class="scan-table view-orders-table{% if leftover_description %} leftover-table{% endif %}">
<thead>
<tr>
<th>ID</th>
<th>Comanda<br>Productie</th>
<th>Cod<br>Articol</th>
<th>Descr. Com.<br>Prod</th>
@@ -189,11 +141,13 @@ table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
<th>Data<br>Livrare</th>
<th>Dimensiune</th>
<th>Com.Achiz.<br>Client</th>
<th>Nr. Linie com.<br>Client</th>
<th>Nr.<br>Linie</th>
<th>Customer<br>Name</th>
<th>Customer Article<br>Number</th>
<th>Open for<br>order</th>
<th>Customer<br>Art. Nr.</th>
<th>Open<br>Order</th>
<th>Line</th>
<th>Printed</th>
<th>Created</th>
</tr>
</thead>
<tbody>
@@ -201,62 +155,77 @@ table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
{% 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('id', '') }}</td>
<td><strong>{{ order.get('comanda_productie', '') }}</strong></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>
<td>{{ order.get('customer_article_number', '') }}</td>
<td>{{ order.get('open_for_order', '') }}</td>
<td>{{ order.get('line_number', '') }}</td>
<td style="text-align: right; font-weight: 600;">{{ order.get('cantitate', '') }}</td>
<td style="text-align: center;">{{ order.get('data_livrare', '') }}</td>
<td style="text-align: center;">{{ order.get('dimensiune', '-') }}</td>
<td>{{ order.get('com_achiz_client', '-') }}</td>
<td style="text-align: right;">{{ order.get('nr_linie_com_client', '-') }}</td>
<td>{{ order.get('customer_name', '-') }}</td>
<td>{{ order.get('customer_article_number', '-') }}</td>
<td>{{ order.get('open_for_order', '-') }}</td>
<td style="text-align: right;">{{ order.get('line_number', '-') }}</td>
<td style="text-align: center;">
{% if order.get('printed_labels', 0) == 1 %}
<span style="color: #28a745; font-weight: bold;">✓ Yes</span>
{% else %}
<span style="color: #dc3545;">✗ No</span>
{% endif %}
</td>
<td style="font-size: 11px; color: #6c757d;">{{ order.get('created_at', '-') }}</td>
</tr>
{% if order.error_message %}
<tr>
<td colspan="15" style="color: #dc3545; font-size: 12px; background: #fff3f3;">
<strong>Error:</strong> {{ order.error_message }}
</td>
</tr>
{% endif %}
{% endif %}
{% endfor %}
{% else %}
<tr><td colspan="12" style="text-align:center;">No CSV file uploaded yet.</td></tr>
<tr><td colspan="15" style="text-align:center;">No CSV file uploaded yet.</td></tr>
{% endif %}
</tbody>
</table>
</div>
{% if validation_errors or validation_warnings %}
<div class="card" style="margin-bottom: 24px;">
<h4>Validation Results</h4>
{% if validation_errors %}
<div style="color: #dc3545; margin-bottom: 16px;">
<strong>Errors found:</strong>
<ul>
{% for error in validation_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% if not leftover_description %}
<div class="card" style="margin-bottom: 24px;">
<h4>Validation Results</h4>
{% if validation_errors %}
<div style="color: #dc3545; margin-bottom: 16px;">
<strong>Errors found:</strong>
<ul>
{% for error in validation_errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if validation_warnings %}
<div style="color: #ffc107;">
<strong>Warnings:</strong>
<ul>
{% for warning in validation_warnings %}
<li>{{ warning }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% if report %}
<div class="card" style="margin-bottom: 24px;">
<h4>Import Report</h4>
<p>{{ report }}</p>
</div>
{% endif %}
{% if validation_warnings %}
<div style="color: #ffc107;">
<strong>Warnings:</strong>
<ul>
{% for warning in validation_warnings %}
<li>{{ warning }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% endif %}
{% if report %}
<div class="card" style="margin-bottom: 24px;">
<h4>Import Report</h4>
<p>{{ report }}</p>
</div>
{% endif %}
{% endif %}
</div>
<style>
@@ -341,4 +310,16 @@ table.upload-orders-table.scan-table tbody tr:has(td[colspan]:empty) {
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
</style>
<style>
/* Special style for leftover orders table to match preview table height and appearance */
.leftover-table-card {
max-height: 480px !important;
overflow-y: auto !important;
border: 2px solid #dc3545 !important;
background: #fff6f6 !important;
}
.leftover-table thead th, .leftover-table td {
background: #fff6f6 !important;
}
</style>
{% endblock %}