Revision 75af6805
Von Werner Hahn vor fast 8 Jahren hinzugefügt
SL/Controller/FileUploader.pm | ||
---|---|---|
|
||
sub action_show_files {
|
||
my ($self) = @_;
|
||
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
|
||
my $images = SL::DB::Manager::File->get_all( query => [ trans_id => $::form->{id}, modul => $::form->{modul} ] );
|
||
$main::lxdebug->dump(0, 'WH: ',\$images);
|
||
|
||
|
||
}
|
SL/Controller/ShopPart.pm | ||
---|---|---|
use Data::Dumper;
|
||
use SL::Locale::String qw(t8);
|
||
use SL::DB::ShopPart;
|
||
use SL::DB::Default;
|
||
use SL::Helper::Flash;
|
||
|
||
use Rose::Object::MakeMethods::Generic
|
||
... | ... | |
|
||
};
|
||
|
||
sub action_show_files {
|
||
my ($self) = @_;
|
||
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
|
||
require SL::DB::File;
|
||
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' );
|
||
$main::lxdebug->dump(0, 'WH: ',\$images);
|
||
#my $html = $self->render('shop_part/_list_images', { output => 0 }, IMAGES => $images);
|
||
$self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
|
||
#$main::lxdebug->dump(0, 'WH: ',\$html);
|
||
|
||
#$self->js->html('#shop_images', $html);
|
||
#$self->js->render;
|
||
|
||
# $self->render('customer_vendor_turnover/count_open_items_by_year', { layout => 0 });
|
||
|
||
|
||
}
|
||
|
||
sub action_get_categories {
|
||
my ($self) = @_;
|
||
|
||
my $shop_part = SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
|
||
die unless $shop_part;
|
||
require SL::Shop;
|
||
my $shop = SL::Shop->new( config => $shop_part->shop );
|
||
my $categories = $shop->connector->get_categories;
|
||
$main::lxdebug->dump(0, 'WH: GET',\$categories);
|
||
|
||
$self->js
|
||
->run(
|
||
'kivi.shop_part.shop_part_dialog',
|
||
t8('Shopcategories'),
|
||
$self->render('shop_part/categories', { output => 0 }, CATEGORIES => $categories ) #, shop_part => $self->shop_part)
|
||
)
|
||
->reinit_widgets;
|
||
|
||
$self->js->render;
|
||
}
|
||
|
||
# old:
|
||
# sub action_edit {
|
||
... | ... | |
$self->js->render;
|
||
}
|
||
|
||
sub action_save_categories {
|
||
sub render_shop_categories_edit_dialog {
|
||
my ($self) = @_;
|
||
|
||
# when self->shop_part is called in template, it will be an existing shop_part with id,
|
||
# or a new shop_part with only part_id and shop_id set
|
||
$self->js
|
||
->run(
|
||
'kivi.shop_part.shop_part_dialog',
|
||
t8('Shopcategories'),
|
||
$self->render('shop_part/categories', { output => 0 }) #, shop_part => $self->shop_part)
|
||
)
|
||
->reinit_widgets;
|
||
|
||
$self->js->render;
|
||
}
|
||
sub action_reorder {
|
||
my ($self) = @_;
|
||
$main::lxdebug->message(0, "WH:REORDER ");
|
||
require SL::DB::File;
|
||
SL::DB::File->reorder_list(@{ $::form->{image_id} || [] });
|
||
$main::lxdebug->message(0, "WH:REORDER II ");
|
||
|
||
$self->render(\'', { type => 'json' });
|
||
}
|
||
|
||
#
|
||
# internal stuff
|
||
#
|
SL/DB/ShopPart.pm | ||
---|---|---|
package SL::DB::ShopPart;
|
||
#package SL::DB::ShopPart;
|
||
|
||
use SL::DB::Helper::AttrHTML;
|
||
use strict;
|
||
|
||
use SL::DB::MetaSetup::ShopPart;
|
||
use SL::DB::Manager::ShopPart;
|
||
use SL::DB::Helper::AttrHTML;
|
||
use SL::DB::Helper::ActsAsList;
|
||
|
||
__PACKAGE__->meta->initialize;
|
||
__PACKAGE__->attr_html('shop_description');
|
SL/ShopConnector/Base.pm | ||
---|---|---|
|
||
sub update_part { die 'update_part needs to be implemented' }
|
||
|
||
sub get_categories { die 'get_order needs to be implemented' }
|
||
1;
|
||
|
||
__END__
|
SL/ShopConnector/Shopware.pm | ||
---|---|---|
# return $import;
|
||
};
|
||
|
||
sub get_categories {
|
||
my ($self) = @_;
|
||
|
||
my $url = $self->url;
|
||
|
||
my $data = $self->connector->get("http://$url/api/categories");
|
||
my $data_json = $data->content;
|
||
my $import = SL::JSON::decode_json($data_json);
|
||
my @daten = @{$import->{data}};
|
||
my %categories = map { ($_->{id} => $_) } @daten;
|
||
|
||
for(@daten) {
|
||
my $parent = $categories{$_->{parentId}};
|
||
$parent->{children} ||= [];
|
||
push @{$parent->{children}},$_;
|
||
}
|
||
|
||
return \@daten;
|
||
}
|
||
|
||
sub get_article {
|
||
}
|
||
|
||
sub get_articles {
|
||
}
|
||
|
||
sub set_article {
|
||
}
|
||
|
||
sub init_url {
|
||
my ($self) = @_;
|
||
# TODO: validate url and port
|
js/kivi.shop_part.js | ||
---|---|---|
namespace('kivi.shop_part', function(ns) {
|
||
var $dialog;
|
||
|
||
// this is called by sub render, with a certain prerendered html (edit.html)
|
||
// this is called by sub render, with a certain prerendered html (edit.html,categories.html)
|
||
ns.shop_part_dialog = function(title, html) {
|
||
var id = 'jqueryui_popup_dialog';
|
||
var dialog_params = {
|
templates/webpages/ic/tabs/_shop.html | ||
---|---|---|
<td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td>
|
||
<td>[% L.button_tag("kivi.shop_part.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit")) %]</td>
|
||
<td>[% L.button_tag("kivi.shop_part.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Update")) %]</td>
|
||
<td>[% L.button_tag("kivi.shop_part.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories")) %]</td>
|
||
</tr>
|
||
[%- END %]
|
||
[%- FOREACH shop = SHOPS_NOT_ASSIGNED %]
|
||
... | ... | |
</p>
|
||
</div>
|
||
[%- END %]
|
||
<div id="shop_images">
|
||
<script type="text/javascript">
|
||
function show_images() {
|
||
var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id=[% shop_part.part_id %]';
|
||
$('#shop_images').load(url);
|
||
}
|
||
|
||
$(window).load(function() {
|
||
show_images();
|
||
});
|
||
</script>
|
||
<div id="shop_images" border=1 >
|
||
</div>
|
||
</div>
|
||
|
templates/webpages/shop_part/_list_images.html | ||
---|---|---|
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
|
||
[%- USE T8 %][% USE Base64 %]
|
||
[%- USE Dumper %]
|
||
<table width="100%" id="images_list">
|
||
<thead>
|
||
<tr class="listheading">
|
||
<th width="10px"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></th>
|
||
<th width="70px"></th>
|
||
<th>[% 'Title' | $T8 %]</th>
|
||
<th>[% 'Description' | $T8 %]</th>
|
||
<th>[% 'Filename' | $T8 %]</th>
|
||
<th>[% 'Orig. Size w/h' | $T8 %]</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
[%- FOREACH img = IMAGES %]
|
||
<tr class="listrow" id="image_id_[% img.id %]">
|
||
<td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td>
|
||
<td width="70px"><img src="data:[% img.thumbnail_img_content_type %];base64,[% img.thumbnail_img_content.encode_base64 %]" alt="[% img.title %]"></td>
|
||
<td>[% HTML.escape(img.title) %]</td>
|
||
<td>[% HTML.escape(img.description) %]</td>
|
||
<td>[% HTML.escape(img.filename) %]</td>
|
||
<td>[% HTML.escape(img.thumbnail_img_width) _ ' x ' _ HTML.escape(img.thumbnail_img_height) %]</td>
|
||
</tr>
|
||
[% END %]
|
||
</tbody>
|
||
</table>
|
||
|
||
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %]
|
||
<p>
|
||
[% L.button_tag("add_file(this.form.id.value,'shop_part')", 'Fileupload') %]
|
||
</p>
|
||
|
||
|
||
|
||
|
||
<script type='text/javascript'>
|
||
<!--
|
||
function add_file(id,modul) {
|
||
//var id = this.$('#part').val();
|
||
kivi.popup_dialog({
|
||
url : 'controller.pl?action=FileUploader/ajax_add_file',
|
||
data: 'id=' + id + '&modul=' + modul,
|
||
dialog: { title: kivi.t8('File upload') }
|
||
} );
|
||
// var url = 'controller.pl?action=ShopPart/show_files?modul=shop_part&id=' + $('#id').val();
|
||
// $('#images_list').load(url);
|
||
//$('#jqueryui_popup_dialog').dialog('close');
|
||
return true;
|
||
}
|
||
-->
|
||
</script>
|
templates/webpages/shop_part/edit.html | ||
---|---|---|
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
|
||
|
||
<form action="controller.pl" method="post">
|
||
<div>
|
||
[% IF SELF.shop_part.id %]
|
||
[%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %]
|
||
[%- L.hidden_tag("shop_part.shop_id", SELF.shop_part.shop_id) %]
|
||
[% ELSE %]
|
||
[%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %]
|
||
[%- L.hidden_tag("shop_part.part_id", FORM.part_id) %]
|
||
[% END %]
|
||
|
||
[% IF SELF.shop_part.id %]
|
||
[%- L.hidden_tag("shop_part.id", SELF.shop_part.id) %]
|
||
[% ELSE %]
|
||
[%- L.hidden_tag("shop_part.shop_id", FORM.shop_id) %]
|
||
[%- L.hidden_tag("shop_part.part_id", FORM.part_id) %]
|
||
[% END %]
|
||
<table>
|
||
<tr>
|
||
<td>[% LxERP.t8("Description") %]</td>
|
||
<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>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Active") %]</td>
|
||
<td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Sort order") %]</td>
|
||
<td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Date") %]</td>
|
||
<td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Front page") %]</td>
|
||
<td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Meta Tags") %]</td>
|
||
<td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Shop Category") %]</td>
|
||
<td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td>
|
||
</tr>
|
||
</table>
|
||
[% # L.dump(SELF.shop_part) %]
|
||
|
||
<table>
|
||
<tr>
|
||
<td>[% LxERP.t8("Description") %]</td>
|
||
<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>
|
||
<td>[% L.textarea_tag('letter.body_as_restricted_html', letter.body_as_restricted_html, style='width:100%', rows=20, class="texteditor") %]</td>
|
||
<!-- <td>[% L.textarea_tag("shop_part.shop_description", SELF.shop_part.shop_description) %]</td> -->
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Active") %]</td>
|
||
<td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Sort order") %]</td>
|
||
<td>[% L.input_tag("shop_part.sortorder", SELF.shop_part.sortorder, size=2) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Date") %]</td>
|
||
<td>[% L.date_tag("shop_part.show_date", SELF.shop_part.show_date) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Front page") %]</td>
|
||
<td>[% L.yes_no_tag('shop_part.front_page', SELF.shop_part.front_page) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Meta Tags") %]</td>
|
||
<td>[% L.input_tag("shop_part.meta_tags", SELF.shop_part.meta_tags, size=2) %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% LxERP.t8("Shop Category") %]</td>
|
||
<td>[% L.input_tag("shop_part.shop_category", SELF.shop_part.category, size=2) %]</td>
|
||
</tr>
|
||
</table>
|
||
[% # L.dump(SELF.shop_part) %]
|
||
[% IF SELF.shop_part.id %]
|
||
[% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save")) %]</td>
|
||
[% ELSE %]
|
||
[% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save")) %]</td>
|
||
[% END %]
|
||
[% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber")) %]</td>
|
||
|
||
[% IF SELF.shop_part.id %]
|
||
[% L.button_tag("kivi.shop_part.save_shop_part(" _ SELF.shop_part.id _ ")", LxERP.t8("Save")) %]</td>
|
||
[% ELSE %]
|
||
[% L.button_tag("kivi.shop_part.add_shop_part(" _ FORM.part_id _", " _ FORM.shop_id _")", LxERP.t8("Save")) %]</td>
|
||
[% END %]
|
||
[% # L.button_tag("kivi.shop_part.update_partnumber()", LxERP.t8("Update Partnumber")) %]</td>
|
||
[% # L.hidden_tag("action", "ShopPart/dispatch") %]
|
||
[% # L.submit_tag('action_update', LxERP.t8('Save')) %]
|
||
|
||
[% # L.hidden_tag("action", "ShopPart/dispatch") %]
|
||
[% # L.submit_tag('action_update', LxERP.t8('Save')) %]
|
||
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
|
||
|
||
[%- IF SELF.shop_part.part.image && INSTANCE_CONF.get_parts_show_image %]
|
||
<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>
|
||
[%- END %]
|
Auch abrufbar als: Unified diff
Shopmodul: ShopPart Bilder und Kategorien
Bilder werden als Tabelle angezeigt
Conflicts:
templates/webpages/ic/tabs/_shop.html
Shopparts: Bilder werden angezeigt TODO Bilder löschen
Shopkategorien werden aus der Api/Shop geholt und angezeigt zum markieren
Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
js/kivi.shop_part.js