mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-03 20:12:59 +00:00
641 lines
26 KiB
HTML
641 lines
26 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="cs">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Poppe Potthoff - Rezervace služebních vozů</title>
|
||
<script src="https://cdn.tailwindcss.com"></script>
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
|
||
<link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.css' rel='stylesheet' />
|
||
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.js'></script>
|
||
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/locales/cs.js'></script>
|
||
|
||
<script>
|
||
tailwind.config = {
|
||
theme: {
|
||
extend: {
|
||
colors: {
|
||
'brand-blue': '#004990',
|
||
'brand-light-blue': '#0072b0',
|
||
'brand-gray': '#f0f2f5'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.fc-event {
|
||
cursor: pointer;
|
||
border-radius: 6px;
|
||
border: none;
|
||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||
transition: transform 0.2s, box-shadow 0.2s;
|
||
}
|
||
|
||
.fc-event:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
|
||
}
|
||
|
||
.fc-toolbar-title {
|
||
text-transform: capitalize;
|
||
font-weight: 600;
|
||
color: #2d3748;
|
||
}
|
||
|
||
.fc .fc-button-primary {
|
||
background-color: #004990;
|
||
border-color: #004990;
|
||
text-transform: uppercase;
|
||
font-size: 0.875rem;
|
||
font-weight: 500;
|
||
padding: 0.5rem 1rem;
|
||
transition: all 0.2s;
|
||
}
|
||
|
||
.fc .fc-button-primary:hover {
|
||
background-color: #0072b0;
|
||
border-color: #0072b0;
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
.fc .fc-button-primary:not(:disabled).fc-button-active,
|
||
.fc .fc-button-primary:not(:disabled):active {
|
||
background-color: #0072b0;
|
||
border-color: #0072b0;
|
||
}
|
||
|
||
.fc-view-harness {
|
||
background: white;
|
||
border-radius: 8px;
|
||
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.fc-scrollgrid {
|
||
border: none !important;
|
||
}
|
||
|
||
.fc-col-header-cell {
|
||
background: #f8fafc;
|
||
padding: 1rem 0;
|
||
}
|
||
|
||
.fc-day-today {
|
||
background: #e8f4ff !important;
|
||
}
|
||
|
||
.fc-timegrid-slot {
|
||
height: 2rem !important;
|
||
}
|
||
|
||
.fc-timegrid-slot-label {
|
||
font-size: 0.75rem !important;
|
||
padding: 0 !important;
|
||
}
|
||
|
||
.reservation-card {
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.reservation-card:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 8px 16px rgba(0,0,0,0.1);
|
||
}
|
||
|
||
/* Vehicle badges */
|
||
.vehicle-badge {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 0.25rem 0.75rem;
|
||
border-radius: 9999px;
|
||
font-size: 0.875rem;
|
||
font-weight: 500;
|
||
margin-right: 0.5rem;
|
||
}
|
||
|
||
.vehicle-badge i {
|
||
margin-right: 0.5rem;
|
||
}
|
||
|
||
/* Vehicle-specific colors */
|
||
.vehicle-vw-caddy { background-color: #e6f3ff; color: #1a73e8; }
|
||
.vehicle-vw-golf { background-color: #e6ffe6; color: #28a745; }
|
||
.vehicle-skoda-fabia { background-color: #fff3e6; color: #fd7e14; }
|
||
.vehicle-bmw-218d { background-color: #f3e6ff; color: #6f42c1; }
|
||
.vehicle-skoda-superb { background-color: #ffe6e6; color: #dc3545; }
|
||
|
||
/* Calendar size adjustments */
|
||
.calendar-container {
|
||
max-width: 800px;
|
||
margin: 0 auto;
|
||
padding: 1rem;
|
||
}
|
||
|
||
/* Responsive calendar styles */
|
||
@media (max-width: 768px) {
|
||
.fc .fc-toolbar {
|
||
flex-direction: column;
|
||
gap: 0.5rem;
|
||
}
|
||
|
||
.fc .fc-toolbar-title {
|
||
font-size: 1.2rem;
|
||
}
|
||
|
||
.fc-header-toolbar {
|
||
padding: 0.5rem !important;
|
||
}
|
||
|
||
.fc-view-harness {
|
||
height: 400px !important;
|
||
}
|
||
|
||
.fc .fc-button {
|
||
padding: 0.4rem 0.8rem;
|
||
font-size: 0.875rem;
|
||
}
|
||
}
|
||
|
||
/* Adjust calendar size for desktop */
|
||
.fc-view-harness {
|
||
height: 500px !important; /* Reduced from 600px */
|
||
}
|
||
|
||
/* Form container styles */
|
||
.form-container {
|
||
max-width: 600px;
|
||
margin: 2rem auto;
|
||
padding: 2rem;
|
||
background: white;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||
}
|
||
|
||
/* Form group spacing */
|
||
.form-group {
|
||
margin-bottom: 1.5rem;
|
||
}
|
||
|
||
.form-group label {
|
||
display: block;
|
||
margin-bottom: 0.5rem;
|
||
font-weight: 500;
|
||
color: #374151;
|
||
}
|
||
|
||
/* Responsive form layout */
|
||
@media (max-width: 640px) {
|
||
.form-container {
|
||
padding: 1rem;
|
||
margin: 1rem;
|
||
}
|
||
|
||
.grid-cols-2 {
|
||
grid-template-columns: 1fr !important;
|
||
}
|
||
|
||
.form-group {
|
||
margin-bottom: 1rem;
|
||
}
|
||
}
|
||
|
||
/* Improve button responsiveness */
|
||
.btn {
|
||
width: 100%;
|
||
padding: 0.75rem;
|
||
border-radius: 0.5rem;
|
||
transition: all 0.2s;
|
||
}
|
||
|
||
@media (min-width: 640px) {
|
||
.btn {
|
||
width: auto;
|
||
}
|
||
}
|
||
</style>
|
||
</head>
|
||
<body class="bg-brand-gray min-h-screen">
|
||
<!-- Nav bar copied from existing template -->
|
||
<nav class="bg-brand-blue text-white shadow-lg">
|
||
<div class="max-w-6xl mx-auto px-4 py-3 flex justify-between items-center">
|
||
<div class="flex items-center space-x-2">
|
||
<a href="http://webportal/index.html"><img src="http://pp-kunovice.cz/wp-content/uploads/2022/04/logo-retina-white.png" alt="Poppe Potthoff Logo" class="h-10"></a>
|
||
<div class="hidden md:block text-xl font-semibold">Poppe + Potthoff</div>
|
||
</div>
|
||
|
||
<!-- Mobile menu button -->
|
||
<div class="md:hidden">
|
||
<button id="mobile-menu-button" class="text-white focus:outline-none">
|
||
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
||
</svg>
|
||
</button>
|
||
</div>
|
||
|
||
<!-- Desktop menu -->
|
||
<div class="hidden md:flex space-x-6">
|
||
<a href="http://webportal/index.html" class="hover:text-brand-light-blue">Rozcestník</a>
|
||
<a href="http://webportal/evidence-aut" class="hover:text-brand-light-blue">Evidence aut</a>
|
||
<a href="http://ppc-app/pwkweb2/" class="hover:text-brand-light-blue">Obědy</a>
|
||
<a href="http://osticket/" class="hover:text-brand-light-blue">OSticket</a>
|
||
<a href="http://kanboard/" class="hover:text-brand-light-blue">Kanboard</a>
|
||
<a href="http://webportal:8080" class="hover:text-brand-light-blue">Kontakt</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Mobile menu -->
|
||
<div id="mobile-menu" class="hidden md:hidden px-2 pt-2 pb-3 space-y-1">
|
||
<a href="webportal/index.html" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Rozcestník</a>
|
||
<a href="webportal/evidence-aut" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Evidence aut</a>
|
||
<a href="http://ppc-app/pwkweb2/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Obědy</a>
|
||
<a href="http://osticket/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">OSticket</a>
|
||
<a href="http://kanboard/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kanboard</a>
|
||
<a href="http://webportal:8080" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kontakt</a>
|
||
</div>
|
||
</nav>
|
||
|
||
<!-- Page Header -->
|
||
<div class="bg-gradient-to-r from-brand-blue to-brand-light-blue text-white py-6 mb-8">
|
||
<div class="max-w-6xl mx-auto px-4">
|
||
<h1 class="text-3xl font-bold">Poppe + Potthoff – Rezervace služebních vozů</h1>
|
||
<p class="text-gray-100 mt-2">Systém pro rezervaci služebních vozidel</p>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Main Content -->
|
||
<div class="container mx-auto px-4 py-8">
|
||
<div class="calendar-container">
|
||
<div id='calendar'></div>
|
||
</div>
|
||
|
||
<!-- Reservation Form -->
|
||
<div class="form-container">
|
||
<h2 class="text-2xl font-bold mb-6 text-gray-800">Nová rezervace</h2>
|
||
<form id="reservationForm" class="space-y-6">
|
||
<!-- Driver Name -->
|
||
<div class="form-group">
|
||
<label for="driverName">Jméno řidiče</label>
|
||
<input type="text" id="driverName" name="driverName" required
|
||
class="w-full p-2 border border-gray-300 rounded-md">
|
||
</div>
|
||
|
||
<!-- Vehicle Selection -->
|
||
<div class="form-group">
|
||
<label for="vehicle">Vozidlo</label>
|
||
<select id="vehicle" name="vehicle" required
|
||
class="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-brand-light-blue focus:border-brand-light-blue appearance-none">
|
||
<option value="" selected disabled>Vyberte vozidlo...</option>
|
||
<option value="VW Caddy - 4Z1 8241">VW Caddy - 4Z1 8241</option>
|
||
<option value="VW Golf - 5Z5 8694">VW Golf - 5Z5 8694</option>
|
||
<option value="Škoda Fabia - 1Z3 5789">Škoda Fabia - 1Z3 5789</option>
|
||
<option value="BMW 218d - 6Z5 4739">BMW 218d - 6Z5 4739</option>
|
||
<option value="BMW 218d - 6Z5 4740">BMW 218d - 6Z5 4740</option>
|
||
<option value="Škoda Superb - 2BY 2398">Škoda Superb - 2BY 2398</option>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- Date and Time Selection -->
|
||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||
<!-- Start Date and Time -->
|
||
<div class="form-group">
|
||
<label for="startDate">Datum začátku</label>
|
||
<input type="date" id="startDate" name="startDate" required
|
||
class="w-full p-2 border border-gray-300 rounded-md">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="startTime">Čas začátku</label>
|
||
<select id="startTime" name="startTime" required
|
||
class="w-full p-2 border border-gray-300 rounded-md">
|
||
<option value="">Vyberte čas</option>
|
||
<option value="06:00">06:00</option>
|
||
<option value="07:00">07:00</option>
|
||
<option value="08:00">08:00</option>
|
||
<option value="09:00">09:00</option>
|
||
<option value="10:00">10:00</option>
|
||
<option value="11:00">11:00</option>
|
||
<option value="12:00">12:00</option>
|
||
<option value="13:00">13:00</option>
|
||
<option value="14:00">14:00</option>
|
||
<option value="15:00">15:00</option>
|
||
<option value="16:00">16:00</option>
|
||
<option value="17:00">17:00</option>
|
||
<option value="18:00">18:00</option>
|
||
<option value="19:00">19:00</option>
|
||
<option value="20:00">20:00</option>
|
||
<option value="21:00">21:00</option>
|
||
<option value="22:00">22:00</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||
<!-- End Date and Time -->
|
||
<div class="form-group">
|
||
<label for="endDate">Datum konce</label>
|
||
<input type="date" id="endDate" name="endDate" required
|
||
class="w-full p-2 border border-gray-300 rounded-md">
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="endTime">Čas konce</label>
|
||
<select id="endTime" name="endTime" required
|
||
class="w-full p-2 border border-gray-300 rounded-md">
|
||
<option value="">Vyberte čas</option>
|
||
<option value="06:00">06:00</option>
|
||
<option value="07:00">07:00</option>
|
||
<option value="08:00">08:00</option>
|
||
<option value="09:00">09:00</option>
|
||
<option value="10:00">10:00</option>
|
||
<option value="11:00">11:00</option>
|
||
<option value="12:00">12:00</option>
|
||
<option value="13:00">13:00</option>
|
||
<option value="14:00">14:00</option>
|
||
<option value="15:00">15:00</option>
|
||
<option value="16:00">16:00</option>
|
||
<option value="17:00">17:00</option>
|
||
<option value="18:00">18:00</option>
|
||
<option value="19:00">19:00</option>
|
||
<option value="20:00">20:00</option>
|
||
<option value="21:00">21:00</option>
|
||
<option value="22:00">22:00</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Purpose -->
|
||
<div class="space-y-2">
|
||
<label for="purpose" class="block text-sm font-medium text-gray-700">Účel jízdy (nepovinné)</label>
|
||
<div class="relative">
|
||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||
<i class="fas fa-briefcase text-gray-400"></i>
|
||
</div>
|
||
<input type="text" id="purpose" name="purpose"
|
||
class="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-brand-light-blue focus:border-brand-light-blue">
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Submit Button -->
|
||
<div class="flex flex-col sm:flex-row gap-4 justify-end">
|
||
<button type="button" id="cancelBtn" class="btn bg-gray-500 text-white hover:bg-gray-600">
|
||
Zrušit
|
||
</button>
|
||
<button type="submit" class="btn bg-brand-blue text-white hover:bg-brand-light-blue">
|
||
Rezervovat
|
||
</button>
|
||
</div>
|
||
</form>
|
||
|
||
<!-- Status message container -->
|
||
<div class="mt-4 p-4 rounded-md hidden" id="statusMessage">
|
||
<div class="flex items-center">
|
||
<i id="messageIcon" class="mr-2"></i>
|
||
<span id="messageText"></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Footer copied from existing template -->
|
||
<footer class="bg-gray-800 text-gray-400 py-8 mt-12">
|
||
<div class="max-w-6xl mx-auto px-4">
|
||
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
||
<!-- Company Info -->
|
||
<div>
|
||
<h3 class="text-white text-lg font-semibold mb-4">Poppe + Potthoff CZ</h3>
|
||
<p class="mb-2">IČO: 26902214</p>
|
||
<p class="mb-2">DIČ: CZ26902214</p>
|
||
<p class="mb-2">Schránka: gfrk5qy</p>
|
||
<p>Na Záhonech 1086, 686 04 Kunovice</p>
|
||
</div>
|
||
|
||
<!-- Quick Links -->
|
||
<div>
|
||
<h3 class="text-white text-lg font-semibold mb-4">Rychlé odkazy</h3>
|
||
<ul class="space-y-2">
|
||
<li><a href="http://webportal/" class="hover:text-white">Rozcestník</a></li>
|
||
<li><a href="http://webportal/evidence-aut" class="hover:text-white">Evidence aut</a></li>
|
||
<li><a href="http://ppc-app/pwkweb2/" class="hover:text-white">Objednávka obědů</a></li>
|
||
<li><a href="http://osticket/" class="hover:text-white">Technická podpora</a></li>
|
||
<li><a href="http://webportal:8080" class="hover:text-white">Kontakty</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<!-- Copyright -->
|
||
<div class="md:text-right">
|
||
<img src="http://pp-kunovice.cz/wp-content/uploads/2022/04/logo-retina-white.png" alt="Poppe Potthoff Logo" class="h-10 mb-4 inline-block">
|
||
<p class="text-sm"> 2025 Poppe + Potthoff CZ</p>
|
||
<p class="text-xs mt-2">Všechna práva vyhrazena</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="border-t border-gray-700 mt-8 pt-6 text-center text-sm">
|
||
<p>Created by <a href="https://tdvorak.dev" class="text-blue-400 hover:text-blue-300">TDvorak</a></p>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
let calendar;
|
||
const reservationForm = document.getElementById('reservationForm');
|
||
const statusMessage = document.getElementById('statusMessage');
|
||
|
||
// Initialize FullCalendar
|
||
const calendarEl = document.getElementById('calendar');
|
||
calendar = new FullCalendar.Calendar(calendarEl, {
|
||
initialView: 'timeGridWeek',
|
||
headerToolbar: {
|
||
left: 'prev,next today',
|
||
center: 'title',
|
||
right: 'dayGridMonth,timeGridWeek,timeGridDay'
|
||
},
|
||
locale: 'cs',
|
||
slotMinTime: '06:00:00',
|
||
slotMaxTime: '22:00:00',
|
||
slotDuration: '01:00:00',
|
||
snapDuration: '01:00:00',
|
||
allDaySlot: false,
|
||
events: '/api/reservations',
|
||
eventDisplay: 'block',
|
||
eventTimeFormat: {
|
||
hour: '2-digit',
|
||
minute: '2-digit',
|
||
hour12: false
|
||
},
|
||
eventContent: function(arg) {
|
||
return {
|
||
html: `
|
||
<div class="event-content">
|
||
<div class="font-bold">${arg.event.extendedProps.driverName || 'Rezervace'}</div>
|
||
<div>${arg.event.extendedProps.purpose || ''}</div>
|
||
</div>
|
||
`
|
||
};
|
||
},
|
||
// Add these properties to ensure proper event rendering
|
||
eventConstraint: {
|
||
startTime: '06:00',
|
||
endTime: '22:00',
|
||
dows: [0,1,2,3,4,5,6]
|
||
},
|
||
selectConstraint: {
|
||
startTime: '06:00',
|
||
endTime: '22:00',
|
||
dows: [0,1,2,3,4,5,6]
|
||
}
|
||
});
|
||
|
||
calendar.render();
|
||
|
||
// Check vehicle availability
|
||
async function checkVehicleAvailability(vehicle, startDate, endDate) {
|
||
try {
|
||
// Format dates for API
|
||
const startDateTime = new Date(startDate);
|
||
const endDateTime = new Date(endDate);
|
||
|
||
const params = new URLSearchParams({
|
||
vehicle: vehicle,
|
||
startDate: startDateTime.toISOString().split('T')[0],
|
||
startTime: startDateTime.toTimeString().split(' ')[0].slice(0, 5),
|
||
endDate: endDateTime.toISOString().split('T')[0],
|
||
endTime: endDateTime.toTimeString().split(' ')[0].slice(0, 5)
|
||
});
|
||
|
||
const response = await fetch(`/api/check-availability?${params}`);
|
||
if (!response.ok) {
|
||
throw new Error('Failed to check availability');
|
||
}
|
||
|
||
const data = await response.json();
|
||
return data.available;
|
||
} catch (error) {
|
||
console.error('Error checking availability:', error);
|
||
throw new Error('Could not verify vehicle availability');
|
||
}
|
||
}
|
||
|
||
// Show status message function
|
||
function showMessage(text, type) {
|
||
const statusContainer = document.getElementById('statusMessage');
|
||
if (!statusContainer) {
|
||
console.error('Status message container not found');
|
||
return;
|
||
}
|
||
|
||
statusContainer.className = 'mt-4 p-4 rounded-md';
|
||
statusContainer.classList.remove('hidden');
|
||
|
||
switch (type) {
|
||
case 'success':
|
||
statusContainer.classList.add('bg-green-100', 'text-green-700');
|
||
break;
|
||
case 'error':
|
||
statusContainer.classList.add('bg-red-100', 'text-red-700');
|
||
break;
|
||
case 'info':
|
||
statusContainer.classList.add('bg-blue-100', 'text-blue-700');
|
||
break;
|
||
}
|
||
|
||
statusContainer.textContent = text;
|
||
|
||
// Auto hide after 5 seconds
|
||
setTimeout(() => {
|
||
statusContainer.classList.add('hidden');
|
||
}, 5000);
|
||
}
|
||
|
||
// Handle form submission
|
||
reservationForm.addEventListener('submit', async function(e) {
|
||
e.preventDefault();
|
||
|
||
const startDate = document.getElementById('startDate').value;
|
||
const startTime = document.getElementById('startTime').value;
|
||
const endDate = document.getElementById('endDate').value;
|
||
const endTime = document.getElementById('endTime').value;
|
||
|
||
// Create ISO datetime strings
|
||
const startDateTime = new Date(`${startDate}T${startTime}`);
|
||
const endDateTime = new Date(`${endDate}T${endTime}`);
|
||
|
||
// Validate dates
|
||
if (endDateTime <= startDateTime) {
|
||
showMessage('Konec musí být později než začátek', 'error');
|
||
return;
|
||
}
|
||
|
||
// Check vehicle availability
|
||
const vehicle = document.getElementById('vehicle').value;
|
||
const isAvailable = await checkVehicleAvailability(vehicle, startDateTime, endDateTime);
|
||
|
||
if (!isAvailable) {
|
||
showMessage('Vozidlo není v tomto čase dostupné', 'error');
|
||
return;
|
||
}
|
||
|
||
// Prepare reservation data
|
||
const reservationData = {
|
||
driverName: document.getElementById('driverName').value,
|
||
vehicle: vehicle,
|
||
startDate: startDate,
|
||
startTime: startTime,
|
||
endDate: endDate,
|
||
endTime: endTime,
|
||
purpose: document.getElementById('purpose').value
|
||
};
|
||
|
||
try {
|
||
const response = await fetch('/api/reservations', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json',
|
||
},
|
||
body: JSON.stringify(reservationData)
|
||
});
|
||
|
||
if (!response.ok) {
|
||
const errorData = await response.json();
|
||
throw new Error(errorData.message || 'Failed to create reservation');
|
||
}
|
||
|
||
showMessage('Rezervace byla úspěšně vytvořena', 'success');
|
||
reservationForm.reset();
|
||
calendar.refetchEvents();
|
||
} catch (error) {
|
||
console.error('Error:', error);
|
||
showMessage(error.message || 'Chyba při vytváření rezervace', 'error');
|
||
}
|
||
});
|
||
|
||
// Populate time dropdowns with full hours
|
||
function populateTimeDropdowns() {
|
||
const timeSelects = [document.getElementById('startTime'), document.getElementById('endTime')];
|
||
|
||
for (let hour = 6; hour <= 22; hour++) { // 6:00 to 22:00
|
||
const hourStr = hour.toString().padStart(2, '0');
|
||
const timeStr = `${hourStr}:00`;
|
||
const option = new Option(timeStr, timeStr);
|
||
|
||
timeSelects.forEach(select => {
|
||
select.appendChild(option.cloneNode(true));
|
||
});
|
||
}
|
||
}
|
||
|
||
// Initialize time dropdowns when page loads
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
populateTimeDropdowns();
|
||
|
||
// Set default dates to today
|
||
const today = new Date();
|
||
const dateStr = today.toISOString().split('T')[0];
|
||
document.getElementById('startDate').value = dateStr;
|
||
document.getElementById('endDate').value = dateStr;
|
||
});
|
||
});
|
||
</script>
|
||
</body>
|
||
</html> |