diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-12-08 01:09:10 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-12-08 01:09:10 +0000 |
commit | 2544135f3eef2df596d0f2a3c61cead6a637160d (patch) | |
tree | 26c1c0edc166b7727454ba048a0621c9c854325c | |
parent | c4896312bed88b2e22cce55d507cf6c0f11ce8ed (diff) |
converting all_years to use extract and group by
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1963 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-x | LedgerSMB/Form.pm | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index e2db2d0c..d14dbfdd 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2165,33 +2165,12 @@ sub all_years { $dbh = $self->{dbh}; + $self->{all_years} = []; + # get years my $query = qq| - SELECT (SELECT transdate FROM acc_trans ORDER BY transdate asc - LIMIT 1), - (SELECT transdate FROM acc_trans ORDER BY transdate desc - LIMIT 1)|; - - 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]; - } - - $self->{all_years} = (); - $startdate = substr( $startdate, 0, 4 ); - $enddate = substr( $enddate, 0, 4 ); - - while ( $enddate >= $startdate ) { - push @{ $self->{all_years} }, $enddate--; - } + SELECT extract('YEARS' FROM transdate) FROM acc_trans + GROUP BY extract('YEARS' FROM transdate) ORDER BY 1 DESC|; #this should probably be changed to use locale %{ $self->{all_month} } = ( |