summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-05 06:29:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-05 06:29:56 +0000
commit60ef7ef2016499372d3fbc45ad7f2433d83fc63e (patch)
tree3af1b5aec82a883160d580ad6c433521c6c53b8e
parentac836087123d066b6fe5277911fa8f8db81292c0 (diff)
Adding proper dateformat handling to LedgerSMB.pm
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1945 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xLedgerSMB.pm21
1 files changed, 14 insertions, 7 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index 61e655ec..c89c4533 100755
--- a/LedgerSMB.pm
+++ b/LedgerSMB.pm
@@ -211,6 +211,16 @@ sub new {
}
$self->{_user} = LedgerSMB::User->fetch_config($self);
}
+ my %date_setting = (
+ 'mm/dd/yy' => "SQL, US",
+ 'mm-dd-yy' => "POSTGRES, US",
+ 'dd/mm/yy' => "SQL, EUROPEAN",
+ 'dd-mm-yy' => "POSTGRES, EUROPEAN",
+ 'dd.mm.yy' => "GERMAN",
+ );
+
+ $self->{dbh}->do("set DateStyle to '"
+ .$date_setting{$self->{_user}->{dateformat}}."'");
#my $locale = LedgerSMB::Locale->get_handle($self->{_user}->{countrycode})
$self->{_locale} = LedgerSMB::Locale->get_handle('en') # temporary
or $self->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n");
@@ -348,7 +358,7 @@ sub format_amount {
# Based on SQL-Ledger's Form::format_amount
my $self = shift @_;
my %args = @_;
- my $myconfig = $args{user};
+ my $myconfig = $args{user} || $self->{_user};
my $amount = $args{amount};
my $places = $args{precision};
my $dash = $args{neg_format};
@@ -530,7 +540,6 @@ sub call_procedure {
my @results;
$procname = $self->{dbh}->quote_identifier($procname);
- print STDERR join(':', @call_args) . "\n";
for ( 1 .. scalar @call_args ) {
$argstr .= "?, ";
}
@@ -542,10 +551,11 @@ sub call_procedure {
$query =~ s/\(\)/($argstr)/;
my $sth = $self->{dbh}->prepare($query);
if (scalar @call_args){
- $sth->execute(@call_args);
+ $sth->execute(@call_args) || $self->error($self->{dbh}->errstr);
} else {
- $sth->execute();
+ $sth->execute() || $self->error($self->{dbh}->errstr);
}
+
my @types = @{$sth->{TYPE}};
my @names = @{$sth->{NAME_lc}};
while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) {
@@ -684,9 +694,6 @@ sub _db_init {
-
- # TODO: Add date handling settings and the like.
-
my $query = "SELECT t.extends,
coalesce (t.table_name, 'custom_' || extends)
|| ':' || f.field_name as field_def