X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a751b16cead5e56b62e18ee616e04323919f5fe1..d56eeaf0da06ce646ee4a053033a8c7a38b60eee:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index e1ea94174..d690be1c1 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -44,6 +44,7 @@ use SL::Template; use CGI::Ajax; use SL::DBUtils; use SL::Menu; +use SL::User; use CGI; sub _input_to_hash { @@ -1377,6 +1378,35 @@ sub get_employee { $main::lxdebug->leave_sub(); } +sub get_salesman { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $salesman_id) = @_; + + my $dbh = $self->dbconnect($myconfig); + + my ($login) = + selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, + $salesman_id); + + if ($login) { + my $user = new User($main::memberfile, $login); + map({ $self->{"salesman_$_"} = $user->{$_}; } + qw(address businessnumber co_ustid company duns email fax name + taxnumber tel)); + $self->{salesman_login} = $login; + + $self->{salesman_name} = $login + if ($self->{salesman_name} eq ""); + + map({ $self->{"salesman_$_"} =~ s/\\n/\n/g; } qw(address company)); + } + + $dbh->disconnect(); + + $main::lxdebug->leave_sub(); +} + sub get_duedate { $main::lxdebug->enter_sub(); @@ -1707,7 +1737,7 @@ sub all_vc { # build selection list if ($count < $myconfig->{vclimit}) { - $query = qq|SELECT id, name + $query = qq|SELECT id, name, salesman_id FROM $table WHERE not obsolete ORDER BY name|; $sth = $dbh->prepare($query); @@ -2498,28 +2528,6 @@ sub update_business { return $var; } -sub get_salesman { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $salesman) = @_; - - my $dbh = $self->dbconnect($myconfig); - my $query = - qq|SELECT id, name FROM customer WHERE (customernumber ilike '%$salesman%' OR name ilike '%$salesman%') AND business_id in (SELECT id from business WHERE salesman)|; - my $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); - - my $i = 0; - while ($ref = $sth->fetchrow_hashref(NAME_lc)) { - push(@{ $self->{salesman_list} }, $ref); - $i++; - } - $dbh->commit; - $main::lxdebug->leave_sub(); - - return $i; -} - sub get_partsgroup { $main::lxdebug->enter_sub();