From: Sven Schöling Date: Wed, 21 Jul 2010 15:39:46 +0000 (+0200) Subject: CVar Inputfelder auf Templateblöcke umgeschrieben. X-Git-Tag: release-2.6.2beta1~228 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7dd8ee369c041cbcd772bb27de8fdacb21166626;p=kivitendo-erp.git CVar Inputfelder auf Templateblöcke umgeschrieben. Bei großen Belegen, sprich 50 Zeilen steigt der Aufwand für die CVars im Moment in der dritten Potenz. Das führt dazu dass selbst auf schnellen Servern die Requests unhaltbar langsam sind. Ab jetzt werden für Belege die CVars nicht mehr vorgrendert, sondern zur Laufzeit gerendert, und dann mit einem vorkompilierten Template, dass im Speicher eingebunden wird. Die anderen beiden Templates sind davon nicht betroffen. --- diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index dc0940d43..94d536cbd 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -2094,30 +2094,30 @@ sub _render_custom_variables_inputs { return; } - foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { - $cvar->{valid} = $params{part_id} - ? CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id}) - : 0; - - $cvar->{value} = $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"}; - } - - CVar->render_inputs(hide_non_editable => 1, - variables => $form->{CVAR_CONFIGS}->{IC}, - name_prefix => 'ic_', - name_postfix => "_$params{row}"); - my $num_visible_cvars = 0; foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { + $cvar->{valid} = $params{part_id} && + CVar->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{part_id}); + my $description = ''; if ($cvar->{flag_editable} && $cvar->{valid}) { $num_visible_cvars++; $description = $cvar->{description} . ' '; } - push @{ $params{ROW2} }, { line_break => $num_visible_cvars == 1, - value => $description . $cvar->{HTML_CODE}, - }; + push @{ $params{ROW2} }, { + line_break => $num_visible_cvars == 1, + description => $description, + cvar => 1, + render_options => { + hide_non_editable => 1, + var => $cvar, + name_prefix => 'ic_', + name_postfix => "_$params{row}", + valid => $cvar->{valid}, + value => $form->{"ic_cvar_" . $cvar->{name} . "_$params{row}"}, + } + }; } $main::lxdebug->leave_sub(2); diff --git a/templates/webpages/amcvar/render_inputs_block.html b/templates/webpages/amcvar/render_inputs_block.html new file mode 100644 index 000000000..bea36c048 --- /dev/null +++ b/templates/webpages/amcvar/render_inputs_block.html @@ -0,0 +1,44 @@ +[%- USE T8 %] +[%- USE HTML %] +[%- BLOCK cvar_inputs %] +[%- var = cvar.var %] +[%- hide_non_editable = cvar.hide_non_editable, %] +[%- name_prefix = cvar.name_prefix, %] +[%- name_postfix = cvar.name_postfix, %] +[%- valid = cvar.valid, %] +[%- value = cvar.value, %] +[%- var_name = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%] +[%- %] +[%- IF hide_non_editable && !var.flag_editable %] + +[%- ELSIF !valid %] + [%- IF show_disabled_message %] +[% 'Element disabled' | $T8 %] + [%- END %] +[%- ELSIF var.type == 'bool' %] + +[%- ELSIF var.type == 'textfield' %] + +[%- ELSIF var.type == 'date' %] + + + +[%- ELSIF var.type == 'timestamp' %] + +[%- ELSIF var.type == 'select' %] + +[%- ELSE %] + +[%- END %] +[%- END %] diff --git a/templates/webpages/oe/sales_order.html b/templates/webpages/oe/sales_order.html index dcde83af6..315d1a9d2 100644 --- a/templates/webpages/oe/sales_order.html +++ b/templates/webpages/oe/sales_order.html @@ -1,5 +1,6 @@ [%- USE T8 %] -[% USE HTML %] +[%- USE HTML %] +[%- PROCESS 'amcvar/render_inputs_block.html' %] @@ -7,23 +8,36 @@ $('#cb_show_details').click(function(){ $('[id$="row2"]').toggle() }); - [% FOREACH header = HEADER %][% IF header.display %] - [% END %][% END %] + +[%- FOREACH header = HEADER %] + [%- IF header.display %] + + [%- END %] +[%- END %] - - [% FOREACH row = ROWS %] - [% FOREACH row1 = row.ROW1 %] - [% END %] +[%- FOREACH row = ROWS %] + + [%- FOREACH row1 = row.ROW1 %] + + [%- END %] - - [% FOREACH hidden = row.HIDDENS %][% hidden.value %] - [% END %] - - - [% END %] + [%- FOREACH hidden = row.HIDDENS %] + [% hidden.value %] + [%- END %] + + + +[%- END %]
[% header.value %]
[% header.value %]
[% row1.value %]
[% row1.value %]
[% FOREACH row2 = row.ROW2 %] - [% IF row2.line_break %]
[% END %] - [% row2.value %][% END %] -
+ [%- FOREACH row2 = row.ROW2 %] + [%- IF row2.line_break %]
[%- END %] + [%- IF row2.cvar %] + [% row2.description %] + [% INCLUDE cvar_inputs cvar = row2.render_options %] + [%- ELSE %] + [% row2.value %] + [%- END %] + [%- END %] +