use strict;
use List::Util qw(first);
+use Scalar::Util qw(blessed);
use Data::Dumper;
use SL::DBUtils;
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__
$description = $cvar->{description} . ' ';
}
+ my $form_key = "ic_cvar_" . $cvar->{name} . "_$params{row}";
+
push @{ $params{ROW2} }, {
line_break => $num_visible_cvars == 1,
description => $description,
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),
}
};
}
[%- 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 %]
[%- END %]
</select>
[%- 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 %]
<input name="[% PROCESS cvar_name %]" value="[% HTML.escape(cvar.value) %]" [%- IF cvar.var.maxlength %] maxlength="[% HTML.escape(cvar.var.maxlength) %]"[% END -%]>
[%- END %]