X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FGoBD.pm;h=182d8b26f3f13df8278fb13e88a2e4dad74c8520;hb=ff159a4d47b9a2d10744dcfc23da2c63605c8a32;hp=463c6d743dc84885755c6720bbf0946630a9c59b;hpb=e2b0403982edf5a329b4dfc9d2b169eac91c3dd8;p=kivitendo-erp.git diff --git a/SL/Controller/GoBD.pm b/SL/Controller/GoBD.pm index 463c6d743..182d8b26f 100644 --- a/SL/Controller/GoBD.pm +++ b/SL/Controller/GoBD.pm @@ -24,6 +24,7 @@ sub action_filter { $self->to(DateTime->today) if !$self->to; $::request->layout->add_javascripts('kivi.GoBD.js'); + $self->setup_filter_action_bar; $self->render('gobd/filter', current_year => DateTime->today->year, title => t8('GoBD Export')); } @@ -35,6 +36,7 @@ sub action_export { return; } + my $filename; my $gobd = SL::GoBD->new( company => $::instance_conf->get_company, location => $::instance_conf->get_address, @@ -42,7 +44,16 @@ sub action_export { to => $self->to, ); - my $filename = $gobd->generate_export; + eval { + $filename = $gobd->generate_export; + } or do { + my $errors = $@; + flash('error', t8('The export failed because of malformed transactions. Please fix those before exporting.')); + flash('error', $_) for @$errors; + + $self->action_filter; + return; + }; $self->send_file($filename, name => t8('gobd-#1-#2.zip', $self->from->ymd, $self->to->ymd), unlink => 1); } @@ -92,4 +103,18 @@ sub available_years { sub init_from { DateTime->from_kivitendo($::form->{from}) } sub init_to { DateTime->from_kivitendo($::form->{to}) } +sub setup_filter_action_bar { + my ($self) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Export'), + submit => [ '#filter_form', { action => 'GoBD/export' } ], + accesskey => 'enter', + ], + ); + } +} + 1;