From 6c56877d1497223a3515dea602de77330626a7bd Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 21 Jul 2008 09:43:44 +0000 Subject: [PATCH] =?utf8?q?Bei=20$form->parse=5Ftemplate()=20nur=20dann=20d?= =?utf8?q?ie=20ganzen=20Variablen=20employee=5F*=20=C3=BCberschreiben,=20w?= =?utf8?q?enn=20employee=5Fid=20nicht=20gesetzt=20ist.=20In=20io.pl=20die?= =?utf8?q?=20ganzen=20employee=5F*-Variablen=20mit=20denen=20des=20ausgew?= =?utf8?q?=C3=A4hlten=20Bearbeiters=20belegen=20und=20nicht=20mit=20denen?= =?utf8?q?=20des=20aktuellen=20Benutzers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 31 ++++++++++++++++++++----------- bin/mozilla/io.pl | 3 ++- 2 files changed, 22 insertions(+), 12 deletions(-) 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); -- 2.20.1