From 7848e9c8d739a6c7628e639c909c343b63b39662 Mon Sep 17 00:00:00 2001 From: Udo Spallek Date: Fri, 26 Jan 2007 09:16:41 +0000 Subject: [PATCH] =?utf8?q?sub=20all=5Fyears=20hinzugefuegt.=20Gibt=20alle?= =?utf8?q?=20Jahreszahlen=20als=20List=20aus,=20in=20denen=20Buchungen=20s?= =?utf8?q?tattgefunden=20haben.=20Sinnvoll=20f=C3=BCr=20Datumsauswahl=20vo?= =?utf8?q?n=20Reports,=20es=20werden=20nur=20Jahre=20zur=20Auswahl=20geste?= =?utf8?q?llt,=20in=20denen=20tatsaechlich=20Buchungsdaten=20vorliegen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/SL/Form.pm b/SL/Form.pm index 95ad61660..5452a3221 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2413,4 +2413,52 @@ sub audittrail { } + +sub all_years { +# usage $form->all_years($myconfig, [$dbh]) +# return list of all years where bookings found +# (@all_years) + + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $dbh) = @_; + + my $disconnect = 0; + if (! $dbh) { + $dbh = $self->dbconnect($myconfig); + $disconnect = 1; + } + + # get years + my $query = qq|SELECT (SELECT MIN(transdate) FROM acc_trans), + (SELECT MAX(transdate) FROM acc_trans) + FROM defaults|; + my ($startdate, $enddate) = $dbh->selectrow_array($query); + + if ($myconfig->{dateformat} =~ /^yy/) { + ($startdate) = split /\W/, $startdate; + ($enddate) = split /\W/, $enddate; + } else { + (@_) = split /\W/, $startdate; + $startdate = $_[2]; + (@_) = split /\W/, $enddate; + $enddate = $_[2]; + } + + my @all_years; + $startdate = substr($startdate,0,4); + $enddate = substr($enddate,0,4); + + while ($enddate >= $startdate) { + push @all_years, $enddate--; + } + + $dbh->disconnect if $disconnect; + + return @all_years; + + $main::lxdebug->leave_sub(); +} + + 1; -- 2.20.1