Initial
This commit is contained in:
commit
9ff7d0da71
16
diagramme.php
Normal file
16
diagramme.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Hello World!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
151
fix_edit.php
Normal file
151
fix_edit.php
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$data = $_SESSION['formdata'] ?? [];
|
||||||
|
unset($_SESSION['formdata']);
|
||||||
|
|
||||||
|
$kostenfix_id = $_POST['kostenfix_id'];
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT kf.id AS kostenfix_id,
|
||||||
|
kf.beschreibung,
|
||||||
|
zt.id AS zahlungstag_id,
|
||||||
|
zm.id AS zahlungsmonate_id,
|
||||||
|
kf.konto_id,
|
||||||
|
kf.betrag
|
||||||
|
FROM kostenfix kf
|
||||||
|
JOIN zahlungstag zt ON zt.id = kf.zahlungstag_id
|
||||||
|
JOIN zahlungsmonate zm ON zm.id = kf.zahlungsmonate_id
|
||||||
|
JOIN konto k ON k.id = kf.konto_id
|
||||||
|
WHERE kf.id = :kostenfix_id;");
|
||||||
|
$stmt->execute(['kostenfix_id' => $kostenfix_id]);
|
||||||
|
$kostenfixFetchAll = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if(count($kostenfixFetchAll) > 1) {
|
||||||
|
//TODO FEHLERHANDLING
|
||||||
|
} else {
|
||||||
|
$kostenfix = $kostenfixFetchAll[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungsmonate
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungsmonate = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungstag
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungstag = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, bezeichnung
|
||||||
|
FROM konto
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/fixkosten.php">
|
||||||
|
<input type="hidden" name="kostenfix_id" value="<?= htmlspecialchars($kostenfix_id) ?>">
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
<button class="header"
|
||||||
|
id="navigationLinks"
|
||||||
|
name="fixkosten_submit"
|
||||||
|
value="speichern"
|
||||||
|
type="submit">
|
||||||
|
<span>speichern</span>
|
||||||
|
</button>
|
||||||
|
<button class="header"
|
||||||
|
id="navigationMitte"
|
||||||
|
name="fixkosten_submit"
|
||||||
|
value="löschen"
|
||||||
|
type="submit">
|
||||||
|
<span>Eintrag löschen</span>
|
||||||
|
</button>
|
||||||
|
<a href="fixkosten.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
abbrechen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="inhalt">
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Zahlungsmonate
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="zahlungsmonate_id" class="fix_select">
|
||||||
|
<?php foreach ($zahlungsmonate as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= ((isset($data['zahlungsmonate_id']) && $y['id'] == $data['zahlungsmonate_id']) || $y['id'] == $kostenfix['zahlungsmonate_id']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['name']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Zahlungstag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="zahlungstag_id" class="fix_select">
|
||||||
|
<?php foreach ($zahlungstag as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= ((isset($data['zahlungstag_id']) && $y['id'] == $data['zahlungstag_id']) || $y['id'] == $kostenfix['zahlungstag_id']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['name']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Konto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="konto_id" class="umsatz_select">
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= ((isset($data['konto_id']) && $y['id'] == $data['konto_id']) || $y['id'] == $kostenfix['konto_id']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['bezeichnung']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="text" name="beschreibung" class="umsatz_text" value="<?= $data['beschreibung'] ?? $kostenfix['beschreibung']?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Betrag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="number" name="betrag" step="0.01" class="umsatz_number" value="<?= $data['betrag'] ?? $kostenfix['betrag'] ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
132
fix_neu.php
Normal file
132
fix_neu.php
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$data = $_SESSION['formdata'] ?? [];
|
||||||
|
unset($_SESSION['formdata']);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungsmonate
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungsmonate = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungstag
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungstag = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, bezeichnung
|
||||||
|
FROM konto
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/fixkosten.php">
|
||||||
|
<div class="header">
|
||||||
|
<button class="header"
|
||||||
|
id="navigationLinks"
|
||||||
|
name="fixkosten_submit"
|
||||||
|
value="hinzufügen"
|
||||||
|
type="submit">
|
||||||
|
<span>hinzufügen</span>
|
||||||
|
</button>
|
||||||
|
<a href="fixkosten.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
abbrechen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Zahlungsmonate
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="zahlungsmonate_id" class="fix_select">
|
||||||
|
<?php foreach ($zahlungsmonate as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= (isset($data['zahlungsmonate']) && $y['id'] == $data['zahlungsmonate']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['name']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Zahlungstag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="zahlungstag_id" class="fix_select">
|
||||||
|
<?php foreach ($zahlungstag as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= (isset($data['zahlungstag']) && $y['id'] == $data['zahlungstag']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['name']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Konto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="konto_id" class="umsatz_select">
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= (isset($data['konto']) && $y['id'] == $data['konto']) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['bezeichnung']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Gegenkonto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="gegenkonto_id" class="umsatz_select">
|
||||||
|
<option value="" disabled selected>Überweisung auf</option>
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?=$y['id']?>" <?php if(isset($data['gegenkonto'])) { if($y['id'] == $data['gegenkonto']) { echo 'selected';}} ?>><?=$y['bezeichnung']?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="text" name="beschreibung" class="umsatz_text" value="<?= ($data['beschreibung']) ?? '' ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Betrag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="number" name="betrag" step="0.01" class="umsatz_number" value="<?= $data['betrag'] ?? '-' ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
190
fix_zuKontobewegung.php
Normal file
190
fix_zuKontobewegung.php
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$data = $_SESSION['formdata'] ?? [];
|
||||||
|
unset($_SESSION['formdata']);
|
||||||
|
|
||||||
|
$konto_id = -1;
|
||||||
|
$monat_wert = -1;
|
||||||
|
$temp_date_gesetzt = false;
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungsmonate
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungsmonate = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id,
|
||||||
|
name,
|
||||||
|
wert
|
||||||
|
FROM monat;");
|
||||||
|
$monat = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, name
|
||||||
|
FROM zahlungstag
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$zahlungstag = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id, bezeichnung
|
||||||
|
FROM konto
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT EXTRACT(YEAR FROM CURRENT_DATE) - 1 AS jahr
|
||||||
|
UNION SELECT EXTRACT(YEAR FROM CURRENT_DATE)
|
||||||
|
UNION SELECT EXTRACT(YEAR FROM CURRENT_DATE) + 1;");
|
||||||
|
$jahr = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT monat_wert
|
||||||
|
FROM temp_daten;");
|
||||||
|
$inhalt_temp_daten = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT kf.id AS kostenfix_id,
|
||||||
|
kf.beschreibung,
|
||||||
|
kf.betrag,
|
||||||
|
zt.name AS zahlungstag,
|
||||||
|
zm.name AS zahlungsmonate,
|
||||||
|
kf.konto_id,
|
||||||
|
k.bezeichnung AS konto
|
||||||
|
FROM kostenfix kf
|
||||||
|
JOIN zahlungstag zt ON zt.id = kf.zahlungstag_id
|
||||||
|
JOIN zahlungsmonate zm ON zm.id = kf.zahlungsmonate_id
|
||||||
|
JOIN konto k ON k.id = kf.konto_id
|
||||||
|
WHERE zm.name LIKE '%' || CAST(:monat_wert AS INT) || '%'
|
||||||
|
ORDER BY kf.id ASC");
|
||||||
|
|
||||||
|
$monat_wert = $monat[0]['wert'];
|
||||||
|
|
||||||
|
if(count($inhalt_temp_daten) > 0) {
|
||||||
|
$monat_wert = $inhalt_temp_daten[0]['monat_wert'];
|
||||||
|
$temp_date_gesetzt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->execute(['monat_wert' => $monat_wert]);
|
||||||
|
$kostenfix = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function aktualisiereTabelle(element) {
|
||||||
|
const monat_wert = element.value;
|
||||||
|
|
||||||
|
if (!monat_wert) return;
|
||||||
|
|
||||||
|
fetch("forms/fixkosten.php", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||||
|
body: "fixkosten_submit=aktualisieren&monat_wert=" + encodeURIComponent(monat_wert)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Server-Antwort:", data.überschrift);
|
||||||
|
element.style.backgroundColor = "#d4edda";
|
||||||
|
setTimeout(() => element.style.backgroundColor = "", 800);
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Fehler:", error);
|
||||||
|
element.style.backgroundColor = "#f8d7da";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/fixkosten.php">
|
||||||
|
<div class="header">
|
||||||
|
<button class="header"
|
||||||
|
id="navigationLinks"
|
||||||
|
name="fixkosten_submit"
|
||||||
|
value="zuKontobewegung"
|
||||||
|
type="submit">
|
||||||
|
<span>hinzufügen</span>
|
||||||
|
</button>
|
||||||
|
<a href="fixkosten.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
abbrechen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Fixkosten für Monat
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="monat_id" class="fix_select" onchange="aktualisiereTabelle(this)">
|
||||||
|
<?php foreach ($monat as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?php
|
||||||
|
if($temp_date_gesetzt) {
|
||||||
|
if($y['wert'] == $monat_wert) echo 'selected';
|
||||||
|
} else {
|
||||||
|
if($y['wert'] == date('m')) echo 'selected';
|
||||||
|
}
|
||||||
|
?>>
|
||||||
|
<?= htmlspecialchars($y['name']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Fixkosten für Jahr
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="jahr" class="fix_select">
|
||||||
|
<?php foreach ($jahr as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['jahr']) ?>" <?php if($y['jahr'] == date('Y')) echo 'selected';?>>
|
||||||
|
<?= htmlspecialchars($y['jahr']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th id="th_gebucht">Zyklus</th>
|
||||||
|
<th id="th_ausgegeben">Tag</th>
|
||||||
|
<th id="th_beschreibung">Beschreibung</th>
|
||||||
|
<th id="th_betrag">Betrag</th>
|
||||||
|
<th id="th_konto">Konto</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($kostenfix as $y): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="td_text">
|
||||||
|
<?= htmlspecialchars($y['zahlungsmonate']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_text">
|
||||||
|
<?= htmlspecialchars($y['zahlungstag']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_text">
|
||||||
|
<?= htmlspecialchars($y['beschreibung']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="<?= $y['betrag'] < 0 ? 'td_zahl_neg' : 'td_zahl_pos' ?>">
|
||||||
|
<?= number_format($y['betrag'], 2, ",", ".") ?> €
|
||||||
|
</td>
|
||||||
|
<td class="td_text">
|
||||||
|
<?= htmlspecialchars($y['konto']) ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<form id="hiddenFormÄndereFix" method="post" action="fix_edit.php">
|
||||||
|
<input id="hiddenInputÄndereFixKostenvariabelID" type="hidden" name="kostenfix_id">
|
||||||
|
<input id="hiddenInputEditTyp" type="hidden" name="editTyp" value="edit">
|
||||||
|
</form>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
93
fixkosten.php
Normal file
93
fixkosten.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT kf.id AS kostenfix_id,
|
||||||
|
kf.beschreibung,
|
||||||
|
kf.betrag,
|
||||||
|
zt.name AS zahlungstag,
|
||||||
|
zm.name AS zahlungsmonate,
|
||||||
|
kf.konto_id,
|
||||||
|
k.bezeichnung AS konto
|
||||||
|
FROM kostenfix kf
|
||||||
|
JOIN zahlungstag zt ON zt.id = kf.zahlungstag_id
|
||||||
|
JOIN zahlungsmonate zm ON zm.id = kf.zahlungsmonate_id
|
||||||
|
JOIN konto k ON k.id = kf.konto_id
|
||||||
|
ORDER BY kf.id ASC");
|
||||||
|
$kostenfix = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<script>
|
||||||
|
function ändereFixkosten(kostenfix_id) {
|
||||||
|
document.getElementById("hiddenInputÄndereFixKostenvariabelID").value = kostenfix_id;
|
||||||
|
document.getElementById("hiddenFormÄndereFix").submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/fixkostenZuKontobewegung.php">
|
||||||
|
<div class="header">
|
||||||
|
<a href="fix_neu.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationLinks">
|
||||||
|
Neue Fixkosten
|
||||||
|
</a>
|
||||||
|
<a href="fix_zuKontobewegung.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationMitte">
|
||||||
|
zu Konto hinzufügen
|
||||||
|
</a>
|
||||||
|
<a href="index.php"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
HOME
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="inhalt">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th id="th_gebucht">Zyklus</th>
|
||||||
|
<th id="th_ausgegeben">Tag</th>
|
||||||
|
<th id="th_beschreibung">Beschreibung</th>
|
||||||
|
<th id="th_betrag">Betrag</th>
|
||||||
|
<th id="th_konto">Konto</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($kostenfix as $y): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="td_text"
|
||||||
|
onClick="ändereFixkosten(<?= htmlspecialchars($y['kostenfix_id']) ?>)">
|
||||||
|
<?= htmlspecialchars($y['zahlungsmonate']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_text"
|
||||||
|
onClick="ändereFixkosten(<?= htmlspecialchars($y['kostenfix_id']) ?>)">
|
||||||
|
<?= htmlspecialchars($y['zahlungstag']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_text"
|
||||||
|
onClick="ändereFixkosten(<?= htmlspecialchars($y['kostenfix_id']) ?>)">
|
||||||
|
<?= htmlspecialchars($y['beschreibung']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="<?= $y['betrag'] < 0 ? 'td_zahl_neg' : 'td_zahl_pos' ?>"
|
||||||
|
onClick="ändereFixkosten(<?= htmlspecialchars($y['kostenfix_id']) ?>)">
|
||||||
|
<?= number_format($y['betrag'], 2, ",", ".") ?> €
|
||||||
|
</td>
|
||||||
|
<td class="td_text"
|
||||||
|
onClick="ändereFixkosten(<?= htmlspecialchars($y['kostenfix_id']) ?>)">
|
||||||
|
<?= htmlspecialchars($y['konto']) ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<form id="hiddenFormÄndereFix" method="post" action="fix_edit.php">
|
||||||
|
<input id="hiddenInputÄndereFixKostenvariabelID" type="hidden" name="kostenfix_id">
|
||||||
|
<input id="hiddenInputEditTyp" type="hidden" name="editTyp" value="edit">
|
||||||
|
</form>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
248
forms/fixkosten.php
Normal file
248
forms/fixkosten.php
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$kostenfix_id = $_POST['kostenfix_id'] ?? -1;
|
||||||
|
$fixkosten_submit = $_POST['fixkosten_submit'] ?? 'c';
|
||||||
|
$zahlungsmonate_id = $_POST['zahlungsmonate_id'] ?? '';
|
||||||
|
$zahlungstag_id = $_POST['zahlungstag_id'] ?? '';
|
||||||
|
$konto_id = $_POST['konto_id'] ?? '';
|
||||||
|
$gegenkonto_id = $_POST['gegenkonto_id'] ?? '';
|
||||||
|
$beschreibung = $_POST['beschreibung'] ?? '';
|
||||||
|
$betrag = $_POST['betrag'] ?? '';
|
||||||
|
$monat_id = $_POST['monat_id'] ?? '';
|
||||||
|
$jahr = $_POST['jahr'] ?? '';
|
||||||
|
$monat_wert = $_POST['monat_wert'] ?? '';
|
||||||
|
|
||||||
|
$returnOfFunction = 0;
|
||||||
|
|
||||||
|
switch($fixkosten_submit) {
|
||||||
|
case 'hinzufügen':
|
||||||
|
$returnOfFunction += insertFixkosten($pdo,
|
||||||
|
$zahlungsmonate_id,
|
||||||
|
$zahlungstag_id,
|
||||||
|
$konto_id,
|
||||||
|
$beschreibung,
|
||||||
|
$betrag);
|
||||||
|
|
||||||
|
if(!empty($gegenkonto_id)) {
|
||||||
|
$returnOfFunction += insertFixkosten($pdo,
|
||||||
|
$zahlungsmonate_id,
|
||||||
|
$zahlungstag_id,
|
||||||
|
$gegenkonto_id,
|
||||||
|
$beschreibung,
|
||||||
|
$betrag * -1);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'speichern':
|
||||||
|
$returnOfFunction += UpdateFixkosten($pdo,
|
||||||
|
$kostenfix_id,
|
||||||
|
$zahlungsmonate_id,
|
||||||
|
$zahlungstag_id,
|
||||||
|
$konto_id,
|
||||||
|
$beschreibung,
|
||||||
|
$betrag);
|
||||||
|
break;
|
||||||
|
case 'löschen':
|
||||||
|
$returnOfFunction += removeFixkosten($pdo,
|
||||||
|
$kostenfix_id);
|
||||||
|
break;
|
||||||
|
case 'zuKontobewegung':
|
||||||
|
$returnOfFunction += fixkostenZuKontobewegung($pdo,
|
||||||
|
$monat_id,
|
||||||
|
$jahr);
|
||||||
|
$returnOfFunction += leereTempTabelle($pdo);
|
||||||
|
break;
|
||||||
|
case 'aktualisieren':
|
||||||
|
$returnOfFunction += aktualisiereTempTabelle($pdo,
|
||||||
|
$monat_wert);
|
||||||
|
$_SESSION['formdata'] = $_POST;
|
||||||
|
echo json_encode(['success' => true, 'monat_wert' => $monat_wert]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($returnOfFunction > 0) {
|
||||||
|
$fehler[] = "Fehler bei Datenbankoperation";
|
||||||
|
$_SESSION['errors'] = $fehler;
|
||||||
|
$_SESSION['formdata'] = $_POST;
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: /../fixkosten.php");
|
||||||
|
//header("Location: /../fix_zuKontobewegung.php");
|
||||||
|
exit;
|
||||||
|
|
||||||
|
function insertFixkosten($para_pdo,
|
||||||
|
$para_zahlungsmonate_id,
|
||||||
|
$para_zahlungstag_id,
|
||||||
|
$para_konto_id,
|
||||||
|
$para_beschreibung,
|
||||||
|
$para_betrag) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("INSERT INTO kostenfix (zahlungsmonate_id, zahlungstag_id, konto_id, beschreibung, betrag)
|
||||||
|
VALUES (:zahlungsmonate_id, :zahlungstag_id, :konto_id, :beschreibung, :betrag);");
|
||||||
|
$stmt->execute(['zahlungsmonate_id' => $para_zahlungsmonate_id,
|
||||||
|
'zahlungstag_id' => $para_zahlungstag_id,
|
||||||
|
'konto_id' => $para_konto_id,
|
||||||
|
'beschreibung' => $para_beschreibung,
|
||||||
|
'betrag' => $para_betrag]);
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateFixkosten($para_pdo,
|
||||||
|
$para_kostenfix_id,
|
||||||
|
$para_zahlungsmonate_id,
|
||||||
|
$para_zahlungstag_id,
|
||||||
|
$para_konto_id,
|
||||||
|
$para_beschreibung,
|
||||||
|
$para_betrag) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE kostenfix
|
||||||
|
SET zahlungstag_id = :zahlungstag_id,
|
||||||
|
zahlungsmonate_id = :zahlungsmonate_id,
|
||||||
|
beschreibung = :beschreibung,
|
||||||
|
konto_id = :konto_id,
|
||||||
|
betrag = :betrag
|
||||||
|
WHERE id = :kostenfix_id;");
|
||||||
|
$stmt->execute(['zahlungstag_id' => $para_zahlungstag_id,
|
||||||
|
'zahlungsmonate_id' => $para_zahlungsmonate_id,
|
||||||
|
'beschreibung' => $para_beschreibung,
|
||||||
|
'konto_id' => $para_konto_id,
|
||||||
|
'betrag' => $para_betrag,
|
||||||
|
'kostenfix_id' => $para_kostenfix_id]);
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFixkosten($para_pdo,
|
||||||
|
$para_kostenfix_id, ) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE kontobewegung
|
||||||
|
SET kostenfix_id = NULL
|
||||||
|
WHERE kostenfix_id = :kostenfix_id;");
|
||||||
|
$stmt->execute(['kostenfix_id' => $para_kostenfix_id]);
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("DELETE FROM kostenfix
|
||||||
|
WHERE id = :kostenfix_id");
|
||||||
|
$stmt->execute(['kostenfix_id' => $para_kostenfix_id]);
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixkostenZuKontobewegung($para_pdo,
|
||||||
|
$para_monat_id,
|
||||||
|
$para_jahr) {
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT wert
|
||||||
|
FROM monat
|
||||||
|
WHERE id = :monat_id;");
|
||||||
|
$stmt->execute([':monat_id' => $para_monat_id]);
|
||||||
|
$monat_wert = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("INSERT INTO kontobewegung (konto_id, betrag, beschreibung, datum_ausgegeben, kostenfix_id, datum_fixkosten_uebernommen)
|
||||||
|
SELECT kf.konto_id,
|
||||||
|
kf.betrag,
|
||||||
|
kf.beschreibung,
|
||||||
|
TO_DATE(:jahr || '-' || :monat_wert || '-' || zt.name, 'YYYY-MM-DD'),
|
||||||
|
kf.id,
|
||||||
|
CURRENT_DATE
|
||||||
|
FROM kostenfix kf
|
||||||
|
JOIN zahlungstag zt ON zt.id = kf.zahlungstag_id
|
||||||
|
JOIN zahlungsmonate zm ON zm.id = kf.zahlungsmonate_id
|
||||||
|
WHERE zm.name LIKE '%' || CAST(:monat_wert AS INT) || '%'
|
||||||
|
AND NOT EXISTS (SELECT *
|
||||||
|
FROM kontobewegung kb_inner
|
||||||
|
WHERE kb_inner.kostenfix_id = kf.id
|
||||||
|
AND EXTRACT(MONTH FROM kb_inner.datum_ausgegeben) = CAST(:monat_wert AS INT)
|
||||||
|
AND EXTRACT(YEAR FROM kb_inner.datum_ausgegeben) = CAST(:jahr AS INT));");
|
||||||
|
$stmt->execute(['monat_wert' => $monat_wert[0]['wert'],
|
||||||
|
'jahr' => $para_jahr]);
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function aktualisiereTempTabelle($para_pdo,
|
||||||
|
$para_monat_wert) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$para_pdo->query("DELETE FROM temp_daten;");
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("INSERT INTO temp_daten(monat_wert)
|
||||||
|
VALUES(:monat_wert);");
|
||||||
|
$stmt->execute(['monat_wert' => $para_monat_wert]);
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function leereTempTabelle($para_pdo) {
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$para_pdo->query("DELETE FROM temp_daten;");
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
293
forms/kontobewegung.php
Normal file
293
forms/kontobewegung.php
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$return = $_POST['return'] ?? 'index.php';
|
||||||
|
$kontobewegung_id = $_POST['kontobewegung_id'] ?? -1;
|
||||||
|
$kontobewegung_submit = $_POST['kontobewegung_submit'] ?? 'c';
|
||||||
|
|
||||||
|
$datum_ausgegeben = $_POST['datum_ausgegeben'] ?? '';
|
||||||
|
$datum_abgebucht = $_POST['datum_abgebucht'] ?? '';
|
||||||
|
$konto_id = $_POST['konto_id'] ?? '';
|
||||||
|
$gegenkonto_id = $_POST['gegenkonto_id'] ?? '';
|
||||||
|
$beschreibung = $_POST['beschreibung'] ?? '';
|
||||||
|
$betrag = $_POST['betrag'] ?? '';
|
||||||
|
|
||||||
|
$fehler = [];
|
||||||
|
|
||||||
|
if($datum_ausgegeben === '') $fehler[] = "Kein Datum eingegeben";
|
||||||
|
if($konto_id === '') $fehler[] = "Kein Konto ausgewählt";
|
||||||
|
if($beschreibung === '') $fehler[] = "Keine Beschreibung eingegeben";
|
||||||
|
if($betrag === '') $fehler[] = "Kein Betrag eingegeben";
|
||||||
|
|
||||||
|
if($fehler) {
|
||||||
|
$_SESSION['errors'] = $fehler;
|
||||||
|
$_SESSION['formdata'] = $_POST;
|
||||||
|
header("LOCATION: /../kontobewegung_neu.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$returnOfFunction = 0;
|
||||||
|
|
||||||
|
switch($kontobewegung_submit) {
|
||||||
|
case 'hinzufügen':
|
||||||
|
$returnOfFunction += insertKontobewegung($pdo,
|
||||||
|
$konto_id,
|
||||||
|
$betrag,
|
||||||
|
$beschreibung,
|
||||||
|
$datum_ausgegeben);
|
||||||
|
if(!empty($gegenkonto_id)) {
|
||||||
|
$returnOfFunction += insertKontobewegung($pdo,
|
||||||
|
$gegenkonto_id,
|
||||||
|
$betrag * -1,
|
||||||
|
$beschreibung,
|
||||||
|
$datum_ausgegeben);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'speichern':
|
||||||
|
$returnOfFunction += updateKontobewegung($pdo,
|
||||||
|
$kontobewegung_id,
|
||||||
|
$konto_id,
|
||||||
|
$betrag,
|
||||||
|
$beschreibung,
|
||||||
|
$datum_ausgegeben,
|
||||||
|
$datum_abgebucht);
|
||||||
|
break;
|
||||||
|
case 'löschen':
|
||||||
|
$returnOfFunction += deleteKontobewegung($pdo,
|
||||||
|
$kontobewegung_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($returnOfFunction > 0) {
|
||||||
|
$fehler[] = "Fehler bei Datenbankoperation";
|
||||||
|
$_SESSION['errors'] = $fehler;
|
||||||
|
$_SESSION['formdata'] = $_POST;
|
||||||
|
header("LOCATION: /../umsatz_neu.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: /../$return");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertKontobewegung($para_pdo,
|
||||||
|
$para_konto_id,
|
||||||
|
$para_betrag,
|
||||||
|
$para_beschreibung,
|
||||||
|
$para_datum_ausgegeben) {
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("INSERT INTO kontobewegung (konto_id, betrag, beschreibung, datum_ausgegeben)
|
||||||
|
VALUES(:konto_id, :betrag, :beschreibung, :datum_ausgegeben);");
|
||||||
|
$stmt->execute(['konto_id' => $para_konto_id,
|
||||||
|
'betrag' => $para_betrag,
|
||||||
|
'beschreibung' => $para_beschreibung,
|
||||||
|
'datum_ausgegeben' => $para_datum_ausgegeben]);
|
||||||
|
|
||||||
|
/*updateHistRestguthaben($para_pdo,
|
||||||
|
$para_datum_ausgegeben,
|
||||||
|
$para_betrag,
|
||||||
|
false);*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateKontobewegung($para_pdo,
|
||||||
|
$para_kontobewegung_id,
|
||||||
|
$para_konto_id,
|
||||||
|
$para_betrag,
|
||||||
|
$para_beschreibung,
|
||||||
|
$para_datum_ausgegeben,
|
||||||
|
$para_datum_abgebucht) {
|
||||||
|
|
||||||
|
$para_datum_abgebucht = $para_datum_abgebucht ?: null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT kb.datum_abgebucht,
|
||||||
|
kb.betrag,
|
||||||
|
k.kontostand,
|
||||||
|
kb.konto_id
|
||||||
|
FROM kontobewegung kb
|
||||||
|
JOIN konto k ON k.id = kb.konto_id
|
||||||
|
WHERE kb.id = :kontobewegung_id;");
|
||||||
|
$stmt->execute(['kontobewegung_id' => $para_kontobewegung_id]);
|
||||||
|
$kontobewegung = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if(count($kontobewegung) > 1) throw new Exception('Mehr als eine Kontobewegung gefunden');
|
||||||
|
|
||||||
|
$konto_id_vorher = $kontobewegung[0]['konto_id'];
|
||||||
|
$datum_abgebucht_vorher = $kontobewegung[0]['datum_abgebucht'];
|
||||||
|
$kontostand_vorher_konto_vorher = $kontobewegung[0]['kontostand'];
|
||||||
|
$betrag_vorher = $kontobewegung[0]['betrag'];
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT kontostand
|
||||||
|
FROM konto
|
||||||
|
WHERE id = :konto_id;");
|
||||||
|
$stmt->execute(['konto_id' => $para_konto_id]);
|
||||||
|
$konto_nachher = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$kontostand_vorher_konto_nachher = $konto_nachher[0]['kontostand'];
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher;
|
||||||
|
|
||||||
|
if($konto_id_vorher == $para_konto_id) {
|
||||||
|
if(isset($datum_abgebucht_vorher) && isset($para_datum_abgebucht)) {
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher - $betrag_vorher + $para_betrag;
|
||||||
|
} elseif(isset($datum_abgebucht_vorher) && !isset($para_datum_abgebucht)) {
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher - $betrag_vorher;
|
||||||
|
} elseif(!isset($datum_abgebucht_vorher) && isset($para_datum_abgebucht)) {
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher + $para_betrag;
|
||||||
|
} elseif(!isset($datum_abgebucht_vorher) && !isset($para_datum_abgebucht)) {
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(isset($datum_abgebucht_vorher)) {
|
||||||
|
$kontostand_nachher_konto_vorher = $kontostand_vorher_konto_vorher - $betrag_vorher;
|
||||||
|
$kontostand_nachher_konto_nachher = $kontostand_vorher_konto_nachher + $para_betrag;
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE konto
|
||||||
|
SET kontostand = :kontostand_neu
|
||||||
|
WHERE id = :konto_id;");
|
||||||
|
$stmt->execute(['kontostand_neu' => $kontostand_nachher_konto_nachher,
|
||||||
|
'konto_id' => $para_konto_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE kontobewegung
|
||||||
|
SET konto_id = :konto_id,
|
||||||
|
betrag = :betrag,
|
||||||
|
beschreibung = :beschreibung,
|
||||||
|
datum_ausgegeben = :datum_ausgegeben,
|
||||||
|
datum_abgebucht = :datum_abgebucht
|
||||||
|
WHERE id = :kontobewegung_id;");
|
||||||
|
$stmt->execute(['konto_id' => $para_konto_id,
|
||||||
|
'betrag' => $para_betrag,
|
||||||
|
'beschreibung' => $para_beschreibung,
|
||||||
|
'datum_ausgegeben' => $para_datum_ausgegeben,
|
||||||
|
'datum_abgebucht' => $para_datum_abgebucht,
|
||||||
|
'kontobewegung_id' => $para_kontobewegung_id]);
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE konto
|
||||||
|
SET kontostand = :kontostand_neu
|
||||||
|
WHERE id = :konto_id;");
|
||||||
|
$stmt->execute(['kontostand_neu' => $kontostand_nachher_konto_vorher,
|
||||||
|
'konto_id' => $konto_id_vorher]);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
/*updateHistRestguthaben($para_pdo,
|
||||||
|
$para_datum_ausgegeben,
|
||||||
|
$para_betrag,
|
||||||
|
false);*/
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteKontobewegung($para_pdo,
|
||||||
|
$para_kontobewegung_id) {
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT datum_abgebucht, betrag, konto_id
|
||||||
|
FROM kontobewegung
|
||||||
|
WHERE id = :kontobewegung_id;");
|
||||||
|
$stmt->execute(['kontobewegung_id' => $para_kontobewegung_id]);
|
||||||
|
$kontobewegung = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(count($kontobewegung) > 1) throw new Exception("Multiple Kontobewegungen gefunden");
|
||||||
|
|
||||||
|
$datum_abgebucht = $kontobewegung[0]['datum_abgebucht'];
|
||||||
|
$betrag = $kontobewegung[0]['betrag'];
|
||||||
|
$konto_id = $kontobewegung[0]['konto_id'];
|
||||||
|
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
if(isset($datum_abgebucht)) {
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE konto
|
||||||
|
SET kontostand = kontostand - :betrag
|
||||||
|
WHERE id = :konto_id;");
|
||||||
|
$stmt->execute(['konto_id' => $konto_id,
|
||||||
|
'betrag' => $betrag]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("DELETE FROM kontobewegung
|
||||||
|
WHERE id = :kontobewegung_id;");
|
||||||
|
$stmt->execute(['kontobewegung_id' => $para_kontobewegung_id]);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
/*updateHistRestguthaben($para_pdo,
|
||||||
|
$para_datum_ausgegeben,
|
||||||
|
$para_betrag,
|
||||||
|
false);*/
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateHistRestguthaben($para_pdo,
|
||||||
|
$para_datum_ausgegeben,
|
||||||
|
$para_betrag,
|
||||||
|
$para_delete) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$para_pdo->beginTransaction();
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT EXTRACT(YEAR FROM CAST(:datum_ausgegeben AS DATE)) AS jahr,
|
||||||
|
id
|
||||||
|
FROM monat
|
||||||
|
WHERE EXTRACT(MONTH FROM CAST(:datum_ausgegeben AS DATE)) = CAST(wert AS INT);");
|
||||||
|
$stmt->execute(['datum_ausgegeben' => $para_datum_ausgegeben]);
|
||||||
|
|
||||||
|
$monat = $stmt->fetchAll(PDO::FETCH_ASSOC)[0];
|
||||||
|
|
||||||
|
$monat_id = $monat['id'];
|
||||||
|
$jahr = $monat['jahr'];
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("SELECT betrag
|
||||||
|
FROM hist_restguthaben
|
||||||
|
WHERE monat_id = :monat_id
|
||||||
|
AND jahr = :jahr;");
|
||||||
|
$stmt->execute(['monat_id' => $monat_id,
|
||||||
|
'jahr' => $jahr]);
|
||||||
|
$hist_restguthaben = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if(isset($hist_restguthaben)) {
|
||||||
|
$betrag = $hist_restguthaben[0]['betrag'] + $para_betrag;
|
||||||
|
|
||||||
|
$stmt = $para_pdo->prepare("UPDATE hist_restguthaben
|
||||||
|
SET betrag = :betrag
|
||||||
|
WHERE monat_id = :monat_id
|
||||||
|
AND jahr = :jahr;");
|
||||||
|
$stmt->execute(['betrag' => $betrag,
|
||||||
|
'monat_id' => $monat_id,
|
||||||
|
'jahr' => $jahr]);
|
||||||
|
} elseif(!$para_delete) {
|
||||||
|
$stmt = $para_pdo->prepare("INSERT INTO hist_restguthaben (monat_id, jahr, betrag)
|
||||||
|
VALUES (:monat_id, :jahr, :betrag);");
|
||||||
|
$stmt->execute(['monat_id' => $monat_id,
|
||||||
|
'jahr' => $jahr,
|
||||||
|
'betrag' => $para_betrag]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$para_pdo->commit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$para_pdo->rollBack();
|
||||||
|
echo "Fehler: " . $e->getMessage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
50
historie.php
Normal file
50
historie.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT m.name,
|
||||||
|
hrg.jahr,
|
||||||
|
hrg.betrag
|
||||||
|
FROM hist_restguthaben hrg
|
||||||
|
JOIN monat m ON m.id = hrg.monat_id;");
|
||||||
|
$historie = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<a href="index.php"
|
||||||
|
class="konto_header"
|
||||||
|
id="konto_navigationRechts">
|
||||||
|
HOME
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th id="th_gebucht">Jahr</th>
|
||||||
|
<th id="th_ausgegeben">Monat</th>
|
||||||
|
<th id="th_betrag">Betrag</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($historie as $y): ?>
|
||||||
|
<tr>
|
||||||
|
<td class="td_datum">
|
||||||
|
<?= htmlspecialchars($y['name']) ?? '' ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_datum">
|
||||||
|
<?= htmlspecialchars($y['jahr']) ?? '' ?>
|
||||||
|
</td>
|
||||||
|
<td class="<?= $y['betrag'] < 0 ? 'td_zahl_neg' : 'td_zahl_pos' ?>">
|
||||||
|
<?= number_format($y['betrag'], 2, ",", ".") ?> €
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
14
includes/db_connect.php
Normal file
14
includes/db_connect.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
$host = 'server';
|
||||||
|
$db = 'haushaltsbuch';
|
||||||
|
$user = getenv('POSTGRES_APPUSER');
|
||||||
|
$pass = getenv('POSTGRES_APPPASSWORD');
|
||||||
|
$port = "5432";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dsn = "pgsql:host=$host;port=$port;dbname=$db;";
|
||||||
|
$pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "Verbindungsfehler: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
?>
|
||||||
84
index.php
Normal file
84
index.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT k.id,
|
||||||
|
k.bezeichnung,
|
||||||
|
k.kontostand,
|
||||||
|
b.name AS bankname,
|
||||||
|
kb.name AS kontoinhaber,
|
||||||
|
k.darstellungsfarbe AS color
|
||||||
|
FROM konto k
|
||||||
|
JOIN kontotyp kt ON kt.id = k.kontotyp_id
|
||||||
|
JOIN bank b ON b.id = k.bank_id
|
||||||
|
JOIN kontobesitzer kb ON kb.id = k.kontobesitzer_id
|
||||||
|
ORDER BY k.id ASC;");
|
||||||
|
$kontos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT SUM(betrag) AS restguthaben
|
||||||
|
FROM kontobewegung
|
||||||
|
WHERE (konto_id = :konto1 OR konto_id = :konto2)
|
||||||
|
AND EXTRACT(MONTH FROM datum_ausgegeben) = EXTRACT(MONTH FROM CURRENT_DATE);");
|
||||||
|
$stmt->execute(['konto1' => 1,
|
||||||
|
'konto2' => 2]);
|
||||||
|
|
||||||
|
$restguthaben = ($stmt->fetchAll(PDO::FETCH_ASSOC))[0]['restguthaben'];
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT name
|
||||||
|
FROM monat
|
||||||
|
WHERE CAST(wert AS INT) = EXTRACT(MONTH FROM CURRENT_DATE);");
|
||||||
|
$monat = $stmt->fetchAll(PDO::FETCH_ASSOC)[0]['name'];
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<h2 class="restguthaben">
|
||||||
|
Restguthaben <?= htmlspecialchars($monat)?>: <?= htmlspecialchars($restguthaben ?? '0') ?> €
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<?php foreach ($kontos as $y): ?>
|
||||||
|
<a href="konto.php?id=<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
class="kontoübersicht"
|
||||||
|
id="container"
|
||||||
|
style="background-color: <?= htmlspecialchars($y['color']) ?>;">
|
||||||
|
|
||||||
|
<div class="kontoübersicht" id="containerInnenLinks">
|
||||||
|
<p class="ausgabe" id="überschrift">
|
||||||
|
<?= htmlspecialchars($y['bezeichnung']) ?>
|
||||||
|
</p>
|
||||||
|
<p id="infotext">
|
||||||
|
<?= htmlspecialchars($y['bankname']) ?> \
|
||||||
|
<?= htmlspecialchars($y['kontoinhaber']) ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="kontoübersicht" id="containerInnenRechts">
|
||||||
|
<p class="ausgabe" id="kontostand">
|
||||||
|
<?= number_format(htmlspecialchars($y['kontostand']), 2, ",", ".") ?> €
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<a href="kontobewegung_neu.php" class="navigation_index">
|
||||||
|
Neue Kontobewegung
|
||||||
|
</a>
|
||||||
|
<a href="fixkosten.php" class="navigation_index">
|
||||||
|
Fixkosten
|
||||||
|
</a>
|
||||||
|
<a href="diagramme.php" class="navigation_index">
|
||||||
|
Diagramme
|
||||||
|
</a>
|
||||||
|
<a href="historie.php" class="navigation_index">
|
||||||
|
Historie
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
112
konto.php
Normal file
112
konto.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
$konto_id = $_GET['id'];
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT id,
|
||||||
|
kontostand,
|
||||||
|
darstellungsfarbe AS backgroundcolor,
|
||||||
|
bezeichnung AS konto
|
||||||
|
FROM konto
|
||||||
|
WHERE id = :konto_id;");
|
||||||
|
$stmt->execute(['konto_id' => $konto_id]);
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Da nur ein Konto abgefragt wird, sind diese Werte in allen Ergebnissen gleich
|
||||||
|
$konto_bezeichnung = $konto[0]['konto'];
|
||||||
|
$konto_kontostand = $konto[0]['kontostand'];
|
||||||
|
$konto_backgroundColor = $konto[0]['backgroundcolor'];
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT kb.id AS kontobewegung_id,
|
||||||
|
kb.betrag,
|
||||||
|
kb.beschreibung,
|
||||||
|
kb.datum_ausgegeben,
|
||||||
|
kb.datum_abgebucht,
|
||||||
|
kb.kostenfix_id
|
||||||
|
FROM kontobewegung kb
|
||||||
|
LEFT OUTER JOIN kostenfix kf ON kf.id = kb.kostenfix_id
|
||||||
|
WHERE kb.konto_id = :konto_id
|
||||||
|
ORDER BY datum_ausgegeben DESC,
|
||||||
|
kb.id DESC;");
|
||||||
|
$stmt->execute(['konto_id' => $konto_id]);
|
||||||
|
$kontobewegung = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<script>
|
||||||
|
function ändereUmsatz(kontobewegung_id, konto_id) {
|
||||||
|
document.getElementById("hiddenInputÄndereUmsatzKontobewegungID").value = kontobewegung_id;
|
||||||
|
document.getElementById("hiddenInputÄndereUmsatzKontoID").value = konto_id;
|
||||||
|
|
||||||
|
document.getElementById("hiddenFormÄndereUmsatz").submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
tr.standard {
|
||||||
|
&>td {
|
||||||
|
background-color: <?= $konto_backgroundColor ?>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<a href="kontobewegung_neu.php?id=<?= htmlspecialchars($konto_id) ?>"
|
||||||
|
class="konto_header"
|
||||||
|
id="konto_navigationLinks">
|
||||||
|
Neue Kontobewegung
|
||||||
|
</a>
|
||||||
|
<h2 class="kontoübersicht" id="h2_kontoübersicht">
|
||||||
|
<?= htmlspecialchars($konto_bezeichnung) ?>: <?= htmlspecialchars(number_format($konto_kontostand, 2, ",", ".")) ?> €
|
||||||
|
</h2>
|
||||||
|
<a href="index.php"
|
||||||
|
class="konto_header"
|
||||||
|
id="konto_navigationRechts">
|
||||||
|
HOME
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th id="th_gebucht">gebucht</th>
|
||||||
|
<th id="th_ausgegeben">ausgegeben</th>
|
||||||
|
<th id="th_beschreibung">Beschreibung</th>
|
||||||
|
<th id="th_betrag">Betrag</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($kontobewegung as $y): ?>
|
||||||
|
<tr <?= $y['kostenfix_id'] ? 'class="konto_fixKosten"' : 'class="standard"' ?>>
|
||||||
|
<!--tr style="background-color: < ?= $konto_backgroundColor ?>"-->
|
||||||
|
<td class="td_datum"
|
||||||
|
onClick="ändereUmsatz(<?= htmlspecialchars($y['kontobewegung_id']) ?>, <?= htmlspecialchars($konto_id) ?>)">
|
||||||
|
<?= empty($y['datum_abgebucht']) ? '' : htmlspecialchars($y['datum_abgebucht']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_datum"
|
||||||
|
onClick="ändereUmsatz(<?= htmlspecialchars($y['kontobewegung_id']) ?>, <?= htmlspecialchars($konto_id) ?>)">
|
||||||
|
<?= htmlspecialchars($y['datum_ausgegeben']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="td_text"
|
||||||
|
onClick="ändereUmsatz(<?= htmlspecialchars($y['kontobewegung_id']) ?>, <?= htmlspecialchars($konto_id) ?>)">
|
||||||
|
<?= htmlspecialchars($y['beschreibung']) ?>
|
||||||
|
</td>
|
||||||
|
<td class="<?= $y['betrag'] < 0 ? 'td_zahl_neg' : 'td_zahl_pos' ?>"
|
||||||
|
onClick="ändereUmsatz(<?= htmlspecialchars($y['kontobewegung_id']) ?>, <?= htmlspecialchars($konto_id) ?>)">
|
||||||
|
<?= number_format($y['betrag'], 2, ",", ".") ?> €
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<form id="hiddenFormÄndereUmsatz" method="post" action="kontobewegung_edit.php">
|
||||||
|
<input id="hiddenInputÄndereUmsatzKontobewegungID" type="hidden" name="kontobewegung_id">
|
||||||
|
<input id="hiddenInputÄndereUmsatzKontoID" type="hidden" name="konto_id">
|
||||||
|
<input id="hiddenInputEditTyp" type="hidden" name="editTyp" value="edit">
|
||||||
|
</form>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
152
kontobewegung_edit.php
Normal file
152
kontobewegung_edit.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$data = $_SESSION['formdata'] ?? [];
|
||||||
|
unset($_SESSION['formdata']);
|
||||||
|
|
||||||
|
$konto_id = $_POST['konto_id'];
|
||||||
|
$kontobewegung_id = $_POST['kontobewegung_id'];
|
||||||
|
|
||||||
|
$return = "konto.php?id=" . $konto_id;
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id,
|
||||||
|
bezeichnung
|
||||||
|
FROM konto
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT datum_abgebucht,
|
||||||
|
datum_ausgegeben,
|
||||||
|
konto_id,
|
||||||
|
beschreibung,
|
||||||
|
betrag
|
||||||
|
FROM kontobewegung
|
||||||
|
WHERE id = :kontobewegung_id;");
|
||||||
|
$stmt->execute(['kontobewegung_id' => $kontobewegung_id]);
|
||||||
|
$kontobewegungFetchAll = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if(count($kontobewegungFetchAll) > 1) {
|
||||||
|
//TODO FEHLERHANDLING
|
||||||
|
} else {
|
||||||
|
$kontobewegung = $kontobewegungFetchAll[0];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function datumLeeren() {
|
||||||
|
const input = document.getElementById('input_datum_abgebucht');
|
||||||
|
input.value = "";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/kontobewegung.php">
|
||||||
|
<input type="hidden" name="kontobewegung_id" value="<?= htmlspecialchars($kontobewegung_id) ?>">
|
||||||
|
<input type="hidden" name="return" value="<?= htmlspecialchars($return) ?>">
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
<button class="header"
|
||||||
|
id="navigationLinks"
|
||||||
|
name="kontobewegung_submit"
|
||||||
|
value="speichern"
|
||||||
|
type="submit">
|
||||||
|
<span>speichern</span>
|
||||||
|
</button>
|
||||||
|
<button class="header"
|
||||||
|
id="navigationMitte"
|
||||||
|
name="kontobewegung_submit"
|
||||||
|
value="löschen"
|
||||||
|
type="submit">
|
||||||
|
<span>Eintrag löschen</span>
|
||||||
|
</button>
|
||||||
|
<a href="konto.php?id= <?= htmlspecialchars($konto_id) ?>"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
abbrechen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="inhalt">
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
abgebucht
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="date"
|
||||||
|
name="datum_abgebucht"
|
||||||
|
class="umsatz_date"
|
||||||
|
id="input_datum_abgebucht"
|
||||||
|
value="<?= $data['datum_abgebucht'] ?? $kontobewegung['datum_abgebucht'] ?>">
|
||||||
|
<button type="button"
|
||||||
|
class="datum_leeren"
|
||||||
|
onclick="datumLeeren()">X</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
ausgegeben
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="date"
|
||||||
|
name="datum_ausgegeben"
|
||||||
|
class="umsatz_date"
|
||||||
|
value="<?= $data['datum_ausgegeben'] ?? $kontobewegung['datum_ausgegeben'] ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Konto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="konto_id" class="umsatz_select">
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= isset($data['konto_id']) && $y['id'] == $data['konto_id'] || $y['id'] == $konto_id ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['bezeichnung']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="text"
|
||||||
|
name="beschreibung"
|
||||||
|
class="umsatz_text"
|
||||||
|
value="<?= $data['beschreibung'] ?? $kontobewegung['beschreibung'] ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Betrag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input class="umsatz_number"
|
||||||
|
type="number"
|
||||||
|
name="betrag"
|
||||||
|
step="0.01"
|
||||||
|
lang="de"
|
||||||
|
value="<?= $data['betrag'] ?? $kontobewegung['betrag'] ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
111
kontobewegung_neu.php
Normal file
111
kontobewegung_neu.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$data = $_SESSION['formdata'] ?? [];
|
||||||
|
unset($_SESSION['formdata']);
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT id,
|
||||||
|
bezeichnung
|
||||||
|
FROM konto
|
||||||
|
ORDER BY id ASC;");
|
||||||
|
$konto = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$konto_id = -1;
|
||||||
|
|
||||||
|
if (isset($_GET['id'])) {
|
||||||
|
$konto_id = $_GET['id'];
|
||||||
|
$return = "konto.php?id=" . $_GET['id'];
|
||||||
|
} else {
|
||||||
|
$return = 'index.php';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form method="POST" action="forms/kontobewegung.php">
|
||||||
|
<input type="hidden" name="return" value="<?php echo $return; ?>">
|
||||||
|
|
||||||
|
<div class="header">
|
||||||
|
<button class="header"
|
||||||
|
id="navigationLinks"
|
||||||
|
name="kontobewegung_submit"
|
||||||
|
value="hinzufügen"
|
||||||
|
type="submit">
|
||||||
|
<span>hinzufügen</span>
|
||||||
|
</button>
|
||||||
|
<a href="<?= $return ?>"
|
||||||
|
class="header"
|
||||||
|
id="navigationRechts">
|
||||||
|
abbrechen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="inhalt">
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
ausgegeben
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="date" name="datum_ausgegeben" class="umsatz_date" value="<?= $data['datum_ausgegeben'] ?? date('Y-m-d') ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Konto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="konto_id" class="umsatz_select">
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?= htmlspecialchars($y['id']) ?>"
|
||||||
|
<?= ((isset($data['konto_id']) && $y['id'] == $data['konto_id']) || $y['id'] == $konto_id) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($y['bezeichnung']) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Gegenkonto
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<select name="gegenkonto_id" class="umsatz_select">
|
||||||
|
<option value="" disabled selected>Überweisung auf</option>
|
||||||
|
<?php foreach ($konto as $y): ?>
|
||||||
|
<option value="<?=$y['id']?>" <?php if(isset($data['gegenkonto_id'])) { if($y['id'] == $data['gegenkonto_id']) { echo 'selected';}} ?>><?=$y['bezeichnung']?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="text" name="beschreibung" class="umsatz_text" value="<?= $data['beschreibung'] ?? ''?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="umsatz_div" id="umsatz_links">
|
||||||
|
<p class="ausgabe" id="umsatz_p">
|
||||||
|
Betrag
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="umsatz_div" id="umsatz_rechts">
|
||||||
|
<input type="number" name="betrag" step="0.01" class="umsatz_number" value="<?= $data['betrag'] ?? '' ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
305
style.css
Normal file
305
style.css
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
/* global */
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: rgb(185, 185, 185);
|
||||||
|
/*background-color: rgb(252, 211, 218);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
line-height: 0.8;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
line-height: 0.8;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: black;
|
||||||
|
line-height: 0.8;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
border: 1px solid black;
|
||||||
|
border-collapse: collapse;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
padding-top: 5px;
|
||||||
|
background-color: rgb(185, 185, 185);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.konto_fixKosten {
|
||||||
|
&>td {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
padding-top: 5px;
|
||||||
|
background-color: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*tr:nth-child(even) {
|
||||||
|
&>td {
|
||||||
|
background-color: lightgrey;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
div.navigation_container {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 20px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigation {
|
||||||
|
float: left;
|
||||||
|
width: 46%;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-right: 20px;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
text-align: center;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
padding-top: 15px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigationLinksIndex {
|
||||||
|
margin-right: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.header{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 97%;
|
||||||
|
height: 60px;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 20px;
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.inhalt {
|
||||||
|
margin-top: 60px;
|
||||||
|
height: calc(100vh - 80px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#umsatz_links {
|
||||||
|
width: 40%;
|
||||||
|
height: 80px;
|
||||||
|
float: left;
|
||||||
|
vertical-align: bottom;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#umsatz_p {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
width: 258px;
|
||||||
|
height: 80px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.umsatz_date {
|
||||||
|
width: 250px;
|
||||||
|
height: 80px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.umsatz_text {
|
||||||
|
width: 500px;
|
||||||
|
height: 80px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.umsatz_number {
|
||||||
|
width: 500px;
|
||||||
|
height: 80px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.header {
|
||||||
|
text-align: center;
|
||||||
|
background-color: white;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigationLinks {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigationRechts {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************/
|
||||||
|
/* Index */
|
||||||
|
/****************************************/
|
||||||
|
|
||||||
|
a.navigation_index {
|
||||||
|
border-style: solid;
|
||||||
|
height: 60px;
|
||||||
|
width: 60%;
|
||||||
|
float: left;
|
||||||
|
border-radius: 15px;
|
||||||
|
margin-right: 20px;
|
||||||
|
margin-top: 50px;
|
||||||
|
margin-left: 20%;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
padding-top: 15px;
|
||||||
|
background-color: white;
|
||||||
|
font-size: 2.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kontoübersicht {
|
||||||
|
border-style: solid;
|
||||||
|
color: black;
|
||||||
|
float: left;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#infotext {
|
||||||
|
margin: 0;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
width: 92%;
|
||||||
|
padding: 10px;
|
||||||
|
padding-left: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#containerInnenLinks {
|
||||||
|
border-style: none;
|
||||||
|
border-right-style: solid;
|
||||||
|
width: 60%;
|
||||||
|
height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#containerInnenRechts {
|
||||||
|
border-style: none;
|
||||||
|
width: 35%;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.ausgabe {
|
||||||
|
font-size: 3rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#überschrift {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#kontostand {
|
||||||
|
margin-top: 25px;
|
||||||
|
margin-right: 5%;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2.restguthaben {
|
||||||
|
width: 100%;
|
||||||
|
/*margin-left: 50%;*/
|
||||||
|
border-style: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************/
|
||||||
|
/* Konto */
|
||||||
|
/****************************************/
|
||||||
|
#hiddenFormÄndereUmsatz {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2.kontoübersicht {
|
||||||
|
width: 50%;
|
||||||
|
/*margin-left: 50%;*/
|
||||||
|
border-style: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.td_text {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.td_zahl_neg {
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 20px;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.td_zahl_pos {
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.td_datum {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#th_gebucht, #th_ausgegeben, #th_betrag, #th_konto {
|
||||||
|
width: 15%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#th_beschreibung {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#datepicker_gebucht {
|
||||||
|
width: 90%;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#konto_navigationLinks {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#konto_navigationRechts {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************/
|
||||||
|
/* Umsatz_edit */
|
||||||
|
/****************************************/
|
||||||
|
|
||||||
|
button.datum_leeren {
|
||||||
|
height: 80px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************/
|
||||||
|
/****************************************/
|
||||||
|
/****************************************/
|
||||||
Loading…
Reference in New Issue
Block a user