mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 04:22:58 +00:00
f
This commit is contained in:
@@ -4955,6 +4955,92 @@ async function saveReservation(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to load and display reservations
|
||||||
|
function loadReservations() {
|
||||||
|
fetch('/api/reservations')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const reservations = data.reservations || [];
|
||||||
|
displayReservations(reservations);
|
||||||
|
updateVehicleFilter(reservations);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error loading reservations:', error);
|
||||||
|
showNotification('Nepodařilo se načíst rezervace', 'error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to display reservations
|
||||||
|
function displayReservations(reservations) {
|
||||||
|
const reservationsContainer = document.getElementById('reservationsContainer');
|
||||||
|
if (!reservationsContainer) return;
|
||||||
|
|
||||||
|
// Clear existing content
|
||||||
|
reservationsContainer.innerHTML = '';
|
||||||
|
|
||||||
|
if (reservations.length === 0) {
|
||||||
|
// Show no reservations message
|
||||||
|
const noReservations = document.createElement('div');
|
||||||
|
noReservations.className = 'text-center py-6 text-gray-500';
|
||||||
|
noReservations.innerHTML = 'Zatím nebyly vytvořeny žádné rezervace.';
|
||||||
|
reservationsContainer.appendChild(noReservations);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort reservations by date
|
||||||
|
reservations.sort((a, b) => new Date(a.date) - new Date(b.date));
|
||||||
|
|
||||||
|
// Add table header
|
||||||
|
const table = document.createElement('table');
|
||||||
|
table.className = 'min-w-full divide-y divide-gray-200';
|
||||||
|
const thead = document.createElement('thead');
|
||||||
|
thead.className = 'bg-gray-50';
|
||||||
|
const headerRow = document.createElement('tr');
|
||||||
|
|
||||||
|
const headers = ['Datum', 'Čas', 'Vozidlo', 'Jméno', 'Telefon', 'Email', 'Délka', 'Akce'];
|
||||||
|
headers.forEach(header => {
|
||||||
|
const th = document.createElement('th');
|
||||||
|
th.className = 'px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider';
|
||||||
|
th.textContent = header;
|
||||||
|
headerRow.appendChild(th);
|
||||||
|
});
|
||||||
|
thead.appendChild(headerRow);
|
||||||
|
table.appendChild(thead);
|
||||||
|
|
||||||
|
// Add table body
|
||||||
|
const tbody = document.createElement('tbody');
|
||||||
|
tbody.className = 'bg-white divide-y divide-gray-200';
|
||||||
|
|
||||||
|
// Add reservations
|
||||||
|
reservations.forEach(reservation => {
|
||||||
|
const row = document.createElement('tr');
|
||||||
|
row.className = 'hover:bg-gray-50';
|
||||||
|
|
||||||
|
// Add cells
|
||||||
|
const cells = [
|
||||||
|
formatDateTime(reservation.date, reservation.time),
|
||||||
|
reservation.vehicle,
|
||||||
|
reservation.name,
|
||||||
|
reservation.phone,
|
||||||
|
reservation.email,
|
||||||
|
calculateDuration(reservation),
|
||||||
|
'<button onclick="editReservation(\'' + reservation.id + '\')" class="text-blue-600 hover:text-blue-900">Upravit</button> '
|
||||||
|
];
|
||||||
|
|
||||||
|
cells.forEach(cellContent => {
|
||||||
|
const cell = document.createElement('td');
|
||||||
|
cell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-900';
|
||||||
|
cell.innerHTML = cellContent;
|
||||||
|
row.appendChild(cell);
|
||||||
|
});
|
||||||
|
|
||||||
|
tbody.appendChild(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
table.appendChild(tbody);
|
||||||
|
reservationsContainer.appendChild(table);
|
||||||
|
}
|
||||||
|
|
||||||
// Add event listeners when the page loads
|
// Add event listeners when the page loads
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Initialize filters
|
// Initialize filters
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ type VisitorStats struct {
|
|||||||
func (v *VisitorStats) init() {
|
func (v *VisitorStats) init() {
|
||||||
if v.UniqueVisitors == nil {
|
if v.UniqueVisitors == nil {
|
||||||
v.UniqueVisitors = make(map[string]struct {
|
v.UniqueVisitors = make(map[string]struct {
|
||||||
FirstVisit time.Time
|
FirstVisit time.Time `json:"first_visit"`
|
||||||
LastVisit time.Time
|
LastVisit time.Time `json:"last_visit"`
|
||||||
Visits int
|
Visits int `json:"visits"`
|
||||||
IP string
|
IP string `json:"ip"`
|
||||||
UserAgent string
|
UserAgent string `json:"user_agent"`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,15 +72,15 @@ func (v *VisitorStats) init() {
|
|||||||
|
|
||||||
if len(v.MostActiveHours) == 0 {
|
if len(v.MostActiveHours) == 0 {
|
||||||
v.MostActiveHours = make([]struct {
|
v.MostActiveHours = make([]struct {
|
||||||
Hour int
|
Hour int `json:"hour"`
|
||||||
Count int
|
Count int `json:"count"`
|
||||||
}, 24)
|
}, 24)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(v.MostActiveDays) == 0 {
|
if len(v.MostActiveDays) == 0 {
|
||||||
v.MostActiveDays = make([]struct {
|
v.MostActiveDays = make([]struct {
|
||||||
Day string
|
Day string `json:"day"`
|
||||||
Count int
|
Count int `json:"count"`
|
||||||
}, 7)
|
}, 7)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user