start_time => t8('Start'),
end_time => t8('End'),
customer => t8('Customer'),
start_time => t8('Start'),
end_time => t8('End'),
customer => t8('Customer'),
project => t8('Project'),
description => t8('Description'),
staff_member => t8('Mitarbeiter'),
project => t8('Project'),
description => t8('Description'),
staff_member => t8('Mitarbeiter'),
- 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;
- $attributes{staff_member_id} = $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;
SL::Controller::Helper::GetModels->new(
controller => $_[0],
sorted => \%sort_columns,
disable_plugin => 'paginated',
SL::Controller::Helper::GetModels->new(
controller => $_[0],
sorted => \%sort_columns,
disable_plugin => 'paginated',
- with_objects => [ 'customer', 'type', 'project', 'staff_member', 'employee' ],
+ query => \@where,
+ with_objects => [ 'customer', 'project', 'staff_member', 'employee' ],
-sub init_all_time_recording_types {
- SL::DB::Manager::TimeRecordingType->get_all_sorted(query => [obsolete => 0]);
+sub init_all_employees {
+ SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
-sub init_all_employees {
- SL::DB::Manager::Employee->get_all_sorted;
+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.'));
+ }
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
end_time => { text => t8('End'), sub => sub { $_[0]->end_time_as_timestamp },
obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) } },
customer => { text => t8('Customer'), sub => sub { $_[0]->customer->displayable_name } },
end_time => { text => t8('End'), sub => sub { $_[0]->end_time_as_timestamp },
obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) } },
customer => { text => t8('Customer'), sub => sub { $_[0]->customer->displayable_name } },
project => { text => t8('Project'), sub => sub { $_[0]->project && $_[0]->project->displayable_name } },
description => { text => t8('Description'), sub => sub { $_[0]->description_as_stripped_html },
raw_data => sub { $_[0]->description_as_restricted_html }, # raw_data only used for html(?)
project => { text => t8('Project'), sub => sub { $_[0]->project && $_[0]->project->displayable_name } },
description => { text => t8('Description'), sub => sub { $_[0]->description_as_stripped_html },
raw_data => sub { $_[0]->description_as_restricted_html }, # raw_data only used for html(?)
$report->set_options_from_form;
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
$report->set_options_from_form;
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;