diff --git a/html/assets/css/style.css b/html/assets/css/style.css index b2bdb44..90c82a9 100644 --- a/html/assets/css/style.css +++ b/html/assets/css/style.css @@ -260,6 +260,10 @@ td.align-right { text-align: right; } +img.pencil { + margin-top: 10px; +} + th { background: var(--primary-color); color: white; diff --git a/html/assets/img/pencil.png b/html/assets/img/pencil.png new file mode 100644 index 0000000..729f56d Binary files /dev/null and b/html/assets/img/pencil.png differ diff --git a/html/dashboard.php b/html/dashboard.php index 5c0ddfe..7007c96 100644 --- a/html/dashboard.php +++ b/html/dashboard.php @@ -44,7 +44,7 @@ WHERE EXTRACT(YEAR FROM e.date) = EXTRACT(YEAR FROM CURRENT_DATE()) AND EXTRACT(MONTH FROM e.date) = EXTRACT(MONTH FROM CURRENT_DATE()) ORDER BY -e.date DESC; +e.date DESC, id desc; "; $stmt = $pdo->prepare($sql); @@ -86,6 +86,7 @@ $entries = $stmt->fetchAll(); Betreff Betrag Hinweis +  @@ -99,6 +100,11 @@ $entries = $stmt->fetchAll(); + + + + + diff --git a/html/edit_entry.php b/html/edit_entry.php new file mode 100644 index 0000000..757c6c5 --- /dev/null +++ b/html/edit_entry.php @@ -0,0 +1,214 @@ +prepare(" + SELECT * FROM entries + WHERE id = :id + "); + $stmtEntry->bindParam(':id', $entry_id, PDO::PARAM_INT); + $stmtEntry->execute(); + $entry = $stmtEntry->fetch(PDO::FETCH_ASSOC); + + if (!$entry) { + header('Location: dashboard.php'); + exit; + } +} catch (PDOException $e) { + $data_saved = "Fehler: Eintrag konnte nicht geladen werden."; +} + +// Speicher-Logik +if (!empty($_POST)) { + $date = isset($_POST['date']) ? trim($_POST['date']) : ''; + $user_id = isset($_POST['user_id']) ? trim($_POST['user_id']) : ''; + $person = isset($_POST['person']) ? $_POST['person'] : []; + $category = isset($_POST['category']) ? trim($_POST['category']) : ''; + $subject = isset($_POST['subject']) ? trim($_POST['subject']) : ''; + $note = isset($_POST['note']) ? trim($_POST['note']) : ''; + $amount = isset($_POST['amount']) ? (float)$_POST['amount'] : 0.0; + $payment_method = isset($_POST['payment_method']) ? trim($_POST['payment_method']) : ''; + $jsonPersonen = json_encode($person); + + try { + $stmt = $pdo->prepare(" + UPDATE entries + SET + date = :date, + user_id = :user_id, + person = :person, + category = :category, + subject = :subject, + amount = :amount, + payment_method = :payment_method, + note = :note + WHERE id = :id + "); + $stmt->bindParam(':id', $entry_id, PDO::PARAM_INT); + $stmt->bindParam(':date', $date); + $stmt->bindParam(':user_id', $user_id); + $stmt->bindParam(':person', $jsonPersonen); + $stmt->bindParam(':category', $category); + $stmt->bindParam(':subject', $subject); + $stmt->bindParam(':amount', $amount); + $stmt->bindParam(':payment_method', $payment_method); + $stmt->bindParam(':note', $note); + + $stmt->execute(); + $data_saved = "true"; + } catch (PDOException $e) { + $data_saved = "Fehler: " . $e->getMessage(); + } +} + +// Benutzer, Kategorien und Zahlweisen laden +try { + $stmtUsers = $pdo->prepare("SELECT * FROM users ORDER BY id;"); + $stmtUsers->execute(); + $users = $stmtUsers->fetchAll(PDO::FETCH_ASSOC); + + foreach ($users as $user) { + if ($user['id'] == $_SESSION['user_id']) { + $loggedInUserId = $user['id']; + break; + } + } + + $stmtCategories = $pdo->prepare("SELECT * FROM categories ORDER BY category_id;"); + $stmtCategories->execute(); + $categories = $stmtCategories->fetchAll(PDO::FETCH_ASSOC); + + $stmtPayMethods = $pdo->prepare("SELECT payment_method_id, name FROM payment_methods ORDER BY name;"); + $stmtPayMethods->execute(); + $pay_methods = $stmtPayMethods->fetchAll(PDO::FETCH_ASSOC); + +} catch (PDOException $e) { + $data_saved = "Fehler: "; +} +?> + + + + + +FSCash - Eintrag bearbeiten + + + +"; ?> + +
+Daten gespeichert ! +Zurück zur Übersicht + +
+ + +
+
+ + + + +
+
+ +
+
+ +
+ +
+ + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +