Revision 99ffc625
Von Werner Hahn vor mehr als 7 Jahren hinzugefügt
SL/Controller/Shop.pm | ||
---|---|---|
65 | 65 |
$self->render(\'', { type => 'json' }); # ' emacs happy again |
66 | 66 |
} |
67 | 67 |
|
68 |
sub check_connectivity { |
|
68 |
sub action_check_connectivity {
|
|
69 | 69 |
my ($self) = @_; |
70 | 70 |
|
71 | 71 |
my $ok = 0; |
72 | 72 |
require SL::Shop; |
73 | 73 |
my $shop = SL::Shop->new( config => $self->shop ); |
74 |
my $version = $shop->connector->get_version; |
|
75 |
$ok = $version->{success}; |
|
76 |
|
|
77 |
if ($ok) { |
|
78 |
flash_later('ok', t8('The connection to the webshop was successful. Version: #1 -- Revision: #2', $version->{data}->{version}, $version->{data}->{revision})); |
|
79 |
return $version; |
|
80 |
} else { |
|
81 |
return $version; |
|
82 |
} |
|
74 |
my $connect = $shop->check_connectivity; |
|
75 |
$ok = $connect->{success}; |
|
76 |
my $version = $connect->{data}->{version}; |
|
77 |
$self->render('shops/test_shop_connection', { layout => 0 }, |
|
78 |
title => t8('Shop Connection Test'), |
|
79 |
ok => $ok, |
|
80 |
version => $version); |
|
83 | 81 |
} |
84 | 82 |
|
85 | 83 |
sub check_auth { |
... | ... | |
107 | 105 |
return; |
108 | 106 |
} |
109 | 107 |
|
110 |
my $version = $self->check_connectivity(); |
|
111 |
if ($version) { |
|
112 |
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})); |
|
113 |
} |
|
114 |
|
|
115 | 108 |
$self->shop->save; |
116 | 109 |
|
117 | 110 |
flash_later('info', $is_new ? t8('The shop has been created.') : t8('The shop has been saved.')); |
... | ... | |
168 | 161 |
submit => [ '#form', { action => "Shop/delete" } ], |
169 | 162 |
], |
170 | 163 |
], |
164 |
action => [ |
|
165 |
t8('Check Api'), |
|
166 |
call => [ 'kivi.Shop.check_connectivity', id => "form" ], |
|
167 |
tooltip => t8('Check connectivity'), |
|
168 |
], |
|
171 | 169 |
action => [ |
172 | 170 |
t8('Cancel'), |
173 | 171 |
submit => [ '#form', { action => "Shop/list" } ], |
... | ... | |
207 | 205 |
|
208 | 206 |
=head1 BUGS |
209 | 207 |
|
210 |
None yet. :)
|
|
208 |
None yet. :) |
|
211 | 209 |
|
212 | 210 |
=head1 AUTHOR |
213 | 211 |
|
214 |
G. Richardson E<lt>information@kivitendo-premium.deE<gt> |
|
215 |
W. Hahn E<lt>wh@futureworldsearch.netE<gt> |
|
212 |
G. Richardson E<lt>information@kivitendo-premium.deE<gt> |
|
213 |
W. Hahn E<lt>wh@futureworldsearch.netE<gt> |
SL/Shop.pm | ||
---|---|---|
79 | 79 |
|
80 | 80 |
=item C<updatable_parts> |
81 | 81 |
|
82 |
=item C<check_connectivity> |
|
83 |
|
|
82 | 84 |
=item C<init_connector> |
83 | 85 |
|
84 | 86 |
=back |
js/kivi.Shop.js | ||
---|---|---|
1 |
namespace('kivi.Shop', function(ns) { |
|
2 |
|
|
3 |
ns.check_connectivity = function() { |
|
4 |
var dat = $('form').serializeArray(); |
|
5 |
kivi.popup_dialog({ |
|
6 |
url: 'controller.pl?action=Shop/check_connectivity', |
|
7 |
data: dat, |
|
8 |
type: 'POST', |
|
9 |
id: 'test_shop_connection_window', |
|
10 |
dialog: { title: kivi.t8('Shop Connection Test') }, |
|
11 |
width: 60, |
|
12 |
height: 40, |
|
13 |
}); |
|
14 |
return true; |
|
15 |
}; |
|
16 |
|
|
17 |
}); |
templates/webpages/shops/test_shop_connection.html | ||
---|---|---|
1 |
[%- USE HTML %][%- USE LxERP -%][%- USE L -%] |
|
2 |
[%- IF ok %] |
|
3 |
|
|
4 |
<p class="message_ok">[% LxERP.t8('The connection was to the shop established successfully.') %]</p> |
|
5 |
<p>[% LxERP.t8('Version: ')%][% HTML.escape(version) %]</p> |
|
6 |
|
|
7 |
[%- ELSE %] |
|
8 |
|
|
9 |
<p class="message_error"> |
|
10 |
[% LxERP.t8('The connection to the shop could not be established.') %] |
|
11 |
[% LxERP.t8('Error message from the webshop api:') %] |
|
12 |
</p> |
|
13 |
|
|
14 |
<p>[% HTML.escape(version) %]</p> |
|
15 |
|
|
16 |
[%- END %] |
|
17 |
|
|
18 |
<div> |
|
19 |
<a href="#" onclick="$('#test_shop_connection_window').dialog('close');">[% LxERP.t8("Close Window") %]</a> |
|
20 |
</div> |
Auch abrufbar als: Unified diff
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