From: Moritz Bunkus Date: Mon, 21 Jul 2008 09:43:44 +0000 (+0000) Subject: Bei $form->parse_template() nur dann die ganzen Variablen employee_* überschreiben... X-Git-Tag: release-2.6.0beta1~47 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6c56877d1497223a3515dea602de77330626a7bd;p=kivitendo-erp.git Bei $form->parse_template() nur dann die ganzen Variablen employee_* überschreiben, wenn employee_id nicht gesetzt ist. In io.pl die ganzen employee_*-Variablen mit denen des ausgewählten Bearbeiters belegen und nicht mit denen des aktuellen Benutzers. --- diff --git a/SL/Form.pm b/SL/Form.pm index d4c1fdf97..5d00a1c90 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1107,9 +1107,9 @@ sub parse_template { # Copy the notes from the invoice/sales order etc. back to the variable "notes" because that is where most templates expect it to be. $self->{"notes"} = $self->{ $self->{"formname"} . "notes" }; - map({ $self->{"employee_${_}"} = $myconfig->{$_}; } - qw(email tel fax name signature company address businessnumber - co_ustid taxnumber duns)); + if (!$self->{employee_id}) { + map { $self->{"employee_${_}"} = $myconfig->{$_}; } qw(email tel fax name signature company address businessnumber co_ustid taxnumber duns); + } map({ $self->{"${_}"} = $myconfig->{$_}; } qw(co_ustid)); @@ -1883,22 +1883,31 @@ sub get_employee { $main::lxdebug->leave_sub(); } -sub get_salesman { +sub get_employee_data { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $salesman_id) = @_; + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(prefix)); + Common::check_params_x(\%params, qw(id)); + + if (!$params{id}) { + $main::lxdebug->leave_sub(); + return; + } - $main::lxdebug->leave_sub() and return unless $salesman_id; + my $myconfig = \%main::myconfig; + my $dbh = $params{dbh} || $self->get_standard_dbh($myconfig); - my $dbh = $self->get_standard_dbh($myconfig); - my ($login) = selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, $salesman_id); + my ($login) = selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, conv_i($params{id})); if ($login) { my $user = User->new($login); - map { $self->{"salesman_$_"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel); + map { $self->{$params{prefix} . "_${_}"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel); - $self->{salesman_login} = $login; - $self->{salesman_name} ||= $login; + $self->{$params{prefix} . '_login'} = $login; + $self->{$params{prefix} . '_name'} ||= $login; } $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 79b787ca1..ea8b20306 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1366,7 +1366,8 @@ sub print_form { IS->invoice_details(\%myconfig, \%$form, $locale); } - $form->get_salesman(\%myconfig, $salesman_id_saved); + $form->get_employee_data('prefix' => 'employee', 'id' => $form->{employee_id}); + $form->get_employee_data('prefix' => 'salesman', 'id' => $salesman_id_saved); if ($form->{shipto_id}) { $form->get_shipto(\%myconfig);