X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d180d84e035a21291e2dc186b4430e3336998156..4fef059183b047e18d8fee7b4b75195b83d6ef23:/SL/Controller/BankImport.pm diff --git a/SL/Controller/BankImport.pm b/SL/Controller/BankImport.pm index 58faf85a1..7e08fc603 100644 --- a/SL/Controller/BankImport.pm +++ b/SL/Controller/BankImport.pm @@ -7,13 +7,18 @@ use SL::Locale::String qw(t8); use SL::DB::CsvImportProfile; use SL::Helper::MT940; +use Rose::Object::MakeMethods::Generic +( + 'scalar --get_set_init' => [ qw(profile) ], +); + +__PACKAGE__->run_before('check_auth'); sub action_upload_mt940 { my ($self, %params) = @_; - my $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => $::myconfig{login}); - $self->render('bankimport/form', title => $::locale->text('MT940 import'), profile => $profile ? 1 : 0); - + $self->setup_upload_mt940_action_bar; + $self->render('bankimport/form', title => $::locale->text('MT940 import'), profile => $self->profile ? 1 : 0); } sub action_import_mt940 { @@ -28,12 +33,35 @@ sub action_import_mt940 { $file->fh->print($converted_data); $file->fh->close; + die t8("The MT940 import needs an import profile called MT940") unless $self->profile; + + $self->redirect_to(controller => 'controller.pl', action => 'CsvImport/test', 'profile.type' => 'bank_transactions', 'profile.id' => $self->profile->id, force_profile => 1); +} + +sub check_auth { + $::auth->assert('bank_transaction'); +} + +sub init_profile { my $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => $::myconfig{login}); - die t8("The MT940 import needs an import profile called MT940") unless $profile; + if ( ! $profile ) { + $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => 'default'); + } + return $profile; +} - $self->redirect_to(controller => 'controller.pl', action => 'CsvImport/test', 'profile.type' => 'bank_transactions', 'profile.id' => $profile->id, force_profile => 1); +sub setup_upload_mt940_action_bar { + my ($self) = @_; -}; + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + $::locale->text('Preview'), + submit => [ '#form', { action => 'BankImport/import_mt940' } ], + accesskey => 'enter', + ], + ); + } +} 1; -