Einkauf/Verkauf: Bemerkungsfeld mit HTML-Editor ausgestattet
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 21 Jan 2015 15:22:49 +0000 (16:22 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 5 Mar 2015 10:44:30 +0000 (11:44 +0100)
14 files changed:
SL/DB/DeliveryOrder.pm
SL/DB/Invoice.pm
SL/DB/Order.pm
SL/DB/PurchaseInvoice.pm
SL/DO.pm
SL/IR.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/io.pl
bin/mozilla/oe.pl
sql/Pg-upgrade2/oe_ar_ap_delivery_orders_edit_notes_as_html.pl [new file with mode: 0644]
templates/webpages/do/form_footer.html
templates/webpages/ir/form_footer.html
templates/webpages/is/form_footer.html

index c99d2fd..b530db7 100644 (file)
@@ -8,6 +8,7 @@ use Rose::DB::Object::Helpers ();
 
 use SL::DB::MetaSetup::DeliveryOrder;
 use SL::DB::Manager::DeliveryOrder;
+use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::FlattenToForm;
 use SL::DB::Helper::LinkedRecords;
 use SL::DB::Helper::TransNumberGenerator;
@@ -29,6 +30,8 @@ __PACKAGE__->meta->add_relationship(orderitems => { type         => 'one to many
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->attr_html('notes');
+
 __PACKAGE__->before_save('_before_save_set_donumber');
 
 # hooks
index a64ef2f..3e6c65a 100644 (file)
@@ -12,6 +12,7 @@ use Rose::DB::Object::Helpers ();
 
 use SL::DB::MetaSetup::Invoice;
 use SL::DB::Manager::Invoice;
+use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::FlattenToForm;
 use SL::DB::Helper::LinkedRecords;
 use SL::DB::Helper::PriceTaxCalculator;
@@ -58,6 +59,8 @@ __PACKAGE__->meta->add_relationship(
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->attr_html('notes');
+
 __PACKAGE__->before_save('_before_save_set_invnumber');
 
 # hooks
index 28b1b57..48e2be6 100644 (file)
@@ -9,6 +9,7 @@ use List::Util qw(max);
 
 use SL::DB::MetaSetup::Order;
 use SL::DB::Manager::Order;
+use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::FlattenToForm;
 use SL::DB::Helper::LinkedRecords;
 use SL::DB::Helper::PriceTaxCalculator;
@@ -41,6 +42,8 @@ __PACKAGE__->meta->add_relationship(
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->attr_html('notes');
+
 __PACKAGE__->before_save('_before_save_set_ord_quo_number');
 
 # hooks
index d5955c5..19808eb 100644 (file)
@@ -6,6 +6,7 @@ use Carp;
 
 use SL::DB::MetaSetup::PurchaseInvoice;
 use SL::DB::Manager::PurchaseInvoice;
+use SL::DB::Helper::AttrHTML;
 use SL::DB::Helper::LinkedRecords;
 use SL::Locale::String qw(t8);
 
@@ -42,6 +43,8 @@ __PACKAGE__->meta->add_relationship(
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->attr_html('notes');
+
 sub items { goto &invoiceitems; }
 sub add_items { goto &add_invoiceitems; }
 
index 5adccd5..17876e5 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -451,7 +451,7 @@ SQL
              $form->{cusordnumber}, conv_date($form->{transdate}),
              conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
              conv_date($form->{reqdate}), $form->{shippingpoint}, $form->{shipvia},
-             $form->{notes}, $form->{intnotes},
+             $restricter->process($form->{notes}), $form->{intnotes},
              $form->{closed} ? 't' : 'f', $form->{delivered} ? "t" : "f",
              conv_i($form->{department_id}), conv_i($form->{language_id}), conv_i($form->{shipto_id}),
              conv_i($form->{globalproject_id}), conv_i($form->{employee_id}),
index a87fca3..6cd5556 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -722,7 +722,7 @@ SQL
                 $form->{invnumber},          $form->{ordnumber},           $form->{quonumber},      conv_date($form->{invdate}),
       conv_date($form->{orddate}), conv_date($form->{quodate}),     conv_i($form->{vendor_id}),               $amount,
                 $netamount,                  $form->{paid},      conv_date($form->{duedate}),
-            '1',                             $taxzone_id,                  $form->{notes},          $form->{taxincluded} ? 't' : 'f',
+            '1',                             $taxzone_id, $restricter->process($form->{notes}),               $form->{taxincluded} ? 't' : 'f',
                 $form->{intnotes},           conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
          conv_i($form->{cp_id}),      conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{delivery_term_id}),
          conv_i($form->{globalproject_id}),
index 43303e8..989330c 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1171,7 +1171,7 @@ SQL
              conv_date($form->{"invdate"}),  conv_date($form->{"orddate"}),    conv_date($form->{"quodate"}),    conv_i($form->{"customer_id"}),
                        $amount,                        $netamount,                       $form->{"paid"},
              conv_date($form->{"duedate"}),  conv_date($form->{"deliverydate"}),    '1',                                $form->{"shippingpoint"},
-                       $form->{"shipvia"},      conv_i($form->{"terms"}),                $form->{"notes"},              $form->{"intnotes"},
+                       $form->{"shipvia"},      conv_i($form->{"terms"}), $restricter->process($form->{"notes"}),       $form->{"intnotes"},
                        $form->{"currency"},     conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}),        $form->{"taxincluded"} ? 't' : 'f',
                        $form->{"type"},         conv_i($form->{"language_id"}),   conv_i($form->{"taxzone_id"}), conv_i($form->{"shipto_id"}),
                 conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}),   conv_i($form->{storno_id}),           $form->{"storno"} ? 't' : 'f',
index 870673a..061cd27 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -634,7 +634,7 @@ SQL
              conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
              $amount, $netamount, conv_date($reqdate),
              $form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
-             $form->{shipvia}, $form->{notes}, $form->{intnotes},
+             $form->{shipvia}, $restricter->process($form->{notes}), $form->{intnotes},
              $form->{currency}, $form->{closed} ? 't' : 'f',
              $form->{delivered} ? "t" : "f", $form->{proforma} ? 't' : 'f',
              $quotation, conv_i($form->{department_id}),
index 3028324..1acd6a0 100644 (file)
@@ -1351,6 +1351,7 @@ sub print_form {
     $form->{TEMPLATE_DRIVER_OPTIONS}->{variable_content_types} = {
       longdescription => 'html',
       partnotes       => 'html',
+      notes           => 'html',
     };
   }
 
index 8e47d51..4483deb 100644 (file)
@@ -510,11 +510,9 @@ sub form_footer {
 
   $form->{invtotal} = $form->{invsubtotal};
 
-  my $rows    = max 2, $form->numtextrows($form->{notes}, 25, 8);
-  my $introws = max 2, $form->numtextrows($form->{intnotes}, 35, 8);
-  $rows    = max $rows, $introws;
+  my $introws = max 5, $form->numtextrows($form->{intnotes}, 35, 8);
 
-  $TMPL_VAR{notes}    = qq|<textarea name=notes rows="$rows" cols="25">| . H($form->{notes}) . qq|</textarea>|;
+  $TMPL_VAR{notes}    = qq|<textarea name="notes" class="texteditor" wrap="soft" style="width: 350px; height: 150px">| . H($form->{notes}) . qq|</textarea>|;
   $TMPL_VAR{intnotes} = qq|<textarea name=intnotes rows="$introws" cols="35">| . H($form->{intnotes}) . qq|</textarea>|;
 
   if( $form->{customer_id} && !$form->{taxincluded_changed_by_user} ) {
diff --git a/sql/Pg-upgrade2/oe_ar_ap_delivery_orders_edit_notes_as_html.pl b/sql/Pg-upgrade2/oe_ar_ap_delivery_orders_edit_notes_as_html.pl
new file mode 100644 (file)
index 0000000..2be82f1
--- /dev/null
@@ -0,0 +1,41 @@
+# @tag: oe_ar_ap_delivery_orders_edit_notes_as_html
+# @description: Einkaufs- und Verkaufsbelege: Bemerkungsfeld in HTML umwandeln
+# @depends: requirement_spec_edit_html
+package SL::DBUpgrade2::oe_ar_ap_delivery_orders_edit_notes_as_html;
+
+use strict;
+use utf8;
+
+use SL::DBUtils;
+
+use parent qw(SL::DBUpgrade2::Base);
+
+sub convert_column {
+  my ($self, $table, $column) = @_;
+
+  my $sth = $self->dbh->prepare(qq|UPDATE $table SET $column = ? WHERE id = ?|) || $self->dberror;
+
+  foreach my $row (selectall_hashref_query($::form, $self->dbh, qq|SELECT id, $column FROM $table WHERE $column IS NOT NULL|)) {
+    next if !$row->{$column} || (($row->{$column} =~ m{^<[a-z]+>}) && ($row->{$column} =~ m{</[a-z]+>$}));
+
+    my $new_content = "" . $::request->presenter->escape($row->{$column});
+    $new_content    =~ s{\r}{}g;
+    $new_content    =~ s{\n\n+}{</p><p>}g;
+    $new_content    =~ s{\n}{<br />}g;
+    $new_content    =  "<p>${new_content}</p>" if $new_content;
+
+    $sth->execute($new_content, $row->{id}) if $new_content ne $row->{$column};
+  }
+
+  $sth->finish;
+}
+
+sub run {
+  my ($self) = @_;
+
+  $self->convert_column($_, 'notes') for qw(oe delivery_orders ar ap);
+
+  return 1;
+}
+
+1;
index 7f6c9bd..6c8e0c6 100644 (file)
@@ -1,5 +1,5 @@
 [%- USE T8 %]
-[% USE HTML %][% USE LxERP %][%- USE L -%]
+[% USE HTML %][% USE LxERP %][%- USE L -%][%- USE P -%]
  [%- IF delivered %]
  [%- SET RO = ' readonly' %]
  [%- END %]
        </tr>
 
        <tr valign="top">
-        <td><textarea name="notes" rows="[% LxERP.numtextrows(notes, 25, 8, 2) %]" cols="25" wrap="soft"[% RO %]>[% HTML.escape(notes) %]</textarea></td>
+        <td>
+         [% IF delivered %]
+          [% L.hidden_tag("notes", notes) %]
+         <div style="width: 350px; height: 150px; border: 1px solid black">[% P.restricted_html(notes) %]</div>
+         [% ELSE %]
+          [% L.textarea_tag("notes", notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
+         [% END %]
+        </td>
         <td><textarea name="intnotes" rows="[% LxERP.numtextrows(intnotes, 35, 8, 2) %]" cols="35" wrap="soft"[% RO %]>[% HTML.escape(intnotes) %]</textarea></td>
        </tr>
 
index 9976715..08fb4cb 100644 (file)
@@ -15,7 +15,7 @@
         </tr>
         <tr valign="top">
          <td>
-          <textarea name="notes" rows="[% rows %]" cols="26" wrap="soft">[% notes %]</textarea>
+          [% L.textarea_tag("notes", notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
          </td>
          <td>
           <textarea name="intnotes" rows="[% rows %]" cols="35" wrap="soft">[% intnotes %]</textarea>
index bc69dfd..e3775c8 100644 (file)
@@ -15,7 +15,7 @@
         </tr>
         <tr valign="top">
          <td>
-          <textarea name="notes" rows="[% rows %]" cols="26">[% notes %]</textarea>
+          [% L.textarea_tag("notes", notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
          </td>
          <td>
           <textarea name="intnotes" rows="[% rows %]" cols="35">[% intnotes %]</textarea>