commit b3483d9c809a1ac17be819ca721e59975cef7f93
Author: Werner Hahn <wh@futureworldsearch.net>
Date:   Thu Dec 8 19:16:00 2016 +0100

    Shopmodul: Anpassungen an neuen Partcontroller; Shopkategorien gehen noch nicht

diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm
index 66f873136..b25faac04 100644
--- a/SL/Controller/Part.pm
+++ b/SL/Controller/Part.pm
@@ -636,7 +636,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.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.shop_part);
   $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id;
 }
 
@@ -803,7 +803,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});
diff --git a/SL/Controller/ShopPart.pm b/SL/Controller/ShopPart.pm
index 0410a3392..0a34f754b 100644
--- a/SL/Controller/ShopPart.pm
+++ b/SL/Controller/ShopPart.pm
@@ -409,7 +409,7 @@ sub init_shop_part {
   if ($::form->{shop_part_id}) {
     SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
   } else {
-    SL::DB::ShopPart->new(shop_id => $::form->{shop_id}, part_id => $::form->{part_id});
+    SL::DB::ShopPart->new(shop_id => $::form->{shop_id}, part_id => $::form->{part_id})->load(with => ['shop']);
   };
 }
 
diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm
index 8e63235f8..0fe7c16e2 100644
--- a/SL/DB/Part.pm
+++ b/SL/DB/Part.pm
@@ -58,6 +58,7 @@ __PACKAGE__->meta->add_relationships(
     type         => 'one to many',
     class        => 'SL::DB::ShopPart',
     column_map   => { id => 'part_id' },
+    manager_args => { with_objects => [ 'shop' ] },
   },
 );
 
diff --git a/SL/DB/Shop.pm b/SL/DB/Shop.pm
index 073c4add6..0c8c5c342 100644
--- a/SL/DB/Shop.pm
+++ b/SL/DB/Shop.pm
@@ -9,13 +9,13 @@ use SL::DB::MetaSetup::Shop;
 use SL::DB::Manager::Shop;
 use SL::DB::Helper::ActsAsList;
 
-__PACKAGE__->meta->add_relationships(
-  shop_parts     => {
-    type         => 'one to many',
-    class        => 'SL::DB::ShopPart',
-    column_map   => { id => 'shop_id' },
-  },
-);
+#__PACKAGE__->meta->add_relationships(
+#  shop_parts     => {
+#    type         => 'one to many',
+#    class        => 'SL::DB::ShopPart',
+#    column_map   => { id => 'shop_id' },
+#  },
+#);
 
 __PACKAGE__->meta->initialize;
 
diff --git a/js/kivi.shop_part.js b/js/kivi.shop_part.js
index bf2cb3b14..b41a66d1c 100644
--- a/js/kivi.shop_part.js
+++ b/js/kivi.shop_part.js
@@ -67,7 +67,7 @@ namespace('kivi.shop_part', function(ns) {
 
   // gets all categories from the webshop
   ns.get_all_categories = function(shop_part_id) {
-    var form = $('form').serializeArray();
+    var form = new Array; //$('form').serializeArray();
     form.push( { name: 'action', value: 'ShopPart/get_categories' }
              , { name: 'shop_part_id', value: shop_part_id }
     );
diff --git a/templates/webpages/part/_shop.html b/templates/webpages/part/_shop.html
index 487ec7c20..b3fd91ead 100644
--- a/templates/webpages/part/_shop.html
+++ b/templates/webpages/part/_shop.html
@@ -18,8 +18,9 @@
    <th>[% LxERP.t8("Action") %]</th>
   </tr>
   </thead>
-
-  [%- FOREACH shop_part = SHOP_PARTS %]
+  [% # L.dump(SELF.part) %]
+  [%- FOREACH shop_part = SELF.part.shop_parts %]
+  [% IF !shop_part.shop.obsolete %]
   <tr class="listrow">
    <td>[% HTML.escape( shop_part.shop.description ) %]</td>
    <td>[% L.html_tag('span', shop_part.active, id => 'shop_part_active_' _ shop_part.id ) %]</td>
@@ -38,6 +39,7 @@
       kivi.shop_part.update_stock([% shop_part.id %]);
     });
   </script>
+  [% END %]
   [%- END %]
   [%- FOREACH shop = SHOPS_NOT_ASSIGNED %]
   <tr>
@@ -55,27 +57,7 @@
 
 
 [% # L.dump(shop_part) %]
-<h2>[% LxERP.t8("Shopvariables and Images - valid for all shops") %]</h2>
-  [%- IF CUSTOM_VARIABLES.size %]
-[%  # L.dump(CUSTOM_VARIABLES) %]
-  <div id="shop_custom_variables">
-   <p>
-    <table>
-     [%- FOREACH var = CUSTOM_VARIABLES %]
-      [%- IF var.name.match('^shop_') %]
-       <tr>
-        [% # IF !var.partsgroup_filtered %]
-          <td align="right" valign="top">[% HTML.escape(var.description) %]</td>
-        [% # END %]
-      <td align="right" valign="top">[% var.VALID_BOX %]</td>
-        <td valign="top">[% var.HTML_CODE %]</td>
-       </tr>
-      [%- END %]
-     [%- END %]
-    </table>
-   </p>
-  </div>
-  [%- END %]
+<h2>[% LxERP.t8("Shopimages - valid for all shops") %]</h2>
   [%- IF shop_part.part_id %]
     <script type="text/javascript">
       $(function() {
