X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a4d740099476b4383a40a21ab5472e75806f3f4f..7635f647ec7dcdef51684b21601ee0930ea2bc5b:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index c4c643751..5a2b38df2 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -138,9 +138,15 @@ sub _flatten_variables_rec { foreach my $idx (0 .. scalar @{ $curr->{$key} } - 1) { my $first_array_entry = 1; - foreach my $hash_key (sort keys %{ $curr->{$key}->[$idx] }) { - push @result, $self->_flatten_variables_rec($curr->{$key}->[$idx], $prefix . $key . ($first_array_entry ? '[+].' : '[].'), $hash_key); - $first_array_entry = 0; + my $element = $curr->{$key}[$idx]; + + if ('HASH' eq ref $element) { + foreach my $hash_key (sort keys %{ $element }) { + push @result, $self->_flatten_variables_rec($element, $prefix . $key . ($first_array_entry ? '[+].' : '[].'), $hash_key); + $first_array_entry = 0; + } + } else { + @result = ({ 'key' => $prefix . $key . ($first_array_entry ? '[+]' : '[]'), 'value' => $element }); } } } @@ -1361,21 +1367,13 @@ sub datetonum { # Database routines used throughout -sub _dbconnect_options { - my $self = shift; - my $options = { pg_enable_utf8 => $::locale->is_utf8, - @_ }; - - return $options; -} - sub dbconnect { $main::lxdebug->enter_sub(2); my ($self, $myconfig) = @_; # connect to database - my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options) + my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, SL::DBConnect->get_options) or $self->dberror; # set db options @@ -1394,7 +1392,7 @@ sub dbconnect_noauto { my ($self, $myconfig) = @_; # connect to database - my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options(AutoCommit => 0)) + my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, SL::DBConnect->get_options(AutoCommit => 0)) or $self->dberror; # set db options @@ -1631,14 +1629,8 @@ sub get_all_currencies { my $dbh = $self->get_standard_dbh($myconfig); my @currencies =(); - my $query = qq|SELECT name AS curr FROM currencies|; - - my $sth = prepare_execute_query($self, $dbh, $query); - - while (my $ref = $sth->fetchrow_hashref()) { - push(@currencies, $ref->{curr}); - } - $sth->finish; + my $query = qq|SELECT name FROM currencies|; + my @currencies = map { $_->{name} } selectall_hashref_query($self, $dbh, $query); $main::lxdebug->leave_sub(); @@ -2504,7 +2496,7 @@ sub all_vc { my $query = qq|SELECT count(*) FROM $table $obsolete|; my ($count) = selectrow_query($self, $dbh, $query); - if ($count < $myconfig->{vclimit}) { + if ($count <= $myconfig->{vclimit}) { $query = qq|SELECT id, name, salesman_id FROM $table $obsolete ORDER BY name|; @@ -2864,7 +2856,7 @@ sub lastname_used { "a.department_id" => "department_id", "d.description" => "department", "ct.name" => $table, - "cu.name AS curr" => "currency", + "cu.name" => "currency", "current_date + ct.terms" => "duedate", );