From: Werner Hahn Date: Fri, 22 Sep 2017 00:27:58 +0000 (+0200) Subject: WebshopApi: Shop-Tab in Partcontroller eingebaut X-Git-Tag: release-3.5.4~791 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e0e75548260827661474c54bf88c0ae74799c0b6;p=kivitendo-erp.git WebshopApi: Shop-Tab in Partcontroller eingebaut --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 66f873136..f152e0844 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base); use Clone qw(clone); use SL::DB::Part; use SL::DB::PartsGroup; +use SL::DB::Shop; use SL::Controller::Helper::GetModels; use SL::Locale::String qw(t8); use SL::JSON; @@ -21,7 +22,7 @@ use Carp; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models - makemodels + makemodels shops_not_assigned orphaned assortment assortment_items assembly assembly_items all_pricegroups all_translations all_partsgroups all_units @@ -636,7 +637,7 @@ sub add { sub _set_javascript { my ($self) = @_; - $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery); + $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart); $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id; } @@ -803,7 +804,7 @@ sub init_part { # used by edit, save, delete and add if ( $::form->{part}{id} ) { - return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup) ]); + return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup shop_parts shop_parts.shop) ]); } else { die "part_type missing" unless $::form->{part}{part_type}; return SL::DB::Part->new(part_type => $::form->{part}{part_type}); @@ -924,6 +925,18 @@ sub init_all_buchungsgruppen { } } +sub init_shops_not_assigned { + my ($self) = @_; + + my @used_shop_ids = map { $_->shop->id } @{ $self->part->shop_parts }; + if ( @used_shop_ids ) { + return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0, '!id' => \@used_shop_ids ], sort_by => 'sortkey' ); + } + else { + return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0 ], sort_by => 'sortkey' ); + } +} + sub init_all_units { my ($self) = @_; if ( $self->part->orphaned ) { diff --git a/templates/webpages/part/_shop.html b/templates/webpages/part/_shop.html new file mode 100644 index 000000000..051a2306c --- /dev/null +++ b/templates/webpages/part/_shop.html @@ -0,0 +1,82 @@ +[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%] +[%- USE Dumper %] +[%- USE JavaScript -%] +
+

[% LxERP.t8("Active shops:") %]

+ + + + + + + + + + + + + + + + [% # L.dump(SELF.part) %] + [%- FOREACH shop_part = SELF.part.shop_parts %] + [% IF !shop_part.shop.obsolete %] + + + + + + + + + + + + + + [% END %] + [%- END %] + [%- FOREACH shop = SELF.shops_not_assigned %] + + + + + + + + + + + [%- END %] +
[% LxERP.t8("Shop") %][% LxERP.t8("Active") %][% LxERP.t8("Shop part") %][% LxERP.t8("Price source") %][% LxERP.t8("Price") %][% LxERP.t8("Stock Local/Shop") %][% LxERP.t8("Last update") %][% LxERP.t8("Action") %][% LxERP.t8("Action") %][% LxERP.t8("Action") %]
[% HTML.escape( shop_part.shop.description ) %][% L.html_tag('span', shop_part.active, id => 'shop_part_active_' _ shop_part.id ) %][% L.html_tag('span', shop_part.shop_description, id => 'shop_part_description_' _ shop_part.id ) %][% L.html_tag('span',LxERP.t8(), id => 'active_price_source_' _ shop_part.id) %] [% L.html_tag('span','Price', id => 'price_' _ shop_part.id) %][% L.html_tag('span','Stock', id => 'stock_' _ shop_part.id) %][% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %][% L.button_tag("kivi.ShopPart.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit")) %][% L.button_tag("kivi.ShopPart.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Upload")) %][% L.button_tag("kivi.ShopPart.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories")) %]
+ [% IF shop_part.shop_category %] + [% IF shop_part.shop_category.1.size > 1%] + [% FOREACH cat = shop_part.shop_category %] + [% HTML.escape(cat.1) %]
+ [% END %] + [% ELSE %] + [% HTML.escape(shop_part.shop_category.1) %]
+ [% END %] + [% END %] +
[% HTML.escape( shop.description ) %][% L.button_tag("kivi.ShopPart.create_shop_part(" _ id _ ", " _ shop.id _ ")", LxERP.t8("Add")) %]
+ + +[% # L.dump(shop_part) %] +

[% LxERP.t8("Shopimages - valid for all shops") %]

+ [%- IF shop_part.part_id %] + +
+ [%- ELSE %] +
[% LxERP.t8('To upload images: Please create shoppart first') %]
+ [%- END %] +
+ diff --git a/templates/webpages/part/form.html b/templates/webpages/part/form.html index b33d5b07e..733fb13bc 100644 --- a/templates/webpages/part/form.html +++ b/templates/webpages/part/form.html @@ -41,6 +41,9 @@ [%- IF CUSTOM_VARIABLES.size %]
  • [% 'Custom Variables' | $T8 %]
  • [%- END %] + [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id && SELF.part.shop %] +
  • [% 'Shop variables' | $T8 %]
  • + [% END %]
    @@ -67,6 +70,11 @@
    [% PROCESS part/_sales_price_information.html id=SELF.part.id %]
    + [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id %] +
    + [% PROCESS 'part/_shop.html' %] +
    + [%- END %] [%- END %] [%- IF CUSTOM_VARIABLES.size %]