Commit 51d53725 authored by uoure's avatar uoure
Browse files

Delete adminScripts.js

parent d22d9d93
var reservationData;
function onLoad() {
loadOpeningDates();
}
function loadOpeningDates() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var dropdown = document.getElementById("reservationDate")
var data = JSON.parse(this.responseText);
data.forEach(function(date) {
var option = document.createElement("option");
option.text = date;
dropdown.add(option);
});
loadReservations();
}
};
xhttp.open("GET", "getOpeningDates.php", true);
xhttp.send();
}
function loadReservations() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
reservationData = JSON.parse(this.responseText);
var table = document.getElementById("reservations");
table.innerHTML = "";
for (var i=0; i<reservationData.length; i++) {
var row = table.insertRow(-1);
row.insertCell(0).innerHTML = reservationData[i]["vname"];
row.insertCell(1).innerHTML = reservationData[i]["nname"];
row.insertCell(2).innerHTML = reservationData[i]["start"];
row.insertCell(3).innerHTML = reservationData[i]["end"];
row.insertCell(4).innerHTML = reservationData[i]["tisch"];
var buttonCell = row.insertCell(5);
buttonCell.innerHTML = "<button onclick='endReservation(" + i + ")'>ENDE</button>";
}
}
};
xhttp.open("POST", "getReservationsAdmin.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("date=" + document.getElementById("reservationDate").value + "&withEnded=" + document.getElementById("withEnded").checked);
}
function endReservation(id) {
if (!confirm("Reservierung für " + reservationData[id]["vname"] + " " + reservationData[id]["nname"] + " wirklich beenden?")) {
return;
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.responseText == "1") {
alert("Reservierung erfolgreich beendet");
} else {
console.log(this.responseText);
alert("Es ist ein Fehler aufgetreten");
}
loadReservations();
}
};
xhttp.open("POST", "endReservationAdmin.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("id=" + reservationData[id]["id"]);
}
function deleteOldData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert("Es wurden " + this.responseText + " Einträge gelöscht!");
}
};
xhttp.open("POST", "deleteOldEntriesAdmin.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send();
}
function createNewEvent() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
if (this.responseText == "1") {
alert("Veranstaltung wurde erstellt.");
} else {
alert("Es ist ein Fehler aufgetreten. Vielleicht existiert an diesem Tag schon eine Veranstaltung");
}
}
};
xhttp.open("POST", "createEventAdmin.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("name=" + document.getElementById("createName").value +
"&date=" + document.getElementById("createDate").value +
"&open=" + document.getElementById("createStartTime").value +
"&close=" + document.getElementById("createEndTime").value +
"&tables=" + document.getElementById("createTables").value);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment