X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/7712480e4a082f84a2229f5b1a90d79a6c01255b..d56eeaf0da06ce646ee4a053033a8c7a38b60eee:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index edf5de978..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 { @@ -959,7 +960,7 @@ sub datetonum { # Database routines used throughout sub dbconnect { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my ($self, $myconfig) = @_; @@ -974,7 +975,7 @@ sub dbconnect { $dbh->do($myconfig->{dboptions}) || $self->dberror($myconfig->{dboptions}); } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); return $dbh; } @@ -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(); @@ -1578,6 +1608,18 @@ sub _get_taxcharts { $main::lxdebug->leave_sub(); } +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_lists { $main::lxdebug->enter_sub(); @@ -1616,6 +1658,10 @@ sub get_lists { $self->_get_taxcharts($dbh, $params{"taxcharts"}); } + if ($params{"employees"}) { + $self->_get_employees($dbh, $params{"employees"}); + } + $dbh->disconnect(); $main::lxdebug->leave_sub(); @@ -1691,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); @@ -1909,7 +1955,8 @@ sub create_links { # now get the account numbers $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id FROM chart c, taxkeys tk - WHERE c.link LIKE '%$module%' AND c.id=tk.chart_id AND tk.id = (SELECT id from taxkeys where taxkeys.chart_id =c.id AND startdate<=$transdate ORDER BY startdate desc LIMIT 1) + WHERE c.link LIKE '%$module%' AND c.id=tk.chart_id AND tk.id = + (SELECT id FROM taxkeys where taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate desc LIMIT 1) ORDER BY c.accno|; $sth = $dbh->prepare($query); @@ -1937,43 +1984,17 @@ sub create_links { } # get taxkeys and description - $query = qq|SELECT id, taxkey, taxdescription - FROM tax|; - $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); - - $ref = $sth->fetchrow_hashref(NAME_lc); - - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $self->{TAXKEY} }, $ref; - } - - $sth->finish; - + $query = qq|SELECT id, taxkey, taxdescription FROM tax|; + $self->{TAXKEY} = selectall_hashref_query($form, $dbh, $query); # get tax zones - $query = qq|SELECT id, description - FROM tax_zones|; - $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); - - - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $self->{TAXZONE} }, $ref; - } - $sth->finish; + $query = qq|SELECT id, description FROM tax_zones|; + $self->{TAXZONE} = selectall_hashref_query($form, $dbh, $query); if (($module eq "AP") || ($module eq "AR")) { - # get tax rates and description $query = qq| SELECT * FROM tax t|; - $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); - $self->{TAX} = (); - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $self->{TAX} }, $ref; - } - $sth->finish; + $self->{TAX} = selectall_hashref_query($form, $dbh, $query); } if ($self->{id}) { @@ -2507,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();