Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4c66b573

Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt

  • ID 4c66b5734eab11ef7d1419423720e2bad5967b44
  • Vorgänger a6782406

Zeiterfassung: Summen-Hack

Unterschiede anzeigen:

SL/Controller/TimeRecording.pm
5 5

  
6 6
use DateTime;
7 7
use English qw(-no_match_vars);
8
use List::Util qw(sum0);
8 9
use POSIX qw(strftime);
9 10

  
10 11
use SL::Controller::Helper::GetModels;
......
17 18
use SL::DB::TimeRecording;
18 19
use SL::DB::TimeRecordingArticle;
19 20
use SL::Helper::Flash qw(flash);
20
use SL::Helper::Number qw(_round_number _parse_number);
21
use SL::Helper::Number qw(_round_number _parse_number _round_total);
21 22
use SL::Helper::UserPreferences::TimeRecording;
22 23
use SL::Locale::String qw(t8);
23 24
use SL::ReportGenerator;
......
63 64
  $self->make_filter_summary;
64 65
  $self->prepare_report;
65 66

  
66
  $self->report_generator_list_objects(report => $self->{report}, objects => $self->models->get);
67
  my $objects = $self->models->get;
68

  
69
  my $total   = sum0 map { _round_total($_->duration_in_hours) } @$objects;
70
  my $total_h = int($total);
71
  my $total_m = int($total * 60.0 + 0.5) % 60;
72
  my $total_s = sprintf('%d:%02d', $total_h, $total_m);
73

  
74
  # test total row as object
75
  my $total_object = SL::DB::TimeRecording->new(duration    => (sum0 map { _round_total($_->duration) } @$objects),
76
                                                description => '' . t8('Total'));
77

  
78
  push @$objects, 'separator';
79
  push @$objects, {
80
    description => t8('Total'),
81
    duration    => $total_s,
82
  };
83

  
84
  # test total row as object
85
  push @$objects, 'separator';
86
  push @$objects, $total_object;
87

  
88
  $self->report_generator_list_objects(report => $self->{report}, objects => $objects);
67 89
}
68 90

  
69 91
sub action_edit {
......
266 288

  
267 289
  my @columns  = qw(date start_time end_time order customer project part description staff_member duration booked);
268 290

  
291
  my $check_ref = sub {'SL::DB::TimeRecording' eq ref $_[0]};
292

  
269 293
  my %column_defs = (
270
    date         => { text => t8('Date'),         sub => sub { $_[0]->date_as_date },
271
                      obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
272
    start_time   => { text => t8('Start'),        sub => sub { $_[0]->start_time_as_timestamp },
273
                      obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
274
    end_time     => { text => t8('End'),          sub => sub { $_[0]->end_time_as_timestamp },
275
                      obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
276
    order        => { text => t8('Sales Order'),  sub => sub { $_[0]->order && $_[0]->order->number } },
277
    customer     => { text => t8('Customer'),     sub => sub { $_[0]->customer->displayable_name } },
278
    part         => { text => t8('Article'),      sub => sub { $_[0]->part && $_[0]->part->displayable_name } },
279
    project      => { text => t8('Project'),      sub => sub { $_[0]->project && $_[0]->project->full_description(sytle => 'both') } },
280
    description  => { text => t8('Description'),  sub => sub { $_[0]->description_as_stripped_html },
281
                      raw_data => sub { $_[0]->description_as_restricted_html }, # raw_data only used for html(?)
282
                      obj_link => sub { $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
283
    staff_member => { text => t8('Mitarbeiter'),  sub => sub { $_[0]->staff_member->safe_name } },
284
    duration     => { text => t8('Duration'),     sub => sub { $_[0]->duration_as_duration_string },
294
    date         => { text  => t8('Date'),         sub      => sub { $check_ref->($_[0]) || return; $_[0]->date_as_date },
295
                                                   obj_link => sub { $check_ref->($_[0]) || return; $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
296
    start_time   => { text  => t8('Start'),        sub      => sub { $check_ref->($_[0]) || return; $_[0]->start_time_as_timestamp; },
297
                                                   obj_link => sub { $check_ref->($_[0]) || return; $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
298
    end_time     => { text  => t8('End'),          sub      => sub { $check_ref->($_[0]) || return; $_[0]->end_time_as_timestamp },
299
                                                   obj_link => sub { $check_ref->($_[0]) || return; $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
300
    order        => { text  => t8('Sales Order'),  sub      => sub { $check_ref->($_[0]) || return; $_[0]->order    && $_[0]->order->number } },
301
    customer     => { text  => t8('Customer'),     sub      => sub { $check_ref->($_[0]) || return; $_[0]->customer && $_[0]->customer->displayable_name } },
302
    part         => { text  => t8('Article'),      sub      => sub { $check_ref->($_[0]) || return; $_[0]->part     && $_[0]->part->displayable_name } },
303
    project      => { text  => t8('Project'),      sub      => sub { $check_ref->($_[0]) || return; $_[0]->project  && $_[0]->project->full_description(sytle => 'both') } },
304
    description  => { text  => t8('Description'),  sub      => sub { $check_ref->($_[0]) || return $_[0]->{description}; $_[0]->description_as_stripped_html },
305
                                                   raw_data => sub { $check_ref->($_[0]) || return $_[0]->{description}; $_[0]->description_as_restricted_html }, # raw_data only used for html(?)
306
                                                   obj_link => sub { $check_ref->($_[0]) || return; $self->url_for(action => 'edit', 'id' => $_[0]->id, callback => $self->models->get_callback) }  },
307
    staff_member => { text  => t8('Mitarbeiter'),  sub      => sub { $check_ref->($_[0]) || return; $_[0]->staff_member && $_[0]->staff_member->safe_name } },
308
    duration     => { text  => t8('Duration'),     sub      => sub { $check_ref->($_[0]) || return $_[0]->{duration}; $_[0]->duration_as_duration_string },
285 309
                      align => 'right'},
286
    booked       => { text => t8('Booked'),       sub => sub { $_[0]->booked ? t8('Yes') : t8('No') } },
310
    booked       => { text  => t8('Booked'),       sub      => sub { $check_ref->($_[0]) || return; $_[0]->booked ? t8('Yes') : t8('No') } },
287 311
  );
288 312

  
289 313
  my $title        = t8('Time Recordings');

Auch abrufbar als: Unified diff