fix scheduler orario start, immagine parcheggio, added more logs function
This commit is contained in:
@@ -17,8 +17,36 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
await loadOffices();
|
||||
setupEventListeners();
|
||||
populateTimeSelects();
|
||||
});
|
||||
|
||||
function populateTimeSelects() {
|
||||
const hoursSelect = document.getElementById('officeCutoffHour');
|
||||
const minutesSelect = document.getElementById('officeCutoffMinute');
|
||||
|
||||
// Clear existing
|
||||
hoursSelect.innerHTML = '';
|
||||
minutesSelect.innerHTML = ''; // Re-creating to allow 0-59 range
|
||||
|
||||
// Populate Hours 0-23
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const val = i.toString().padStart(2, '0');
|
||||
const opt = document.createElement('option');
|
||||
opt.value = i;
|
||||
opt.textContent = val;
|
||||
hoursSelect.appendChild(opt);
|
||||
}
|
||||
|
||||
// Populate Minutes 0-59
|
||||
for (let i = 0; i < 60; i++) {
|
||||
const val = i.toString().padStart(2, '0');
|
||||
const opt = document.createElement('option');
|
||||
opt.value = i;
|
||||
opt.textContent = val;
|
||||
minutesSelect.appendChild(opt);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadOffices() {
|
||||
const response = await api.get('/api/offices');
|
||||
if (response && response.ok) {
|
||||
@@ -70,6 +98,11 @@ async function editOffice(officeId) {
|
||||
document.getElementById('officeName').value = office.name;
|
||||
document.getElementById('officeQuota').value = office.parking_quota;
|
||||
|
||||
// Set booking window settings
|
||||
document.getElementById('officeWindowEnabled').checked = office.booking_window_enabled !== false;
|
||||
document.getElementById('officeCutoffHour').value = office.booking_window_end_hour != null ? office.booking_window_end_hour : 18;
|
||||
document.getElementById('officeCutoffMinute').value = office.booking_window_end_minute != null ? office.booking_window_end_minute : 0;
|
||||
|
||||
openModal('Modifica Ufficio');
|
||||
}
|
||||
|
||||
@@ -123,7 +156,10 @@ async function handleOfficeSubmit(e) {
|
||||
const officeId = document.getElementById('officeId').value;
|
||||
const data = {
|
||||
name: document.getElementById('officeName').value,
|
||||
parking_quota: parseInt(document.getElementById('officeQuota').value) || 0
|
||||
parking_quota: parseInt(document.getElementById('officeQuota').value) || 0,
|
||||
booking_window_enabled: document.getElementById('officeWindowEnabled').checked,
|
||||
booking_window_end_hour: parseInt(document.getElementById('officeCutoffHour').value),
|
||||
booking_window_end_minute: parseInt(document.getElementById('officeCutoffMinute').value)
|
||||
};
|
||||
|
||||
console.log('Payload:', data);
|
||||
|
||||
@@ -72,6 +72,15 @@ function populateHourSelect() {
|
||||
option.textContent = h.toString().padStart(2, '0');
|
||||
select.appendChild(option);
|
||||
}
|
||||
|
||||
const minuteSelect = document.getElementById('bookingWindowMinute');
|
||||
minuteSelect.innerHTML = '';
|
||||
for (let m = 0; m < 60; m++) {
|
||||
const option = document.createElement('option');
|
||||
option.value = m;
|
||||
option.textContent = m.toString().padStart(2, '0');
|
||||
minuteSelect.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadOfficeSettings(id) {
|
||||
|
||||
Reference in New Issue
Block a user