Zeiterfassung: Mitarbeiter ändern können bei entspr. Recht
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 28 Dec 2020 16:33:11 +0000 (17:33 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 5 May 2021 15:25:03 +0000 (17:25 +0200)
SL/Controller/TimeRecording.pm
templates/webpages/time_recording/form.html

index b72b0d1..44d54ca 100644 (file)
@@ -121,9 +121,12 @@ sub init_time_recording {
     }
   }
 
-  $attributes{employee_id}     = SL::DB::Manager::Employee->current->id;
+  # do not overwright staff member if you do not have the right
+  delete $attributes{staff_member_id} if !$_[0]->can_edit_all;
   $attributes{staff_member_id} = SL::DB::Manager::Employee->current->id if $is_new;
 
+  $attributes{employee_id}     = SL::DB::Manager::Employee->current->id;
+
   $time_recording->assign_attributes(%attributes);
 
   return $time_recording;
index 119de5c..f0d4c1e 100644 (file)
@@ -2,6 +2,7 @@
 [% USE P %]
 [% USE T8 %]
 [% USE LxERP %]
+[% USE HTML %]
 
 <h1>[% title %]</h1>
 
@@ -19,6 +20,7 @@
       <th>[% 'Type' | $T8 %]</th>
       <th>[% 'Project' | $T8 %]</th>
       <th>[% 'Description' | $T8 %]</th>
+      <th>[% 'Mitarbeiter' | $T8 %]</th>
     </thead>
     <tbody valign="top">
       <td>
       <td>[% P.select_tag('time_recording.type_id', SELF.all_time_recording_types, default=SELF.time_recording.type.id, with_empty=1, title_key='abbreviation') %]</td>
       <td>[% P.project.picker('time_recording.project_id', SELF.time_recording.project_id, style='width: 300px') %]</td>
       <td>[% L.textarea_tag('time_recording.description', SELF.time_recording.description, wrap="soft", style="width: 350px; height: 150px", class="texteditor", "data-validate"="required", "data-title"=LxERP.t8('Description')) %]</td>
+      <td>
+        [%- IF SELF.can_edit_all -%]
+          [% L.select_tag('time_recording.staff_member_id', SELF.all_employees,
+                           default    => SELF.time_recording.staff_member_id,
+                           title_key  => 'safe_name',
+                           value_key  => 'id',
+                           style      => 'width: 200px') %]
+        [%- ELSE -%]
+          [% SELF.time_recording.staff_member.safe_name | html %]
+        [%- END -%]
+      </td>
     </tbody>
   </table>