344 lines
12 KiB
HTML
344 lines
12 KiB
HTML
{% 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) -->
|
|
<div class="card scan-form-card" style="margin-bottom: 24px;">
|
|
<h3>Upload Order Data for Labels</h3>
|
|
<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 %}
|
|
<input type="file" name="csv_file" accept=".csv" required><br>
|
|
<button type="submit" class="btn">Upload & Preview</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>
|
|
{% endif %}
|
|
</form>
|
|
|
|
<!-- Popup Modal -->
|
|
<div id="popup-modal" class="popup" style="display:none; position:fixed; top:0; left:0; width:100vw; height:100vh; background:var(--app-overlay-bg, rgba(30,41,59,0.85)); z-index:9999; align-items:center; justify-content:center;">
|
|
<div class="popup-content" style="margin:auto; padding:32px; border-radius:8px; box-shadow:0 2px 8px #333; min-width:320px; max-width:400px; text-align:center;">
|
|
<h3 style="color:var(--app-label-text);">Saving orders to database...</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function showPopupAndSubmit() {
|
|
document.getElementById('popup-modal').style.display = 'flex';
|
|
// Submit the form after showing popup
|
|
setTimeout(function() {
|
|
var form = document.getElementById('csv-upload-form');
|
|
var input = document.createElement('input');
|
|
input.type = 'hidden';
|
|
input.name = 'save_to_database';
|
|
input.value = '1';
|
|
form.appendChild(input);
|
|
form.submit();
|
|
}, 500);
|
|
}
|
|
window.onload = function() {
|
|
if (window.location.hash === '#saved') {
|
|
document.getElementById('popup-modal').style.display = 'none';
|
|
}
|
|
}
|
|
</script>
|
|
</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">
|
|
<thead>
|
|
<tr>
|
|
<th>Comanda<br>Productie</th>
|
|
<th>Cod<br>Articol</th>
|
|
<th>Descr. Com.<br>Prod</th>
|
|
<th>Cantitate</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>
|
|
<td>{{ order.get('customer_article_number', '') }}</td>
|
|
<td>{{ order.get('open_for_order', '') }}</td>
|
|
<td>{{ order.get('line_number', '') }}</td>
|
|
</tr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% else %}
|
|
<tr><td colspan="12" 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>
|
|
</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 %}
|
|
</div>
|
|
|
|
<style>
|
|
/* 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: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:not(.upload-orders-table) th {
|
|
font-size: 10px !important;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.3px;
|
|
}
|
|
|
|
/* 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: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: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: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:not(.upload-orders-table) th:nth-child(5),
|
|
.scan-table:not(.upload-orders-table) td:nth-child(5) {
|
|
max-width: 90px;
|
|
min-width: 90px;
|
|
}
|
|
|
|
/* Ensure table container fits */
|
|
.scan-table-card {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
/* Hover effects for NON-upload-orders tables */
|
|
.scan-table:not(.upload-orders-table) tbody tr:hover td {
|
|
background-color: #f8f9fa !important;
|
|
position: relative;
|
|
}
|
|
|
|
.scan-table:not(.upload-orders-table) td {
|
|
cursor: help;
|
|
}
|
|
|
|
.scan-table:not(.upload-orders-table) td:hover {
|
|
overflow: visible;
|
|
white-space: normal;
|
|
word-wrap: break-word;
|
|
z-index: 10;
|
|
position: relative;
|
|
background-color: #fff3cd !important;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
}
|
|
</style>
|
|
{% endblock %} |