Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorG. Richardson <information@lx-office-hosting.de>
Wed, 1 Aug 2012 10:03:07 +0000 (12:03 +0200)
committerG. Richardson <information@lx-office-hosting.de>
Wed, 1 Aug 2012 10:03:07 +0000 (12:03 +0200)
SL/BackgroundJob/SelfTest/Base.pm
SL/Controller/CsvImport/CustomerVendor.pm
SL/Controller/CsvImport/Part.pm
SL/DB/MetaSetup/Customer.pm
SL/DB/MetaSetup/Vendor.pm
SL/Helper/Csv.pm
sql/Pg-upgrade2/customer_vendor_phone_no_limits.sql [new file with mode: 0644]
t/helper/csv.t
templates/webpages/ct/form_header.html

index f790137..857de8a 100644 (file)
@@ -1,5 +1,7 @@
 package SL::BackgroundJob::SelfTest::Base;
 
+use strict;
+
 use Test::Builder;
 
 use parent qw(Rose::Object);
index c0d9ca2..02d8483 100644 (file)
@@ -182,7 +182,6 @@ sub field_lengths {
            city           => 75,
            country        => 75,
            contact        => 75,
-           phone          => 30,
            fax            => 30,
            account_number => 15,
            bank_code      => 10,
index d707aaa..3be6f2a 100644 (file)
@@ -194,7 +194,10 @@ sub check_existing {
 
   my $object = $entry->{object};
 
-  $entry->{part} = $self->parts_by->{partnumber}->{ $object->type }->{ $object->partnumber };
+  $entry->{part} = SL::DB::Manager::Part->find_by(
+    SL::DB::Manager::Part->type_filter($object->type),
+    ( partnumber => $object->partnumber )                 x!! $object->partnumber,
+  );
 
   if ($self->settings->{article_number_policy} eq 'update_prices') {
     if ($entry->{part}) {
index 8735268..722ff9d 100644 (file)
@@ -19,7 +19,7 @@ __PACKAGE__->meta->setup(
     city           => { type => 'varchar', length => 75 },
     country        => { type => 'varchar', length => 75 },
     contact        => { type => 'text' },
-    phone          => { type => 'varchar', length => 30 },
+    phone          => { type => 'text' },
     fax            => { type => 'varchar', length => 30 },
     homepage       => { type => 'text' },
     email          => { type => 'text' },
index 6511ea2..387b2d8 100644 (file)
@@ -19,7 +19,7 @@ __PACKAGE__->meta->setup(
     city           => { type => 'varchar', length => 75 },
     country        => { type => 'varchar', length => 75 },
     contact        => { type => 'varchar', length => 75 },
-    phone          => { type => 'varchar', length => 30 },
+    phone          => { type => 'text' },
     fax            => { type => 'varchar', length => 30 },
     homepage       => { type => 'text' },
     email          => { type => 'text' },
index 3132b28..5b629ee 100644 (file)
@@ -111,6 +111,14 @@ sub _check_header {
     ]) unless $header;
   }
 
+  # Special case: utf8 BOM.
+  # certain software (namely MS Office and notepad.exe insist on prefixing
+  # data with a discouraged but valid byte order mark
+  # if not removed, the first header field will not be recognized
+  if ($header && $header->[0] && $self->encoding =~ /utf-?8/i) {
+    $header->[0] =~ s/^\x{FEFF}//;
+  }
+
   return unless $header;
   return $self->header([ map { lc } @$header ]);
 }
diff --git a/sql/Pg-upgrade2/customer_vendor_phone_no_limits.sql b/sql/Pg-upgrade2/customer_vendor_phone_no_limits.sql
new file mode 100644 (file)
index 0000000..30998ea
--- /dev/null
@@ -0,0 +1,7 @@
+-- @tag: customer_vendor_phone_no_limits
+-- @description: Keine Längenbeschränkung für Spalte phone in den Tabellen customer und vendor.
+-- @depends: release_2_7_0
+-- @charset: utf-8
+
+ALTER TABLE customer ALTER COLUMN phone TYPE text;
+ALTER TABLE vendor   ALTER COLUMN phone TYPE text;
index 4e7ef12..63fc858 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 40;
+use Test::More tests => 41;
 
 use lib 't';
 
@@ -285,11 +285,21 @@ is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'case insensitive hea
 #####
 
 $csv = SL::Helper::Csv->new(
-  file   => \"Kaffee",
-  header => [ 'Description' ],
-  class  => 'SL::DB::Part',
+file   => \"Kaffee",
+header => [ 'Description' ],
+class  => 'SL::DB::Part',
 );
 $csv->parse;
 is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'case insensitive header as param works';
 
+#####
+
+$csv = SL::Helper::Csv->new(
+  file   => \"\x{FEFF}description\nKaffee",
+  class  => 'SL::DB::Part',
+  encoding => 'utf8',
+);
+$csv->parse;
+is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'utf8 BOM works (bug 1872)';
+
 # vim: ft=perl
index 8263d87..bdf22df 100644 (file)
 
      <tr>
       <th align="right" nowrap>[% 'Phone' | $T8 %]</th>
-      <td><input name="phone" size="30" maxlength="30" value="[% HTML.escape(phone) %]"></td>
+      <td><input name="phone" size="30" value="[% HTML.escape(phone) %]"></td>
      </tr>
 
      <tr>