From: Sven Schöling Date: Wed, 12 Oct 2011 12:49:13 +0000 (+0200) Subject: cvars in aufträgen bei update korrekt parsen und formatieren X-Git-Tag: release-2.7.0beta1~233 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=db7c3a525af246d3373e63b4e8b5b7edc82b0a9f;p=kivitendo-erp.git cvars in aufträgen bei update korrekt parsen und formatieren --- diff --git a/SL/CVar.pm b/SL/CVar.pm index e91a2366d..240822278 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -3,6 +3,7 @@ package CVar; use strict; use List::Util qw(first); +use Scalar::Util qw(blessed); use Data::Dumper; use SL::DBUtils; @@ -706,6 +707,15 @@ sub custom_variables_validity_by_trans_id { return sub { !$invalids{+shift} }; } +sub parse { + my ($self, $value, $config) = @_; + + return $::form->parse_amount(\%::myconfig, $value) if $config->{type} eq 'number'; + return DateTime->from_lxoffice($value) if $config->{type} eq 'date'; + return !ref $value ? SL::DB::Manager::Customer->find_by(id => $value * 1) : $value if $config->{type} eq 'customer'; + return $value; +} + 1; __END__ diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 3479485d5..e647db693 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1796,6 +1796,8 @@ sub _render_custom_variables_inputs { $description = $cvar->{description} . ' '; } + my $form_key = "ic_cvar_" . $cvar->{name} . "_$params{row}"; + push @{ $params{ROW2} }, { line_break => $num_visible_cvars == 1, description => $description, @@ -1806,7 +1808,7 @@ sub _render_custom_variables_inputs { name_prefix => 'ic_', name_postfix => "_$params{row}", valid => $cvar->{valid}, - value => $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"}, + value => CVar->parse($::form->{$form_key}, $cvar), } }; } diff --git a/templates/webpages/amcvar/render_inputs_block.html b/templates/webpages/amcvar/render_inputs_block.html index e769291e6..329b94cd8 100644 --- a/templates/webpages/amcvar/render_inputs_block.html +++ b/templates/webpages/amcvar/render_inputs_block.html @@ -1,6 +1,7 @@ [%- USE T8 %] [%- USE HTML %] [%- USE L %] +[%- USE LxERP %] [%- BLOCK cvar_name %][% HTML.escape(cvar.name_prefix) _ "cvar_" _ HTML.escape(cvar.var.name) _ HTML.escape(cvar.name_postfix) -%][% END %] [%- BLOCK cvar_inputs %] [% render_input_blocks__cvar_name = PROCESS cvar_name %] @@ -27,7 +28,11 @@ [%- END %] [%- ELSIF cvar.var.type == 'customer' %] -[% render_input_blocks__cvar_name = PROCESS cvar_name %][% L.customer_picker(render_input_blocks__cvar_name, cvar.value) %] +[%- L.customer_picker(render_input_blocks__cvar_name, cvar.value) %] + +[%- ELSIF cvar.var.type == 'number' %] +[%- L.input_tag(render_input_blocks__cvar_name, LxERP.format_amount(cvar.value, -2)) %] + [%- ELSE %] [%- END %]