From 8610cf401997e83c6ab4124988408a5ab0ead2fa Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Mon, 1 Aug 2016 11:18:47 +0200 Subject: [PATCH] =?utf8?q?Projektbericht=20-=20Datumsfelder=20besser=20pr?= =?utf8?q?=C3=BCfen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/rp.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index d6c5532ba..96a425d8c 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -468,6 +468,18 @@ sub generate_projects { my $project = $form->{project_id} ? SL::DB::Project->new(id => $form->{project_id})->load : undef; $form->{projectnumber} = $project ? $project->projectnumber : ''; + # make sure todate and fromdate always have a value, even if the date fields + # were left empty or the inputs weren't valid dates/couldn't be parsed + + $project = SL::DB::Project->new() unless $project; # dummy object for dbh + unless ($::locale->parse_date_to_object($::form->{fromdate})) { + ($form->{fromdate}) = $project->db->dbh->selectrow_array('select min(transdate) from acc_trans'); + }; + + unless ($::locale->parse_date_to_object($::form->{todate})) { + ($form->{todate}) = $project->db->dbh->selectrow_array('select max(transdate) from acc_trans'); + }; + $form->{nextsub} = "generate_projects"; $form->{title} = $locale->text('Project Transactions'); RP->trial_balance(\%myconfig, \%$form); -- 2.20.1