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

@@ -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 */
@@ -721,4 +814,173 @@ body.dark-mode .export-description {
position: relative;
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;
}
}