X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=sql%2FPg-upgrade2%2Fcp_greeting_migration.pl;h=cb2ed66cff9972f8e5b4af1c5d7ec4d1986dcc3c;hb=da2f5aa8cea79ff0a3e1e5e88e74cbf7e9e79794;hp=40c1ebdfac56954dffe3b47cee9fdaaa9bd2cb22;hpb=76c486e3bf157e844b0cf11828d55dae2cb7e439;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/cp_greeting_migration.pl b/sql/Pg-upgrade2/cp_greeting_migration.pl
index 40c1ebdfa..cb2ed66cf 100644
--- a/sql/Pg-upgrade2/cp_greeting_migration.pl
+++ b/sql/Pg-upgrade2/cp_greeting_migration.pl
@@ -1,128 +1,132 @@
# @tag: cp_greeting_migration
# @description: Migration of cp_greeting to cp_gender
# @depends: generic_translations
+package SL::DBUpgrade2::cp_greeting_migration;
use strict;
+use utf8;
-die("This script cannot be run from the command line.") unless ($main::form);
-
-# import vars from caller
-our ($dbup_locale, $dbup_myconfig, $dbh, $iconv);
-
-sub mydberror {
- my ($msg) = @_;
- die($dbup_locale->text("Database update error:") .
- " $msg " . $DBI::errstr);
-}
-
-sub do_query {
- my ($query, $may_fail) = @_;
-
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
- }
-}
-
+use parent qw(SL::DBUpgrade2::Base);
sub query_result {
+ my ($self) = @_;
# list of all entries where cp_greeting is empty, meaning can't determine gender from parsing Herr/Frau/...
# this assumes cp_greeting still exists, i.e. gender.sql was not run yet
my ($gender_table, $mchecked, $fchecked);
my $sql2 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%') ";
- my $sth2 = $dbh->prepare($sql2) or die $dbh->errstr();
- $sth2->execute() or die $dbh->errstr();
+ my $sth2 = $self->dbh->prepare($sql2) or die $self->dbh->errstr();
+ $sth2->execute() or die $self->dbh->errstr();
my $i = 1;
$gender_table .= '
";
- $main::form->{gender_table} = $gender_table;
+ $::form->{gender_table} = $gender_table;
my $title_table;
my $sql3 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not ( (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%')) and not (cp_greeting like ''); ";
- my $sth3 = $dbh->prepare($sql3) or die $dbh->errstr();
- $sth3->execute() or die $dbh->errstr();
+ my $sth3 = $self->dbh->prepare($sql3) or die $self->dbh->errstr();
+ $sth3->execute() or die $self->dbh->errstr();
$title_table = '
cp_givenname
cp_name
cp_title
cp_greeting
cp_title new
';
my $j = 1;
while (my $row = $sth3->fetchrow_hashref()) {
# Vorschlagsfeld fuer neuen Titel mit Werten von cp_greeting und cp_title vorbelegen
- my $value = "$row->{cp_greeting}";
- $value .= " " if $row->{cp_greeting};
- $value .= "$row->{cp_title}";
+ my $value = "$row->{cp_greeting}";
+ $value .= " " if $row->{cp_greeting};
+ $value .= "$row->{cp_title}";
- $title_table .= "