From: Sven Schöling Date: Tue, 11 Oct 2011 13:01:46 +0000 (+0200) Subject: CVars für Kunden X-Git-Tag: release-2.7.0beta1~242 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ef90159c18e52835e03b1775a23c64fbb91436de;p=kivitendo-erp.git CVars für Kunden Experimentelles Feature! Das gleiche kann später für vendors auch analog gemacht werden, beides gleichzeitig (also eine kompinierte vc box) ist im moment nicht vorgesehen. Bugs: - Erneuern sowohl in überlagerten Belegen als auch in den Waren funktioniert noch nicht richtig - Drucken ist ungetestet - invalid + überlagern funktioniert noch nicht. --- diff --git a/SL/CVar.pm b/SL/CVar.pm index 779bfc325..8b3cd8e27 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -240,6 +240,7 @@ sub get_custom_variables { $cvar->{value} = $cvar->{type} eq 'date' ? $act_var->{date_value} : $cvar->{type} eq 'timestamp' ? $act_var->{timestamp_value} : $cvar->{type} eq 'number' ? $act_var->{number_value} + : $cvar->{type} eq 'customer' ? $act_var->{number_value} : $cvar->{type} eq 'bool' ? $act_var->{bool_value} : $act_var->{text_value}; $cvar->{valid} = $valid; @@ -273,6 +274,9 @@ sub get_custom_variables { if ($cvar->{type} eq 'number') { $cvar->{value} = $form->format_amount($myconfig, $cvar->{value} * 1, $cvar->{precision}); + } elsif ($cvar->{type} eq 'customer') { + require SL::DB::Customer; + $cvar->{value} = SL::DB::Manager::Customer->find_by(id => $cvar->{value} * 1); } } @@ -334,6 +338,8 @@ sub save_custom_variables { } elsif ($config->{type} eq 'bool') { push @values, $value ? 't' : 'f', undef, undef, undef; + } elsif ($config->{type} eq 'customer') { + push @values, undef, undef, undef, $value * 1; } do_statement($form, $sth, $query, @values); @@ -489,6 +495,11 @@ sub build_filter_query { $not = 'NOT' if ($params{filter}->{$name} eq 'no'); push @sub_where, qq|COALESCE(cvar.bool_value, false) = TRUE|; + } elsif ($config->{type} eq 'customer') { + next unless $params{filter}->{$name}; + + push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM customer WHERE name ILIKE ?)|; + push @sub_values, "%$params{filter}->{$name}%"; } if (@sub_where) { @@ -562,6 +573,7 @@ sub add_custom_variables_to_report { $cfg->{type} eq 'date' ? $ref->{date_value} : $cfg->{type} eq 'timestamp' ? $ref->{timestamp_value} : $cfg->{type} eq 'number' ? $form->format_amount($myconfig, $ref->{number_value} * 1, $cfg->{precision}) + : $cfg->{type} eq 'customer' ? SL::DB::Manager::Customer->find_by(id => 1* $ref->{number_value})->name : $cfg->{type} eq 'bool' ? ($ref->{bool_value} ? $locale->text('Yes') : $locale->text('No')) : $ref->{text_value}; } diff --git a/bin/mozilla/amcvar.pl b/bin/mozilla/amcvar.pl index fc4f26f14..c0a0e88cc 100644 --- a/bin/mozilla/amcvar.pl +++ b/bin/mozilla/amcvar.pl @@ -54,9 +54,10 @@ our %translations = ('text' => $locale->text('Free-form text'), 'timestamp' => $locale->text('Timestamp'), 'bool' => $locale->text('Yes/No (Checkbox)'), 'select' => $locale->text('Selection'), + 'customer' => $locale->text('Customer'), ); -our @types = qw(text textfield number date bool select); # timestamp +our @types = qw(text textfield number date bool select customer); # timestamp our @modules = ({ module => 'CT', description => $locale->text('Customers and vendors') }, { module => 'IC', description => $locale->text('Parts, services and assemblies') }, diff --git a/templates/webpages/amcvar/render_inputs.html b/templates/webpages/amcvar/render_inputs.html index 335a77c9f..ba350da2f 100644 --- a/templates/webpages/amcvar/render_inputs.html +++ b/templates/webpages/amcvar/render_inputs.html @@ -1,5 +1,6 @@ [%- USE T8 %] -[% USE HTML %] +[%- USE HTML %] +[%- USE L %] [%- SET var_name = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%] @@ -33,6 +34,9 @@ [%- ELSIF var.type == 'timestamp' %] +[%- ELSIF var.type == 'customer' %] +[% L.customer_picker(var_name, var.value) %] + [%- ELSIF var.type == 'select' %] +[%- ELSIF cvar.var.type == 'customer' %] +[% render_input_blocks__cvar_name = PROCESS cvar_name %][% L.customer_picker(render_input_blocks__cvar_name, cvar.value) %] [%- ELSE %] [%- END %] diff --git a/templates/webpages/amcvar/search_filter.html b/templates/webpages/amcvar/search_filter.html index 0bf105e78..db37d08a7 100644 --- a/templates/webpages/amcvar/search_filter.html +++ b/templates/webpages/amcvar/search_filter.html @@ -46,6 +46,9 @@ + [%- ELSIF var.type == 'customer' %] + + [% ELSIF var.type == 'select' %]