1 # @tag: ar_ap_fix_notes_as_html_for_non_invoices
2 # @description: Kreditoren-/Debitorenbuchungen: Bemerkungsfeld darf kein HTML sein
3 # @depends: oe_ar_ap_delivery_orders_edit_notes_as_html
4 package SL::DBUpgrade2::ar_ap_fix_notes_as_html_for_non_invoices;
11 use parent qw(SL::DBUpgrade2::Base);
14 my ($self, $table) = @_;
16 my $sth = $self->dbh->prepare(qq|UPDATE $table SET notes = ? WHERE id = ?|) || $self->dberror;
21 WHERE (notes IS NOT NULL)
22 AND (NOT COALESCE(invoice, FALSE))
26 WHERE tag = 'oe_ar_ap_delivery_orders_edit_notes_as_html'))
29 foreach my $row (selectall_hashref_query($::form, $self->dbh, $query)) {
30 next if !$row->{notes} || (($row->{notes} !~ m{^<[a-z]+>}) && ($row->{notes} !~ m{</[a-z]+>$}));
32 my $new_content = $row->{notes};
33 $new_content =~ s{^<p>|</p>$}{}gi;
34 $new_content =~ s{<br */>}{\n}gi;
35 $new_content =~ s{</p><p>}{\n\n}gi;
36 $new_content = $::locale->unquote_special_chars('html', $new_content);
38 $sth->execute($new_content, $row->{id}) if $new_content ne $row->{notes};
47 $self->fix_column($_) for qw(ar ap);