Fix: Kategorie-Farben werden nun korrekt gespeichert
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 40s
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 40s
This commit is contained in:
@@ -44,9 +44,12 @@ $types = str_repeat('i', count($household_member_ids));
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (isset($_POST['add_category'])) {
|
||||
$category_name = trim($_POST['category_name']);
|
||||
$category_color = trim($_POST['category_color'] ?? '#e2e8f0');
|
||||
if (!preg_match('/^#[a-f0-9]{6}$/i', $category_color)) $category_color = '#e2e8f0';
|
||||
|
||||
if (!empty($category_name)) {
|
||||
$stmt = $conn->prepare("INSERT INTO categories (name, user_id) VALUES (?, ?)");
|
||||
$stmt->bind_param("si", $category_name, $current_user_id);
|
||||
$stmt = $conn->prepare("INSERT INTO categories (name, user_id, color) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("sis", $category_name, $current_user_id, $category_color);
|
||||
if ($stmt->execute()) {
|
||||
if ($household_id) {
|
||||
$log_message = htmlspecialchars($_SESSION['username']) . " hat die Kategorie '" . htmlspecialchars($category_name) . "' hinzugefügt.";
|
||||
@@ -68,10 +71,12 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
elseif (isset($_POST['edit_category'])) {
|
||||
$category_id = intval($_POST['category_id']);
|
||||
$category_name = trim($_POST['category_name']);
|
||||
$category_color = trim($_POST['category_color'] ?? '#e2e8f0');
|
||||
if (!preg_match('/^#[a-f0-9]{6}$/i', $category_color)) $category_color = '#e2e8f0';
|
||||
|
||||
if (!empty($category_name) && $category_id > 0) {
|
||||
$stmt = $conn->prepare("UPDATE categories SET name = ? WHERE id = ? AND user_id = ?");
|
||||
$stmt->bind_param("sii", $category_name, $category_id, $current_user_id);
|
||||
$stmt = $conn->prepare("UPDATE categories SET name = ?, color = ? WHERE id = ? AND user_id = ?");
|
||||
$stmt->bind_param("ssii", $category_name, $category_color, $category_id, $current_user_id);
|
||||
if ($stmt->execute()) {
|
||||
if ($household_id) {
|
||||
$log_message = htmlspecialchars($_SESSION['username']) . " hat die Kategorie '" . htmlspecialchars($category_name) . "' bearbeitet.";
|
||||
|
||||
Reference in New Issue
Block a user