11 |
11 |
use SL::Controller::Helper::ReportGenerator;
|
12 |
12 |
use SL::DB::Customer;
|
13 |
13 |
use SL::DB::Employee;
|
|
14 |
use SL::DB::Part;
|
14 |
15 |
use SL::DB::TimeRecording;
|
|
16 |
use SL::DB::TimeRecordingArticle;
|
15 |
17 |
use SL::Locale::String qw(t8);
|
16 |
18 |
use SL::ReportGenerator;
|
17 |
19 |
|
18 |
20 |
use Rose::Object::MakeMethods::Generic
|
19 |
21 |
(
|
20 |
22 |
# scalar => [ qw() ],
|
21 |
|
'scalar --get_set_init' => [ qw(time_recording models all_employees can_view_all can_edit_all) ],
|
|
23 |
'scalar --get_set_init' => [ qw(time_recording models all_employees all_time_recording_articles can_view_all can_edit_all) ],
|
22 |
24 |
);
|
23 |
25 |
|
24 |
26 |
|
... | ... | |
26 |
28 |
__PACKAGE__->run_before('check_auth');
|
27 |
29 |
__PACKAGE__->run_before('check_auth_edit', only => [ qw(edit save delete) ]);
|
28 |
30 |
|
29 |
|
#
|
30 |
|
# actions
|
31 |
|
#
|
32 |
|
|
33 |
31 |
my %sort_columns = (
|
34 |
32 |
start_time => t8('Start'),
|
35 |
33 |
end_time => t8('End'),
|
36 |
34 |
customer => t8('Customer'),
|
|
35 |
part => t8('Article'),
|
37 |
36 |
project => t8('Project'),
|
38 |
37 |
description => t8('Description'),
|
39 |
38 |
staff_member => t8('Mitarbeiter'),
|
40 |
39 |
duration => t8('Duration'),
|
41 |
40 |
);
|
42 |
41 |
|
|
42 |
#
|
|
43 |
# actions
|
|
44 |
#
|
|
45 |
|
43 |
46 |
sub action_list {
|
44 |
47 |
my ($self, %params) = @_;
|
45 |
48 |
|
... | ... | |
150 |
153 |
sorted => \%sort_columns,
|
151 |
154 |
disable_plugin => 'paginated',
|
152 |
155 |
query => \@where,
|
153 |
|
with_objects => [ 'customer', 'project', 'staff_member', 'employee' ],
|
|
156 |
with_objects => [ 'customer', 'part', 'project', 'staff_member', 'employee' ],
|
154 |
157 |
);
|
155 |
158 |
}
|
156 |
159 |
|
... | ... | |
158 |
161 |
SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
|
159 |
162 |
}
|
160 |
163 |
|
|
164 |
sub init_all_time_recording_articles {
|
|
165 |
my $selectable_parts = SL::DB::Manager::TimeRecordingArticle->get_all_sorted(
|
|
166 |
query => [or => [ 'part.obsolete' => 0, 'part.obsolete' => undef ]],
|
|
167 |
with_objects => ['part']);
|
|
168 |
|
|
169 |
my $res = [ map { {id => $_->part_id, description => $_->part->displayable_name} } @$selectable_parts];
|
|
170 |
my $curr_id = $_[0]->time_recording->part_id;
|
|
171 |
|
|
172 |
if ($curr_id && !grep { $curr_id == $_->{id} } @$res) {
|
|
173 |
unshift @$res, {id => $curr_id, description => $_[0]->time_recording->part->displayable_name};
|
|
174 |
}
|
|
175 |
|
|
176 |
return $res;
|
|
177 |
}
|
|
178 |
|
161 |
179 |
sub check_auth {
|
162 |
180 |
$::auth->assert('time_recording');
|
163 |
181 |
}
|
... | ... | |
176 |
194 |
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
|
177 |
195 |
$self->{report} = $report;
|
178 |
196 |
|
179 |
|
my @columns = qw(start_time end_time customer project description staff_member duration);
|
|
197 |
my @columns = qw(start_time end_time customer part project description staff_member duration);
|
180 |
198 |
|
181 |
199 |
my %column_defs = (
|
182 |
200 |
start_time => { text => t8('Start'), sub => sub { $_[0]->start_time_as_timestamp },
|
... | ... | |
184 |
202 |
end_time => { text => t8('End'), sub => sub { $_[0]->end_time_as_timestamp },
|
185 |
203 |
obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) } },
|
186 |
204 |
customer => { text => t8('Customer'), sub => sub { $_[0]->customer->displayable_name } },
|
|
205 |
part => { text => t8('Article'), sub => sub { $_[0]->part && $_[0]->part->displayable_name } },
|
187 |
206 |
project => { text => t8('Project'), sub => sub { $_[0]->project && $_[0]->project->displayable_name } },
|
188 |
207 |
description => { text => t8('Description'), sub => sub { $_[0]->description_as_stripped_html },
|
189 |
208 |
raw_data => sub { $_[0]->description_as_restricted_html }, # raw_data only used for html(?)
|
Zeiterfassung: Artikel beim Erfassen wählen können und mit auflisten