Revision 237d9e65
Von Werner Hahn vor mehr als 8 Jahren hinzugefügt
SL/Controller/ShopPart.pm | ||
---|---|---|
7 | 7 |
use Data::Dumper; |
8 | 8 |
use SL::Locale::String qw(t8); |
9 | 9 |
use SL::DB::ShopPart; |
10 |
use SL::DB::Default; |
|
10 | 11 |
use SL::Helper::Flash; |
11 | 12 |
|
12 | 13 |
use Rose::Object::MakeMethods::Generic |
... | ... | |
56 | 57 |
my ($self) = @_; |
57 | 58 |
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form); |
58 | 59 |
require SL::DB::File; |
59 |
my $images = SL::DB::Manager::File->get_all( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ] );
|
|
60 |
my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' );
|
|
60 | 61 |
$main::lxdebug->dump(0, 'WH: ',\$images); |
61 | 62 |
#my $html = $self->render('shop_part/_list_images', { output => 0 }, IMAGES => $images); |
62 | 63 |
$self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images); |
... | ... | |
70 | 71 |
|
71 | 72 |
} |
72 | 73 |
|
74 |
sub action_get_categories { |
|
75 |
my ($self) = @_; |
|
76 |
|
|
77 |
my $shop_part = SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id}); |
|
78 |
die unless $shop_part; |
|
79 |
require SL::Shop; |
|
80 |
my $shop = SL::Shop->new( config => $shop_part->shop ); |
|
81 |
my $categories = $shop->connector->get_categories; |
|
82 |
$main::lxdebug->dump(0, 'WH: GET',\$categories); |
|
83 |
|
|
84 |
$self->js |
|
85 |
->run( |
|
86 |
'kivi.shop_part.shop_part_dialog', |
|
87 |
t8('Shopcategories'), |
|
88 |
$self->render('shop_part/categories', { output => 0 }, CATEGORIES => $categories ) #, shop_part => $self->shop_part) |
|
89 |
) |
|
90 |
->reinit_widgets; |
|
73 | 91 |
|
92 |
$self->js->render; |
|
93 |
} |
|
74 | 94 |
|
75 | 95 |
# old: |
76 | 96 |
# sub action_edit { |
... | ... | |
124 | 144 |
$self->js->render; |
125 | 145 |
} |
126 | 146 |
|
147 |
sub render_shop_categories_edit_dialog { |
|
148 |
my ($self) = @_; |
|
149 |
|
|
150 |
# when self->shop_part is called in template, it will be an existing shop_part with id, |
|
151 |
# or a new shop_part with only part_id and shop_id set |
|
152 |
$self->js |
|
153 |
->run( |
|
154 |
'kivi.shop_part.shop_part_dialog', |
|
155 |
t8('Shopcategories'), |
|
156 |
$self->render('shop_part/categories', { output => 0 }) #, shop_part => $self->shop_part) |
|
157 |
) |
|
158 |
->reinit_widgets; |
|
159 |
|
|
160 |
$self->js->render; |
|
161 |
} |
|
162 |
sub action_reorder { |
|
163 |
my ($self) = @_; |
|
164 |
$main::lxdebug->message(0, "WH:REORDER "); |
|
165 |
require SL::DB::File; |
|
166 |
SL::DB::File->reorder_list(@{ $::form->{image_id} || [] }); |
|
167 |
$main::lxdebug->message(0, "WH:REORDER II "); |
|
168 |
|
|
169 |
$self->render(\'', { type => 'json' }); |
|
170 |
} |
|
171 |
|
|
127 | 172 |
# |
128 | 173 |
# internal stuff |
129 | 174 |
# |
SL/DB/Manager/File.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use parent qw(SL::DB::Helper::Manager); |
9 |
use SL::DB::Helper::Sorted; |
|
9 | 10 |
|
10 | 11 |
sub object_class { 'SL::DB::File' } |
11 | 12 |
|
SL/DB/ShopPart.pm | ||
---|---|---|
3 | 3 |
|
4 | 4 |
package SL::DB::ShopPart; |
5 | 5 |
|
6 |
use SL::DB::Helper::AttrHTML; |
|
7 | 6 |
use strict; |
8 | 7 |
|
9 | 8 |
use SL::DB::MetaSetup::ShopPart; |
10 | 9 |
use SL::DB::Manager::ShopPart; |
10 |
use SL::DB::Helper::AttrHTML; |
|
11 |
use SL::DB::Helper::ActsAsList; |
|
11 | 12 |
|
12 | 13 |
__PACKAGE__->meta->initialize; |
13 | 14 |
__PACKAGE__->attr_html('shop_description'); |
SL/ShopConnector/Base.pm | ||
---|---|---|
13 | 13 |
|
14 | 14 |
sub update_part { die 'update_part needs to be implemented' } |
15 | 15 |
|
16 |
sub get_categories { die 'get_order needs to be implemented' } |
|
16 | 17 |
1; |
17 | 18 |
|
18 | 19 |
__END__ |
SL/ShopConnector/Shopware.pm | ||
---|---|---|
20 | 20 |
my ($self, $id) = @_; |
21 | 21 |
|
22 | 22 |
my $url = $self->url; |
23 |
#TODO Letzte Bestellnummer und Anzahl der abzuholenden Bestellungen muss noch in die Shopconfig |
|
23 | 24 |
my $ordnumber = 63641; |
24 |
# Muss noch angepasst werden |
|
25 |
#TODO Muss noch angepasst werden
|
|
25 | 26 |
for(my $i=1;$i<=350;$i++) { |
26 |
my $data = $self->connector->get("http://$url/api/orders/$ordnumber?useNumberAsId=true"); |
|
27 |
my $data = $self->connector->get("https://$url/api/orders/$ordnumber?useNumberAsId=true");
|
|
27 | 28 |
$ordnumber++; |
28 | 29 |
$::lxdebug->dump(0, "WH: DATA ", \$data); |
29 | 30 |
my $data_json = $data->content; |
30 | 31 |
my $import = SL::JSON::decode_json($data_json); |
31 | 32 |
$::lxdebug->dump(0, "WH: IMPORT ", \$import); |
33 |
# Mapping to table shoporders |
|
32 | 34 |
my %columns = ( |
33 | 35 |
amount => $import->{data}->{invoiceAmount}, |
34 | 36 |
billing_city => $import->{data}->{billing}->{city}, |
... | ... | |
147 | 149 |
# return $import; |
148 | 150 |
}; |
149 | 151 |
|
152 |
sub get_categories { |
|
153 |
my ($self) = @_; |
|
154 |
|
|
155 |
my $url = $self->url; |
|
156 |
|
|
157 |
my $data = $self->connector->get("http://$url/api/categories"); |
|
158 |
my $data_json = $data->content; |
|
159 |
my $import = SL::JSON::decode_json($data_json); |
|
160 |
my @daten = @{$import->{data}}; |
|
161 |
my %categories = map { ($_->{id} => $_) } @daten; |
|
162 |
|
|
163 |
for(@daten) { |
|
164 |
my $parent = $categories{$_->{parentId}}; |
|
165 |
$parent->{children} ||= []; |
|
166 |
push @{$parent->{children}},$_; |
|
167 |
} |
|
168 |
|
|
169 |
return \@daten; |
|
170 |
} |
|
171 |
|
|
172 |
sub get_article { |
|
173 |
} |
|
174 |
|
|
175 |
sub get_articles { |
|
176 |
} |
|
177 |
|
|
178 |
sub set_article { |
|
179 |
} |
|
180 |
|
|
150 | 181 |
sub init_url { |
151 | 182 |
my ($self) = @_; |
152 | 183 |
# TODO: validate url and port |
js/kivi.shop_part.js | ||
---|---|---|
1 | 1 |
namespace('kivi.shop_part', function(ns) { |
2 | 2 |
var $dialog; |
3 | 3 |
|
4 |
// this is called by sub render, with a certain prerendered html (edit.html) |
|
4 |
// this is called by sub render, with a certain prerendered html (edit.html,categories.html)
|
|
5 | 5 |
ns.shop_part_dialog = function(title, html) { |
6 | 6 |
var id = 'jqueryui_popup_dialog'; |
7 | 7 |
var dialog_params = { |
... | ... | |
28 | 28 |
$dialog.dialog("close"); |
29 | 29 |
} |
30 | 30 |
|
31 |
|
|
32 |
// save existing shop_part_id with new params from form, calls create_or_update and saves to db
|
|
33 |
ns.save_shop_part = function(shop_part_id) {
|
|
34 |
var form = $('form').serializeArray();
|
|
35 |
form.push( { name: 'action', value: 'ShopPart/update' }
|
|
36 |
, { name: 'shop_part_id', value: shop_part_id }
|
|
37 |
);
|
|
38 |
|
|
39 |
$.post('controller.pl', form, function(data) {
|
|
40 |
kivi.eval_json_result(data);
|
|
41 |
});
|
|
42 |
}
|
|
43 |
|
|
44 |
// add part to a shop
|
|
45 |
ns.add_shop_part = function(part_id,shop_id) {
|
|
46 |
var form = $('form').serializeArray();
|
|
47 |
form.push( { name: 'action', value: 'ShopPart/update' }
|
|
48 |
);
|
|
49 |
|
|
50 |
$.post('controller.pl', form, function(data) {
|
|
51 |
kivi.eval_json_result(data);
|
|
52 |
});
|
|
53 |
}
|
|
31 |
|
|
32 |
// save existing shop_part_id with new params from form, calls create_or_update and saves to db |
|
33 |
ns.save_shop_part = function(shop_part_id) { |
|
34 |
var form = $('form').serializeArray(); |
|
35 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
36 |
, { name: 'shop_part_id', value: shop_part_id } |
|
37 |
); |
|
38 |
|
|
39 |
$.post('controller.pl', form, function(data) { |
|
40 |
kivi.eval_json_result(data); |
|
41 |
}); |
|
42 |
} |
|
43 |
|
|
44 |
// add part to a shop |
|
45 |
ns.add_shop_part = function(part_id,shop_id) { |
|
46 |
var form = $('form').serializeArray(); |
|
47 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
48 |
); |
|
49 |
|
|
50 |
$.post('controller.pl', form, function(data) { |
|
51 |
kivi.eval_json_result(data); |
|
52 |
}); |
|
53 |
} |
|
54 | 54 |
|
55 | 55 |
// this is called from tabs/_shop.html, opens edit_window (render) |
56 | 56 |
ns.edit_shop_part = function(shop_part_id) { |
... | ... | |
66 | 66 |
}); |
67 | 67 |
} |
68 | 68 |
|
69 |
// gets all categories from the webshop |
|
70 |
ns.get_all_categories = function(shop_part_id) { |
|
71 |
var form = $('form').serializeArray(); |
|
72 |
form.push( { name: 'action', value: 'ShopPart/get_categories' } |
|
73 |
, { name: 'shop_part_id', value: shop_part_id } |
|
74 |
); |
|
75 |
|
|
76 |
$.post('controller.pl', form, function(data) { |
|
77 |
kivi.eval_json_result(data); |
|
78 |
}); |
|
79 |
} |
|
80 |
// write categories in kivi DB not in the shops DB TODO: create new categories in the shops db |
|
81 |
ns.set_categorie = function(shop_id, shop_part_id) { |
|
82 |
var form = $('form').serializeArray(); |
|
83 |
form.push( { name: 'action', value: 'ShopPart/set_categorie' } |
|
84 |
, { name: 'shop_id', value: shop_id } |
|
85 |
); |
|
86 |
|
|
87 |
$.post('controller.pl', form, function(data) { |
|
88 |
kivi.eval_json_result(data); |
|
89 |
}); |
|
90 |
} |
|
91 |
|
|
69 | 92 |
ns.update_discount_source = function(row, source, discount_str) { |
70 | 93 |
$('#active_discount_source_' + row).val(source); |
71 | 94 |
if (discount_str) $('#discount_' + row).val(discount_str); |
templates/webpages/ic/tabs/_shop.html | ||
---|---|---|
22 | 22 |
<td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td> |
23 | 23 |
<td>[% L.button_tag("kivi.shop_part.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit")) %]</td> |
24 | 24 |
<td>[% L.button_tag("kivi.shop_part.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Update")) %]</td> |
25 |
<td>[% L.button_tag("kivi.shop_part.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories")) %]</td> |
|
25 | 26 |
</tr> |
26 | 27 |
[%- END %] |
27 | 28 |
[%- FOREACH shop = SHOPS_NOT_ASSIGNED %] |
templates/webpages/shop_part/_list_images.html | ||
---|---|---|
4 | 4 |
<table width="100%" id="images_list"> |
5 | 5 |
<thead> |
6 | 6 |
<tr class="listheading"> |
7 |
<th width="10px"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></th> |
|
7 | 8 |
<th width="70px"></th> |
8 | 9 |
<th>[% 'Title' | $T8 %]</th> |
9 | 10 |
<th>[% 'Description' | $T8 %]</th> |
... | ... | |
13 | 14 |
</thead> |
14 | 15 |
<tbody> |
15 | 16 |
[%- FOREACH img = IMAGES %] |
16 |
<tr class="listrow" id="image_id_[% img.id %]"> |
|
17 |
<td><img src="data:[% img.thumbnail_img_content_type %];base64,[% img.thumbnail_img_content.encode_base64 %]" alt="[% img.title %]"></td> |
|
18 |
<td>[% HTML.escape(img.title) %]</td> |
|
19 |
<td>[% HTML.escape(img.description) %]</td> |
|
20 |
<td>[% HTML.escape(img.filename) %]</td> |
|
21 |
<td>[% HTML.escape(img.thumbnail_img_width) _ ' x ' _ HTML.escape(img.thumbnail_img_height) %]</td> |
|
22 |
</tr> |
|
17 |
<tr class="listrow" id="image_id_[% img.id %]"> |
|
18 |
<td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td> |
|
19 |
<td width="70px"><img src="data:[% img.thumbnail_img_content_type %];base64,[% img.thumbnail_img_content.encode_base64 %]" alt="[% img.title %]"></td> |
|
20 |
<td>[% HTML.escape(img.title) %]</td> |
|
21 |
<td>[% HTML.escape(img.description) %]</td> |
|
22 |
<td>[% HTML.escape(img.filename) %]</td> |
|
23 |
<td>[% HTML.escape(img.thumbnail_img_width) _ ' x ' _ HTML.escape(img.thumbnail_img_height) %]</td> |
|
24 |
</tr> |
|
23 | 25 |
[% END %] |
24 | 26 |
</tbody> |
25 | 27 |
</table> |
26 | 28 |
|
29 |
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %] |
|
30 |
<p> |
|
31 |
[% L.button_tag("add_file(this.form.id.value,'shop_part')", 'Fileupload') %] |
|
32 |
</p> |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
<script type='text/javascript'> |
|
38 |
<!-- |
|
39 |
function add_file(id,modul) { |
|
40 |
//var id = this.$('#part').val(); |
|
41 |
kivi.popup_dialog({ |
|
42 |
url : 'controller.pl?action=FileUploader/ajax_add_file', |
|
43 |
data: 'id=' + id + '&modul=' + modul, |
|
44 |
dialog: { title: kivi.t8('File upload') } |
|
45 |
} ); |
|
46 |
// var url = 'controller.pl?action=ShopPart/show_files?modul=shop_part&id=' + $('#id').val(); |
|
47 |
// $('#images_list').load(url); |
|
48 |
//$('#jqueryui_popup_dialog').dialog('close'); |
|
49 |
return true; |
|
50 |
} |
|
51 |
--> |
|
52 |
</script> |
templates/webpages/shop_part/edit.html | ||
---|---|---|
8 | 8 |
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %] |
9 | 9 |
|
10 | 10 |
<form action="controller.pl" method="post"> |
11 |
<div> |
|
12 |
[% IF SELF.shop_part.id %] |
|
13 |
[%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %] |
|
14 |
[%- L.hidden_tag("shop_part.shop_id", SELF.shop_part.shop_id) %] |
|
15 |
[% ELSE %] |
|
16 |
[%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %] |
|
17 |
[%- L.hidden_tag("shop_part.part_id", FORM.part_id) %] |
|
18 |
[% END %] |
|
11 | 19 |
|
12 |
[% IF SELF.shop_part.id %] |
|
13 |
[%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %] |
|
14 |
[% ELSE %] |
|
15 |
[%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %] |
|
16 |
[%- L.hidden_tag("shop_part.part_id", FORM.part_id) %] |
|
17 |
[% END %] |
|
20 |
<table> |
|
21 |
<tr> |
|
22 |
<td>[% LxERP.t8("Description") %]</td> |
|
23 |
<td>[% L.textarea_tag('shop_part.shop_description_as_restricted_html', SELF.shop_part.shop_description_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td> |
|
24 |
</tr> |
|
25 |
<tr> |
|
26 |
<td>[% LxERP.t8("Active") %]</td> |
|
27 |
<td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td> |
|
28 |
</tr> |
|
29 |
<tr> |
|
30 |
<td>[% LxERP.t8("Sort order") %]</td> |
|
31 |
<td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td> |
|
32 |
</tr> |
|
33 |
<tr> |
|
34 |
<td>[% LxERP.t8("Date") %]</td> |
|
35 |
<td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td> |
|
36 |
</tr> |
|
37 |
<tr> |
|
38 |
<td>[% LxERP.t8("Front page") %]</td> |
|
39 |
<td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td> |
|
40 |
</tr> |
|
41 |
<tr> |
|
42 |
<td>[% LxERP.t8("Meta Tags") %]</td> |
|
43 |
<td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td> |
|
44 |
</tr> |
|
45 |
<tr> |
|
46 |
<td>[% LxERP.t8("Shop Category") %]</td> |
|
47 |
<td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td> |
|
48 |
</tr> |
|
49 |
</table> |
|
50 |
[% # L.dump(SELF.shop_part) %] |
|
18 | 51 |
|
19 |
<table> |
|
20 |
<tr> |
|
21 |
<td>[% LxERP.t8("Description") %]</td> |
|
22 |
<td>[% L.textarea_tag('shop_part.shop_description_as_restricted_html', SELF.shop_part.shop_description_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td> |
|
23 |
<td>[% L.textarea_tag('letter.body_as_restricted_html', letter.body_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td> |
|
24 |
<!-- <td>[% L.textarea_tag("shop_part.shop_description", SELF.shop_part.shop_description) %]</td> --> |
|
25 |
</tr> |
|
26 |
<tr> |
|
27 |
<td>[% LxERP.t8("Active") %]</td> |
|
28 |
<td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td> |
|
29 |
</tr> |
|
30 |
<tr> |
|
31 |
<td>[% LxERP.t8("Sort order") %]</td> |
|
32 |
<td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td> |
|
33 |
</tr> |
|
34 |
<tr> |
|
35 |
<td>[% LxERP.t8("Date") %]</td> |
|
36 |
<td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td> |
|
37 |
</tr> |
|
38 |
<tr> |
|
39 |
<td>[% LxERP.t8("Front page") %]</td> |
|
40 |
<td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td> |
|
41 |
</tr> |
|
42 |
<tr> |
|
43 |
<td>[% LxERP.t8("Meta Tags") %]</td> |
|
44 |
<td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td> |
|
45 |
</tr> |
|
46 |
<tr> |
|
47 |
<td>[% LxERP.t8("Shop Category") %]</td> |
|
48 |
<td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td> |
|
49 |
</tr> |
|
50 |
</table> |
|
51 |
[% # L.dump(SELF.shop_part) %] |
|
52 |
[% IF SELF.shop_part.id %] |
|
53 |
[% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save")) %]</td> |
|
54 |
[% ELSE %] |
|
55 |
[% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save")) %]</td> |
|
56 |
[% END %] |
|
57 |
[% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber")) %]</td> |
|
52 | 58 |
|
53 |
[% IF SELF.shop_part.id %] |
|
54 |
[% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save")) %]</td> |
|
55 |
[% ELSE %] |
|
56 |
[% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save")) %]</td> |
|
57 |
[% END %] |
|
58 |
[% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber")) %]</td> |
|
59 |
[% # L.hidden_tag("action", "ShopPart/dispatch") %] |
|
60 |
[% # L.submit_tag('action_update', LxERP.t8('Save')) %] |
|
59 | 61 |
|
60 |
[% # L.hidden_tag("action", "ShopPart/dispatch") %] |
|
61 |
[% # L.submit_tag('action_update', LxERP.t8('Save')) %] |
|
62 | 62 |
|
63 |
</div> |
|
63 |
</div>
|
|
64 | 64 |
</form> |
65 |
|
|
66 |
|
|
67 |
|
|
65 | 68 |
[%- IF SELF.shop_part.part.image && INSTANCE_CONF.get_parts_show_image %] |
66 | 69 |
<a href="[% SELF.shop_part.part.image | html %]" target="_blank"><img style="[% INSTANCE_CONF.get_parts_image_css %]" src="[% SELF.shop_part.part.image | html %]"/></a> |
67 | 70 |
[%- END %] |
Auch abrufbar als: Unified diff
Shopparts: Bilder werden angezeigt TODO Bilder löschen
Shopkategorien werden aus der Api/Shop geholt und angezeigt zum markieren