day of hard work with xkirsch #2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
function openReservationForm() {
|
||||
const now = new Date();
|
||||
const formattedDate = now.toLocaleDateString('cs-CZ', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
const formattedDate = now.toISOString().split('T')[0]; // Format date as YYYY-MM-DD
|
||||
document.getElementById('date').value = formattedDate;
|
||||
document.getElementById('reservationForm').style.display = 'block';
|
||||
}
|
||||
|
||||
61
web/static/scripts/statistics.js
Normal file
61
web/static/scripts/statistics.js
Normal file
@@ -0,0 +1,61 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const ctx = document.getElementById('repairsChart').getContext('2d');
|
||||
const repairsData = JSON.parse(document.getElementById('repairsData').textContent);
|
||||
const labels = repairsData.map(data => data.employee);
|
||||
const data = repairsData.map(data => data.count);
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Počet Oprav',
|
||||
data: data,
|
||||
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
||||
borderColor: 'rgba(255, 99, 132, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function fetchRepairsByDate() {
|
||||
const startDate = document.getElementById('startDate').value;
|
||||
const endDate = document.getElementById('endDate').value;
|
||||
|
||||
fetch(`/repairs_by_date?start=${startDate}&end=${endDate}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const ctx = document.getElementById('timeRepairsChart').getContext('2d');
|
||||
const labels = data.map(item => item.date);
|
||||
const counts = data.map(item => item.count);
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Počet Oprav',
|
||||
data: counts,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user