Revision fa6816bc
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/Controller/ShopPart.pm | ||
---|---|---|
26 | 26 |
$self->render_shop_part_edit_dialog(); |
27 | 27 |
}; |
28 | 28 |
|
29 |
sub action_update_shop { |
|
30 |
my ($self, %params) = @_; |
|
31 |
|
|
32 |
my $shop_part = SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id}); |
|
33 |
die unless $shop_part; |
|
34 |
require SL::Shop; |
|
35 |
my $shop = SL::Shop->new( config => $shop_part->shop ); |
|
36 |
|
|
37 |
# TODO: generate data to upload to shop |
|
38 |
my $part_hash = $shop_part->part->as_tree; |
|
39 |
my $json = SL::JSON::to_json($part_hash); |
|
40 |
my $return = $shop->connector->update_part($self->shop_part, $json); |
|
41 |
|
|
42 |
# the connector deals with parsing/result verification, just needs to return success or failure |
|
43 |
if ( $return == 1 ) { |
|
44 |
# TODO: write update time to DB |
|
45 |
my $now = DateTime->now; |
|
46 |
$self->js->html('#shop_part_last_update_' . $shop_part->id, $now->to_kivitendo('precision' => 'minute')) |
|
47 |
->flash('info', t8("Updated part [#1] in shop [#2] at #3", $shop_part->part->displayable_name, $shop_part->shop->description, $now->to_kivitendo('precision' => 'minute') ) ) |
|
48 |
->render; |
|
49 |
} else { |
|
50 |
$self->js->flash('error', t8('The shop part wasn\'t updated.'))->render; |
|
51 |
}; |
|
52 |
|
|
53 |
}; |
|
54 |
|
|
55 |
|
|
29 | 56 |
|
30 | 57 |
# old: |
31 | 58 |
# sub action_edit { |
... | ... | |
79 | 106 |
$self->js->render; |
80 | 107 |
} |
81 | 108 |
|
82 |
|
|
83 | 109 |
# |
84 | 110 |
# internal stuff |
85 | 111 |
# |
... | ... | |
103 | 129 |
|
104 | 130 |
1; |
105 | 131 |
|
132 |
=pod |
|
133 |
|
|
134 |
=encoding utf-8 |
|
135 |
|
|
136 |
=head1 NAME |
|
137 |
|
|
138 |
SL::Controller::ShopPart - Controller for managing ShopParts |
|
139 |
|
|
140 |
=head1 SYNOPSIS |
|
141 |
|
|
142 |
ShopParts are configured in a tab of the corresponding part. |
|
143 |
|
|
144 |
=head1 FUNCTIONS |
|
145 |
|
|
146 |
=over 4 |
|
147 |
|
|
148 |
=item C<action_update_shop> |
|
149 |
|
|
150 |
To be called from the "Update" button, for manually syncing a part with its |
|
151 |
shop. Generates a Calls some ClientJS functions to modifiy original page. |
|
152 |
|
|
153 |
=back |
|
154 |
|
|
155 |
=head1 AUTHORS |
|
156 |
|
|
157 |
G. Richardson E<lt>information@kivitendo-premium.deE<gt> |
|
158 |
|
|
159 |
=cut |
templates/webpages/ic/tabs/_shop.html | ||
---|---|---|
10 | 10 |
<th>[% LxERP.t8("Shop part") %]</th> |
11 | 11 |
<th>[% LxERP.t8("Last update") %]</th> |
12 | 12 |
<th>[% LxERP.t8("Action") %]</th> |
13 |
<th>[% LxERP.t8("Action") %]</th> |
|
13 | 14 |
</tr> |
14 | 15 |
</thead> |
15 | 16 |
[%- FOREACH shop_part = SHOP_PARTS %] |
... | ... | |
17 | 18 |
<td>[% HTML.escape( shop_part.shop.description ) %]</td> |
18 | 19 |
<td>[% L.html_tag('span', shop_part.active, id => 'shop_part_active_' _ shop_part.id ) %]</td> |
19 | 20 |
<td>[% L.html_tag('span', shop_part.shop_description, id => 'shop_part_description_' _ shop_part.id ) %]</td> |
20 |
<td>[% HTML.escape( shop_part.last_update.to_kivitendo('precision' => 'minute') ) %]</td>
|
|
21 |
<td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td>
|
|
21 | 22 |
<td>[% L.button_tag("kivi.shop_part.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit")) %]</td> |
23 |
<td>[% L.button_tag("kivi.shop_part.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Update")) %]</td> |
|
22 | 24 |
</tr> |
23 | 25 |
[%- END %] |
24 | 26 |
[%- FOREACH shop = SHOPS_NOT_ASSIGNED %] |
... | ... | |
28 | 30 |
<td></td> |
29 | 31 |
<td></td> |
30 | 32 |
<td>[% L.button_tag("kivi.shop_part.create_shop_part(" _ id _ ", " _ shop.id _ ")", LxERP.t8("Add")) %]</td> |
33 |
<td></td> |
|
31 | 34 |
</tr> |
32 | 35 |
[%- END %] |
33 | 36 |
</table> |
Auch abrufbar als: Unified diff
ShopPart - In Artikel Reiter ShopSync ausführen
neuer Knopf "erneuern", wenn erfolgreich wird die "Last update" Spalte
aktualisiert