updated to uplodad orders

This commit is contained in:
2025-09-15 21:14:48 +03:00
parent 8a7aa193dc
commit ceda2447a6
12 changed files with 1142 additions and 14 deletions

View File

@@ -9,11 +9,11 @@
<!-- Row of evenly distributed cards -->
<div class="dashboard-container">
<!-- Card 1: Upload Data -->
<!-- Card 1: View Orders -->
<div class="dashboard-card">
<h3>Upload Data</h3>
<p>Upload data into the database for label management.</p>
<a href="{{ url_for('main.upload_data') }}" class="btn">Go to Upload Data</a>
<h3>View Orders</h3>
<p>View uploaded orders and manage label data for printing.</p>
<a href="{{ url_for('main.view_orders') }}" class="btn">View Orders</a>
</div>
<!-- Card 2: Launch Print Module -->

View File

@@ -1,10 +0,0 @@
{% extends "base.html" %}
{% block title %}Upload Data{% endblock %}
{% block content %}
<div class="upload-data-container">
<h1>Upload Data</h1>
<p>This page will allow users to upload data into the database.</p>
</div>
{% endblock %}

View File

@@ -0,0 +1,244 @@
{% extends "base.html" %}
{% block title %}Upload Order Data for Labels{% 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">
<thead>
<tr>
<th>Comanda Productie</th>
<th>Cod Articol</th>
<th>Descr. Com. 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>Line</th>
</tr>
</thead>
<tbody>
{% if orders %}
{% for order in orders %}
<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('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>
{% endfor %}
{% else %}
<tr><td colspan="10" 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>
/* Optimize table for better content fitting */
.scan-table {
font-size: 11px !important;
line-height: 1.2;
}
.scan-table th,
.scan-table td {
padding: 6px 4px !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.scan-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;
}
.scan-table th:nth-child(2), /* Cod Articol */
.scan-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) {
max-width: 120px;
min-width: 120px;
}
.scan-table th:nth-child(4), /* Cantitate */
.scan-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) {
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 */
.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 {
background-color: #f8f9fa !important;
position: relative;
}
/* Tooltip on hover for truncated text */
.scan-table td {
cursor: help;
}
.scan-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 %}

View File

@@ -0,0 +1,266 @@
{% extends "base.html" %}
{% block title %}View Uploaded Orders{% endblock %}
{% block content %}
<div class="scan-container">
<!-- Orders Actions Card (first, narrower) -->
<div class="card report-form-card">
<h3>List Uploaded Orders</h3>
<!-- Orders Actions -->
<div class="reports-grid">
<div class="form-centered">
<label class="report-description">View all uploaded orders in the current day for labels generation</label>
<button class="btn report-btn" onclick="window.location.reload()">Refresh Orders List</button>
</div>
<div class="form-centered">
<label class="report-description">View all uploaded orders for labels generation</label>
<button class="btn report-btn" onclick="window.location.reload()">Fetch Orders List</button>
</div>
<div class="form-centered">
<label class="report-description">Upload new CSV file with order data</label>
<button class="btn report-btn" onclick="location.href='/upload_orders'">Upload New Orders</button>
</div>
</div>
<!-- Separator -->
<div class="report-separator"></div>
<!-- Export Section -->
<div class="export-section">
<div class="form-centered last-buttons">
<label class="export-description">Export orders as:</label>
<div class="button-row">
<button class="btn export-btn" onclick="window.print()">Print Orders</button>
</div>
</div>
</div>
</div>
<!-- Orders Table Card (second, wider) -->
<div class="card report-table-card">
{% if orders %}
<h3>Uploaded Orders ({{ orders|length }} total)</h3>
{% else %}
<h3>No orders uploaded yet</h3>
{% endif %}
<div class="report-table-container">
{% if orders %}
<table class="scan-table">
<thead>
<tr>
<th>ID</th>
<th>Comanda Productie</th>
<th>Cod Articol</th>
<th>Descr. Com. 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>Line</th>
<th>Printed</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td>{{ order.id }}</td>
<td><strong>{{ order.comanda_productie }}</strong></td>
<td>{{ order.cod_articol or '-' }}</td>
<td>{{ order.descr_com_prod }}</td>
<td style="text-align: right; font-weight: 600;">{{ order.cantitate }}</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>
<td>{{ order.customer_article_number or '-' }}</td>
<td>{{ order.open_for_order or '-' }}</td>
<td style="text-align: right;">{{ order.line_number or '-' }}</td>
<td style="text-align: center;">
{% if order.printed_labels == 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;">
{% if order.created_at %}
{{ order.created_at.strftime('%Y-%m-%d %H:%M') }}
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div style="text-align: center; padding: 40px; color: #6c757d;">
<div style="font-size: 48px; margin-bottom: 20px;">📦</div>
<h4>No Orders Found</h4>
<p>Upload your first CSV file to see orders here.</p>
<button class="btn report-btn" onclick="location.href='/upload_orders'" style="margin-top: 20px;">
Upload Orders
</button>
</div>
{% endif %}
</div>
</div>
</div>
<style>
/* View Orders Table Optimization - Higher specificity to override base styles */
.report-table-card .scan-table {
font-size: 11px !important;
line-height: 1.3 !important;
}
.report-table-card .scan-table th {
font-size: 10px !important;
padding: 8px 6px !important;
font-weight: 600 !important;
text-transform: uppercase;
letter-spacing: 0.3px;
white-space: nowrap;
}
.report-table-card .scan-table td {
padding: 6px 6px !important;
font-size: 11px !important;
line-height: 1.2 !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 150px;
}
/* Specific column optimizations for better content fitting */
.report-table-card .scan-table th:nth-child(1), /* ID */
.report-table-card .scan-table td:nth-child(1) {
max-width: 50px !important;
min-width: 50px !important;
}
.report-table-card .scan-table th:nth-child(2), /* Comanda Productie */
.report-table-card .scan-table td:nth-child(2) {
max-width: 90px !important;
min-width: 90px !important;
}
.report-table-card .scan-table th:nth-child(3), /* Cod Articol */
.report-table-card .scan-table td:nth-child(3) {
max-width: 80px !important;
min-width: 80px !important;
}
.report-table-card .scan-table th:nth-child(4), /* Descr. Com. Prod */
.report-table-card .scan-table td:nth-child(4) {
max-width: 140px !important;
min-width: 140px !important;
}
.report-table-card .scan-table th:nth-child(5), /* Cantitate */
.report-table-card .scan-table td:nth-child(5) {
max-width: 70px !important;
min-width: 70px !important;
text-align: right !important;
}
.report-table-card .scan-table th:nth-child(6), /* Com.Achiz.Client */
.report-table-card .scan-table td:nth-child(6) {
max-width: 100px !important;
min-width: 100px !important;
}
.report-table-card .scan-table th:nth-child(7), /* Nr. Linie */
.report-table-card .scan-table td:nth-child(7) {
max-width: 60px !important;
min-width: 60px !important;
text-align: right !important;
}
.report-table-card .scan-table th:nth-child(8), /* Customer Name */
.report-table-card .scan-table td:nth-child(8) {
max-width: 120px !important;
min-width: 120px !important;
}
.report-table-card .scan-table th:nth-child(9), /* Customer Art. Nr. */
.report-table-card .scan-table td:nth-child(9) {
max-width: 90px !important;
min-width: 90px !important;
}
.report-table-card .scan-table th:nth-child(10), /* Open Order */
.report-table-card .scan-table td:nth-child(10) {
max-width: 70px !important;
min-width: 70px !important;
text-align: center !important;
}
.report-table-card .scan-table th:nth-child(11), /* Line */
.report-table-card .scan-table td:nth-child(11) {
max-width: 50px !important;
min-width: 50px !important;
text-align: right !important;
}
.report-table-card .scan-table th:nth-child(12), /* Printed */
.report-table-card .scan-table td:nth-child(12) {
max-width: 60px !important;
min-width: 60px !important;
text-align: center !important;
}
.report-table-card .scan-table th:nth-child(13), /* Created */
.report-table-card .scan-table td:nth-child(13) {
max-width: 110px !important;
min-width: 110px !important;
font-size: 10px !important;
}
/* Hover effects for better readability */
.report-table-card .scan-table tbody tr:hover {
background-color: #f8f9fa !important;
}
.report-table-card .scan-table tbody tr:hover td {
background-color: #f8f9fa !important;
}
/* Table container optimization */
.report-table-card .report-table-container {
overflow-x: auto !important;
}
.report-table-card .scan-table {
min-width: 1060px !important;
width: 100% !important;
table-layout: fixed !important;
}
/* Print styles */
@media print {
.report-form-card {
display: none !important;
}
.card {
box-shadow: none !important;
border: none !important;
}
.scan-table {
font-size: 9px !important;
}
.scan-table th,
.scan-table td {
padding: 3px 2px !important;
font-size: 9px !important;
}
}
</style>
{% endblock %}