X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FTimeRecording.pm;h=d326522be5636f5f2068f828ee8c6180eaefc889;hb=9db8b697e257cef1e8ffaef832cd650873eb971e;hp=6e0493b401088142c915a3b34153f3cc0ee48eb9;hpb=fdb3de6969b279fa5d385c4e2c664e6c12823707;p=kivitendo-erp.git diff --git a/SL/Controller/TimeRecording.pm b/SL/Controller/TimeRecording.pm index 6e0493b40..d326522be 100644 --- a/SL/Controller/TimeRecording.pm +++ b/SL/Controller/TimeRecording.pm @@ -13,9 +13,11 @@ use SL::DB::Customer; use SL::DB::Employee; use SL::DB::Order; use SL::DB::Part; +use SL::DB::Project; use SL::DB::TimeRecording; use SL::DB::TimeRecordingArticle; use SL::Helper::Flash qw(flash); +use SL::Helper::Number qw(_round_number _parse_number); use SL::Helper::UserPreferences::TimeRecording; use SL::Locale::String qw(t8); use SL::ReportGenerator; @@ -95,8 +97,8 @@ sub action_save { my ($self) = @_; if ($self->use_duration) { - $self->time_recording->start_date(undef); - $self->time_recording->end_date(undef); + $self->time_recording->start_time(undef); + $self->time_recording->end_time(undef); } my @errors = $self->time_recording->validate; @@ -136,6 +138,22 @@ sub action_ajaj_get_order_info { $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); } +sub action_ajaj_get_project_info { + + my $project = SL::DB::Project->new(id => $::form->{id})->load; + + my $data; + if ($project->customer_id) { + $data = { customer => { id => $project->customer_id, + value => $project->customer->displayable_name, + type => 'customer' + }, + }; + } + + $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); +} + sub init_time_recording { my ($self) = @_; @@ -146,7 +164,12 @@ sub init_time_recording { my %attributes = %{ $::form->{time_recording} || {} }; - if (!$self->use_duration) { + if ($self->use_duration) { + if (exists $::form->{duration_h} || exists $::form->{duration_m}) { + $attributes{duration} = _round_number(_parse_number($::form->{duration_h}) * 60 + _parse_number($::form->{duration_m}), 0); + } + + } else { foreach my $type (qw(start end)) { if ($::form->{$type . '_date'}) { my $date = DateTime->from_kivitendo($::form->{$type . '_date'}); @@ -214,8 +237,9 @@ sub init_all_time_recording_articles { } sub init_all_orders { - SL::DB::Manager::Order->get_all_sorted(query => [or => [ closed => 0, closed => undef ], - '!customer_id' => undef]); + 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 { @@ -240,7 +264,7 @@ sub prepare_report { my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; - my @columns = qw(date start_time end_time order customer part project description staff_member duration booked); + my @columns = qw(date start_time end_time order customer project part description staff_member duration booked); my %column_defs = ( date => { text => t8('Date'), sub => sub { $_[0]->date_as_date },