FlattenToForm - Employee-Daten mit integrieren
authorG. Richardson <information@kivitendo-premium.de>
Wed, 14 Sep 2016 11:15:30 +0000 (13:15 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Wed, 14 Sep 2016 11:21:32 +0000 (13:21 +0200)
Wenn Rechnungen per flatten_to_form gedruckt werden, sollten auch die
Druckvorlagenvariablen employee_tel, employee_fax und employee_email im
Template zur Verfügung stehen. Diese Daten stehen aber nur in der
$::auth.

SL/DB/Helper/FlattenToForm.pm

index 7a3922c..cda59e7 100644 (file)
@@ -52,6 +52,11 @@ sub flatten_to_form {
   _copy($self->salesman,                $form, 'salesman_',     '', 0, map { $_->name } SL::DB::Employee->meta->columns)                   if _has($self, 'salesman_id');
   _copy($self->acceptance_confirmed_by, $form, 'acceptance_confirmed_by_', '', 0, map { $_->name } SL::DB::Employee->meta->columns)        if _has($self, 'acceptance_confirmed_by_id');
 
+  if (_has($self, 'employee_id')) {
+    my $user = User->new(login => $self->employee->login);
+    $form->{"employee_$_"} = $user->{$_} for qw(tel email fax);
+  }
+
   $form->{employee}   = $self->employee->name          if _has($self, 'employee_id');
   $form->{language}   = $self->language->template_code if _has($self, 'language_id');
   $form->{department} = $self->department->description if _has($self, 'department_id');