Add Prozent im ADmin für wochenende
This commit is contained in:
@@ -54,6 +54,43 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// LDAP-Konfiguration laden
|
||||
loadLDAPConfig();
|
||||
|
||||
// Optionen laden
|
||||
loadOptions();
|
||||
|
||||
// Optionen-Formular
|
||||
const optionsForm = document.getElementById('optionsForm');
|
||||
if (optionsForm) {
|
||||
optionsForm.addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = {
|
||||
saturday_percentage: document.getElementById('saturdayPercentage').value,
|
||||
sunday_percentage: document.getElementById('sundayPercentage').value
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch('/admin/options', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alert('Optionen wurden erfolgreich gespeichert!');
|
||||
} else {
|
||||
alert('Fehler: ' + (result.error || 'Optionen konnten nicht gespeichert werden'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler:', error);
|
||||
alert('Fehler beim Speichern der Optionen');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// LDAP-Konfigurationsformular
|
||||
const ldapConfigForm = document.getElementById('ldapConfigForm');
|
||||
if (ldapConfigForm) {
|
||||
@@ -161,6 +198,27 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Optionen laden und Formular ausfüllen
|
||||
async function loadOptions() {
|
||||
try {
|
||||
const response = await fetch('/admin/options');
|
||||
const result = await response.json();
|
||||
|
||||
if (result.config) {
|
||||
const config = result.config;
|
||||
|
||||
if (document.getElementById('saturdayPercentage')) {
|
||||
document.getElementById('saturdayPercentage').value = config.saturday_percentage || 0;
|
||||
}
|
||||
if (document.getElementById('sundayPercentage')) {
|
||||
document.getElementById('sundayPercentage').value = config.sunday_percentage || 0;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Optionen:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// LDAP-Konfiguration laden und Formular ausfüllen
|
||||
async function loadLDAPConfig() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user