From 4f6a2fa1d46212e189bc46a04fce62a77120e02f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 18 Apr 2012 17:11:37 +0200 Subject: [PATCH] CVars in Ansprechpartnern. --- SL/CT.pm | 12 ++++++++++++ bin/mozilla/amcvar.pl | 1 + bin/mozilla/ct.pl | 17 +++++++++++++++-- locale/de/all | 1 + templates/webpages/ct/_contact.html | 13 +++++++++++++ templates/webpages/ct/form_header.html | 6 +++--- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index eece19e44..6dbbec568 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -448,6 +448,12 @@ sub save_customer { 'trans_id' => $form->{id}, 'variables' => $form, 'always_valid' => 1); + CVar->save_custom_variables('dbh' => $dbh, + 'module' => 'Contacts', + 'trans_id' => $form->{cp_id}, + 'variables' => $form, + 'name_prefix' => 'cp', + 'always_valid' => 1); my $rc = $dbh->commit(); @@ -657,6 +663,12 @@ sub save_vendor { 'trans_id' => $form->{id}, 'variables' => $form, 'always_valid' => 1); + CVar->save_custom_variables('dbh' => $dbh, + 'module' => 'Contacts', + 'trans_id' => $form->{cp_id}, + 'variables' => $form, + 'name_prefix' => 'cp', + 'always_valid' => 1); my $rc = $dbh->commit(); diff --git a/bin/mozilla/amcvar.pl b/bin/mozilla/amcvar.pl index ea023b2fe..25e3ec738 100644 --- a/bin/mozilla/amcvar.pl +++ b/bin/mozilla/amcvar.pl @@ -60,6 +60,7 @@ our %translations = ('text' => $locale->text('Free-form text'), our @types = qw(text textfield number date bool select customer); # timestamp our @modules = ({ module => 'CT', description => $locale->text('Customers and vendors') }, + { module => 'Contacts', description => $locale->text('Contact persons') }, { module => 'IC', description => $locale->text('Parts, services and assemblies') }, { module => 'Projects', description => $locale->text('Projects') }, ); diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 9e814e17b..dbf8cdd82 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -353,9 +353,18 @@ sub form_header { $form->{currency} = $form->{curr}; } - $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'CT', 'trans_id' => $form->{id}); + $::form->{CUSTOM_VARIABLES} = { }; + my %specs = ( CT => { field => 'id', name_prefix => '', }, + Contacts => { field => 'cp_id', name_prefix => 'cp', }, + ); - CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} }); + for my $module (keys %specs) { + my $spec = $specs{$module}; + + $::form->{CUSTOM_VARIABLES}->{$module} = CVar->get_custom_variables(module => $module, trans_id => $::form->{ $spec->{field} }); + CVar->render_inputs(variables => $::form->{CUSTOM_VARIABLES}->{$module}, name_prefix => $spec->{name_prefix}) + if scalar @{ $::form->{CUSTOM_VARIABLES}->{$module} }; + } $form->header; print $form->parse_html_template('ct/form_header'); @@ -672,6 +681,10 @@ sub get_contact { CT->query_titles_and_greetings(\%::myconfig, $::form); CT->get_contact(\%::myconfig, $::form) if $::form->{cp_id}; + $::form->{CUSTOM_VARIABLES}{Contacts} = CVar->get_custom_variables(module => 'Contacts', trans_id => $::form->{cp_id}); + CVar->render_inputs(variables => $::form->{CUSTOM_VARIABLES}{Contacts}, name_prefix => 'cp') + if scalar @{ $::form->{CUSTOM_VARIABLES}->{Contacts} }; + $::form->{contacts_label} = \&_contacts_label; print $::form->ajax_response_header(), $::form->parse_html_template('ct/_contact'); diff --git a/locale/de/all b/locale/de/all index 1d1c9fd00..1e9b423fb 100644 --- a/locale/de/all +++ b/locale/de/all @@ -422,6 +422,7 @@ $self->{texts} = { 'Contact deleted.' => 'Ansprechpartner gelöscht.', 'Contact is in use and was flagged invalid.' => 'Ansprechpartner ist noch in Verwendung, und wurde als ungültig markiert.', 'Contact person (surname)' => 'Ansprechpartner (Nachname)', + 'Contact persons' => 'Ansprechpartner', 'Contacts' => 'Ansprechpartner', 'Continue' => 'Weiter', 'Contra' => 'gegen', diff --git a/templates/webpages/ct/_contact.html b/templates/webpages/ct/_contact.html index 755260062..1c24fe1d4 100644 --- a/templates/webpages/ct/_contact.html +++ b/templates/webpages/ct/_contact.html @@ -114,6 +114,19 @@ [% 'Bcc' | $T8 %] + [% IF CUSTOM_VARIABLES.Contacts.size %] + +
+ + + [%- FOREACH var = CUSTOM_VARIABLES.Contacts %] + + [% HTML.escape(var.description) %] + [% var.HTML_CODE %] + + [%- END %] + [%- END %] + [% IF cp_id %] diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index 8f71e65f5..92c098d7e 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -17,7 +17,7 @@
  • [% 'Supplies' | $T8 %]
  • [%- END %]
  • [% 'Notes' | $T8 %]
  • - [%- IF CUSTOM_VARIABLES.size %] + [%- IF CUSTOM_VARIABLES.CT.size %]
  • [% 'Custom Variables' | $T8 %]
  • [%- END %] @@ -413,12 +413,12 @@
    - [%- IF CUSTOM_VARIABLES.size %] + [%- IF CUSTOM_VARIABLES.CT.size %]

    - [%- FOREACH var = CUSTOM_VARIABLES %] + [%- FOREACH var = CUSTOM_VARIABLES.CT %] -- 2.20.1
    [% HTML.escape(var.description) %] [% var.HTML_CODE %]