let currentDate = new Date(); let selectedDate = null; let selectedTime = null; let occupiedSlots = {}; const demoData = { fecha: null, hora: null, nombre: '', apellido: '', email: '', telefono: '', empresa: '', cargo: '', tamano: '', industria: '', notas: '', codigoPromo: null }; function parseOccupiedDates(fechasArray) { occupiedSlots = {}; fechasArray.forEach(fechaISO => { const [datePart, timePart] = fechaISO.split('T'); const [hours, minutes] = timePart.split(':'); const timeSlot = `${hours}:${minutes}`; if (!occupiedSlots[datePart]) { occupiedSlots[datePart] = []; } occupiedSlots[datePart].push(timeSlot); }); } // Horarios disponibles const timeSlots = [ { time: '09:00', label: '9:00 AM' }, { time: '10:00', label: '10:00 AM' }, { time: '11:00', label: '11:00 AM' }, { time: '12:00', label: '12:00 PM' }, { time: '13:00', label: '1:00 PM' }, { time: '14:00', label: '2:00 PM' }, { time: '15:00', label: '3:00 PM' }, { time: '16:00', label: '4:00 PM' }, { time: '17:00', label: '5:00 PM' } ]; function initCalendar() { renderCalendar(currentDate); } function isBusinessDay(date) { const day = date.getDay(); return day !== 0 && day !== 6; } function getMinimumDate() { let minDate = new Date(); let businessDaysCount = 0; while (businessDaysCount < 2) { minDate.setDate(minDate.getDate() + 1); if (isBusinessDay(minDate)) { businessDaysCount++; } } return minDate; } function isDateSelectable(date) { const minDate = getMinimumDate(); minDate.setHours(0, 0, 0, 0); const checkDate = new Date(date); checkDate.setHours(0, 0, 0, 0); return isBusinessDay(date) && checkDate >= minDate; } function renderCalendar(date) { const year = date.getFullYear(); const month = date.getMonth(); const monthNames = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']; $('#monthYear').text(`${monthNames[month]} ${year}`); const firstDay = new Date(year, month, 1); const lastDay = new Date(year, month + 1, 0); const prevLastDay = new Date(year, month, 0); const grid = $('#calendarGrid'); grid.find('.calendar-day').remove(); const firstDayOfWeek = firstDay.getDay(); for (let i = firstDayOfWeek - 1; i >= 0; i--) { const day = prevLastDay.getDate() - i; const dayDate = new Date(year, month - 1, day); const dayDiv = $('
Estás por agendar una demo con los siguientes datos:
📅 Fecha: ${fechaTexto}
🕐 Horario: ${horaTexto}
📧 Correo: ${demoData.email}