Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 8 Nov 2012 13:16:44 +0000 (14:16 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 8 Nov 2012 13:16:44 +0000 (14:16 +0100)
SL/CT.pm
SL/DB/MetaSetup/Contact.pm
SL/IC.pm
locale/de/all
sql/Pg-upgrade2/contacts_convert_cp_birthday_to_date.pl [new file with mode: 0644]
sql/Pg-upgrade2/finanzamt_update_fa_bufa_nr_hamburg.pl [new file with mode: 0644]
templates/webpages/ct/_contact.html
templates/webpages/dbupgrade/contacts_convert_cp_birthday_to_date_form.html [new file with mode: 0644]

index 93c3fce..082afdf 100644 (file)
--- a/SL/CT.pm
+++ b/SL/CT.pm
@@ -552,7 +552,18 @@ sub _save_contact {
   my @columns = qw(cp_title cp_givenname cp_name cp_email cp_phone1 cp_phone2 cp_abteilung cp_fax
                    cp_mobile1 cp_mobile2 cp_satphone cp_satfax cp_project cp_privatphone cp_privatemail cp_birthday cp_gender
                    cp_street cp_zipcode cp_city);
-  my @values  = map { $_ eq 'cp_gender' ? ($form->{$_} eq 'f' ? 'f' : 'm') : $form->{$_} } @columns;
+  my @values  = map(
+    {
+      if ( $_ eq 'cp_gender' ) {
+        $form->{$_} eq 'f' ? 'f' : 'm';
+      } elsif ( $_ eq 'cp_birthday' && $form->{cp_birthday} eq '' ) {
+        undef;
+      } else {
+        $form->{$_};
+      }
+    }
+    @columns
+  );
 
   my ($query, $cp_id);
   if ($form->{cp_id}) {
index 2eb4fa5..322f826 100644 (file)
@@ -28,9 +28,12 @@ __PACKAGE__->meta->setup(
     cp_project     => { type => 'text' },
     cp_privatphone => { type => 'text' },
     cp_privatemail => { type => 'text' },
-    cp_birthday    => { type => 'text' },
     cp_abteilung   => { type => 'text' },
     cp_gender      => { type => 'character', length => 1 },
+    cp_street      => { type => 'text' },
+    cp_zipcode     => { type => 'text' },
+    cp_city        => { type => 'text' },
+    cp_birthday    => { type => 'date' },
   ],
 
   primary_key_columns => [ 'cp_id' ],
index ff80d76..f5f014b 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -1008,7 +1008,7 @@ sub all_parts {
   $joins_needed{makemodel}   = 1 if grep { $form->{$_} || $form->{"l_$_"} } @makemodel_filters;
   $joins_needed{mv}          = 1 if $joins_needed{makemodel};
   $joins_needed{cv}          = 1 if $bsooqr;
-  $joins_needed{apoe}        = 1 if $joins_needed{cv}   || grep { $form->{$_} || $form->{"l_$_"} } @apoe_filters;
+  $joins_needed{apoe}        = 1 if $joins_needed{project} || $joins_needed{cv}   || grep { $form->{$_} || $form->{"l_$_"} } @apoe_filters;
   $joins_needed{invoice_oi}  = 1 if $joins_needed{project} || $joins_needed{apoe} || grep { $form->{$_} || $form->{"l_$_"} } @invoice_oi_filters;
 
   # special case for description search.
index 6ed0ddd..3060507 100644 (file)
@@ -296,6 +296,8 @@ $self->{texts} = {
   'Bins saved.'                 => 'Lagerpl&auml;tze gespeichert.',
   'Bins that have been used in the past cannot be deleted anymore. For these bins there\'s no checkbox in the &quot;Delete&quot; column.' => 'Lagerpl&auml;tze, die bereits benutzt wurden, k&ouml;nnen nicht mehr gel&ouml;scht werden. Deswegen fehlt bei ihnen die Checkbox in der Spalte &quot;L&ouml;schen&quot;.',
   'Birthday'                    => 'Geburtstag',
+  'Birthday (after conversion)' => 'Geburtstag (nach Umstellung)',
+  'Birthday (before conversion)' => 'Geburtstag (vor Umstellung)',
   'Bis'                         => 'bis',
   'Bis Konto: '                 => 'bis Konto: ',
   'Block'                       => 'Block',
@@ -446,6 +448,7 @@ $self->{texts} = {
   'Contacts'                    => 'Ansprechpersonen',
   'Continue'                    => 'Weiter',
   'Contra'                      => 'gegen',
+  'Conversion of "birthday" contact person attribute' => 'Umstellung des Kontaktpersonenfeldes "Geburtstag"',
   'Copies'                      => 'Kopien',
   'Correct taxkey'              => 'Richtiger Steuerschlüssel',
   'Corrections'                 => 'Korrekturen',
@@ -562,6 +565,7 @@ $self->{texts} = {
   'Database Administration'     => 'Datenbankadministration',
   'Database Connection Test'    => 'Test der Datenbankverbindung',
   'Database Host'               => 'Datenbankcomputer',
+  'Database ID'                 => 'Datenbank-ID',
   'Database User'               => 'Datenbankbenutzer',
   'Database User missing!'      => 'Datenbankbenutzer fehlt!',
   'Database backups and restorations are disabled in the configuration.' => 'Datenbanksicherungen und -wiederherstellungen sind in der Konfiguration deaktiviert.',
@@ -796,6 +800,8 @@ $self->{texts} = {
   'Enter longdescription'       => 'Langtext eingeben',
   'Enter the abbreviations separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' => 'Geben Sie Ihre und weitere Währungen als Abkürzungen durch Doppelpunkte getrennt ein (z.B. EUR:USD:CAD)',
   'Enter the requested execution date or leave empty for the quickest possible execution:' => 'Geben Sie das jeweils gewünschte Ausführungsdatum an, oder lassen Sie das Feld leer für die schnellstmögliche Ausführung:',
+  'Entries for which automatic conversion failed:' => 'Einträge, für die die automatische Umstellung fehlschlug:',
+  'Entries for which automatic conversion succeeded:' => 'Einträge, für die die automatische Umstellung erfolgreich war:',
   'Equity'                      => 'Passiva',
   'Error'                       => 'Fehler',
   'Error in database control file \'%s\': %s' => 'Fehler in Datenbankupgradekontrolldatei \'%s\': %s',
@@ -1901,6 +1907,7 @@ $self->{texts} = {
   'The connection to the database could not be established.' => 'Die Verbindung zur Datenbank konnte nicht hergestellt werden.',
   'The connection to the template database failed:' => 'Die Verbindung zur Vorlagendatenbank schlug fehl:',
   'The connection was established successfully.' => 'Die Verbindung zur Datenbank wurde erfolgreich hergestellt.',
+  'The contact person attribute "birthday" is converted from a free-form text field into a date field.' => 'Das Kontaktpersonenfeld "Geburtstag" wird von einem freien Textfeld auf ein Datumsfeld umgestellt.',
   'The creation of the authentication database failed:' => 'Das Anlegen der Authentifizierungsdatenbank schlug fehl:',
   'The custom variable has been deleted.' => 'Die benutzerdefinierte Variable wurde gel&ouml;scht.',
   'The custom variable has been saved.' => 'Die benutzerdefinierte Variable wurde gespeichert.',
@@ -2059,6 +2066,7 @@ $self->{texts} = {
   'This option controls the method used for profit determination.' => 'Dieser Parameter legt die Berechnungsmethode für die Gewinnermittlung fest.',
   'This option controls the posting and calculation behavior for the accounting method.' => 'Dieser Parameter steuert die Buchungs- und Berechnungsmethoden für die Versteuerungsart.',
   'This partnumber is not unique. You should change it.' => 'Diese Artikelnummer ist nicht eindeutig. Bitte wählen Sie eine andere.',
+  'This requires you to manually correct entries for which an automatic conversion failed and to check those for which it succeeded.' => 'Dies erfordert, dass Sie diejenigen Einträge manuell korrigieren, für die die automatische Umstellung fehlschlug, sowie dass Sie diejenigen überprüfen, für die die Umstellung erfolgreich war.',
   'This transaction has to be split into several transactions manually.' => 'Diese Buchung muss manuell in mehrere Buchungen aufgeteilt werden.',
   'This update will change the nature the onhand of goods is tracked.' => 'Dieses update &auml;ndert die Art und Weise wie Lagermengen gez&auml;lt werden.',
   'This upgrade script tries to map all existing parts in the database to the newly created Buchungsgruppen.' => 'Dieses Upgradescript versucht, bei allen bestehenden Artikeln neu erstellte Buchungsgruppen zuzuordnen.',
diff --git a/sql/Pg-upgrade2/contacts_convert_cp_birthday_to_date.pl b/sql/Pg-upgrade2/contacts_convert_cp_birthday_to_date.pl
new file mode 100644 (file)
index 0000000..2f10670
--- /dev/null
@@ -0,0 +1,80 @@
+# @tag: contacts_convert_cp_birthday_to_date
+# @description: Umstellung cp_birthday von Freitext auf Datumsfeld
+# @depends: release_2_7_0
+package contacts_convert_cp_birthday_to_date;
+use strict;
+
+die 'This script cannot be run from the command line.' if !$::form;
+
+sub convert_to_date {
+  my ($str) = @_;
+
+  return '' if !$str;
+
+  my $sth = $dbh->prepare('SELECT ?::date AS date') or return undef;
+  $sth->execute($str)                               or return undef;
+
+  return $sth->fetchrow_hashref->{date};
+}
+
+sub update {
+  my @data      = ();
+  my @auto_data = ();
+  my $sql       = <<SQL;
+    SELECT
+      cp_id,
+      cp_givenname,
+      cp_name,
+      cp_birthday AS cp_birthday_old
+    FROM contacts
+    ORDER BY cp_id;
+SQL
+
+  my $sth = $dbh->prepare($sql) or die $dbh->errstr;
+  $sth->execute or die $dbh->errstr;
+
+  my $i = -1;
+  while (my $row = $sth->fetchrow_hashref) {
+    $i++;
+    $row->{cp_birthday} = convert_to_date($::form->{form_submitted} ? $::form->{'cp_birthday_'. $i} : $row->{cp_birthday_old});
+    $row->{row_index}   = $i;
+
+    if ( defined($row->{cp_birthday}) ) {
+       push(@auto_data, $row);
+    } else {
+       push(@data,      $row);
+    }
+  }
+
+  $::form->{data}       = \@data;
+  $::form->{auto_data}  = \@auto_data;
+  $::form->{row_length} = $i;
+
+  if (@data) {
+    print $::form->parse_html_template('dbupgrade/contacts_convert_cp_birthday_to_date_form');
+    return 2;
+  } else {
+    $sql = <<SQL;
+      ALTER TABLE contacts DROP COLUMN cp_birthday;
+      ALTER TABLE contacts ADD COLUMN cp_birthday date;
+SQL
+
+    $dbh->do($sql);
+
+    $sql = <<SQL;
+      UPDATE contacts
+      SET   cp_birthday = ?
+      WHERE cp_id = ?
+SQL
+
+    $sth = $dbh->prepare($sql) or die $dbh->errstr;
+
+    foreach (grep { $_->{cp_birthday} ne '' } @auto_data) {
+      $sth->execute($_->{cp_birthday}, $_->{cp_id}) or die $dbh->errstr;
+    }
+
+    return 1;
+  }
+}
+
+return update();
diff --git a/sql/Pg-upgrade2/finanzamt_update_fa_bufa_nr_hamburg.pl b/sql/Pg-upgrade2/finanzamt_update_fa_bufa_nr_hamburg.pl
new file mode 100644 (file)
index 0000000..d0b14db
--- /dev/null
@@ -0,0 +1,46 @@
+# @tag: finanzamt_update_fa_bufa_nr_hamburg
+# @description: Aktualisiert die fa_bufa_nr für Hamburg
+# @depends: release_2_7_0
+# @charset: utf-8
+package finanzamt_update_fa_bufa_nr_hamburg;
+use utf8;
+use strict;
+
+if ( !$::form ) {
+  die('This script cannot be run from the command line.');
+}
+
+sub query {
+  my ($query) = @_;
+
+  if ( !$dbh->do($query) ) {
+    die($dbup_locale->text('Database update error:') .'<br>'. $query .'<br>'. $DBI::errstr);
+  }
+}
+
+my @data = (
+    ['02', '41'],
+    ['57', '42'],
+    ['71', '43'],
+    ['15', '43'],
+    ['03', '44'],
+    ['54', '45'],
+    ['22', '46'],
+    ['06', '47'],
+    ['74', '48'],
+    ['26', '49'],
+    ['09', '50'],
+    ['08', '51'],
+  );
+
+foreach my $entry (@data) {
+  query('
+    UPDATE finanzamt
+    SET
+      fa_bufa_nr = \'22'. $entry->[1] .'\'
+    WHERE
+          fa_land_nr = \'2\'
+      AND fa_bufa_nr = \'22'. $entry->[0] .'\';');
+}
+
+return 1;
index 6b22e47..2b126c6 100644 (file)
 
      <tr>
       <th align="left" nowrap>[% 'Birthday' | $T8 %]</th>
-      <td><input id="cp_birthday" name="cp_birthday" size="40" value="[% HTML.escape(cp_birthday) %]"></td>
+      <td>
+        [% L.date_tag('cp_birthday', cp_birthday) %]
+      </td>
      </tr>
 
      <tr>
diff --git a/templates/webpages/dbupgrade/contacts_convert_cp_birthday_to_date_form.html b/templates/webpages/dbupgrade/contacts_convert_cp_birthday_to_date_form.html
new file mode 100644 (file)
index 0000000..c613264
--- /dev/null
@@ -0,0 +1,48 @@
+[%- USE HTML %]
+[%- USE L %]
+[%- USE LxERP %]
+
+<h1>[%- LxERP.t8('Conversion of "birthday" contact person attribute') %]</h1>
+
+<p>
+ [%- LxERP.t8('The contact person attribute "birthday" is converted from a free-form text field into a date field.') %]
+ [%- LxERP.t8('This requires you to manually correct entries for which an automatic conversion failed and to check those for which it succeeded.') %]
+</p>
+
+[% BLOCK birthday_table %]
+  <table>
+
+    <tr>
+      <th>[%- LxERP.t8('Database ID') %]</th>
+      <th>[%- LxERP.t8('Name') %]</th>
+      <th>[%- LxERP.t8('Given Name') %]</th>
+      <th>[%- LxERP.t8('Birthday (before conversion)') %]</th>
+      <th>[%- LxERP.t8('Birthday (after conversion)') %]</th>
+    </tr>
+
+    [% FOREACH row IN data %]
+      <tr class="listrow[% loop.count % 2 %]">
+        <input type="hidden" name="cp_id_[% row.row_index %]" value="[% row.cp_id %]">
+
+        <td>[% row.cp_id %]</td>
+        <td>[% row.cp_givenname | html %]</td>
+        <td>[% row.cp_name | html %]</td>
+        <td>[% row.cp_birthday_old | html %]</td>
+        <td>[% L.date_tag('cp_birthday_'_ row.row_index, row.cp_birthday) %]</td>
+      </tr>
+    [% END %]
+
+  </table>
+[% END %]
+
+<form action="[% script %]" method="POST">
+  <h2>[%- LxERP.t8('Entries for which automatic conversion failed:') %]</h2>
+  [% PROCESS birthday_table data = data %]
+
+  <h2>[%- LxERP.t8('Entries for which automatic conversion succeeded:') %]</h2>
+  [% PROCESS birthday_table data = auto_data %]
+
+  <input type="hidden" name="row_length" value="[% row_length %]">
+  <input type="hidden" name="action" value="LoginScreen/login">
+  <input type="submit" name="form_submitted" value="save">
+</form>