From 2b573268fa2c98bdffabfa48dd6bf94c0c887e18 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 1 Apr 2023 20:42:37 +0200 Subject: [PATCH] fibu buchungen --- phpwf/plugins/class.yui.php | 5 +- upgrade/data/db_schema.json | 4 +- www/pages/ajax.php | 14 + www/pages/content/fibu_buchungen_list.tpl | 9 +- www/pages/content/fibu_buchungen_zuordnen.tpl | 34 +++ www/pages/content/kontoauszuege_list.tpl | 3 +- www/pages/fibu_buchungen.php | 244 +++++++++++++++--- www/pages/gutschrift.php | 2 +- www/pages/kontoauszuege.php | 60 ++++- www/pages/rechnung.php | 12 +- www/widgets/templates/_gen/gutschrift.tpl | 2 +- www/widgets/templates/_gen/rechnung.tpl | 2 +- 12 files changed, 341 insertions(+), 50 deletions(-) create mode 100644 www/pages/content/fibu_buchungen_zuordnen.tpl diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php index afdc3318..41ba736e 100644 --- a/phpwf/plugins/class.yui.php +++ b/phpwf/plugins/class.yui.php @@ -6139,7 +6139,10 @@ r.land as land, p.abkuerzung as projekt, r.zahlungsweise as zahlungsweise, DATE_FORMAT(r.datum,'%d.%m.%Y') as vom, adr.kundennummer as kundennummer, CONCAT(" . $this->app->erp->MarkerUseredit("r.name", "r.useredittimestamp") . ", if(r.internebezeichnung!='',CONCAT('
',r.internebezeichnung,''),'')) as kunde, r.land as land, p.abkuerzung as projekt, r.zahlungsweise as zahlungsweise, - FORMAT(r.soll,2{$extended_mysql55}) as soll, r.zahlungsstatus as zahlung, r.soll-r.ist as differenz, re.belegnr as rechnung, UPPER(r.status) as status, + ".$this->app->erp->FormatMenge('r.soll',2)." as soll, + r.zahlungsstatus as zahlung, + ".$this->app->erp->FormatMenge('r.soll-r.ist',2)." as differenz, + re.belegnr as rechnung, UPPER(r.status) as status, ".$this->IconsSQLReturnOrder()." ,r.id FROM gutschrift r LEFT JOIN rechnung re ON re.id=r.rechnungid diff --git a/upgrade/data/db_schema.json b/upgrade/data/db_schema.json index 6294a233..9423364a 100644 --- a/upgrade/data/db_schema.json +++ b/upgrade/data/db_schema.json @@ -117360,12 +117360,12 @@ { "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`" + "Create": "CREATE VIEW `fibu_objekte` AS select `auftrag`.`datum` AS `datum`,'auftrag' collate utf8mb4_general_ci AS `typ`,`auftrag`.`id` AS `id`,`auftrag`.`belegnr` AS `info` from `auftrag` where `auftrag`.`belegnr` <> '' union 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 `datum`,'kontorahmen' AS `'kontorahmen'`,`kontorahmen`.`id` AS `id`,`kontorahmen`.`beschriftung` AS `beschriftung` from `kontorahmen`" }, { "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(`fibu_objekte`.`datum` <> '' collate utf8mb4_general_ci,`fibu_objekte`.`datum`,`fb`.`datum`) AS `datum`,`fb`.`gegen_typ` collate utf8mb4_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` <> '' collate utf8mb4_general_ci 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` <> '' collate utf8mb4_general_ci 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` <> '' collate utf8mb4_general_ci 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` <> '' collate utf8mb4_general_ci 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` <> '' collate utf8mb4_general_ci 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`))" + "Create": "CREATE VIEW `fibu_buchungen_alle` AS select `fb`.`buchungsart` AS `buchungsart`,`fb`.`typ` AS `typ`,`fb`.`id` AS `id`,if(`fibu_objekte`.`datum` <> '' collate utf8mb4_general_ci,`fibu_objekte`.`datum`,`fb`.`datum`) AS `datum`,`fb`.`gegen_typ` collate utf8mb4_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` <> '' collate utf8mb4_general_ci union select 'umsatz' AS `umsatz`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`soll` AS `soll`,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `edit_module`,`gutschrift`.`id` AS `id` from `gutschrift` where `gutschrift`.`belegnr` <> '' collate utf8mb4_general_ci union select 'abbuchung' AS `abbuchung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,-`gutschrift`.`soll` AS `-``openxe``.``gutschrift``.``soll```,`gutschrift`.`waehrung` AS `waehrung`,'rechnung' AS `rechnung`,`gutschrift`.`rechnungid` AS `rechnungid`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' collate utf8mb4_general_ci union select 'abbuchung' AS `abbuchung`,'rechnung' AS `rechnung`,`gutschrift`.`rechnungid` AS `rechnungid`,`gutschrift`.`soll` AS `soll`,`gutschrift`.`waehrung` AS `waehrung`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id` from `gutschrift` where `gutschrift`.`rechnungid` > 0 and `gutschrift`.`belegnr` <> '' collate utf8mb4_general_ci union select 'aufwand' AS `aufwand`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`betrag` AS `betrag`,`verbindlichkeit`.`waehrung` AS `waehrung`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' collate utf8mb4_general_ci union select 'zahlung' AS `zahlung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,`kontoauszuege`.`soll` AS `soll`,`kontoauszuege`.`waehrung` AS `waehrung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,`kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `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 `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 `fibu_buchungen`,`fibu_buchungen`.`id` AS `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 `-``openxe``.``fibu_buchungen``.``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 `fibu_buchungen`,`fibu_buchungen`.`id` AS `id` from `fibu_buchungen`) `fb` left join `fibu_objekte` on(`fb`.`gegen_typ` = `fibu_objekte`.`typ` and `fb`.`gegen_id` = `fibu_objekte`.`id`))" } ] } diff --git a/www/pages/ajax.php b/www/pages/ajax.php index b5276378..192fcfc4 100644 --- a/www/pages/ajax.php +++ b/www/pages/ajax.php @@ -2072,6 +2072,20 @@ select a.kundennummer, (SELECT name FROM adresse a2 WHERE a2.kundennummer = a.ku $newarr[] = $arr[$i]['name']; break; + case "fibu_objekte": + $arr = $this->app->DB->SelectArr("SELECT CONCAT(".$this->app->erp->FormatUCfirst('typ').",'-',id,'-',info) as objekt FROM fibu_objekte WHERE info LIKE '%$term%' LIMIT 20"); + $carr = !empty($arr)?count($arr):0; + for($i = 0; $i < $carr; $i++) + $newarr[] = $arr[$i]['objekt']; + break; + + case "fibu_belege": + $arr = $this->app->DB->SelectArr("SELECT CONCAT(".$this->app->erp->FormatUCfirst('typ').",'-',id,'-',info) as objekt FROM fibu_objekte WHERE info LIKE '%$term%' AND typ IN ('auftrag','rechnung','gutschrift','verbindlichkeit') LIMIT 20"); + $carr = !empty($arr)?count($arr):0; + for($i = 0; $i < $carr; $i++) + $newarr[] = $arr[$i]['objekt']; + break; + case "vpeartikel": $arr = $this->app->DB->SelectArr("SELECT DISTINCT vpe FROM verkaufspreise WHERE geloescht=0 AND vpe LIKE '%$term%' ORDER by vpe"); $carr = !empty($arr)?count($arr):0; diff --git a/www/pages/content/fibu_buchungen_list.tpl b/www/pages/content/fibu_buchungen_list.tpl index 394c103a..5432fc4e 100644 --- a/www/pages/content/fibu_buchungen_list.tpl +++ b/www/pages/content/fibu_buchungen_list.tpl @@ -1,10 +1,17 @@
+ Salden müssen über Gegenbuchungen ausgeglichen werden. [MESSAGE] [TAB1] [TAB1NEXT]
+
+ [MESSAGE] + [TAB2] + [TAB2NEXT] +
diff --git a/www/pages/content/fibu_buchungen_zuordnen.tpl b/www/pages/content/fibu_buchungen_zuordnen.tpl new file mode 100644 index 00000000..0d3a577f --- /dev/null +++ b/www/pages/content/fibu_buchungen_zuordnen.tpl @@ -0,0 +1,34 @@ +
+ +
+ [MESSAGE] +
+ [FORMHANDLEREVENT] +
+
+
+
+
+ {|Offene Einzelsalden|} + [TAB1] +
+
+
+
+
+
+ + {|Aktionen|} + +
+
+
+
+
+
+
+
+
+ diff --git a/www/pages/content/kontoauszuege_list.tpl b/www/pages/content/kontoauszuege_list.tpl index 5a9b28d2..2a35563f 100644 --- a/www/pages/content/kontoauszuege_list.tpl +++ b/www/pages/content/kontoauszuege_list.tpl @@ -11,7 +11,8 @@ Stapelverarbeitung - + +
 alle markieren  alle markieren 
diff --git a/www/pages/fibu_buchungen.php b/www/pages/fibu_buchungen.php index 19fff834..cfede1a8 100644 --- a/www/pages/fibu_buchungen.php +++ b/www/pages/fibu_buchungen.php @@ -19,6 +19,7 @@ class Fibu_buchungen { $this->app->ActionHandler("edit", "fibu_buchungen_edit"); $this->app->ActionHandler("delete", "fibu_buchungen_delete"); $this->app->ActionHandler("assoc", "fibu_buchungen_assoc"); + $this->app->ActionHandler("zuordnen", "fibu_buchungen_zuordnen"); $this->app->DefaultActionHandler("list"); $this->app->ActionHandlerListen($app); @@ -30,32 +31,7 @@ class Fibu_buchungen { } 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; + switch ($name) { case "fibu_buchungen_list": $allowed['fibu_buchungen_list'] = array('list'); @@ -101,6 +77,69 @@ class Fibu_buchungen { // $groupby = ""; break; + case "fibu_buchungen_salden": + $allowed['fibu_buchungen_salden'] = array('list'); + $heading = array( '', 'Typ','Anzahl', 'Saldo', 'Menü'); + $width = array( '1%', '96%', '1%', '1%', '1%'); + + $findcols = array('','','typ','anzahl','saldo'); + $searchsql = array(); + + $defaultorder = 1; + $defaultorderdesc = 0; + + $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; + + $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">
"; + + $linkstart = '
'; + + $id = $app->Secure->GetGET('id'); + + $saldolink = array ( + ' 'typ'], + '">', + ['sql' => $this->app->erp->FormatMenge('SUM(COALESCE(saldonum,0))',2)], + '' + ); + + $sql = "SELECT + '', + '', + ".$this->app->erp->FormatUCfirst('typ')." AS typ, + count(id) anzahl, + ".$this->app->erp->ConcatSQL($saldolink)." AS saldo, + typ + FROM + ( + SELECT + fb.typ, + fb.id, + fo.info, + SUM(betrag) AS saldonum + FROM + `fibu_buchungen_alle` fb + INNER JOIN fibu_objekte fo ON + fb.typ = fo.typ AND fb.id = fo.id + WHERE + fb.typ <> 'kontorahmen' + GROUP BY + fb.typ, + fb.id + ) salden + "; + + $where = "saldonum <> 0"; +// $count = "SELECT count(DISTINCT id) FROM fibu_buchungen_alle WHERE $where"; + $groupby = "GROUP BY typ"; + $orderby = "ORDER BY typ"; + +// echo($sql." WHERE ".$where." ".$groupby); + + break; + case "fibu_buchungen_wahl": $allowed['fibu_buchungen_wahl'] = array('list'); $heading = array('', '', 'Datum', 'Typ', 'Beleg', 'Von','Nach', 'Menü'); @@ -154,9 +193,7 @@ class Fibu_buchungen { 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"); +// $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=create", "Neu anlegen"); // For transfer to tablesearch $doc_typ = $this->app->Secure->GetGET('doc_typ'); @@ -165,7 +202,9 @@ class Fibu_buchungen { $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->YUI->TableSearch('TAB1', 'fibu_buchungen_salden', "show", "", "", basename(__FILE__), __CLASS__); + $this->app->YUI->TableSearch('TAB2', 'fibu_buchungen_list', "show", "", "", basename(__FILE__), __CLASS__); + $this->app->Tpl->Parse('PAGE', "fibu_buchungen_list.tpl"); } @@ -369,4 +408,149 @@ class Fibu_buchungen { } + function fibu_buchungen_zuordnen() { + + $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=list", "Übersicht"); + + $submit = $this->app->Secure->GetPOST('ausfuehren'); + $count_success = 0; + if ($submit == 'BUCHEN') { + + // Process multi action + $von_typen = $this->app->Secure->GetPOST('fibu_typ'); + $von_ids = $this->app->Secure->GetPOST('fibu_id'); + $betraege = $this->app->Secure->GetPOST('fibu_betrag'); + $waehrungen = $this->app->Secure->GetPOST('fibu_waehrung'); + $objekte = $this->app->Secure->GetPOST('fibu_objekt'); + + if(!empty($von_ids)) { + $count = -1; + foreach ($von_ids as $von_id) { + $count++; + if ($von_id > 0) { + $von_typ = $von_typen[$count]; + $objekt = $objekte[$count]; + $objekt = explode('-',$objekt); + $doc_typ = strtolower($objekt[0]); + $doc_id = (int) $objekt[1]; + $betrag = $betraege[$count]; + $betrag = (float) $this->app->erp->ReplaceBetrag(true,$betrag); + $waehrung = $waehrungen[$count]; + if (empty($von_typ) || empty($doc_typ) || empty($doc_id) || empty($betrag) || empty($waehrung)) { + continue; + } + $sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','".$doc_typ."', '".$doc_id."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','". $input['zeit'] = date("Y-m-d H:i")."', '')"; + + $this->app->DB->Insert($sql); + + $count_success++; + } + } + } + $msg .= "
".$count_success." Buchung".(($count_success===1)?'':'en')." durchgeführt.
"; + } + + $typ = $this->app->Secure->GetGET('typ'); + + $objektlink = array ( + ' 'fb.typ'], + '&id=', + ['sql' => 'fb.id'], + '">', + ['sql' => 'fo.info'], + '' + ); + + $sql = "SELECT + salden.typ, + salden.id, + salden.info, + salden.saldo, + salden.objektlink, + salden.saldonum, + salden.waehrung + FROM + ( + SELECT + fb.typ, + fb.id, + fo.info, + ".$this->app->erp->ConcatSQL($objektlink)." AS objektlink, + ".$this->app->erp->FormatMenge('SUM(COALESCE(fb.betrag,0))',2)."AS saldo, + SUM(betrag) AS saldonum, + fb.waehrung + FROM + `fibu_buchungen_alle` fb + INNER JOIN fibu_objekte fo ON + fb.typ = fo.typ AND fb.id = fo.id + WHERE fb.typ <> 'kontorahmen' AND (fb.typ = '".$typ."' OR '".$typ."' = '') + GROUP BY + fb.typ, + fb.id, + fb.waehrung + ) salden + WHERE + salden.saldonum <> 0 + LIMIT 100 + "; + +// echo($sql); + + $items = $this->app->DB->SelectArr($sql); + + //print_r($items); + + $et = new EasyTable($this->app); + + $et->headings = array('Typ','Info','Betrag','Buchbetrag','Zuordnung'); + + foreach ($items as $item) { + + $checked = empty($item['doc_typ'])?'':'checked'; + + if (empty($item['doc_id'])) { + $object_identifier = ''; + } else { + $object_identifier = ucfirst($item['doc_typ'])."-".$item['doc_id']."-".$item['doc_belegnr']; + } + + $input_id = 'fibu_object_select_'.$item['id']; + $object_select = ''; + + if ($item['saldonum'] < 0) { + $min = $item['saldo']; + $max = '0'; + } else { + $max = $item['saldo']; + $min = '0'; + } + + $row = array( + ucfirst($item['typ']), + $item['objektlink'], + $item['saldo'], + ''.$item['waehrung'], + $object_select, + '', + '', + '' + ); + $et->AddRow($row); + + $this->app->YUI->Autocomplete($input_id,'fibu_objekte'); + + } + + $et->DisplayNew('TAB1',"Gegenbuchung","noAction"); + $this->app->Tpl->Set('MESSAGE', $msg); + $this->app->Tpl->Parse('PAGE', "fibu_buchungen_zuordnen.tpl"); + } + } diff --git a/www/pages/gutschrift.php b/www/pages/gutschrift.php index 712d153d..0ca5986b 100644 --- a/www/pages/gutschrift.php +++ b/www/pages/gutschrift.php @@ -1392,7 +1392,7 @@ class Gutschrift extends GenGutschrift if (!empty($saldo)) { if ($saldo['waehrung'] == $openid['waehrung']) { - $sql = "UPDATE gutschrift SET ist = '".$saldo['betrag']."'+soll WHERE id=".$openid['id']; + $sql = "UPDATE gutschrift SET ist = soll-'".$saldo['betrag']."' WHERE id=".$openid['id']; $result = $this->app->DB->Update($sql); } } diff --git a/www/pages/kontoauszuege.php b/www/pages/kontoauszuege.php index 1413fc0b..dd05a2ed 100644 --- a/www/pages/kontoauszuege.php +++ b/www/pages/kontoauszuege.php @@ -15,7 +15,7 @@ class Kontoauszuege { $this->app->ActionHandlerInit($this); $this->app->ActionHandler("list", "kontoauszuege_konto_list"); - $this->app->ActionHandler("listentries", "kontoauszuege_list"); + $this->app->ActionHandler("listentries", "kontoauszuege_list"); $this->app->ActionHandler("create", "kontoauszuege_edit"); // This automatically adds a "New" button $this->app->ActionHandler("edit", "kontoauszuege_edit"); $this->app->ActionHandler("delete", "kontoauszuege_delete"); @@ -51,8 +51,7 @@ class Kontoauszuege { $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">
"; $saldolink = array ( - ' 'k.id'], + '', ['sql' => $this->app->erp->FormatMenge('SUM(COALESCE(fb.betrag,0))',2)], '' @@ -198,6 +197,48 @@ class Kontoauszuege { // $count = "SELECT count(DISTINCT id) FROM kontoauszuege k WHERE $where"; // $groupby = ""; +// echo($sql." WHERE ".$where." ".$groupby); + + break; + case "kontoauszuege_salden": + $allowed['kontoauszuege_list'] = array('list'); + + $kontoid = $this->app->User->getParameter('kontoauszuege_konto_id'); + $onlysaldo = $this->app->User->getParameter('kontoauszuege_only_saldo'); + + $heading = array('','', 'Buchungstext', 'Betrag', 'Waehrung', 'Betrag zuordnen', 'Beleg', 'ID','Beleg-Nr.','', 'Menü'); + $width = array('1%','1%', '20%', '1%', '1%', '1%', '1%', '1%','1%', '1%','1%'); + + // columns that are aligned right (numbers etc) + $alignright = array(6); + + $sumcol = array(10); + + $findcols = array('q.id','q.id','q.konto', 'q.importdatum', 'q.buchung', 'q.soll', 'q.waehrung', 'q.buchungstext','q.internebemerkung','q.saldo'); + $searchsql = array('q.konto', 'q.buchung', 'q.soll', 'q.buchungstext','q.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 + ".$this->app->erp->FormatUCfirst('typ')." + SUM(betrag) + FROM `fibu_buchungen_alle` + "; + + $where = "1"; + if ($onlysaldo) { + $where .= " AND q.saldonum != 0"; + } + +// $count = "SELECT count(DISTINCT id) FROM kontoauszuege k WHERE $where"; + $groupby = "GROUP BY typ"; + // echo($sql." WHERE ".$where." ".$groupby); break; @@ -262,14 +303,21 @@ class Kontoauszuege { $this->app->YUI->TableSearch('TAB1', 'kontoauszuege_list', "show", "", "", basename(__FILE__), __CLASS__); $this->app->Tpl->Parse('PAGE', "kontoauszuege_list.tpl"); + } public function kontoauszuege_delete() { $id = (int) $this->app->Secure->GetGET('id'); - $this->app->DB->Delete("UPDATE `kontoauszuege` SET importfehler = 1 WHERE `id` = '{$id}'"); - $this->app->Tpl->Set('MESSAGE', "
Der Eintrag wurde als Importfehler markiert.
"); - + $sql = "SELECT id FROM fibu_buchungen_alle WHERE CONCAT(doc_typ,doc_id) <> CONCAT('kontoauszuege','".$id."') AND typ = 'kontoauszuege' AND id = ".$id; + $result = $this->app->DB->SelectArr($sql); + + if (!empty($result)) { + $this->app->Tpl->Set('MESSAGE', "
Es existieren Buchungen, Eintrag wurde nicht als Importfehler markiert!
"); + } else { + $this->app->DB->Delete("UPDATE `kontoauszuege` SET importfehler = 1 WHERE `id` = '{$id}'"); + $this->app->Tpl->Set('MESSAGE', "
Der Eintrag wurde als Importfehler markiert.
"); + } $this->kontoauszuege_list(); } diff --git a/www/pages/rechnung.php b/www/pages/rechnung.php index 50244957..c68ae2ed 100644 --- a/www/pages/rechnung.php +++ b/www/pages/rechnung.php @@ -277,7 +277,7 @@ class Rechnung extends GenRechnung */ public function removeManualPayed($invoiceId) { - if(empty($invoiceId) || !$this->app->DB->Select(sprintf('SELECT id FROM rechnung WHERE id = %d', $invoiceId))) { +/* if(empty($invoiceId) || !$this->app->DB->Select(sprintf('SELECT id FROM rechnung WHERE id = %d', $invoiceId))) { return false; } $this->app->erp->RechnungProtokoll($invoiceId,'Rechnung manuell als bezahlt entfernt'); @@ -288,7 +288,7 @@ class Rechnung extends GenRechnung WHERE id='$invoiceId'" ); - return true; + return true;*/ } public function RechnungManuellBezahltEntfernen() @@ -2078,9 +2078,9 @@ class Rechnung extends GenRechnung } } else { - $this->app->DB->Update("UPDATE rechnung SET ist = null"); + $this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$openid['id']); } - } + } if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit')) { @@ -2102,10 +2102,10 @@ class Rechnung extends GenRechnung switch($aktion) { case 'bezahlt': - $this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='bezahlt', bezahlt_am = now(), ist=soll,mahnwesenfestsetzen='1',mahnwesen_internebemerkung=CONCAT(mahnwesen_internebemerkung,'\r\n','Manuell als bezahlt markiert am ".date('d.m.Y')."') WHERE id IN (".implode(', ',$auswahl).')'); + $this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='bezahlt', bezahlt_am = now(), mahnwesenfestsetzen='1',mahnwesen_internebemerkung=CONCAT(mahnwesen_internebemerkung,'\r\n','Manuell als bezahlt markiert am ".date('d.m.Y')."') WHERE id IN (".implode(', ',$auswahl).')'); break; case 'offen': - $this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen',bezahlt_am = NULL, ist='0',mahnwesen_internebemerkung=CONCAT(mahnwesen_internebemerkung,'\r\n','Manuell als bezahlt entfernt am ".date('d.m.Y')."') WHERE id IN (".implode(', ',$auswahl).')'); + $this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen',bezahlt_am = NULL, mahnwesen_internebemerkung=CONCAT(mahnwesen_internebemerkung,'\r\n','Manuell als bezahlt entfernt am ".date('d.m.Y')."') WHERE id IN (".implode(', ',$auswahl).')'); break; case 'mail': $auswahl = $this->app->DB->SelectFirstCols( diff --git a/www/widgets/templates/_gen/gutschrift.tpl b/www/widgets/templates/_gen/gutschrift.tpl index 2fc7aee2..0663d801 100644 --- a/www/widgets/templates/_gen/gutschrift.tpl +++ b/www/widgets/templates/_gen/gutschrift.tpl @@ -94,7 +94,7 @@ - {|OFFEN|}: + {|FEHLT|}: [ISTDB] diff --git a/www/widgets/templates/_gen/rechnung.tpl b/www/widgets/templates/_gen/rechnung.tpl index bc29928d..d6ec54ff 100644 --- a/www/widgets/templates/_gen/rechnung.tpl +++ b/www/widgets/templates/_gen/rechnung.tpl @@ -125,7 +125,7 @@ - {|OFFEN|}: + {|FEHLT|}: [ISTDB]