From 9ff7d0da7196983396843bc0029c99bf763b06d8 Mon Sep 17 00:00:00 2001 From: p3t3rp1Lz Date: Tue, 18 Nov 2025 20:37:13 +0100 Subject: [PATCH] Initial --- diagramme.php | 16 +++ favicon.ico | Bin 0 -> 15406 bytes fix_edit.php | 151 ++++++++++++++++++++ fix_neu.php | 132 +++++++++++++++++ fix_zuKontobewegung.php | 190 +++++++++++++++++++++++++ fixkosten.php | 93 ++++++++++++ forms/fixkosten.php | 248 ++++++++++++++++++++++++++++++++ forms/kontobewegung.php | 293 ++++++++++++++++++++++++++++++++++++++ historie.php | 50 +++++++ includes/db_connect.php | 14 ++ index.php | 84 +++++++++++ konto.php | 112 +++++++++++++++ kontobewegung_edit.php | 152 ++++++++++++++++++++ kontobewegung_neu.php | 111 +++++++++++++++ style.css | 305 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 1951 insertions(+) create mode 100644 diagramme.php create mode 100644 favicon.ico create mode 100644 fix_edit.php create mode 100644 fix_neu.php create mode 100644 fix_zuKontobewegung.php create mode 100644 fixkosten.php create mode 100644 forms/fixkosten.php create mode 100644 forms/kontobewegung.php create mode 100644 historie.php create mode 100644 includes/db_connect.php create mode 100644 index.php create mode 100644 konto.php create mode 100644 kontobewegung_edit.php create mode 100644 kontobewegung_neu.php create mode 100644 style.css diff --git a/diagramme.php b/diagramme.php new file mode 100644 index 0000000..f02dfd6 --- /dev/null +++ b/diagramme.php @@ -0,0 +1,16 @@ + + + + + + + + + +

Hello World!

+ + \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..d19311a7a34a0031743fce7549bd3202e7cb8f97 GIT binary patch literal 15406 zcmeI2SBMr#5XWcTHK$#5#en*mPDL?*oB_pEM8$+C_+Y?O5KjetFn|w=3MNF%Sx;1a z5HlDsuKHjGQ4}$YIp>_}=2za#jbEH^_FGPFyJ2?c>+YKRcXf4jRaaY9nw4&4W?J_D zko9MVW&LhhRw(r2cl|8O`pd3s+Vr3H-z@7`wq@0~``9El#gBUXU(_Q1v$AB#61j2X zM#QL&9z7~McI=3#53d+FaG;z#c{03O)~s10GiJ<)s1L751^wW`gJu5w`SR@9Gxzh0 z7A=yA6DPXAW4*wC!h{Jje*Ac8-MY1W{rXkDfB!C>I(3p3En3L8Z{K2(YCZHPPMlDh z4jnqk#ful^`t|G5u3bB!?fCKIzUjMl>!z}tG-;ABFS~c|mZ3w3CZwM^bEeFlJ6CGf ztSK*FzLW+H8px9;Pvq05PtveqLwWuBb#ImMxQe_wLE#$B$*hh7CF% zh<5GTB{y&0j7eY68loD7Br35pA^XX(AM8`CQqbgT#%m;yj09f1cp=-iZBv`&hYp*5 z`t)hpzkk2lct14p`tTil?aJcCi{o{3+u+asP_=4RdH3#}TOagg-@bjypMB0xfq(n< z?WIbUDu#aw<-c&@LOLy8wKuKrPYd$PZs^@q>Xs#Pm#)TogZDN;mAlqexvw{DHV zfG?GnmZodQk6)SykHa6o6QA+JhYzxS`*tZ=vZU0lTlc3mhCKTA?JK2AmsWoatn|-I zariG-u)zHceDD_;=i$SL-Fp1GGG)q0&z?PH-n@BIs8FGw+TD&xyhP&(|TGt5;PA@Y$p3i9?g9!XYKmb7WpCh%V9@JF@-1`Lp1y?RM@cD9ad$dDn5 zhdsJ-<;qg4R;`Hj(7%6wDO|X)oI7{U#g)v9oaiPPMtcXwvgB+|vB$B0-F-6I}D=fVs0#AVQ#VkBTBU?kv` zK&*3tf>O^piG4(C{b4`moW!dc=G{oZNWe(INT47}fH;ryo@>{xX}&8wuJJ1q=*SP< zzI|Kse{bHriHMQ>ek+-NuU@^95hF%Ovu4eNJQp!ikOKbm=g$i{GxBs>wrq(SX9f9o zJesFZpK9D}yCr&_5;T4Te{OEB#>bpnaV`_@{4O4*WZDe=AJQ`NPeyD0?Q8Vs*V3P$ z=g7Z;{$snJKY#9?pJD&N<)_f^(4j+8sZu39_x~^KXPr8AWbD|ndVgf<)Ty#+)ha#j z^|P0Pf9KAfQlUZxJqMjOZJO@Ke#V}cKHl|9o*+FvT_4V<$<2_T96o%w+`4ru?p!ce zVCJlu?~vc{-oMEU#(1<|{Op^Y@A8x{UtaNpg|Q48G)V5=y&H23=v|jCUG%(~y_|F8 zGiT1kW1W&VFMj+M&ZxO#vuV>N%^i>%0#B(@rSx7-w6kM?aIXm6Xa2}5ah6VAE75(W zybi*PzkB!Yx^~fJ_~HwJi}QZQKyL2NojVaM8Pk|CV>Ay%pHZVm>3fqVO*BUnL6E`< zFa91qdPL;m7zcN$&>`|6po+;SAvba6M9457X2d+*0yb1?cck1@3{BH@;ViM@ZZ0GUm7=Vtauz9bNE8f-8{zD zvSmw+UC=x3?;(H2P0o#Z%8%j)Kk*sy4H&ue!G1si)4_uWHSdIOjUGK(-oAaS_1tA) zFTkeFnKLJFT$E_ce(-Z2w07;!I;T2BZK@X ziSUDE&z?PMKg0FktLNBRFgtp}8kszKvf{_C9yxL(Kj2F^e)5N4;K44Et4HU-?${Hj zJ=cyGS+lg^cX(rG`kXy`R`)@4YuvbT`4SI%@pGSqJ@dka3(6ZE?$@uM>IWFn2Pel4 zR^onaW@cul+DtHe3%+chK7Dk2prepare("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); + +?> + + + + + + + + + +
+ + +
+ + + + abbrechen + +
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/fix_neu.php b/fix_neu.php new file mode 100644 index 0000000..74f1c6c --- /dev/null +++ b/fix_neu.php @@ -0,0 +1,132 @@ +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); +?> + + + + + + + + + +
+
+ + + abbrechen + +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/fix_zuKontobewegung.php b/fix_zuKontobewegung.php new file mode 100644 index 0000000..5104838 --- /dev/null +++ b/fix_zuKontobewegung.php @@ -0,0 +1,190 @@ +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); +?> + + + + + + + + + + + +
+
+ + + abbrechen + +
+
+ +
+ +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
ZyklusTagBeschreibungBetragKonto
+ + + + + + + € + + +
+
+ + + + \ No newline at end of file diff --git a/fixkosten.php b/fixkosten.php new file mode 100644 index 0000000..03c725f --- /dev/null +++ b/fixkosten.php @@ -0,0 +1,93 @@ +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); +?> + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
ZyklusTagBeschreibungBetragKonto
+ + + + + + + € + + +
+
+ + + \ No newline at end of file diff --git a/forms/fixkosten.php b/forms/fixkosten.php new file mode 100644 index 0000000..939aa5e --- /dev/null +++ b/forms/fixkosten.php @@ -0,0 +1,248 @@ + 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; + } + } +?> \ No newline at end of file diff --git a/forms/kontobewegung.php b/forms/kontobewegung.php new file mode 100644 index 0000000..33be12a --- /dev/null +++ b/forms/kontobewegung.php @@ -0,0 +1,293 @@ + 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; + } + } +?> \ No newline at end of file diff --git a/historie.php b/historie.php new file mode 100644 index 0000000..dea2ba2 --- /dev/null +++ b/historie.php @@ -0,0 +1,50 @@ +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); +?> + + + + + + + + + +
+ + + + + + + + + + + + + +
JahrMonatBetrag
+ + + + + € +
+
+ + + \ No newline at end of file diff --git a/includes/db_connect.php b/includes/db_connect.php new file mode 100644 index 0000000..9dab534 --- /dev/null +++ b/includes/db_connect.php @@ -0,0 +1,14 @@ + PDO::ERRMODE_EXCEPTION]); + } catch (PDOException $e) { + echo "Verbindungsfehler: " . $e->getMessage(); + } +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..c53830b --- /dev/null +++ b/index.php @@ -0,0 +1,84 @@ +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']; +?> + + + + + + + + + +
+

+ Restguthaben : € +

+
+ + + + \ No newline at end of file diff --git a/konto.php b/konto.php new file mode 100644 index 0000000..c383e43 --- /dev/null +++ b/konto.php @@ -0,0 +1,112 @@ +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); + +?> + + + + + + + + + + + +
+ + + + + + + + + > + + + + + + + + + + + + + +
gebuchtausgegebenBeschreibungBetrag
+ + + + + + + € +
+
+ + + \ No newline at end of file diff --git a/kontobewegung_edit.php b/kontobewegung_edit.php new file mode 100644 index 0000000..714d70c --- /dev/null +++ b/kontobewegung_edit.php @@ -0,0 +1,152 @@ +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]; + } +?> + + + + + + + + + + + +
+ + + +
+ + + + abbrechen + +
+ +
+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/kontobewegung_neu.php b/kontobewegung_neu.php new file mode 100644 index 0000000..3765913 --- /dev/null +++ b/kontobewegung_neu.php @@ -0,0 +1,111 @@ +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'; + } +?> + + + + + + + + + +
+ + +
+ + + abbrechen + +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..e0293eb --- /dev/null +++ b/style.css @@ -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; +} + +/****************************************/ +/****************************************/ +/****************************************/ \ No newline at end of file