From e09347c89ca119213c4d8ba43083653cda793399 Mon Sep 17 00:00:00 2001 From: Geoffrey Richardson Date: Mon, 29 Jun 2009 14:36:53 +0000 Subject: [PATCH] Ansprechpartner: cp_greeting durch cp_gender ersetzt contacts->cp_greeting, was normalerweise fuer Frau/Herr benutzt wird, wird durch cp_gender (m/f) ersetzt, was den Vorteil hat, dass man je nach beim Kunden definierter Sprache verschiedene Anreden generieren und die Anreden zentral verwalten kann. 1. cp_gender wird fuer alle Ansprechpartner auf "m" gesetzt 2. cp_gender wird fuer die Ansprechpartner auf "f" gesetzt, bei denen in cp_greeting Frau/Mrs/Miss vorkam, bei abweichender weiblicher Deklaration muss hier also noch nachgepflegt werden 3. alle cp_greeting-Eintraege, die nicht Herr/Frau/Mrs/Miss enthalten werden nach cp_title verschoben 4. cp_greeting wird geloescht --- SL/CT.pm | 56 ++++++++++--------- SL/Common.pm | 4 +- SL/Form.pm | 4 ++ SL/IR.pm | 5 ++ SL/IS.pm | 9 +++ bin/mozilla/common.pl | 2 +- bin/mozilla/ct.pl | 2 +- locale/de/all | 7 +++ locale/de/menu | 1 + locale/de/menunew | 1 + menu.ini | 5 ++ sql/Pg-upgrade2/gender.sql | 14 +++++ sql/Pg-upgrade2/generic_translations.sql | 15 +++++ templates/webpages/ct/form_header_de.html | 42 +++++++++----- templates/webpages/ct/form_header_master.html | 42 +++++++++----- 15 files changed, 150 insertions(+), 59 deletions(-) create mode 100644 sql/Pg-upgrade2/gender.sql create mode 100644 sql/Pg-upgrade2/generic_translations.sql diff --git a/SL/CT.pm b/SL/CT.pm index a8ea84e36..0b276efce 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -194,25 +194,26 @@ sub query_titles_and_greetings { my $dbh = $form->dbconnect($myconfig); - $query = - qq|SELECT DISTINCT(cp_greeting) | . - qq|FROM contacts | . - qq|WHERE cp_greeting ~ '[a-zA-Z]' | . - qq|ORDER BY cp_greeting|; - $form->{GREETINGS} = [ selectall_array_query($form, $dbh, $query) ]; - - $query = - qq|SELECT DISTINCT(greeting) | . - qq|FROM customer | . - qq|WHERE greeting ~ '[a-zA-Z]' | . - qq|UNION | . - qq|SELECT DISTINCT(greeting) | . - qq|FROM vendor | . - qq|WHERE greeting ~ '[a-zA-Z]' | . - qq|ORDER BY greeting|; - my %tmp; - map({ $tmp{$_} = 1; } selectall_array_query($form, $dbh, $query)); - $form->{COMPANY_GREETINGS} = [ sort(keys(%tmp)) ]; +# edit: cp_greeting wurde entfernt, wird durch cp_gender ersetzt +# $query = +# qq|SELECT DISTINCT(cp_greeting) | . +# qq|FROM contacts | . +# qq|WHERE cp_greeting ~ '[a-zA-Z]' | . +# qq|ORDER BY cp_greeting|; +# $form->{GREETINGS} = [ selectall_array_query($form, $dbh, $query) ]; +# +# $query = +# qq|SELECT DISTINCT(greeting) | . +# qq|FROM customer | . +# qq|WHERE greeting ~ '[a-zA-Z]' | . +# qq|UNION | . +# qq|SELECT DISTINCT(greeting) | . +# qq|FROM vendor | . +# qq|WHERE greeting ~ '[a-zA-Z]' | . +# qq|ORDER BY greeting|; +# my %tmp; +# map({ $tmp{$_} = 1; } selectall_array_query($form, $dbh, $query)); +# $form->{COMPANY_GREETINGS} = [ sort(keys(%tmp)) ]; $query = qq|SELECT DISTINCT(cp_title) | . @@ -392,7 +393,8 @@ sub save_customer { qq|cp_project = ?, | . qq|cp_privatphone = ?, | . qq|cp_privatemail = ?, | . - qq|cp_birthday = ? | . + qq|cp_birthday = ?, | . + qq|cp_gender = ? | . qq|WHERE cp_id = ?|; @values = ( $form->{cp_greeting}, @@ -412,6 +414,7 @@ sub save_customer { $form->{cp_privatphone}, $form->{cp_privatemail}, $form->{cp_birthday}, + $form->{cp_gender} eq 'f' ? 'f' : 'm', $form->{cp_id} ); } elsif ( $form->{cp_name} || $form->{cp_givenname} ) { @@ -419,8 +422,8 @@ sub save_customer { qq|INSERT INTO contacts ( cp_cv_id, cp_greeting, cp_title, cp_givenname, | . qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | . qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | . - qq| cp_birthday) | . - qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; + qq| cp_birthday, cp_gender) | . + qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; @values = ( $form->{id}, $form->{cp_greeting}, @@ -439,7 +442,8 @@ sub save_customer { $form->{cp_project}, $form->{cp_privatphone}, $form->{cp_privatemail}, - $form->{cp_birthday} + $form->{cp_birthday}, + $form->{cp_gender} eq 'f' ? 'f' : 'm', ); } do_query( $form, $dbh, $query, @values ) if ($query); @@ -598,6 +602,7 @@ sub save_vendor { qq|cp_privatphone = ?, | . qq|cp_privatemail = ?, | . qq|cp_birthday = ? | . + qq|cp_gender = ? | . qq|WHERE cp_id = ?|; @values = ( $form->{cp_greeting}, @@ -617,6 +622,7 @@ sub save_vendor { $form->{cp_privatphone}, $form->{cp_privatemail}, $form->{cp_birthday}, + $form->{cp_gender} eq 'f' ? 'f' : 'm', $form->{cp_id} ); } elsif ( $form->{cp_name} || $form->{cp_givenname} ) { @@ -624,8 +630,8 @@ sub save_vendor { qq|INSERT INTO contacts ( cp_cv_id, cp_greeting, cp_title, cp_givenname, | . qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | . qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | . - qq| cp_birthday) | . - qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; + qq| cp_birthday, cp_gender) | . + qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; @values = ( $form->{id}, $form->{cp_greeting}, diff --git a/SL/Common.pm b/SL/Common.pm index b5e231c7b..bdc4c5dd6 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -194,7 +194,7 @@ sub retrieve_customers_or_vendors { push(@queries, qq|SELECT c.id, c.name, 0 AS customer_is_vendor, c.street, c.zipcode, c.city, - ct.cp_greeting, ct.cp_title, ct.cp_givenname, ct.cp_name + ct.cp_gender, ct.cp_title, ct.cp_givenname, ct.cp_name FROM customer c LEFT JOIN contacts ct ON (c.id = ct.cp_cv_id) $c_filter|); @@ -207,7 +207,7 @@ sub retrieve_customers_or_vendors { push(@queries, qq|SELECT v.id, v.name, 1 AS customer_is_vendor, v.street, v.zipcode, v.city, - ct.cp_greeting, ct.cp_title, ct.cp_givenname, ct.cp_name + ct.cp_gender, ct.cp_title, ct.cp_givenname, ct.cp_name FROM vendor v LEFT JOIN contacts ct ON (v.id = ct.cp_cv_id) $v_filter|); diff --git a/SL/Form.pm b/SL/Form.pm index 3075968b6..b85d3748f 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1355,6 +1355,10 @@ Content-Length: $numbytes while () { print OUT $_; + open(DUMP_OUT, "> /tmp/lx2.dump" ); + print(DUMP_OUT Dumper($self)); + close(DUMP_OUT); + } close(OUT); diff --git a/SL/IR.pm b/SL/IR.pm index c59f9eee8..02b2fa680 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -39,6 +39,7 @@ use SL::ARAP; use SL::Common; use SL::DBUtils; use SL::DO; +use SL::GenericTranslations; use SL::MoreCommon; use List::Util qw(min); @@ -1147,6 +1148,10 @@ sub vendor_details { 'trans_id' => $form->{vendor_id}); map { $form->{"vc_cvar_$_->{name}"} = $_->{value} } @{ $custom_variables }; + $form->{cp_greeting} = GenericTranslations->get('dbh' => $dbh, + 'translation_type' => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'), + 'allow_fallback' => 1); + $dbh->disconnect(); $main::lxdebug->leave_sub(); diff --git a/SL/IS.pm b/SL/IS.pm index f1cddcd83..f1c95e957 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -44,6 +44,7 @@ use SL::CVar; use SL::Common; use SL::DBUtils; use SL::DO; +use SL::GenericTranslations; use SL::MoreCommon; use SL::IC; use Data::Dumper; @@ -423,6 +424,8 @@ sub customer_details { # connect to database my $dbh = $form->dbconnect($myconfig); + my $language_id = $form->{language_id}; + # get contact id, set it if nessessary $form->{cp_id} *= 1; @@ -484,6 +487,12 @@ sub customer_details { 'trans_id' => $form->{customer_id}); map { $form->{"vc_cvar_$_->{name}"} = $_->{value} } @{ $custom_variables }; + $form->{cp_greeting} = GenericTranslations->get('dbh' => $dbh, + 'translation_type' => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'), + 'language_id' => $language_id, + 'allow_fallback' => 1); + + $dbh->disconnect; $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index efeb8f040..6ace578f2 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -572,7 +572,7 @@ sub cov_selection_internal { $cov->{address} =~ s{^,}{}x; $cov->{address} =~ s{\ +}{\ }gx; - $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_greeting cp_title cp_givenname cp_name); + $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name); $cov->{contact} =~ s{\ +}{\ }gx; } diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 7b051dff3..e5f707f72 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -576,7 +576,7 @@ sub get_contact { CT->get_contact(\%myconfig, \%$form); print $form->ajax_response_header(), join '__pjx__', map $form->{"cp_$_"}, - qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used); + qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used gender); $lxdebug->leave_sub(); } diff --git a/locale/de/all b/locale/de/all index ec3775515..bd45eb859 100644 --- a/locale/de/all +++ b/locale/de/all @@ -479,6 +479,7 @@ $self->{texts} = { 'December' => 'Dezember', 'Decimalplaces' => 'Dezimalstellen', 'Decrease' => 'Verringern', + 'Default (no language selected)' => 'Standard (keine Sprache ausgewählt)', 'Default Accounts' => 'Standardkonten', 'Default output medium' => 'Standardausgabekanal', 'Default printer' => 'Standarddrucker', @@ -624,6 +625,7 @@ $self->{texts} = { 'Edit and delete a group' => 'Gruppen bearbeiten und löschen', 'Edit custom variable' => 'Benutzerdefinierte Variable bearbeiten', 'Edit file' => 'Datei bearbeiten', + 'Edit greetings' => 'Anreden bearbeiten', 'Edit group ' => 'Gruppe bearbeiten', 'Edit group membership' => 'Gruppenmitgliedschaften bearbeiten', 'Edit groups' => 'Gruppen bearbeiten', @@ -723,6 +725,7 @@ $self->{texts} = { 'Full access to all functions' => 'Vollzugriff auf alle Funktionen', 'GL Transaction' => 'Dialogbuchung', 'Gegenkonto' => 'Gegenkonto', + 'Gender' => 'Geschlecht', 'General Ledger' => 'Finanzbuchhaltung', 'General Ledger Corrections' => 'Korrekturen im Hauptbuch', 'General Ledger Transaction' => 'Dialogbuchung', @@ -732,6 +735,7 @@ $self->{texts} = { 'German' => 'Deutsch', 'Given Name' => 'Vorname', 'Greeting' => 'Anrede', + 'Greetings' => 'Anreden', 'Group' => 'Warengruppe', 'Group Invoices' => 'Rechnungen zusammenfassen', 'Group Items' => 'Waren gruppieren', @@ -1506,6 +1510,7 @@ $self->{texts} = { 'The following users have been migrated into the authentication database:' => 'Die folgenden Benutzer wurden in die Authentifizierungsdatenbank migriert:', 'The following warnings occured during an upgrade to the document templates:' => 'Die folgenden Warnungen traten während einer Aktualisierung der Dokumentenvorlagen auf:', 'The formula needs the following syntax:
For regular article:
Variablename= Variable Unit;
Variablename2= Variable2 Unit2;
...
###
Variable + ( Variable2 / Variable )
Please be beware of the spaces in the formula
' => 'Die Formeln müssen in der folgenden Syntax eingegeben werden:
Bei normalen Artikeln:
Variablenname = Variable Einheit;
Variablenname2 = Variable2 Einheit2;
...
###
Variable + Variable2 * ( Variable - Variable2 )
Variablennamen und Einheiten dürfen nur aus alphanumerischen Zeichen bestehen.
Es muss jeweils die Gesamte Zeile eingegeben werden', + 'The greetings have been saved.' => 'Die Anreden wurden gespeichert', 'The group has been added.' => 'Die Gruppe wurde erfasst.', 'The group has been deleted.' => 'Die Gruppe wurde gelöscht.', 'The group has been saved.' => 'Die Gruppe wurde gespeichert.', @@ -1815,6 +1820,7 @@ $self->{texts} = { 'eMail?' => 'eMail?', 'ea' => 'St.', 'emailed to' => 'gemailt an', + 'female' => 'weiblich', 'follow_up_list' => 'wiedervorlageliste', 'for' => 'für', 'for Period' => 'für den Zeitraum', @@ -1832,6 +1838,7 @@ $self->{texts} = { 'list_of_receipts' => 'zahlungseingaenge', 'list_of_transactions' => 'buchungsliste', 'logout' => 'abmelden', + 'male' => 'männlich', 'mark as paid' => 'als bezahlt markieren', 'master' => 'de', 'missing' => 'Fehlbestand', diff --git a/locale/de/menu b/locale/de/menu index af2d6016c..cc0d24b5f 100644 --- a/locale/de/menu +++ b/locale/de/menu @@ -106,6 +106,7 @@ $self->{texts} = { 'General Ledger' => 'Finanzbuchhaltung', 'General Ledger Corrections' => 'Korrekturen im Hauptbuch', 'General ledger and cash' => 'Finanzbuchhaltung und Zahlungsverkehr', + 'Greetings' => 'Anreden', 'Groups' => 'Warengruppen', 'HTML Templates' => 'HTML-Vorlagen', 'History Search Engine' => 'Historien Suchmaschine', diff --git a/locale/de/menunew b/locale/de/menunew index c77080923..6fcf371c5 100644 --- a/locale/de/menunew +++ b/locale/de/menunew @@ -105,6 +105,7 @@ $self->{texts} = { 'General Ledger' => 'Finanzbuchhaltung', 'General Ledger Corrections' => 'Korrekturen im Hauptbuch', 'General ledger and cash' => 'Finanzbuchhaltung und Zahlungsverkehr', + 'Greetings' => 'Anreden', 'Groups' => 'Warengruppen', 'HTML Templates' => 'HTML-Vorlagen', 'History Search Engine' => 'Historien Suchmaschine', diff --git a/menu.ini b/menu.ini index bb4deb426..92bbfa855 100644 --- a/menu.ini +++ b/menu.ini @@ -642,6 +642,11 @@ action=add_language module=am.pl action=list_language +[System--Languages--Greetings] +module=generictranslations.pl +action=edit_greetings + + [System--Printer] module=menu.pl action=acc_menu diff --git a/sql/Pg-upgrade2/gender.sql b/sql/Pg-upgrade2/gender.sql new file mode 100644 index 000000000..2f92f5387 --- /dev/null +++ b/sql/Pg-upgrade2/gender.sql @@ -0,0 +1,14 @@ +-- @tag: gender +-- @description: Feld "Geschlecht" zu Kontaktdaten hinzufuegen, cp_greeting entferne +-- @depends: release_2_6_0 + +ALTER TABLE contacts ADD COLUMN cp_gender char(1); +UPDATE contacts SET cp_gender = 'm'; +UPDATE contacts SET cp_gender = 'f' + WHERE (cp_greeting ILIKE '%frau%') + OR (cp_greeting ILIKE '%mrs.%') + OR (cp_greeting ILIKE '%miss%'); + +UPDATE contacts SET cp_title = cp_greeting WHERE NOT (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%'); + +ALtER TABLE contacts DROP COLUMN cp_greeting; diff --git a/sql/Pg-upgrade2/generic_translations.sql b/sql/Pg-upgrade2/generic_translations.sql new file mode 100644 index 000000000..1dfbee769 --- /dev/null +++ b/sql/Pg-upgrade2/generic_translations.sql @@ -0,0 +1,15 @@ +-- @tag: generic_translations +-- @description: Allgemeine Tabelle fuer Uebersetzungen +-- @depends: release_2_6_0 +CREATE TABLE generic_translations ( + id SERIAL, + language_id integer, + translation_type varchar(100) NOT NULL, + translation_id integer, + translation text, + + PRIMARY KEY (id), + FOREIGN KEY (language_id) REFERENCES language (id) +); +CREATE INDEX generic_translations_type_id_idx ON generic_translations (language_id, translation_type, translation_id); + diff --git a/templates/webpages/ct/form_header_de.html b/templates/webpages/ct/form_header_de.html index 45fb81fb9..d041793b9 100644 --- a/templates/webpages/ct/form_header_de.html +++ b/templates/webpages/ct/form_header_de.html @@ -245,7 +245,7 @@ name = 'shipto_id', id = 'shipto_id', DATA = SHIPTO, - onChange = "get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail',enable_delete_shipto])", + onChange = "get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail',enable_delete_shipto,set_gender])", id_key = 'shipto_id', label_sub = 'shipto_label', label_key = 'shipto_label', @@ -326,26 +326,23 @@ name = 'cp_id', id = 'cp_id', DATA = CONTACTS, - onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_greeting','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact])", + onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact,set_gender])", id_key = 'cp_id', label_sub = 'contacts_label', -%] - - Anrede - -   - [%- INCLUDE generic/multibox.html - name = 'selected_cp_greeting', - DATA = MB_GREETINGS, - show_empty = 1, - id_key = 'id', - label_key = 'description', - -%] - - + + Geschlecht + + + + + Titel @@ -598,3 +595,18 @@ [%- END %] + + + + + diff --git a/templates/webpages/ct/form_header_master.html b/templates/webpages/ct/form_header_master.html index c40d3a2f0..00d0fa1ad 100644 --- a/templates/webpages/ct/form_header_master.html +++ b/templates/webpages/ct/form_header_master.html @@ -245,7 +245,7 @@ name = 'shipto_id', id = 'shipto_id', DATA = SHIPTO, - onChange = "get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail',enable_delete_shipto])", + onChange = "get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail',enable_delete_shipto,set_gender])", id_key = 'shipto_id', label_sub = 'shipto_label', label_key = 'shipto_label', @@ -326,26 +326,23 @@ name = 'cp_id', id = 'cp_id', DATA = CONTACTS, - onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_greeting','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact])", + onChange = "get_contact(['cp_id__'+this.value],['cp_name','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2','cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact,set_gender])", id_key = 'cp_id', label_sub = 'contacts_label', -%] - - Greeting - -   - [%- INCLUDE generic/multibox.html - name = 'selected_cp_greeting', - DATA = MB_GREETINGS, - show_empty = 1, - id_key = 'id', - label_key = 'description', - -%] - - + + Gender + + + + + Title @@ -598,3 +595,18 @@ [%- END %] + + + + + -- 2.20.1