X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e7367fb51e706abc8c54495e1623a5e1d2aca7fa..41cedb2da32e79e2ac55533f8d6ab0d1d3950043:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index 921832edd..dbffe1ff7 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1193,7 +1193,10 @@ sub check_exchangerate { my $query = qq|SELECT e.$fld FROM exchangerate e WHERE e.curr = ? AND e.transdate = ?|; my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate); - $dbh->disconnect; + $dbh->disconnect(); + + $exchangerate = 1 if ($exchangerate == 0); + $exchangerate = 1 if ($exchangerate eq ""); $main::lxdebug->leave_sub(); @@ -1611,23 +1614,10 @@ sub _get_taxzones { sub _get_employees { $main::lxdebug->enter_sub(); - my ($self, $dbh, $key) = @_; - - $key = "all_employees" unless ($key); - $self->{$key} = - selectall_hashref_query($self, $dbh, qq|SELECT * FROM employee|); - - $main::lxdebug->leave_sub(); -} - -sub _get_salesmen { - $main::lxdebug->enter_sub(); - - my ($self, $dbh, $key) = @_; + my ($self, $dbh, $default_key, $key) = @_; - $key = "all_salesmen" unless ($key); - $self->{$key} = - selectall_hashref_query($self, $dbh, qq|SELECT * FROM employee|); + $key = $default_key unless ($key); + $self->{$key} = selectall_hashref_query($self, $dbh, qq|SELECT * FROM employee ORDER BY name|); $main::lxdebug->leave_sub(); } @@ -1707,7 +1697,7 @@ sub _get_customers { $key = "all_customers" unless ($key); - my $query = qq|SELECT * FROM customer|; + my $query = qq|SELECT * FROM customer WHERE NOT obsolete ORDER BY name|; $self->{$key} = selectall_hashref_query($self, $dbh, $query); @@ -1721,7 +1711,7 @@ sub _get_vendors { $key = "all_vendors" unless ($key); - my $query = qq|SELECT * FROM vendor|; + my $query = qq|SELECT * FROM vendor WHERE NOT obsolete ORDER BY name|; $self->{$key} = selectall_hashref_query($self, $dbh, $query); @@ -1735,7 +1725,7 @@ sub _get_departments { $key = "all_departments" unless ($key); - my $query = qq|SELECT * FROM department|; + my $query = qq|SELECT * FROM department ORDER BY description|; $self->{$key} = selectall_hashref_query($self, $dbh, $query); @@ -1789,11 +1779,11 @@ sub get_lists { } if ($params{"employees"}) { - $self->_get_employees($dbh, $params{"employees"}); + $self->_get_employees($dbh, "all_employees", $params{"employees"}); } if ($params{"salesmen"}) { - $self->_get_salesmen($dbh, $params{"salesmen"}); + $self->_get_employees($dbh, "all_salesmen", $params{"salesmen"}); } if ($params{"business_types"}) { @@ -2026,7 +2016,7 @@ sub all_departments { sub create_links { $main::lxdebug->enter_sub(); - my ($self, $module, $myconfig, $table) = @_; + my ($self, $module, $myconfig, $table, $provided_dbh) = @_; my ($fld, $arap); if ($table eq "customer") { @@ -2043,7 +2033,7 @@ sub create_links { # get last customers or vendors my ($query, $sth, $ref); - my $dbh = $self->dbconnect($myconfig); + my $dbh = $provided_dbh ? $provided_dbh : $self->dbconnect($myconfig); my %xkeyref = (); if (!$self->{id}) { @@ -2237,7 +2227,7 @@ sub create_links { } - $dbh->disconnect; + $dbh->disconnect() unless $provided_dbh; $main::lxdebug->leave_sub(); }