From 8ae5d46d28055bea4e44bb36243ab935120ac2c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 9 Jul 2021 11:19:54 +0200 Subject: [PATCH] =?utf8?q?Dialogbuchung:=20Redirects=20nach=20Buchen=20auf?= =?utf8?q?ger=C3=A4umt=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - nicht in der transaction-subroutine, sondern in der Aktion, wo auch das redirect für den "Normal-Fall" schon war. Damit sind die Redirects an einer Stelle. - kein redirect nach redirect_header. redirect schickt ruft auch redirect_header auf, prüft aber, ob schon ein header geschickt wurde und bricht dann ab. - Einheitliche Info-Ausgabe. Hinweis: callback und redirect mit Fragment geht (noch) nicht, da bei redirect die callback-Parameter recht simple geparsed werden, um diese in der Session zu hinterlegen. Das berücksichtigt das Fragment nicht. --- bin/mozilla/gl.pl | 33 +++++++++++++++++++-------------- locale/de/all | 3 +-- locale/en/all | 3 +-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 6f519428b..8efe48fb8 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -43,7 +43,7 @@ use SL::DB::BankTransactionAccTrans; use SL::DB::Tax; use SL::FU; use SL::GL; -use SL::Helper::Flash qw(flash); +use SL::Helper::Flash qw(flash flash_later); use SL::IS; use SL::ReportGenerator; use SL::DBUtils qw(selectrow_query selectall_hashref_query); @@ -1398,17 +1398,6 @@ sub post_transaction { 1; }) or do { die SL::DB->client->error }; - if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) { - print $form->redirect_header($form->{callback}); - $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}); - } elsif ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) { - my $add_doc_url = build_std_url("script=gl.pl", 'action=edit', 'id=' . E($form->{id}), 'fragment=ui-tabs-docs'); - print $form->redirect_header($add_doc_url); - $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id}); - } - - # remove or clarify - undef($form->{callback}); $main::lxdebug->leave_sub(); } @@ -1434,8 +1423,24 @@ sub post { )->webdav_path; } - $form->{callback} = build_std_url("action=add", "show_details"); - $form->redirect($::locale->text("General ledger transaction '#1' posted", $form->{reference})); + my $msg = $::locale->text("General ledger transaction '#1' posted (ID: #2)", $form->{reference}, $form->{id}); + if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) { + $form->redirect($msg); + + } elsif ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) { + # Redirect with callback containing a fragment does not work (by now) + # because the callback info is stored in the session an parsing the + # callback parameters does not support fragments (see SL::Form::redirect). + # So use flash_later for the message and redirect_headers for redirecting. + my $add_doc_url = build_std_url("script=gl.pl", 'action=edit', 'id=' . E($form->{id}), 'fragment=ui-tabs-docs'); + SL::Helper::Flash::flash_later('info', $msg); + print $form->redirect_header($add_doc_url); + $::dispatcher->end_request; + + } else { + $form->{callback} = build_std_url("action=add", "show_details"); + $form->redirect($msg); + } $main::lxdebug->leave_sub(); } diff --git a/locale/de/all b/locale/de/all index eb89c4fd6..5dc036db0 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1583,7 +1583,6 @@ $self->{texts} = { 'GL Transactions' => 'Dialogbuchungen', 'GL search' => 'FiBu Suche', 'GL template suggestions' => 'Vorschlag Dialogbuchung', - 'GL transaction posted.' => 'Dialogbuchung verbucht.', 'GL transactions changeable' => 'Änderbarkeit von Dialogbuchungen', 'GLN' => 'GLN', 'Gegenkonto' => 'Gegenkonto', @@ -1594,7 +1593,7 @@ $self->{texts} = { 'General Ledger Transaction' => 'Dialogbuchung', 'General ledger and cash' => 'Finanzbuchhaltung und Zahlungsverkehr', 'General ledger corrections' => 'Korrekturen im Hauptbuch', - 'General ledger transaction \'#1\' posted' => 'Dialogbuchung \'#1\' verbucht.', + 'General ledger transaction \'#1\' posted (ID: #2)' => 'Dialogbuchung \'#1\' verbucht (Buchungsnummer: #2)', 'General ledger transactions can only be changed on the day they are posted.' => 'Dialogbuchungen können nur am Buchungstag geändert werden.', 'General settings' => 'Allgemeine Einstellungen', 'Generate and print sales delivery orders' => 'Erzeuge und drucke Lieferscheine', diff --git a/locale/en/all b/locale/en/all index 164b33cff..194ceac4e 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1583,7 +1583,6 @@ $self->{texts} = { 'GL Transactions' => '', 'GL search' => '', 'GL template suggestions' => '', - 'GL transaction posted.' => '', 'GL transactions changeable' => '', 'GLN' => '', 'Gegenkonto' => '', @@ -1594,7 +1593,7 @@ $self->{texts} = { 'General Ledger Transaction' => '', 'General ledger and cash' => '', 'General ledger corrections' => '', - 'General ledger transaction \'#1\' posted' => '', + 'General ledger transaction \'#1\' posted (ID: #2)' => '', 'General ledger transactions can only be changed on the day they are posted.' => '', 'General settings' => '', 'Generate and print sales delivery orders' => '', -- 2.20.1