Zeiterfassung: Beim Bearbeiten fremder Einträge, Mitarbeiter behalten
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 28 Dec 2020 15:33:12 +0000 (16:33 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 5 May 2021 15:25:02 +0000 (17:25 +0200)
SL/Controller/TimeRecording.pm

index 9ed3c72..28cd68b 100644 (file)
@@ -102,8 +102,9 @@ sub action_delete {
 }
 
 sub init_time_recording {
-  my $time_recording = ($::form->{id}) ? SL::DB::TimeRecording->new(id => $::form->{id})->load
-                                       : SL::DB::TimeRecording->new(start_time => DateTime->now_local);
+  my $is_new         = !$::form->{id};
+  my $time_recording = $is_new ? SL::DB::TimeRecording->new(start_time => DateTime->now_local)
+                               : SL::DB::TimeRecording->new(id => $::form->{id})->load;
 
   my %attributes = %{ $::form->{time_recording} || {} };
 
@@ -119,7 +120,8 @@ sub init_time_recording {
     }
   }
 
-  $attributes{staff_member_id} = $attributes{employee_id} = SL::DB::Manager::Employee->current->id;
+  $attributes{employee_id}     = SL::DB::Manager::Employee->current->id;
+  $attributes{staff_member_id} = SL::DB::Manager::Employee->current->id if $is_new;
 
   $time_recording->assign_attributes(%attributes);