From c1551e49adc832aae84be606c74794679ebc1bec Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 10 Nov 2021 15:53:41 +0100 Subject: [PATCH] =?utf8?q?Benutzerdef.=20Var.=20als=20HTML-Feld:=20Druckun?= =?utf8?q?terst=C3=BCtzung?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 1 + SL/Controller/Order.pm | 1 + SL/DN.pm | 1 + SL/Form.pm | 32 +++++++++++++++++++++- templates/print/marei/requirement_spec.tex | 17 ++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 58f1febab..f41135387 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -451,6 +451,7 @@ sub _email_invoice { longdescription => 'html', partnotes => 'html', notes => 'html', + $::form->get_variable_content_types_for_cvars, }, ); diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 4cf9f614a..b030d83cd 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -2118,6 +2118,7 @@ sub generate_pdf { longdescription => 'html', partnotes => 'html', notes => 'html', + $::form->get_variable_content_types_for_cvars, }, ); 1; diff --git a/SL/DN.pm b/SL/DN.pm index 8224172bf..b3c4d897a 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -1217,6 +1217,7 @@ sub print_original_invoice { longdescription => 'html', partnotes => 'html', notes => 'html', + $print_form->get_variable_content_types_for_cvars, }, ); diff --git a/SL/Form.pm b/SL/Form.pm index e6cb33271..52d222bab 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -61,6 +61,7 @@ use SL::DBConnect; use SL::DBUtils; use SL::DB::AdditionalBillingAddress; use SL::DB::Customer; +use SL::DB::CustomVariableConfig; use SL::DB::Default; use SL::DB::PaymentTerm; use SL::DB::Vendor; @@ -2713,6 +2714,8 @@ sub lastname_used { } sub get_variable_content_types { + my ($self) = @_; + my %html_variables = ( longdescription => 'html', partnotes => 'html', @@ -2725,7 +2728,34 @@ sub get_variable_content_types { header_text => 'html', footer_text => 'html', ); - return \%html_variables; + + return { + %html_variables, + $self->get_variable_content_types_for_cvars, + }; +} + +sub get_variable_content_types_for_cvars { + my ($self) = @_; + my $html_configs = SL::DB::Manager::CustomVariableConfig->get_all(where => [ type => 'htmlfield' ]); + my %types; + + if (@{ $html_configs }) { + my %prefix_by_module = ( + Contacts => 'cp_cvar_', + CT => 'vc_cvar_', + IC => 'ic_cvar_', + Projects => 'project_cvar_', + ShipTo => 'shiptocvar_', + ); + + foreach my $cfg (@{ $html_configs }) { + my $prefix = $prefix_by_module{$cfg->module}; + $types{$prefix . $cfg->name} = 'html' if $prefix; + } + } + + return %types; } sub current_date { diff --git a/templates/print/marei/requirement_spec.tex b/templates/print/marei/requirement_spec.tex index d8fb2e5dc..bd08dc695 100644 --- a/templates/print/marei/requirement_spec.tex +++ b/templates/print/marei/requirement_spec.tex @@ -59,6 +59,23 @@ $( KiviLatex.required_packages_for_html )$ %\tableofcontents +%%%% Deaktiviertes Beispiel, wie benutzerdefinierte Variablen ausgegeben werden können: %%%% +%% \newpage +%% +%% \section{Benutzerdefinierte Variablen} +%% +%% %$ ( FOREACH cvar = rspec.cvars_by_config ) $ +%% Name: $ ( KiviLatex.filter(cvar.config.name) ) $ +%% +%% Wert:% $ ( IF cvar.config.type == 'htmlfield' ) $ +%% $ ( KiviLatex.filter_html(cvar.value_as_text) ) $ +%% % $ ( ELSE ) $ +%% $ ( KiviLatex.filter(cvar.value_as_text) ) $ +%% % $ ( END ) $ +%% +%% %$ ( END ) $ +%%%% ENDE Beispiel für benutzerdefinierte Variablen %%%% + %% Versionen \newpage -- 2.20.1