[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1949] trunk/LedgerSMB/Form.pm



Revision: 1949
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1949&view=rev
Author:   einhverfr
Date:     2007-12-05 11:54:51 -0800 (Wed, 05 Dec 2007)

Log Message:
-----------
Fixing long dropdown boxes when too long dates are entered.

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2007-12-05 19:54:26 UTC (rev 1948)
+++ trunk/LedgerSMB/Form.pm	2007-12-05 19:54:51 UTC (rev 1949)
@@ -1145,10 +1145,10 @@
     };
 
     $self->{dbh} = $self->dbconnect_noauto($dbconfig) || $self->dberror();
+    $self->{dbh}->{pg_server_prepare} = 0;
     my $dbh = $self->{dbh};
     my %date_query = (
         'mm/dd/yy' => 'set DateStyle to \'SQL, US\'',
-
         'mm-dd-yy' => 'set DateStyle to \'POSTGRES, US\'',
         'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'',
         'dd-mm-yy' => 'set DateStyle to \'POSTGRES, EUROPEAN\'',
@@ -2070,35 +2070,19 @@
     my ( $self, $myconfig, $dbh2 ) = @_;
 
     my $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)|;
+	SELECT extract('YEARS' FROM transdate) FROM acc_trans 
+	GROUP BY extract('YEARS' FROM transdate) ORDER BY 1 DESC|;
 
-    my ( $startdate, $enddate ) = $dbh->selectrow_array($query);
-
-    if ( $myconfig->{dateformat} =~ /^yy/ ) {
-        ($startdate) = split /\W/, $startdate;
-        ($enddate)   = split /\W/, $enddate;
+    my $sth = $dbh->prepare($query);
+    $sth->execute();
+    while (my ($year) = $sth->fetchrow_array()){
+      push @{$self->{all_years}}, $year; 
     }
-    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--;
-    }
-
     #this should probably be changed to use locale
     %{ $self->{all_month} } = (
         '01' => 'January',


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.