Finish Opfer Page
This commit is contained in:
31
api/opfer/delete.php
Normal file
31
api/opfer/delete.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
require "../api.php";
|
||||||
|
|
||||||
|
$api = new spamhasiApi();
|
||||||
|
|
||||||
|
if (!$api->checkAuth()) {
|
||||||
|
header("Location: /index.html?status=500&error=Unauthorized");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_POST["id"])) {
|
||||||
|
die('{"status":500, "error":"Missing fields"}');
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = intval($_POST["id"]);
|
||||||
|
|
||||||
|
$db = $api->getDB();
|
||||||
|
|
||||||
|
$sql = "DELETE FROM opfer WHERE id = :id";
|
||||||
|
|
||||||
|
$stmt = $db->prepare($sql);
|
||||||
|
|
||||||
|
$sql_exec = $stmt->execute([':id' => $id]);
|
||||||
|
|
||||||
|
if ($sql_exec) {
|
||||||
|
header("Location: /index.html?status=200");
|
||||||
|
}else{
|
||||||
|
header("Location: /index.html?status=500&error=SQL Error");
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
?>
|
||||||
44
api/opfer/edit.php
Normal file
44
api/opfer/edit.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
require "../api.php";
|
||||||
|
|
||||||
|
ini_set("display_errors", 1);
|
||||||
|
ini_set("display_startup_errors", 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
$api = new spamhasiApi();
|
||||||
|
|
||||||
|
if (!$api->checkAuth()) {
|
||||||
|
header("Location: /index.html?status=500&error=Unauthorized");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_POST["id"]) || !isset($_POST["name"]) || !isset($_POST["mail"]) || !isset($_POST["number"])) {
|
||||||
|
die('{"status":500, "error":"Missing fields"}');
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = htmlspecialchars($_POST["name"]);
|
||||||
|
$mail = htmlspecialchars($_POST["mail"]);
|
||||||
|
$number = intval(htmlspecialchars($_POST["number"]));
|
||||||
|
echo $number;
|
||||||
|
$id = intval(htmlspecialchars($_POST["id"]));
|
||||||
|
if (isset($_POST["enabled2"])) {
|
||||||
|
$enabled = 1;
|
||||||
|
}else{
|
||||||
|
$enabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = $api->getDB();
|
||||||
|
|
||||||
|
$sql = "UPDATE opfer SET name = :name, mail = :mail, number = :number, status = :status WHERE id = :id";
|
||||||
|
|
||||||
|
$stmt = $db->prepare($sql);
|
||||||
|
|
||||||
|
$sql_exec = $stmt->execute([':name' => $name, ':mail' => $mail, ':number' => $number, ':status' => $enabled, ':id' => $id]);
|
||||||
|
|
||||||
|
if ($sql_exec) {
|
||||||
|
header("Location: /index.html?status=200");
|
||||||
|
}else{
|
||||||
|
header("Location: /index.html?status=500&error=SQL Error");
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
?>
|
||||||
@@ -19,7 +19,7 @@ $sql = "SELECT * FROM opfer WHERE id = :id";
|
|||||||
$stmt = $db->prepare($sql);
|
$stmt = $db->prepare($sql);
|
||||||
$stmt->execute([':id' => $id]);
|
$stmt->execute([':id' => $id]);
|
||||||
|
|
||||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$json["opfer"] = $result;
|
$json["opfer"] = $result;
|
||||||
|
|||||||
@@ -665,7 +665,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<!---<script>
|
||||||
fetch("/api/opfer/list.php")
|
fetch("/api/opfer/list.php")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -691,7 +691,8 @@
|
|||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
@click="isOpferAdd = true"
|
@click="isOpferEdit = true"
|
||||||
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
>
|
>
|
||||||
` + opfer.name + `
|
` + opfer.name + `
|
||||||
@@ -727,7 +728,53 @@
|
|||||||
document.getElementById("opfer_table").innerHTML = list;
|
document.getElementById("opfer_table").innerHTML = list;
|
||||||
})
|
})
|
||||||
.catch(error => console.error("API Error: " + error))
|
.catch(error => console.error("API Error: " + error))
|
||||||
</script>
|
|
||||||
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
|
fetch("/api/opfer/info.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const opfer = data.opfer;
|
||||||
|
|
||||||
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
</script>--->
|
||||||
</div>
|
</div>
|
||||||
<!-- ====== Table Six End -->
|
<!-- ====== Table Six End -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
208
front/index.html
208
front/index.html
@@ -639,7 +639,7 @@
|
|||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
||||||
Das neue Opfer wurde erfolgreich hinzugefügt!
|
Die Aktion wurde erfolgreich ausgeführt
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -751,7 +751,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<!---<script>
|
||||||
fetch("/api/opfer/list.php")
|
fetch("/api/opfer/list.php")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -777,7 +777,8 @@
|
|||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
@click="isOpferAdd = true"
|
@click="isOpferEdit = true"
|
||||||
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
>
|
>
|
||||||
` + opfer.name + `
|
` + opfer.name + `
|
||||||
@@ -813,7 +814,53 @@
|
|||||||
document.getElementById("opfer_table").innerHTML = list;
|
document.getElementById("opfer_table").innerHTML = list;
|
||||||
})
|
})
|
||||||
.catch(error => console.error("API Error: " + error))
|
.catch(error => console.error("API Error: " + error))
|
||||||
</script>
|
|
||||||
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
|
fetch("/api/opfer/info.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const opfer = data.opfer;
|
||||||
|
|
||||||
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
</script>--->
|
||||||
</div>
|
</div>
|
||||||
<!-- ====== Table Six End -->
|
<!-- ====== Table Six End -->
|
||||||
</div>
|
</div>
|
||||||
@@ -1014,6 +1061,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
required
|
required
|
||||||
|
id="opfer_name"
|
||||||
type="text"
|
type="text"
|
||||||
value=""
|
value=""
|
||||||
name="name"
|
name="name"
|
||||||
@@ -1029,6 +1077,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
required
|
required
|
||||||
|
id="opfer_mail"
|
||||||
type="text"
|
type="text"
|
||||||
name="mail"
|
name="mail"
|
||||||
value=""
|
value=""
|
||||||
@@ -1044,6 +1093,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
required
|
required
|
||||||
|
id="opfer_number"
|
||||||
name="number"
|
name="number"
|
||||||
type="text"
|
type="text"
|
||||||
value=""
|
value=""
|
||||||
@@ -1051,15 +1101,15 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div x-data="{ switcherToggle: false }">
|
<!---<div x-data="{ switcherToggle: false }" id="toogle_div">
|
||||||
<label
|
<label
|
||||||
for="toggle1"
|
for="opfer_aktive"
|
||||||
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
||||||
>
|
>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="toggle1"
|
id="opfer_aktive"
|
||||||
name="enabled"
|
name="enabled"
|
||||||
class="sr-only"
|
class="sr-only"
|
||||||
@change="switcherToggle = !switcherToggle"
|
@change="switcherToggle = !switcherToggle"
|
||||||
@@ -1074,12 +1124,39 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Aktiviert
|
||||||
|
</label>
|
||||||
|
</div>--->
|
||||||
|
<div x-data="{ switcherToggle: false }" id="toogle2_div">
|
||||||
|
<label
|
||||||
|
for="toggle2"
|
||||||
|
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
||||||
|
>
|
||||||
|
<div class="relative">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="toggle2"
|
||||||
|
name="enabled2"
|
||||||
|
class="sr-only"
|
||||||
|
@change="switcherToggle = !switcherToggle"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="block h-6 w-11 rounded-full"
|
||||||
|
:class="switcherToggle ? 'bg-brand-500 dark:bg-brand-500' : 'bg-gray-200 dark:bg-white/10'"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
:class="switcherToggle ? 'translate-x-full': 'translate-x-0'"
|
||||||
|
class="shadow-theme-sm absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white duration-300 ease-linear"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
Aktiviert
|
Aktiviert
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="id" value="" id="opfer_id">
|
||||||
<div class="flex items-center gap-3 px-2 mt-6 lg:justify-end">
|
<div class="flex items-center gap-3 px-2 mt-6 lg:justify-end">
|
||||||
<button
|
<button
|
||||||
@click="isOpferEdit = false"
|
@click="isOpferEdit = false"
|
||||||
@@ -1088,6 +1165,14 @@
|
|||||||
>
|
>
|
||||||
Später
|
Später
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onclick="removeOpfer()"
|
||||||
|
type="button"
|
||||||
|
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
||||||
|
style="background-color: #e70000;"
|
||||||
|
>
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
||||||
@@ -1108,6 +1193,115 @@
|
|||||||
document.getElementById("alert-error").style.display = "block";
|
document.getElementById("alert-error").style.display = "block";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetch("/api/opfer/list.php")
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = document.getElementById("opfer_table").innerHTML;
|
||||||
|
|
||||||
|
for (const opfer of data.opfer) {
|
||||||
|
if (opfer.enabled) {
|
||||||
|
var status_class = "rounded-full bg-success-50 px-2 py-0.5 text-theme-xs font-medium text-success-700 dark:bg-success-500/15 dark:text-success-500";
|
||||||
|
var status_text = "Enabled";
|
||||||
|
}else{
|
||||||
|
var status_class = "rounded-full bg-error-50 px-2 py-0.5 text-theme-xs font-medium text-error-700 dark:bg-error-500/15 dark:text-error-500";
|
||||||
|
var status_text = "Disabled";
|
||||||
|
}
|
||||||
|
|
||||||
|
list += `
|
||||||
|
<tr>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
@click="isOpferEdit = true"
|
||||||
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
|
>
|
||||||
|
` + opfer.name + `
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p class="text-gray-500 text-theme-sm dark:text-gray-400">
|
||||||
|
` + opfer.mail + `
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p
|
||||||
|
class="` + status_class + `"
|
||||||
|
>
|
||||||
|
` + status_text + `
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p class="text-gray-500 text-theme-sm dark:text-gray-400">` + opfer.number + `</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
document.getElementById("opfer_table").innerHTML = list;
|
||||||
|
})
|
||||||
|
.catch(error => console.error("API Error: " + error))
|
||||||
|
|
||||||
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
|
fetch("/api/opfer/info.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const opfer = data.opfer;
|
||||||
|
|
||||||
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script defer src="bundle.js"></script></body>
|
<script defer src="bundle.js"></script></body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -665,7 +665,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<!---<script>
|
||||||
fetch("/api/opfer/list.php")
|
fetch("/api/opfer/list.php")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -691,7 +691,8 @@
|
|||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
@click="isOpferAdd = true"
|
@click="isOpferEdit = true"
|
||||||
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
>
|
>
|
||||||
` + opfer.name + `
|
` + opfer.name + `
|
||||||
@@ -727,7 +728,53 @@
|
|||||||
document.getElementById("opfer_table").innerHTML = list;
|
document.getElementById("opfer_table").innerHTML = list;
|
||||||
})
|
})
|
||||||
.catch(error => console.error("API Error: " + error))
|
.catch(error => console.error("API Error: " + error))
|
||||||
</script>
|
|
||||||
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
|
fetch("/api/opfer/info.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const opfer = data.opfer;
|
||||||
|
|
||||||
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
</script>--->
|
||||||
</div>
|
</div>
|
||||||
<!-- ====== Table Six End -->
|
<!-- ====== Table Six End -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
||||||
Das neue Opfer wurde erfolgreich hinzugefügt!
|
Die Aktion wurde erfolgreich ausgeführt
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -179,6 +179,115 @@
|
|||||||
document.getElementById("alert-error").style.display = "block";
|
document.getElementById("alert-error").style.display = "block";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetch("/api/opfer/list.php")
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = document.getElementById("opfer_table").innerHTML;
|
||||||
|
|
||||||
|
for (const opfer of data.opfer) {
|
||||||
|
if (opfer.enabled) {
|
||||||
|
var status_class = "rounded-full bg-success-50 px-2 py-0.5 text-theme-xs font-medium text-success-700 dark:bg-success-500/15 dark:text-success-500";
|
||||||
|
var status_text = "Enabled";
|
||||||
|
}else{
|
||||||
|
var status_class = "rounded-full bg-error-50 px-2 py-0.5 text-theme-xs font-medium text-error-700 dark:bg-error-500/15 dark:text-error-500";
|
||||||
|
var status_text = "Disabled";
|
||||||
|
}
|
||||||
|
|
||||||
|
list += `
|
||||||
|
<tr>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
@click="isOpferEdit = true"
|
||||||
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
|
>
|
||||||
|
` + opfer.name + `
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p class="text-gray-500 text-theme-sm dark:text-gray-400">
|
||||||
|
` + opfer.mail + `
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p
|
||||||
|
class="` + status_class + `"
|
||||||
|
>
|
||||||
|
` + status_text + `
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-5 py-4 sm:px-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<p class="text-gray-500 text-theme-sm dark:text-gray-400">` + opfer.number + `</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
document.getElementById("opfer_table").innerHTML = list;
|
||||||
|
})
|
||||||
|
.catch(error => console.error("API Error: " + error))
|
||||||
|
|
||||||
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
|
fetch("/api/opfer/info.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.status == 500) {
|
||||||
|
console.error("API Error: " + data.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const opfer = data.opfer;
|
||||||
|
|
||||||
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div x-data="{ switcherToggle: false }">
|
<!---<div x-data="{ switcherToggle: false }" id="toogle_div">
|
||||||
<label
|
<label
|
||||||
for="opfer_aktive"
|
for="opfer_aktive"
|
||||||
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
||||||
@@ -113,12 +113,39 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Aktiviert
|
||||||
|
</label>
|
||||||
|
</div>--->
|
||||||
|
<div x-data="{ switcherToggle: false }" id="toogle2_div">
|
||||||
|
<label
|
||||||
|
for="toggle2"
|
||||||
|
class="flex cursor-pointer items-center gap-3 text-sm font-medium text-gray-700 select-none dark:text-gray-400"
|
||||||
|
>
|
||||||
|
<div class="relative">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="toggle2"
|
||||||
|
name="enabled2"
|
||||||
|
class="sr-only"
|
||||||
|
@change="switcherToggle = !switcherToggle"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="block h-6 w-11 rounded-full"
|
||||||
|
:class="switcherToggle ? 'bg-brand-500 dark:bg-brand-500' : 'bg-gray-200 dark:bg-white/10'"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
:class="switcherToggle ? 'translate-x-full': 'translate-x-0'"
|
||||||
|
class="shadow-theme-sm absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white duration-300 ease-linear"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
Aktiviert
|
Aktiviert
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" name="id" value="" id="opfer_id">
|
||||||
<div class="flex items-center gap-3 px-2 mt-6 lg:justify-end">
|
<div class="flex items-center gap-3 px-2 mt-6 lg:justify-end">
|
||||||
<button
|
<button
|
||||||
@click="isOpferEdit = false"
|
@click="isOpferEdit = false"
|
||||||
@@ -127,6 +154,14 @@
|
|||||||
>
|
>
|
||||||
Später
|
Später
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onclick="removeOpfer()"
|
||||||
|
type="button"
|
||||||
|
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
||||||
|
style="background-color: #e70000;"
|
||||||
|
>
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
class="flex w-full justify-center rounded-lg bg-brand-500 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-600 sm:w-auto"
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<!---<script>
|
||||||
fetch("/api/opfer/list.php")
|
fetch("/api/opfer/list.php")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
@click="isOpferAdd = true"
|
@click="isOpferEdit = true"
|
||||||
onclick="opferEdit(` + opfer.id + `)"
|
onclick="opferEdit(` + opfer.id + `)"
|
||||||
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||||
>
|
>
|
||||||
@@ -116,25 +116,49 @@
|
|||||||
.catch(error => console.error("API Error: " + error))
|
.catch(error => console.error("API Error: " + error))
|
||||||
|
|
||||||
function opferEdit(id) {
|
function opferEdit(id) {
|
||||||
|
console.log(document.getElementById("opfer_name"));
|
||||||
fetch("/api/opfer/info.php", {
|
fetch("/api/opfer/info.php", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: "id=" + id
|
||||||
id: id
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.then(respone => respone.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.status == 500) {
|
if (data.status == 500) {
|
||||||
console.error("API Error: " + data.error);
|
console.error("API Error: " + data.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("opfer_name").innerHTML = data.name;
|
const opfer = data.opfer;
|
||||||
document.getElementById("opfer_mail").innerHTML = data.mail;
|
|
||||||
document.getElementById("opfer_name").innerHTML = data.number;
|
document.getElementById("opfer_id").value = id;
|
||||||
|
document.getElementById("opfer_name").value = opfer.name;
|
||||||
|
document.getElementById("opfer_mail").value = opfer.mail;
|
||||||
|
document.getElementById("opfer_number").value = opfer.number;
|
||||||
|
|
||||||
|
|
||||||
|
if (data.status == 1) {
|
||||||
|
const toogle_el = document.querySelector('#toggle2');
|
||||||
|
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||||
|
|
||||||
|
toogle_data.switcherToggle = data.status;
|
||||||
|
toogle_el.checked = data.status;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
|
function removeOpfer() {
|
||||||
|
const id = document.getElementById("opfer_id").value;
|
||||||
|
|
||||||
|
fetch("/api/opfer/delete.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: "id=" + id
|
||||||
|
})
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
</script>--->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"270":{"session_id":"896d8b84fd9ae2471bc70a2023f55db83a8e88244bfb92f0c06e7a05c8d03599"}}
|
{"790":{"session_id":"a1e9095da4163edca39dac5b27750ebabbe40cb047115202465374ced9e3732b"}}
|
||||||
Reference in New Issue
Block a user