commit 99ffc62560eef8183918b2274352280ffc4b24b1
Author: Werner Hahn <wh@futureworldsearch.net>
Date:   Thu Sep 21 12:45:49 2017 +0200

    Shopmodul: check_connectivity in SL::Shop ausgelagert
    Button zum Überprüfen der Verbindung beim Shop edit Form
    Überprüfung bei Fehlkonfigurierten Shops beim Shopbestellungen holen

diff --git a/SL/Controller/Shop.pm b/SL/Controller/Shop.pm
index 4699a9cdc..afc766296 100644
--- a/SL/Controller/Shop.pm
+++ b/SL/Controller/Shop.pm
@@ -65,21 +65,19 @@ sub action_reorder {
   $self->render(\'', { type => 'json' }); # ' emacs happy again
 }
 
-sub check_connectivity {
+sub action_check_connectivity {
   my ($self) = @_;
 
   my $ok = 0;
   require SL::Shop;
   my $shop = SL::Shop->new( config => $self->shop );
-  my $version = $shop->connector->get_version;
-  $ok       = $version->{success};
-
-  if ($ok) {
-    flash_later('ok', t8('The connection to the webshop was successful. Version: #1 -- Revision: #2', $version->{data}->{version}, $version->{data}->{revision}));
-    return $version;
-  } else {
-    return $version;
-  }
+  my $connect = $shop->check_connectivity;
+  $ok       = $connect->{success};
+  my  $version = $connect->{data}->{version};
+  $self->render('shops/test_shop_connection', { layout => 0 },
+                title   => t8('Shop Connection Test'),
+                ok      => $ok,
+                version => $version);
 }
 
 sub check_auth {
@@ -107,11 +105,6 @@ sub create_or_update {
     return;
   }
 
-  my $version = $self->check_connectivity();
-  if ($version) {
-    flash_later('error', t8('The connection to the webshop is not success. Message: #1 -- URL: #2 -- Datatype: #3', $version->{message}, $version->{data}->{version}, $version->{data}->{revision}));
-  }
-
   $self->shop->save;
 
   flash_later('info', $is_new ? t8('The shop has been created.') : t8('The shop has been saved.'));
@@ -168,6 +161,11 @@ sub _setup_form_action_bar {
           submit => [ '#form', { action => "Shop/delete" } ],
         ],
       ],
+      action => [
+        t8('Check Api'),
+        call => [ 'kivi.Shop.check_connectivity', id => "form" ],
+        tooltip => t8('Check connectivity'),
+      ],
       action => [
         t8('Cancel'),
         submit => [ '#form', { action => "Shop/list" } ],
@@ -207,9 +205,9 @@ __END__
 
 =head1 BUGS
 
-  None yet. :)
+None yet. :)
 
 =head1 AUTHOR
 
-  G. Richardson E<lt>information@kivitendo-premium.deE<gt>
-  W. Hahn E<lt>wh@futureworldsearch.netE<gt>
+G. Richardson E<lt>information@kivitendo-premium.deE<gt>
+W. Hahn E<lt>wh@futureworldsearch.netE<gt>
diff --git a/SL/Shop.pm b/SL/Shop.pm
index 3cad0d2cf..22b5667a0 100644
--- a/SL/Shop.pm
+++ b/SL/Shop.pm
@@ -79,6 +79,8 @@ $shop->connector->get_new_orders;
 
 =item C<updatable_parts>
 
+=item C<check_connectivity>
+
 =item C<init_connector>
 
 =back
diff --git a/js/kivi.Shop.js b/js/kivi.Shop.js
new file mode 100644
index 000000000..b2c0a7d34
--- /dev/null
+++ b/js/kivi.Shop.js
@@ -0,0 +1,17 @@
+namespace('kivi.Shop', function(ns) {
+
+ ns.check_connectivity = function() {
+   var dat = $('form').serializeArray();
+    kivi.popup_dialog({
+      url:    'controller.pl?action=Shop/check_connectivity',
+      data:   dat,
+      type:   'POST',
+      id:     'test_shop_connection_window',
+      dialog: { title: kivi.t8('Shop Connection Test') },
+      width: 60,
+      height: 40,
+    });
+    return true;
+  };
+
+});
diff --git a/templates/webpages/shops/test_shop_connection.html b/templates/webpages/shops/test_shop_connection.html
new file mode 100644
index 000000000..d9ff48254
--- /dev/null
+++ b/templates/webpages/shops/test_shop_connection.html
@@ -0,0 +1,20 @@
+[%- USE HTML %][%- USE LxERP -%][%- USE L -%]
+[%- IF ok %]
+
+ <p class="message_ok">[% LxERP.t8('The connection was to the shop established successfully.') %]</p>
+ <p>[% LxERP.t8('Version: ')%][% HTML.escape(version) %]</p>
+
+[%- ELSE %]
+
+ <p class="message_error">
+  [% LxERP.t8('The connection to the shop could not be established.') %]
+  [% LxERP.t8('Error message from the webshop api:') %]
+ </p>
+
+ <p>[% HTML.escape(version) %]</p>
+
+[%- END %]
+
+<div>
+ <a href="#" onclick="$('#test_shop_connection_window').dialog('close');">[% LxERP.t8("Close Window") %]</a>
+</div>
