Revision 3ccf1a99
Von Moritz Bunkus vor mehr als 12 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
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}) {
|
SL/DB/MetaSetup/Contact.pm | ||
---|---|---|
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' ],
|
locale/de/all | ||
---|---|---|
'Bins saved.' => 'Lagerplätze gespeichert.',
|
||
'Bins that have been used in the past cannot be deleted anymore. For these bins there\'s no checkbox in the "Delete" column.' => 'Lagerplätze, die bereits benutzt wurden, können nicht mehr gelöscht werden. Deswegen fehlt bei ihnen die Checkbox in der Spalte "Löschen".',
|
||
'Birthday' => 'Geburtstag',
|
||
'Birthday (after conversion)' => 'Geburtstag (nach Umstellung)',
|
||
'Birthday (before conversion)' => 'Geburtstag (vor Umstellung)',
|
||
'Bis' => 'bis',
|
||
'Bis Konto: ' => 'bis Konto: ',
|
||
'Block' => 'Block',
|
||
... | ... | |
'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',
|
||
... | ... | |
'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.',
|
||
... | ... | |
'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',
|
||
... | ... | |
'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öscht.',
|
||
'The custom variable has been saved.' => 'Die benutzerdefinierte Variable wurde gespeichert.',
|
||
... | ... | |
'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 ändert die Art und Weise wie Lagermengen gezä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.',
|
sql/Pg-upgrade2/contacts_convert_cp_birthday_to_date.pl | ||
---|---|---|
# @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();
|
templates/webpages/ct/_contact.html | ||
---|---|---|
|
||
<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>
|
templates/webpages/dbupgrade/contacts_convert_cp_birthday_to_date_form.html | ||
---|---|---|
[%- 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>
|
Auch abrufbar als: Unified diff
Kontaktpersonenfeld von Freitext auf Datum umstelen
Basierend auf Patch von Thomas Heck <t.heck@linet-services.de> mit
Verfeinerungen von mir.
Implementiert #2021.