+sub init_all_time_recording_articles {
+ my $selectable_parts = SL::DB::Manager::TimeRecordingArticle->get_all_sorted(
+ query => [or => [ 'part.obsolete' => 0, 'part.obsolete' => undef ]],
+ with_objects => ['part']);
+
+ my $res = [ map { {id => $_->part_id, description => $_->part->displayable_name} } @$selectable_parts];
+ my $curr_id = $_[0]->time_recording->part_id;
+
+ if ($curr_id && !grep { $curr_id == $_->{id} } @$res) {
+ unshift @$res, {id => $curr_id, description => $_[0]->time_recording->part->displayable_name};
+ }
+
+ return $res;
+}
+
+sub check_auth {
+ $::auth->assert('time_recording');
+}
+
+sub check_auth_edit {
+ my ($self) = @_;
+
+ if (!$self->can_edit_all && ($self->time_recording->staff_member_id != SL::DB::Manager::Employee->current->id)) {
+ $::form->error(t8('You do not have permission to access this entry.'));
+ }