+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 init_all_orders {
+ my $orders = SL::DB::Manager::Order->get_all(query => [or => [ closed => 0, closed => undef ],
+ '!customer_id' => undef]);
+ return [ map { [$_->id, sprintf("%s %s", $_->number, $_->customervendor->name) ] } sort { $a->number <=> $b->number } @{$orders||[]} ];
+}
+
+sub init_use_duration {
+ return SL::Helper::UserPreferences::TimeRecording->new()->get_use_duration();
+}
+
+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.'));
+ }