From 133cdef385504fa50075c5f361de672a12cc6af2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 18 May 2021 13:28:43 +0200 Subject: [PATCH] =?utf8?q?Zeiterfassung:=20Im=20Bericht=20Eintr=C3=A4ge=20?= =?utf8?q?als=20gebucht=20markieren=20k=C3=B6nnen,=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … wenn man das Recht hat, alle zu ändern. --- SL/Controller/TimeRecording.pm | 45 ++++++++++++++++++- locale/de/all | 2 + locale/en/all | 2 + .../time_recording/report_bottom.html | 8 +--- .../webpages/time_recording/report_top.html | 1 + 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/SL/Controller/TimeRecording.pm b/SL/Controller/TimeRecording.pm index 628c8ae1e..38771d1fc 100644 --- a/SL/Controller/TimeRecording.pm +++ b/SL/Controller/TimeRecording.pm @@ -22,6 +22,7 @@ use SL::Helper::Flash qw(flash); use SL::Helper::Number qw(_round_number _parse_number _round_total); use SL::Helper::UserPreferences::TimeRecording; use SL::Locale::String qw(t8); +use SL::Presenter::Tag qw(checkbox_tag); use SL::ReportGenerator; use Rose::Object::MakeMethods::Generic @@ -33,7 +34,9 @@ use Rose::Object::MakeMethods::Generic # safety __PACKAGE__->run_before('check_auth'); -__PACKAGE__->run_before('check_auth_edit', only => [ qw(edit save delete) ]); +__PACKAGE__->run_before('check_auth_edit', only => [ qw(edit save delete) ]); +__PACKAGE__->run_before('check_auth_edit_all', only => [ qw(mark_as_booked) ]); + my %sort_columns = ( date => t8('Date'), @@ -83,6 +86,17 @@ sub action_list { $self->report_generator_list_objects(report => $self->{report}, objects => $objects); } +sub action_mark_as_booked { + my ($self) = @_; + + if (scalar @{ $::form->{ids} }) { + my $trs = SL::DB::Manager::TimeRecording->get_all(query => [id => $::form->{ids}]); + $_->update_attributes(booked => 1) for @$trs; + } + + $self->redirect_to(safe_callback()); +} + sub action_edit { my ($self) = @_; @@ -279,15 +293,24 @@ sub check_auth_edit { } } +sub check_auth_edit_all { + my ($self) = @_; + + $::auth->assert('time_recording_edit_all'); +} + sub prepare_report { my ($self) = @_; my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; - my @columns = qw(date start_time end_time order customer project part description staff_member duration booked); + my @columns = qw(ids date start_time end_time order customer project part description staff_member duration booked); my %column_defs = ( + ids => { raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]"), + align => 'center', + raw_data => sub { $_[0]->booked ? '' : checkbox_tag("ids[]", value => $_[0]->id, "data-checkall" => 1) } }, date => { text => t8('Date'), sub => sub { $_[0]->date_as_date }, obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) } }, start_time => { text => t8('Start'), sub => sub { $_[0]->start_time_as_timestamp }, @@ -307,6 +330,11 @@ sub prepare_report { booked => { text => t8('Booked'), sub => sub { $_[0]->booked ? t8('Yes') : t8('No') } }, ); + if (!$self->can_edit_all) { + @columns = grep {'ids' ne $_} @columns; + delete $column_defs{ids}; + } + my $title = t8('Time Recordings'); $report->{title} = $title; # for browser titlebar (title-tag) @@ -373,6 +401,19 @@ sub setup_list_action_bar { submit => [ '#filter_form', { action => 'TimeRecording/list' } ], accesskey => 'enter', ], + combobox => [ + action => [ + t8('Actions'), + only_if => $self->can_edit_all, + ], + action => [ + t8('Mark as booked'), + submit => [ '#form', { action => 'TimeRecording/mark_as_booked', callback => $self->models->get_callback } ], + checks => [ [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ], + confirm => $::locale->text('Do you really want to mark the selected entries as booked?'), + only_if => $self->can_edit_all, + ], + ], action => [ t8('Add'), link => $self->url_for(action => 'edit', callback => $self->models->get_callback), diff --git a/locale/de/all b/locale/de/all index aa5777350..3d498ee68 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1106,6 +1106,7 @@ $self->{texts} = { 'Do you really want to delete this draft?' => 'Möchten Sie diesen Entwurf wirklich löschen?', 'Do you really want to delete this object?' => 'Möchten Sie dieses Objekt wirklich löschen?', 'Do you really want to delete this record template?' => 'Möchten Sie diese Belegvorlage wirklich löschen?', + 'Do you really want to mark the selected entries as booked?' => 'Möchten Sie die ausgewählten Einträge wirklich als gebucht markieren?', 'Do you really want to print?' => 'Wollen Sie wirklich drucken?', 'Do you really want to revert to this version?' => 'Möchten Sie wirklich auf diese Version zurücksetzen?', 'Do you really want to undo the selected SEPA exports? You have to reassign the export again.' => 'Möchten Sie wirklich die ausgewählten SEPA-Exports rückgängig machen? Der Export muss anschließend neu erzeugt werden.', @@ -1990,6 +1991,7 @@ $self->{texts} = { 'Margepercent' => 'Ertrag prozentual', 'Margetotal' => 'Ertrag', 'Margins' => 'Seitenränder', + 'Mark as booked' => 'Als gebucht markieren', 'Mark as closed' => 'Als geschlossen markieren', 'Mark as paid' => 'Als bezahlt markieren', 'Mark as shop article if column missing' => 'Als Shopartikel setzen, falls Spalte nicht vorhanden', diff --git a/locale/en/all b/locale/en/all index b8752cc2c..d796bdc93 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1106,6 +1106,7 @@ $self->{texts} = { 'Do you really want to delete this draft?' => '', 'Do you really want to delete this object?' => '', 'Do you really want to delete this record template?' => '', + 'Do you really want to mark the selected entries as booked?' => '', 'Do you really want to print?' => '', 'Do you really want to revert to this version?' => '', 'Do you really want to undo the selected SEPA exports? You have to reassign the export again.' => '', @@ -1990,6 +1991,7 @@ $self->{texts} = { 'Margepercent' => '', 'Margetotal' => '', 'Margins' => '', + 'Mark as booked' => '', 'Mark as closed' => '', 'Mark as paid' => '', 'Mark as shop article if column missing' => '', diff --git a/templates/webpages/time_recording/report_bottom.html b/templates/webpages/time_recording/report_bottom.html index a27818a5e..71dddfe68 100644 --- a/templates/webpages/time_recording/report_bottom.html +++ b/templates/webpages/time_recording/report_bottom.html @@ -1,9 +1,3 @@ -[% USE HTML%] -[%- USE T8 %] -[%- USE L %][%- USE LxERP -%] +[%- USE L %] [% L.paginate_controls(models=SELF.models) %] - - [%- FOREACH item = HIDDEN %] - - [%- END %] diff --git a/templates/webpages/time_recording/report_top.html b/templates/webpages/time_recording/report_top.html index 9541d808f..12bb508e6 100644 --- a/templates/webpages/time_recording/report_top.html +++ b/templates/webpages/time_recording/report_top.html @@ -1,2 +1,3 @@ [%- PROCESS 'time_recording/_filter.html' filter=SELF.models.filtered.laundered %]
+
-- 2.20.1