settings.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. require_once __DIR__ . "/../config.php";
  3. require_once __DIR__ . "/../includes/functions.php";
  4. if (empty($_SESSION["admin_logged_in"])) {
  5. header("Location: login.php");
  6. exit();
  7. }
  8. $pageTitle = "Einstellungen";
  9. $message = "";
  10. $messageType = "";
  11. if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["save_settings"])) {
  12. // Validate CSRF token
  13. if (!validateCsrfToken($_POST["csrf_token"] ?? "")) {
  14. $message = "Ungültiges Token. Bitte versuchen Sie es erneut.";
  15. $messageType = "error";
  16. } else {
  17. $settings = [
  18. "order_recipient_email" => $_POST["order_recipient_email"] ?? "",
  19. "order_confirmation_required" => isset(
  20. $_POST["order_confirmation_required"],
  21. ),
  22. "order_confirmation_expiry_days" =>
  23. (int) ($_POST["order_confirmation_expiry_days"] ?? 7),
  24. "attach_order_pdf_to_admin_email" => isset(
  25. $_POST["attach_order_pdf_to_admin_email"],
  26. ),
  27. ];
  28. saveSystemSettings($settings);
  29. logAccess("Admin updated system settings");
  30. $message = "Einstellungen wurden gespeichert.";
  31. $messageType = "success";
  32. }
  33. }
  34. $settings = getSystemSettings();
  35. $bodyClass = "admin-page";
  36. include __DIR__ . "/../includes/header.php";
  37. ?>
  38. <div class="admin-header">
  39. <h2>Einstellungen</h2>
  40. <div>
  41. <a href="index.php" class="btn btn-secondary">Zurück zum Dashboard</a>
  42. </div>
  43. </div>
  44. <?php if ($message !== ""): ?>
  45. <div class="alert alert-<?php echo escape($messageType); ?>">
  46. <?php echo escape($message); ?>
  47. </div>
  48. <?php endif; ?>
  49. <div class="panel panel-lg">
  50. <form method="POST">
  51. <?php echo csrfField(); ?>
  52. <div class="form-group">
  53. <label for="order_recipient_email">Empfängeradresse für interne Bestellungen *</label>
  54. <input type="email" id="order_recipient_email" name="order_recipient_email" required value="<?php echo escape(
  55. $settings["order_recipient_email"],
  56. ); ?>">
  57. </div>
  58. <div class="form-group">
  59. <label>
  60. <input type="checkbox" name="order_confirmation_required" value="1" <?php echo !empty(
  61. $settings["order_confirmation_required"]
  62. )
  63. ? "checked"
  64. : ""; ?>>
  65. Bestellungen müssen vor interner Weiterleitung per E-Mail bestätigt werden
  66. </label>
  67. </div>
  68. <div class="form-group">
  69. <label for="order_confirmation_expiry_days">Bestätigungsfrist in Tagen *</label>
  70. <input type="number" id="order_confirmation_expiry_days" name="order_confirmation_expiry_days" min="1" required value="<?php echo (int) $settings[
  71. "order_confirmation_expiry_days"
  72. ]; ?>">
  73. </div>
  74. <div class="form-group">
  75. <label>
  76. <input type="checkbox" name="attach_order_pdf_to_admin_email" value="1" <?php echo !empty(
  77. $settings["attach_order_pdf_to_admin_email"]
  78. )
  79. ? "checked"
  80. : ""; ?>>
  81. PDF an interne Bestell-E-Mails anhängen
  82. </label>
  83. </div>
  84. <button type="submit" name="save_settings" class="btn">Speichern</button>
  85. </form>
  86. </div>
  87. <?php include __DIR__ . "/../includes/footer.php"; ?>