update pages

This commit is contained in:
2025-09-14 14:46:21 +03:00
parent 9d80252c14
commit f8ce4baa7a
7 changed files with 538 additions and 40 deletions

View File

@@ -338,7 +338,7 @@ def get_report_data():
""")
rows = cursor.fetchall()
print("Fetched rows for report 5 (all rows):", rows)
data["headers"] = ["Id", "Operator Code", "CP Base Code", "CP Full Code", "OC1 Code", "OC2 Code", "Quality Code", "Date", "Time", "Approved Quantity", "Rejected Quantity"]
data["headers"] = ["Id", "Operator Code", "CP Base Code", "CP Full Code", "OC1 Code", "OC2 Code", "Quality Code", "Date", "Time", "Approved Quantity of order", "Rejected Quantity of order"]
data["rows"] = [[str(cell) if isinstance(cell, (datetime, timedelta)) else cell for cell in row] for row in rows]
conn.close()
@@ -349,6 +349,37 @@ def get_report_data():
print("Data being returned:", data)
return jsonify(data)
@bp.route('/generate_report', methods=['GET'])
def generate_report():
"""Generate report for specific date (calendar-based report)"""
report = request.args.get('report')
selected_date = request.args.get('date')
data = {"headers": [], "rows": []}
try:
conn = get_db_connection()
cursor = conn.cursor()
if report == "6" and selected_date: # Custom date report
cursor.execute("""
SELECT Id, operator_code, CP_base_code, OC1_code, OC2_code, quality_code, date, time, approved_quantity, rejected_quantity
FROM scan1_orders
WHERE date = ?
ORDER BY time DESC
""", (selected_date,))
rows = cursor.fetchall()
print(f"Fetched rows for report 6 (custom date {selected_date}):", rows)
data["headers"] = ["Id", "Operator Code", "CP Base Code", "OC1 Code", "OC2 Code", "Quality Code", "Date", "Time", "Approved Quantity", "Rejected Quantity"]
data["rows"] = [[str(cell) if isinstance(cell, (datetime, timedelta)) else cell for cell in row] for row in rows]
conn.close()
except mariadb.Error as e:
print(f"Error fetching custom date report: {e}")
data["error"] = f"Error fetching report data for {selected_date}."
print("Custom date report data being returned:", data)
return jsonify(data)
@bp.route('/etichete')
def etichete():
if 'role' not in session or session['role'] not in ['superadmin', 'etichete']:

View File

@@ -284,4 +284,156 @@ document.addEventListener('DOMContentLoaded', () => {
draggingField.style.top = `${e.clientY - rect.top}px`;
});
}
// Calendar functionality for date selection
const selectDayReportBtn = document.getElementById('select-day-report');
const calendarModal = document.getElementById('calendar-modal');
const closeModal = document.querySelector('.close-modal');
const cancelDate = document.getElementById('cancel-date');
const confirmDate = document.getElementById('confirm-date');
const calendarDays = document.getElementById('calendar-days');
const calendarMonthYear = document.getElementById('calendar-month-year');
const prevMonth = document.getElementById('prev-month');
const nextMonth = document.getElementById('next-month');
let currentDate = new Date();
let selectedDate = null;
// Show calendar modal
if (selectDayReportBtn) {
selectDayReportBtn.addEventListener('click', () => {
calendarModal.style.display = 'block';
generateCalendar(currentDate);
});
}
// Close modal events
if (closeModal) {
closeModal.addEventListener('click', closeCalendarModal);
}
if (cancelDate) {
cancelDate.addEventListener('click', closeCalendarModal);
}
// Click outside modal to close
window.addEventListener('click', (e) => {
if (e.target === calendarModal) {
closeCalendarModal();
}
});
// Navigation buttons
if (prevMonth) {
prevMonth.addEventListener('click', () => {
currentDate.setMonth(currentDate.getMonth() - 1);
generateCalendar(currentDate);
});
}
if (nextMonth) {
nextMonth.addEventListener('click', () => {
currentDate.setMonth(currentDate.getMonth() + 1);
generateCalendar(currentDate);
});
}
// Confirm date selection
if (confirmDate) {
confirmDate.addEventListener('click', () => {
if (selectedDate) {
// Format date as YYYY-MM-DD
const formattedDate = selectedDate.toISOString().split('T')[0];
closeCalendarModal();
// Fetch report data for the selected date
fetchCustomDateReport(formattedDate);
}
});
}
function closeCalendarModal() {
calendarModal.style.display = 'none';
selectedDate = null;
confirmDate.disabled = true;
// Remove selected class from all days
const selectedDays = document.querySelectorAll('.calendar-day.selected');
selectedDays.forEach(day => day.classList.remove('selected'));
}
function generateCalendar(date) {
const year = date.getFullYear();
const month = date.getMonth();
// Update header
const monthNames = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];
calendarMonthYear.textContent = `${monthNames[month]} ${year}`;
// Clear previous days
calendarDays.innerHTML = '';
// Get first day of month and number of days
const firstDay = new Date(year, month, 1).getDay();
const daysInMonth = new Date(year, month + 1, 0).getDate();
const today = new Date();
// Add empty cells for days before month starts
for (let i = 0; i < firstDay; i++) {
const emptyDay = document.createElement('div');
emptyDay.classList.add('calendar-day', 'other-month');
calendarDays.appendChild(emptyDay);
}
// Add days of the month
for (let day = 1; day <= daysInMonth; day++) {
const dayElement = document.createElement('div');
dayElement.classList.add('calendar-day');
dayElement.textContent = day;
const dayDate = new Date(year, month, day);
// Highlight today
if (dayDate.toDateString() === today.toDateString()) {
dayElement.classList.add('today');
}
// Add click event
dayElement.addEventListener('click', () => {
// Remove previous selection
const previousSelected = document.querySelector('.calendar-day.selected');
if (previousSelected) {
previousSelected.classList.remove('selected');
}
// Select this day
dayElement.classList.add('selected');
selectedDate = new Date(year, month, day);
confirmDate.disabled = false;
});
calendarDays.appendChild(dayElement);
}
}
function fetchCustomDateReport(dateString) {
reportTitle.textContent = `Loading report for ${dateString}...`;
fetch(`/generate_report?report=6&date=${dateString}`)
.then(response => response.json())
.then(data => {
if (data.error) {
reportTitle.textContent = `Error: ${data.error}`;
populateTable({ headers: [], rows: [] });
} else {
reportTitle.textContent = `Daily Report for ${dateString}`;
populateTable(data);
}
})
.catch(error => {
console.error('Error fetching custom date report:', error);
reportTitle.textContent = 'Error loading report';
populateTable({ headers: [], rows: [] });
});
}
});

View File

@@ -678,6 +678,99 @@ body.dark-mode .export-description {
border: 1px solid #ddd; /* Add borders to table cells */
}
/* Reports Grid Layout - Label and Button Side by Side */
.reports-grid {
display: flex;
flex-direction: column;
gap: 8px; /* Reduced spacing between report rows */
margin-bottom: 25px; /* More space before separator */
}
.report-column {
display: flex;
flex-direction: column;
gap: 8px;
}
/* Specific styles for Quality Reports Card ONLY */
.report-form-card .form-centered {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 15px;
align-items: center;
padding: 6px 0; /* Reduced vertical padding */
}
.report-form-card .form-centered .report-description {
margin: 0;
padding-right: 10px;
font-size: 0.85em; /* Smaller text for quality reports */
line-height: 1.3;
}
.report-form-card .form-centered .btn {
margin: 0;
white-space: nowrap;
font-size: 0.8em; /* Smaller button text for quality reports */
padding: 8px 12px; /* Adjust padding for smaller text */
}
/* Keep original form-centered styles for other pages */
.form-centered:not(.report-form-card .form-centered) {
display: flex;
flex-direction: column;
align-items: center;
margin: 20px 0;
}
/* Separator between reports and export section */
.report-separator {
width: 100%;
height: 2px;
background: linear-gradient(to right, #ddd, #999, #ddd);
margin: 25px 0 20px 0; /* More space above, good space below */
border-radius: 1px;
}
/* Export section styling - specific to quality reports */
.export-section {
padding-top: 5px;
margin-bottom: 15px; /* Add space at bottom of card */
}
.report-form-card .export-section .export-description {
font-size: 0.85em; /* Smaller export label text */
margin-bottom: 8px; /* Reduced margin */
}
.report-form-card .export-section .btn {
font-size: 0.8em; /* Smaller export button text */
padding: 8px 12px;
}
.report-form-card .export-section .form-centered.last-buttons {
padding: 5px 0; /* Reduced padding for export section */
}
/* Responsive design for Quality Reports Card only */
@media (max-width: 768px) {
.report-form-card .form-centered {
grid-template-columns: 1fr;
gap: 10px;
text-align: center;
}
.report-form-card .form-centered .report-description {
padding-right: 0;
margin-bottom: 5px;
font-size: 0.8em; /* Even smaller on mobile */
}
.report-form-card .form-centered .btn {
font-size: 0.75em; /* Smaller buttons on mobile */
}
}
.go-to-main-etichete-btn {
background-color: #28a745; /* Green background */
color: #fff; /* White text */
@@ -722,3 +815,172 @@ body.dark-mode .export-description {
background-color: #f8f9fa; /* Light gray background */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow for better visibility */
}
/* Calendar Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #fefefe;
margin: 5% auto;
padding: 0;
border-radius: 8px;
width: 400px;
max-width: 90%;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
background-color: #f8f9fa;
border-radius: 8px 8px 0 0;
border-bottom: 1px solid #ddd;
}
.modal-header h4 {
margin: 0;
color: #333;
}
.close-modal {
font-size: 24px;
font-weight: bold;
cursor: pointer;
color: #666;
line-height: 1;
}
.close-modal:hover {
color: #333;
}
.modal-body {
padding: 20px;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
padding: 15px 20px;
border-top: 1px solid #ddd;
border-radius: 0 0 8px 8px;
background-color: #f8f9fa;
}
/* Calendar Styles */
.calendar-container {
width: 100%;
}
.calendar-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.calendar-header h3 {
margin: 0;
color: #333;
font-size: 1.1em;
}
.calendar-nav {
background: none;
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px 10px;
cursor: pointer;
font-size: 14px;
color: #666;
}
.calendar-nav:hover {
background-color: #f0f0f0;
color: #333;
}
.calendar-grid {
width: 100%;
}
.calendar-weekdays {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 2px;
margin-bottom: 5px;
}
.calendar-weekdays div {
padding: 8px 4px;
text-align: center;
font-weight: bold;
font-size: 0.85em;
color: #666;
background-color: #f8f9fa;
}
.calendar-days {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 2px;
}
.calendar-day {
padding: 10px 4px;
text-align: center;
cursor: pointer;
border-radius: 4px;
font-size: 0.9em;
min-height: 35px;
display: flex;
align-items: center;
justify-content: center;
}
.calendar-day:hover {
background-color: #e9ecef;
}
.calendar-day.other-month {
color: #ccc;
}
.calendar-day.today {
background-color: #007bff;
color: white;
}
.calendar-day.selected {
background-color: #28a745;
color: white;
}
.calendar-day.selected:hover {
background-color: #218838;
}
/* Responsive Calendar */
@media (max-width: 480px) {
.modal-content {
margin: 10% auto;
width: 95%;
}
.calendar-day {
min-height: 30px;
font-size: 0.8em;
}
}

View File

@@ -7,28 +7,28 @@
<!-- Row of evenly distributed cards -->
<div class="dashboard-card">
<h3>Accesare modul scanare</h3>
<p>Modul de scanare finala a comenzilor de productie</p>
<a href="{{ url_for('main.scan') }}" class="btn">Lansare modul de scanare</a>
<h3>Access Scanning Module</h3>
<p>Final scanning module for production orders</p>
<a href="{{ url_for('main.scan') }}" class="btn">Launch Scanning Module</a>
</div>
<div class="dashboard-card">
<h3>Accesare modul calitate</h3>
<p>Modul de verificare si configurare setari calitate.</p>
<a href="{{ url_for('main.quality') }}" class="btn">Lansare modul calitate</a>
<h3>Access Reports Module</h3>
<p>Module for verification and quality settings configuration.</p>
<a href="{{ url_for('main.quality') }}" class="btn">Launch Reports Module</a>
</div>
<div class="dashboard-card">
<h3>Accesare modul magazie</h3>
<p>Acceseaza functionalitatile modulului de magazie.</p>
<a href="{{ url_for('main.warehouse') }}" class="btn" id="launch-warehouse">Deschide magazie</a>
<h3>Access Warehouse Module</h3>
<p>Access warehouse module functionalities.</p>
<a href="{{ url_for('main.warehouse') }}" class="btn" id="launch-warehouse">Open Warehouse</a>
</div>
<!-- New Card: Accesare modul Etichete -->
<!-- New Card: Access Labels Module -->
<div class="dashboard-card">
<h3>Accesare modul Etichete</h3>
<p>Modul pentru gestionarea etichetelor.</p>
<a href="{{ url_for('main.etichete') }}" class="btn">Lansare modul Etichete</a>
<h3>Access Labels Module</h3>
<p>Module for label management.</p>
<a href="{{ url_for('main.etichete') }}" class="btn">Launch Labels Module</a>
</div>
<div class="dashboard-card">

View File

@@ -4,27 +4,41 @@
<div class="scan-container">
<!-- Reports Card -->
<div class="card report-form-card">
<h3>Rapoarte</h3>
<h3>Reports</h3>
<!-- Reports List with Label-Button Layout -->
<div class="reports-grid">
<div class="form-centered">
<label class="report-description">Raport zilnic va exporta toate comenzile scanate la punctele de scanare calitate</label>
<button class="btn report-btn" data-report="1">Raport zilnic de comenzi complet</button>
<label class="report-description">Daily report will export all orders scanned at quality scanning points</label>
<button class="btn report-btn" data-report="1">Daily Complete Orders Report</button>
</div>
<div class="form-centered">
<label class="report-description">Raport 5 zile va exporta toate comenzile scanate la punctele de scanare calitate</label>
<button class="btn report-btn" data-report="2">Raport 5 zile de comenzi complet</button>
<label class="report-description">Select day for daily report will export all orders scanned at quality scanning points</label>
<button class="btn report-btn" id="select-day-report">Select Day Daily Report</button>
</div>
<div class="form-centered">
<label class="report-description">Raport articole cu probleme de calitate pe ziua curenta</label>
<button class="btn report-btn" data-report="3">Raport Articole cu defecte ziua curenta</button>
<label class="report-description">5-day report will export all orders scanned at quality scanning points</label>
<button class="btn report-btn" data-report="2">5-Day Complete Orders Report</button>
</div>
<div class="form-centered">
<label class="report-description">Raport articole cu probleme de calitate din ultimile 5 zile</label>
<button class="btn report-btn" data-report="4">Raport Articole cu defecte in ultimile 5 zile</button>
<label class="report-description">Report on items with quality issues for the current day</label>
<button class="btn report-btn" data-report="3">Report on Items with Defects for the Current Day</button>
</div>
<div class="form-centered">
<label class="report-description">Raportarea tuturor intrarilor din baza de date</label>
<button class="btn report-btn" data-report="5">Raporteaza bazade date</button>
<label class="report-description">Report on items with quality issues for the last 5 days</label>
<button class="btn report-btn" data-report="4">Report on Items with Defects for the Last 5 Days</button>
</div>
<div class="form-centered">
<label class="report-description">Report all entries from the database</label>
<button class="btn report-btn" data-report="5">Report Database</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 current report as:</label>
<div class="button-row">
@@ -33,6 +47,7 @@
</div>
</div>
</div>
</div>
<!-- Data Display Card -->
<div class="card report-table-card">
@@ -51,5 +66,43 @@
</div>
</div>
</div>
<!-- Calendar Popup Modal -->
<div id="calendar-modal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h4>Select Date for Daily Report</h4>
<span class="close-modal">&times;</span>
</div>
<div class="modal-body">
<div class="calendar-container">
<div class="calendar-header">
<button id="prev-month" class="calendar-nav">&lt;</button>
<h3 id="calendar-month-year"></h3>
<button id="next-month" class="calendar-nav">&gt;</button>
</div>
<div class="calendar-grid">
<div class="calendar-weekdays">
<div>Sun</div>
<div>Mon</div>
<div>Tue</div>
<div>Wed</div>
<div>Thu</div>
<div>Fri</div>
<div>Sat</div>
</div>
<div class="calendar-days" id="calendar-days">
<!-- Days will be populated by JavaScript -->
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" id="cancel-date">Cancel</button>
<button class="btn btn-primary" id="confirm-date" disabled>Generate Report</button>
</div>
</div>
</div>
{% endblock %}

View File

@@ -6,7 +6,7 @@
<div class="card scan-form-card">
<h3>Scan Input</h3>
<form method="POST" class="form-centered">
<label for="operator_code">Operator Code:</label>
<label for="operator_code">Quality Operator Code:</label>
<input type="text" id="operator_code" name="operator_code" maxlength="4" required>
<label for="cp_code">CP Code:</label>