diff --git a/upgrade/data/db_schema.json b/upgrade/data/db_schema.json index d3a09d16..08f20d8d 100644 --- a/upgrade/data/db_schema.json +++ b/upgrade/data/db_schema.json @@ -8072,7 +8072,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -10249,7 +10249,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -21837,7 +21837,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -27031,7 +27031,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -32938,7 +32938,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -44111,7 +44111,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -60739,7 +60739,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -65936,7 +65936,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -68245,7 +68245,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -72138,7 +72138,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -74147,7 +74147,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -81287,7 +81287,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -83531,7 +83531,7 @@ "Collation": "utf8mb3_general_ci", "Null": "YES", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -104480,7 +104480,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -107296,7 +107296,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -110141,7 +110141,7 @@ "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", - "Default": "'eur'", + "Default": "'EUR'", "Extra": "", "Privileges": "select,insert,update,references", "Comment": "" @@ -114485,10 +114485,15 @@ "type": "VIEW", "Create": "CREATE VIEW `belegeregs` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift`" }, - { + { "name": "fibu_buchungen_alle", "type": "VIEW", - "Create": "CREATE VIEW `fibu_buchungen_alle` AS select `fb`.`buchungsart` AS `buchungsart`,`fb`.`typ` AS `typ`,`fb`.`id` AS `id`,if(`bl`.`datum` <> '',`bl`.`datum`,`fb`.`datum`) AS `datum`,`fb`.`gegen_typ` AS `doc_typ`,`fb`.`gegen_id` AS `doc_id`,`bl`.`belegnr` AS `doc_belegnr`,`fb`.`soll` AS `betrag`,`fb`.`waehrung` AS `waehrung`,`fb`.`edit_module` AS `edit_module`,`fb`.`edit_id` AS `edit_id` from ((select 'umsatz' AS `buchungsart`,'rechnung' AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`soll` AS `soll`,`rechnung`.`waehrung` AS `waehrung`,'rechnung' AS `gegen_typ`,`rechnung`.`id` AS `gegen_id`,`rechnung`.`datum` AS `datum`,'rechnung' AS `edit_module`,`rechnung`.`id` AS `edit_id` from `rechnung` where `rechnung`.`belegnr` <> '' union select 'umsatz' AS `umsatz`,'gutschrift' AS `'gutschrift'`,`gutschrift`.`id` AS `id`,-`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select 'abbuchung' AS `abbuchung`,'gutschrift' AS `rechnung`,`gutschrift`.`id` AS `id`,`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'rechnung' AS `gutschrift`,`gutschrift`.`rechnungid` AS `rechnungid`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' union select 'abbuchung' AS `abbuchung`,'rechnung' AS `rechnung`,`gutschrift`.`rechnungid` AS `rechnungid`,-`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' union select 'aufwand' AS `aufwand`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,-`verbindlichkeit`.`betrag` AS `- ``openxe``.``verbindlichkeit``.``betrag```,`verbindlichkeit`.`waehrung` AS `waehrung`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `edit_module`,`verbindlichkeit`.`id` AS `edit_id` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select 'abbuchung' AS `abbuchung`,`fibu_buchungen`.`von_typ` AS `von_typ`,`fibu_buchungen`.`von_id` AS `von_id`,-`fibu_buchungen`.`betrag` AS `- ``openxe``.``fibu_buchungen``.``betrag```,`fibu_buchungen`.`waehrung` AS `waehrung`,`fibu_buchungen`.`nach_typ` AS `nach_typ`,`fibu_buchungen`.`nach_id` AS `nach_id`,`fibu_buchungen`.`zeit` AS `zeit`,'fibu_buchungen' AS `edit_module`,`fibu_buchungen`.`id` AS `edit_id` from `fibu_buchungen` union select 'zubuchung' AS `zubuchung`,`fibu_buchungen`.`nach_typ` AS `nach_typ`,`fibu_buchungen`.`nach_id` AS `nach_id`,`fibu_buchungen`.`betrag` AS `betrag`,`fibu_buchungen`.`waehrung` AS `waehrung`,`fibu_buchungen`.`von_typ` AS `von_typ`,`fibu_buchungen`.`von_id` AS `von_id`,`fibu_buchungen`.`zeit` AS `zeit`,'fibu_buchungen' AS `edit_module`,`fibu_buchungen`.`id` AS `edit_id` from `fibu_buchungen`) `fb` left join (select `rechnung`.`datum` AS `datum`,'rechnung' AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`belegnr` AS `belegnr` from `rechnung` where `rechnung`.`belegnr` <> '' union select `gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`belegnr` AS `belegnr` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select `verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`belegnr` AS `belegnr` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select `kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,`kontoauszuege`.`buchungstext` AS `buchungstext` from `kontoauszuege` union select '','kontorahmen' AS `'kontorahmen'`,`kontorahmen`.`id` AS `id`,`kontorahmen`.`beschriftung` AS `beschriftung` from `kontorahmen`) `bl` on(`fb`.`gegen_typ` = `bl`.`typ` and `fb`.`gegen_id` = `bl`.`id`))" + "Create": "CREATE VIEW `fibu_buchungen_alle` AS select `fb`.`buchungsart` AS `buchungsart`,`fb`.`typ` AS `typ`,`fb`.`id` AS `id`,if(`fibu_objekte`.`datum` <> '',`fibu_objekte`.`datum`,`fb`.`datum`) AS `datum`,`fb`.`gegen_typ` collate utf8mb3_general_ci AS `doc_typ`,`fb`.`gegen_id` AS `doc_id`,`fibu_objekte`.`info` AS `doc_belegnr`,`fb`.`soll` AS `betrag`,`fb`.`waehrung` AS `waehrung`,`fb`.`edit_module` collate utf8mb4_general_ci AS `edit_module`,`fb`.`edit_id` AS `edit_id` from ((select 'umsatz' AS `buchungsart`,'rechnung' AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`soll` AS `soll`,`rechnung`.`waehrung` AS `waehrung`,'rechnung' AS `gegen_typ`,`rechnung`.`id` AS `gegen_id`,`rechnung`.`datum` AS `datum`,'rechnung' AS `edit_module`,`rechnung`.`id` AS `edit_id` from `rechnung` where `rechnung`.`belegnr` <> '' union select 'umsatz' AS `umsatz`,'gutschrift' AS `'gutschrift'`,`gutschrift`.`id` AS `id`,-`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select 'abbuchung' AS `abbuchung`,'gutschrift' AS `rechnung`,`gutschrift`.`id` AS `id`,`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'rechnung' AS `gutschrift`,`gutschrift`.`rechnungid` AS `rechnungid`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' union select 'abbuchung' AS `abbuchung`,'rechnung' AS `rechnung`,`gutschrift`.`rechnungid` AS `rechnungid`,-`gutschrift`.`soll` AS `- ``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `edit_id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' union select 'aufwand' AS `aufwand`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,-`verbindlichkeit`.`betrag` AS `- ``openxe``.``verbindlichkeit``.``betrag```,`verbindlichkeit`.`waehrung` AS `waehrung`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `edit_module`,`verbindlichkeit`.`id` AS `edit_id` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select 'zahlung' AS `zahlung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,-`kontoauszuege`.`soll` AS `- ``openxe``.``kontoauszuege``.``soll```,`kontoauszuege`.`waehrung` AS `waehrung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,`kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `edit_module`,`kontoauszuege`.`id` AS `edit_id` from `kontoauszuege` where `kontoauszuege`.`importfehler` is null union select 'abbuchung' AS `abbuchung`,`fibu_buchungen`.`von_typ` AS `von_typ`,`fibu_buchungen`.`von_id` AS `von_id`,-`fibu_buchungen`.`betrag` AS `- ``openxe``.``fibu_buchungen``.``betrag```,`fibu_buchungen`.`waehrung` AS `waehrung`,`fibu_buchungen`.`nach_typ` AS `nach_typ`,`fibu_buchungen`.`nach_id` AS `nach_id`,`fibu_buchungen`.`zeit` AS `zeit`,'fibu_buchungen' AS `edit_module`,`fibu_buchungen`.`id` AS `edit_id` from `fibu_buchungen` union select 'zubuchung' AS `zubuchung`,`fibu_buchungen`.`nach_typ` AS `nach_typ`,`fibu_buchungen`.`nach_id` AS `nach_id`,`fibu_buchungen`.`betrag` AS `betrag`,`fibu_buchungen`.`waehrung` AS `waehrung`,`fibu_buchungen`.`von_typ` AS `von_typ`,`fibu_buchungen`.`von_id` AS `von_id`,`fibu_buchungen`.`zeit` AS `zeit`,'fibu_buchungen' AS `edit_module`,`fibu_buchungen`.`id` AS `edit_id` from `fibu_buchungen`) `fb` left join `fibu_objekte` on(`fb`.`gegen_typ` = `fibu_objekte`.`typ` and `fb`.`gegen_id` = `fibu_objekte`.`id`))" + }, + { + "name": "fibu_objekte", + "type": "VIEW", + "Create": "CREATE VIEW `fibu_objekte` AS select `rechnung`.`datum` AS `datum`,'rechnung' collate utf8mb4_general_ci AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`belegnr` AS `info` from `rechnung` where `rechnung`.`belegnr` <> '' union select `gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`belegnr` AS `belegnr` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select `verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`belegnr` AS `belegnr` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select `kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,concat(`konten`.`kurzbezeichnung`,' - ',`kontoauszuege`.`buchungstext`) AS `buchungstext` from (`kontoauszuege` left join `konten` on(`konten`.`id` = `kontoauszuege`.`konto`)) union select '' AS `Name_exp_1`,'kontorahmen' AS `'kontorahmen'`,`kontorahmen`.`id` AS `id`,`kontorahmen`.`beschriftung` AS `beschriftung` from `kontorahmen`" } ] } diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index e3d96046..1e9eb848 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -1510,6 +1510,11 @@ public function NavigationHooks(&$menu) // return "replace(trim($spalte)+0,'.',',')"; } + function FormatUCfirst($spalte) + { + return ('CONCAT(UCASE(LEFT('.$spalte.', 1)),SUBSTRING('.$spalte.', 2))'); + } + static function add_alias(string $text, $alias = false) { if (empty($alias)) { return($text); @@ -7089,6 +7094,7 @@ title: 'Abschicken', $navarray['menu']['admin'][$menu]['sec'][] = array('Gutschrift / '.$this->Firmendaten("bezeichnungstornorechnung"),'gutschrift','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Proformarechnung','proformarechnung','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Kontoauszüge','kontoauszuege','list'); + $navarray['menu']['admin'][$menu]['sec'][] = array('Buchungen','fibu_buchungen','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','rechnungslauf'); $navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list'); @@ -36097,10 +36103,10 @@ function Firmendaten($field,$projekt="") * Gutschrift -> Rechnungid, Rechnung -> Auftragid */ - public function GetZahlungen(int $id, string $type, bool $cascade = false, string $lastlevel = 'auftrag') : array { + public function GetZahlungen(int $id, string $type, string $cascadelevel = '') : array { - if ($cascade) { - $documents = $this->GetZahlungenAssociatedDocuments($id, $type, $lastlevel); + if ($cascadelevel != '') { + $documents = $this->GetZahlungenAssociatedDocuments($id, $type, $cascadelevel); } else { $documents = array(array('id' => $id, 'type' => $type)); } @@ -36146,7 +36152,23 @@ function Firmendaten($field,$projekt="") * Auftrag: gesamtsumme, rechnung: soll, gutschrift: soll verbindlichkeit: betrag * returns array(array(betrag, waehrung)) one line per waehrung */ - public function GetSaldenDokument($id, $type, string $lastlevel = 'auftrag') : array { + public function GetSaldenDokument($id, $type, string $cascadelevel = '') : array { + + if ($cascadelevel != '') { + $documents = $this->GetZahlungenAssociatedDocuments($id, $type, $cascadelevel); + } else { + $documents = array(array('id' => $id, 'type' => $type)); + } + + if (empty($documents)) { + return(array()); + } + + $ids = array(); + + foreach ($documents as $document) { + $ids[] = $document['type'].$document['id']; + } $sql = " SELECT @@ -36155,7 +36177,7 @@ function Firmendaten($field,$projekt="") FROM fibu_buchungen_alle WHERE - typ = '".$type."' AND id = ".$id." + CONCAT(typ,id) IN ('".implode("','",$ids)."') GROUP BY waehrung"; diff --git a/www/pages/auftrag.php b/www/pages/auftrag.php index 5a336f42..6528b92d 100644 --- a/www/pages/auftrag.php +++ b/www/pages/auftrag.php @@ -3423,46 +3423,37 @@ class Auftrag extends GenAuftrag { $id = $this->app->Secure->GetGET('id'); - $zahlungen = $this->app->erp->GetZahlungen($id,'auftrag',true); + $zahlungen = $this->app->erp->GetZahlungen($id,'auftrag',true); + if (!empty($zahlungen)) { + $et = new EasyTable($this->app); -// print_r($zahlungen); + $et->headings = array('Datum','Beleg','Betrag','Währung'); - $result = ""; + foreach ($zahlungen as $zahlung) { + $row = array( + $zahlung['datum'], + " + ".ucfirst($zahlung['doc_typ'])." + ".$zahlung['doc_belegnr']." + ", + $zahlung['betrag'], + $zahlung['waehrung'] + ); + $et->AddRow($row); + } - foreach ($zahlungen as $zahlung) { - $result .= " - - - ".$zahlung['datum']." - - - - ".ucfirst($zahlung['doc_type'])." - ".$zahlung['doc_belegnr']." - - - - ".$zahlung['konto']." - - - - ".$zahlung['betrag']." ".$zahlung['waehrung']." - - - "; + $salden = $this->app->erp->GetSaldenDokument($id,'auftrag',true); + foreach ($salden as $saldo) { + $row = array( + '', + 'Saldo', + "".$saldo['betrag']."", + "".$saldo['waehrung']."" + ); + $et->AddRow($row); + } + return($et->DisplayNew('return',"")); } - - $saldo = $this->app->erp->GetSaldoDokument($id,'auftrag'); - - $result .= " - - - ".$saldo." - - - "; - - return("".$result."
"); } function AuftragZahlungsmail() diff --git a/www/pages/content/fibu_buchungen_edit.tpl b/www/pages/content/fibu_buchungen_edit.tpl new file mode 100644 index 00000000..9a550898 --- /dev/null +++ b/www/pages/content/fibu_buchungen_edit.tpl @@ -0,0 +1,204 @@ +
+ + +
+ [MESSAGE] +
+ [FORMHANDLEREVENT] +
+
+
+
+
+ {|Buchung|} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {|Von|}: + + [VON] + + +
+ {|Nach|}: + + [NACH] + + +
+ {|Betrag|}: + + +
+ {|Währung|}: + + +
+ {|Benutzer|}: + + [BENUTZER] +
+ {|Zeit|}: + + [ZEIT] +
+ {|Internebemerkung|}: + + +
+
+ +
+
+
+
+ [TAB1] + +
+
+ +
+ diff --git a/www/pages/content/fibu_buchungen_list.tpl b/www/pages/content/fibu_buchungen_list.tpl new file mode 100644 index 00000000..394c103a --- /dev/null +++ b/www/pages/content/fibu_buchungen_list.tpl @@ -0,0 +1,10 @@ +
+ +
+ [MESSAGE] + [TAB1] + [TAB1NEXT] +
+
diff --git a/www/pages/content/kontoauszuege_edit.tpl b/www/pages/content/kontoauszuege_edit.tpl index 9a3b966f..e8cab37b 100644 --- a/www/pages/content/kontoauszuege_edit.tpl +++ b/www/pages/content/kontoauszuege_edit.tpl @@ -17,7 +17,7 @@
- {|Kontoauszüg Eintrag|} + {|Kontoauszug Eintrag|}
diff --git a/www/pages/fibu_buchungen.php b/www/pages/fibu_buchungen.php new file mode 100644 index 00000000..19fff834 --- /dev/null +++ b/www/pages/fibu_buchungen.php @@ -0,0 +1,372 @@ +app = $app; + if ($intern) + return; + + $this->app->ActionHandlerInit($this); + $this->app->ActionHandler("list", "fibu_buchungen_list"); + $this->app->ActionHandler("create", "fibu_buchungen_edit"); // This automatically adds a "New" button + $this->app->ActionHandler("edit", "fibu_buchungen_edit"); + $this->app->ActionHandler("delete", "fibu_buchungen_delete"); + $this->app->ActionHandler("assoc", "fibu_buchungen_assoc"); + $this->app->DefaultActionHandler("list"); + $this->app->ActionHandlerListen($app); + + $this->app->erp->Headlines('Buchhaltung Buchungen'); + } + + public function Install() { + /* Fill out manually later */ + } + + function TableSearch(&$app, $name, $erlaubtevars) { + switch ($name) { + case "fibu_buchungen_list_tabelle": + $allowed['fibu_buchungen_list'] = array('list'); + $heading = array('','','Von_typ', 'Von_id', 'Nach_typ', 'Nach_id', 'Betrag', 'Waehrung', 'Benutzer', 'Zeit', 'Internebemerkung', 'Menü'); + $width = array('1%','1%','10%'); // Fill out manually later + + // columns that are aligned right (numbers etc) + // $alignright = array(4,5,6,7,8); + + $findcols = array('f.id','f.id','f.von_typ', 'f.von_id', 'f.nach_typ', 'f.nach_id', 'f.betrag', 'f.waehrung', 'f.benutzer', 'f.zeit', 'f.internebemerkung'); + $searchsql = array('f.von_typ', 'f.von_id', 'f.nach_typ', 'f.nach_id', 'f.betrag', 'f.waehrung', 'f.benutzer', 'f.zeit', 'f.internebemerkung'); + + $defaultorder = 1; + $defaultorderdesc = 0; + + $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; + + $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"> " . "Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">" . "
"; + + $sql = "SELECT SQL_CALC_FOUND_ROWS f.id, $dropnbox, f.von_typ, f.von_id, f.nach_typ, f.nach_id, f.betrag, f.waehrung, f.benutzer, f.zeit, f.internebemerkung, f.id FROM fibu_buchungen f"; + + $where = "1"; + $count = "SELECT count(DISTINCT id) FROM fibu_buchungen WHERE $where"; +// $groupby = ""; + + break; + case "fibu_buchungen_list": + $allowed['fibu_buchungen_list'] = array('list'); + + $doc_typ = $this->app->User->GetParameter('fibu_buchungen_doc_typ'); + $doc_id = $this->app->User->GetParameter('fibu_buchungen_doc_id'); + + $heading = array('','','Buchungsart', 'Typ', 'Datum', 'Beleg', 'Betrag', 'Währung', 'Menü'); + $width = array('1%','1%','10%'); // Fill out manually later + + // columns that are aligned right (numbers etc) + $alignright = array(7); + $sumcol= array(7); + + $findcols = array('f.id','f.id','f.buchungsart', 'f.typ', 'f.datum', 'f.doc_typ', 'f.betrag', 'f.waehrung'); + $searchsql = array('f.buchungsart', 'f.typ', 'f.datum', 'f.doc_typ', 'f.doc_belegnr'); + + $defaultorder = 1; + $defaultorderdesc = 0; + + $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; + + $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">
"; + + if (!empty($doc_typ) && !empty($doc_id)) { + $where = "`doc_typ` = '$doc_typ' AND `doc_id` = $doc_id"; + } else{ + $where = "1"; + } + + $sql = "SELECT SQL_CALC_FOUND_ROWS + f.id, + $dropnbox, + ".$app->erp->FormatUCfirst('f.buchungsart').", + ".$app->erp->FormatUCfirst('f.typ').", + ".$app->erp->FormatDate('f.datum').", + CONCAT(".$app->erp->FormatUCfirst('f.doc_typ').",' ',f.doc_belegnr), + ".$app->erp->FormatMenge('f.betrag',2).", + f.waehrung, + CONCAT(f.edit_module,'&id=',f.edit_id) + FROM fibu_buchungen_alle f"; + + $count = "SELECT count(*) FROM fibu_buchungen_alle WHERE $where"; +// $groupby = ""; + + break; + case "fibu_buchungen_wahl": + $allowed['fibu_buchungen_wahl'] = array('list'); + $heading = array('', '', 'Datum', 'Typ', 'Beleg', 'Von','Nach', 'Menü'); + $width = array( '1%','1%','1%', '20%', '80%', '1%', '1%', '%1' ); + + $findcols = array('f.id','f.id','f.typ'); + $searchsql = array('f.buchungsart', 'f.typ', 'f.datum', 'f.doc_typ', 'f.doc_belegnr'); + + $defaultorder = 1; + $defaultorderdesc = 0; + + $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; + + $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">
"; + $menu = null; + + $linkstart = '
'; + + $id = $app->Secure->GetGET('id'); + + $sql = "SELECT SQL_CALC_FOUND_ROWS + f.id, + $dropnbox, + ".$app->erp->FormatDate('f.datum').", + ".$app->erp->FormatUCfirst('f.typ').", + f.info, + CONCAT('".$linkstart."','direction=von&id=".$id."&doc_typ=',f.typ,'&doc_id=',f.id,'".$linkend."'), + CONCAT('".$linkstart."','direction=nach&id=".$id."&doc_typ=',f.typ,'&doc_id=',f.id,'".$linkend."'), + f.id, + f.id + FROM fibu_objekte f + "; + + $where = "1"; + $count = "SELECT count(DISTINCT id) FROM fibu_buchungen_alle WHERE $where"; +// $groupby = ""; + + break; + } + + $erg = false; + + foreach ($erlaubtevars as $k => $v) { + if (isset($$v)) { + $erg[$v] = $$v; + } + } + return $erg; + } + + function fibu_buchungen_list() { + $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=list", "Übersicht"); + $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=create", "Neu anlegen"); + + $this->app->erp->MenuEintrag("index.php", "Zurück"); + + // For transfer to tablesearch + $doc_typ = $this->app->Secure->GetGET('doc_typ'); + $doc_id = $this->app->Secure->GetGET('doc_id'); + + $this->app->User->SetParameter('fibu_buchungen_doc_typ', $doc_typ); + $this->app->User->SetParameter('fibu_buchungen_doc_id', $doc_id); + + $this->app->YUI->TableSearch('TAB1', 'fibu_buchungen_list', "show", "", "", basename(__FILE__), __CLASS__); + $this->app->Tpl->Parse('PAGE', "fibu_buchungen_list.tpl"); + } + + public function fibu_buchungen_delete() { + $id = (int) $this->app->Secure->GetGET('id'); + +// $this->app->DB->Delete("DELETE FROM `fibu_buchungen` WHERE `id` = '{$id}'"); + $this->app->Tpl->Set('MESSAGE', "
Der Eintrag wurde gelöscht.
"); + + $this->fibu_buchungen_list(); + } + + /* + * Edit fibu_buchungen item + * If id is empty, create a new one + */ + + function fibu_buchungen_edit() { + $id = $this->app->Secure->GetGET('id'); + + // Check if other users are editing this id + if($this->app->erp->DisableModul('artikel',$id)) + { + return; + } + + // Assoc? + $direction = $this->app->Secure->GetGET('direction'); + $doc_typ = $this->app->Secure->GetGET('doc_typ'); + $doc_id = $this->app->Secure->GetGET('doc_id'); + if (in_array($direction,array('von','nach'))) { + $sql = "SELECT typ, id FROM fibu_objekte WHERE typ = '".$doc_typ."' AND id = '".$doc_id."'"; + + $result = $this->app->DB->SelectArr($sql); + + if (!empty($result)) { + $sql = "UPDATE fibu_buchungen SET ".$direction."_typ = '".$doc_typ."', ".$direction."_id = '".$doc_id."' WHERE id = '".$id."'"; + $this->app->DB->Update($sql); + } + } + + $this->app->Tpl->Set('ID', $id); + + $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=edit&id=$id", "Details"); + $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=list", "Zurück zur Übersicht"); + $id = $this->app->Secure->GetGET('id'); + $input = $this->GetInput(); + $submit = $this->app->Secure->GetPOST('submit'); + + if (empty($id)) { + // New item + $id = 'NULL'; + } + + if ($submit != '') + { + + // Write to database + + // Add checks here + $input['benutzer'] = $this->app->User->GetId(); + $input['zeit'] = date("Y-m-d H:i"); + $input['betrag'] = $this->app->erp->ReplaceBetrag(true,$input['betrag']); + $input['zeit'] = date("Y-m-d H:i"); + + $input['internebemerkung'] = $this->app->DB->real_escape_string($input['internebemerkung']); + + $columns = "id, "; + $values = "$id, "; + $update = ""; + + $fix = ""; + + foreach ($input as $key => $value) { + $columns = $columns.$fix.$key; + $values = $values.$fix."'".$value."'"; + $update = $update.$fix.$key." = '$value'"; + + $fix = ", "; + } + + $sql = "INSERT INTO fibu_buchungen (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update; + + $this->app->DB->Update($sql); + + if ($id == 'NULL') { + $msg = $this->app->erp->base64_url_encode("
Das Element wurde erfolgreich angelegt.
"); + header("Location: index.php?module=fibu_buchungen&action=list&msg=$msg"); + } else { + $this->app->Tpl->Set('MESSAGE', "
Die Einstellungen wurden erfolgreich übernommen.
"); + } + } + + + // Load values again from database + $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; + + $sql = " + SELECT SQL_CALC_FOUND_ROWS f.id, + $dropnbox, + f.von_typ, + f.von_id, + f.nach_typ, + f.nach_id, + ".$this->app->erp->FormatMenge('f.betrag',2)." AS betrag, + f.waehrung, + adresse.name as benutzer, + ".$this->app->erp->FormatDateTime('f.zeit','zeit').", + f.internebemerkung, + f.id, + fvon.info AS von_info, + fnach.info AS nach_info + FROM + fibu_buchungen f"." + LEFT JOIN + fibu_objekte fvon + ON + f.von_typ = fvon.typ AND f.von_id = fvon.id + LEFT JOIN + fibu_objekte fnach + ON + f.nach_typ = fnach.typ AND f.nach_id = fnach.id + LEFT JOIN + user + ON + f.benutzer = user.id + LEFT JOIN + adresse + ON + user.adresse = adresse.id + WHERE + f.id=$id + + "; + + $result = $this->app->DB->SelectArr($sql); + + $this->app->erp->ReplaceDatum(false,$result[0]['zeit'],false); + + $result[0]['internebemerkung'] = htmlentities($result[0]['internebemerkung']); + + foreach ($result[0] as $key => $value) { + $this->app->Tpl->Set(strtoupper($key), $value); + } + + /* + * Add displayed items later + * + + $this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email); + $this->app->Tpl->Add('EMAIL', $email); + $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername); + */ + + $this->app->Tpl->Set('VON',ucfirst($result[0]['von_typ'])." ".$result[0]['von_info']); + $this->app->Tpl->Set('NACH',ucfirst($result[0]['nach_typ'])." ".$result[0]['nach_info']); + + $this->app->Tpl->Set('WAEHRUNG',$this->app->erp->getSelectAsso($this->app->erp->GetWaehrung(), $result[0]['waehrung_von'])); + + $this->app->YUI->TableSearch('TAB1', 'fibu_buchungen_wahl', "show", "", "", basename(__FILE__), __CLASS__); + + $this->app->Tpl->Parse('PAGE', "fibu_buchungen_edit.tpl"); + } + + /** + * Get all paramters from html form and save into $input + */ + public function GetInput(): array { + $input = array(); + //$input['EMAIL'] = $this->app->Secure->GetPOST('email'); + + $input['von_typ'] = $this->app->Secure->GetPOST('von_typ'); + $input['von_id'] = $this->app->Secure->GetPOST('von_id'); + $input['nach_typ'] = $this->app->Secure->GetPOST('nach_typ'); + $input['nach_id'] = $this->app->Secure->GetPOST('nach_id'); + $input['betrag'] = $this->app->Secure->GetPOST('betrag'); + $input['waehrung'] = $this->app->Secure->GetPOST('waehrung'); + $input['benutzer'] = $this->app->Secure->GetPOST('benutzer'); + $input['zeit'] = $this->app->Secure->GetPOST('zeit'); + $input['internebemerkung'] = $this->app->Secure->GetPOST('internebemerkung'); + + + return $input; + } + + /* + * Set all fields in the page corresponding to $input + */ + function SetInput($input) { + // $this->app->Tpl->Set('EMAIL', $input['email']); + + $this->app->Tpl->Set('VON_TYP', $input['von_typ']); + $this->app->Tpl->Set('VON_ID', $input['von_id']); + $this->app->Tpl->Set('NACH_TYP', $input['nach_typ']); + $this->app->Tpl->Set('NACH_ID', $input['nach_id']); + $this->app->Tpl->Set('BETRAG', $input['betrag']); + $this->app->Tpl->Set('WAEHRUNG', $input['waehrung']); + $this->app->Tpl->Set('BENUTZER', $input['benutzer']); + $this->app->Tpl->Set('ZEIT', $input['zeit']); + $this->app->Tpl->Set('INTERNEBEMERKUNG', $input['internebemerkung']); + + } + +} diff --git a/www/pages/importvorlage.php b/www/pages/importvorlage.php index 0689e2ea..d09a4a88 100644 --- a/www/pages/importvorlage.php +++ b/www/pages/importvorlage.php @@ -5148,8 +5148,6 @@ class Importvorlage extends GenImportvorlage { implode("', '",array_values($row)). "')"; - $msg .= $sql; - $result = $this->app->DB->Update($sql); } } else {