X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FController%2FEmployee.pm;fp=SL%2FController%2FEmployee.pm;h=431c8b77502c633acb33f623bd18940d0fc7c1a6;hp=265d1db3c432123346b1330b7c18ca37e9e396dd;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44 diff --git a/SL/Controller/Employee.pm b/SL/Controller/Employee.pm index 265d1db3c..431c8b775 100644 --- a/SL/Controller/Employee.pm +++ b/SL/Controller/Employee.pm @@ -5,6 +5,7 @@ use parent qw(SL::Controller::Base); use SL::DB::Employee; use SL::Helper::Flash; +use SL::Locale::String qw(t8); __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('load_all'); @@ -23,9 +24,10 @@ sub action_edit { my ($self, %params) = @_; if ($self->{employee}) { + $self->setup_edit_action_bar; $self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name)); } else { - flash('error', $::locale->text('Could not load employee')); + flash_later('error', $::locale->text('Could not load employee')); $self->redirect_to(action => 'list'); } } @@ -33,9 +35,26 @@ sub action_edit { sub action_save { my ($self, %params) = @_; - $self->{employee}->save; + SL::DB->client->with_transaction(sub { + 1; - flash('info', $::locale->text('Employee #1 saved!')); + $self->{employee}->save; + + if ($self->{employee}->deleted) { + my $auth_user = SL::DB::Manager::AuthUser->get_first(login => $self->{employee}->login); + if ($auth_user) { + SL::DB::Manager::AuthClientUser->delete_all( + where => [ + client_id => $::auth->client->{id}, + user_id => $auth_user->id, + ]); + } + } + + 1; + }); + + flash('info', $::locale->text('Employee #1 saved!', $self->{employee}->safe_name)); $self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id); } @@ -63,6 +82,26 @@ sub assign_from_form { return 1; } +sub setup_edit_action_bar { + my ($self) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => 'Employee/save' } ], + accesskey => 'enter', + ], + + 'separator', + + link => [ + t8('Abort'), + link => $self->url_for(action => 'list'), + ], + ); + } +} ######################## behaviour ##########################