commit 13e2867426816f9894937bcf4ac510e0f0092ccc
Author: Werner Hahn <wh@futureworldsearch.net>
Date:   Thu Sep 14 07:19:48 2017 +0200

    Shopmodul: Filter nach Shop in Shopartikellisting und Bestelllisting

diff --git a/SL/Controller/ShopOrder.pm b/SL/Controller/ShopOrder.pm
index 3bba2616b..2a52a6908 100644
--- a/SL/Controller/ShopOrder.pm
+++ b/SL/Controller/ShopOrder.pm
@@ -18,7 +18,7 @@ use SL::Locale::String;
 use SL::Controller::Helper::ParseFilter;
 use Rose::Object::MakeMethods::Generic
 (
-  'scalar --get_set_init' => [ qw(shop_order transferred js) ],
+  'scalar --get_set_init' => [ qw(shop_order shops transferred js) ],
 );
 
 __PACKAGE__->run_before('setup');
@@ -242,6 +242,10 @@ sub init_transferred {
     { title => t8("not transferred"), value => 0  }, ]
 }
 
+sub init_shops {
+  SL::DB::Shop->shops_dd;
+}
+
 sub _setup_list_action_bar {
   my ($self) = @_;
 
@@ -359,6 +363,10 @@ Shows the backgroundjobdata for the popup status window
 
 Transferstatuses for the filter dropdown
 
+=item C<init_shops>
+
+Filter dropdown Shops
+
 =back
 
 =head1 TODO
diff --git a/SL/Controller/ShopPart.pm b/SL/Controller/ShopPart.pm
index 7d27f6f47..a11ad8965 100644
--- a/SL/Controller/ShopPart.pm
+++ b/SL/Controller/ShopPart.pm
@@ -9,16 +9,18 @@ use SL::System::TaskServer;
 use Data::Dumper;
 use SL::Locale::String qw(t8);
 use SL::DB::ShopPart;
+use SL::DB::Shop;
 use SL::DB::File;
 use SL::DB::ShopImage;
 use SL::DB::Default;
 use SL::Helper::Flash;
+use SL::Controller::Helper::ParseFilter;
 use MIME::Base64;
 
 use Rose::Object::MakeMethods::Generic
 (
    scalar                 => [ qw(price_sources) ],
-  'scalar --get_set_init' => [ qw(shop_part file shops producers) ],
+  'scalar --get_set_init' => [ qw(shop_part file shops) ],
 );
 
 __PACKAGE__->run_before('check_auth');
@@ -193,12 +195,11 @@ sub action_reorder {
 sub action_list_articles {
   my ($self) = @_;
 
-  my %filter      = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]);
-  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
+  my %filter      = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ 'shop.obsolete' => 0 ]);
   my $sort_by     = $::form->{sort_by} ? $::form->{sort_by} : 'part.partnumber';
   $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
 
-  my $articles = SL::DB::Manager::ShopPart->get_all(where => [ 'shop.obsolete' => 0 ],with_objects => [ 'part','shop' ], sort_by => $sort_by );
+  my $articles = SL::DB::Manager::ShopPart->get_all( %filter ,with_objects => [ 'part','shop' ], sort_by => $sort_by );
 
   foreach my $article (@{ $articles}) {
     my $images = SL::DB::Manager::ShopImage->get_all_count( where => [ 'files.object_id' => $article->part->id, ], with_objects => 'file', sort_by => 'position' );
@@ -352,11 +353,7 @@ sub init_file {
 }
 
 sub init_shops {
-  require SL::DB::Shop;
-  my @shops_dd = [ { title => t8("all") ,   value =>'' } ];
-  my $shops = SL::DB::Mangager::Shop->get_all( where => [ obsolete => 0 ] );
-  my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
-  return @shops_dd;
+  SL::DB::Shop->shops_dd;
 }
 
 1;
diff --git a/SL/DB/Shop.pm b/SL/DB/Shop.pm
index 0c8c5c342..952ae8b5c 100644
--- a/SL/DB/Shop.pm
+++ b/SL/DB/Shop.pm
@@ -8,14 +8,7 @@ use strict;
 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' },
-#  },
-#);
+use SL::Locale::String qw(t8);
 
 __PACKAGE__->meta->initialize;
 
@@ -28,4 +21,51 @@ sub validate {
 
   return @errors;
 }
+
+sub shops_dd {
+  my ( $self ) = @_;
+
+  my @shops_dd = [ { title => t8("all") ,   value =>'' } ];
+  my $shops = SL::DB::Manager::Shop->get_all( where => [ obsolete => 0 ] );
+  my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
+  push @shops_dd, @tmp;
+  return \@shops_dd;
+}
+
 1;
+
+__END__
+
+=pod
+
+=encoding utf-8
+
+=head1 NAME
+
+SL::DB::Shop - Model for the 'shops' table
+
+=head1 SYNOPSIS
+
+This is a standard Rose::DB::Object based model and can be used as one.
+
+=head1 METHODS
+
+=over 4
+
+=item C<validate>
+
+Returns an error if the shop description is missing
+
+=item C<shops_dd>
+
+Returns an array of hashes for dropdowns in filters
+
+=back
+
+=head1 AUTHORS
+
+Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
+
+G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
+
+=cut
diff --git a/templates/webpages/shop_order/_filter.html b/templates/webpages/shop_order/_filter.html
index 0e2d520f9..b07d7f787 100644
--- a/templates/webpages/shop_order/_filter.html
+++ b/templates/webpages/shop_order/_filter.html
@@ -5,6 +5,11 @@
  <form method="post" action="controller.pl" name="shop_orders" id="shoporders">
  <table id='filter_table'>
 
+    <tr>
+     <th align="right">[% 'Shop' | $T8 %]</th>
+     <td>[% L.select_tag('filter.shop_id:eq_ignore_empty', SELF.shops, value_key = 'value', title_key = 'title', default=0) %]</td>
+    </tr>
+
     <tr>
      <th align="right">[% 'Status' | $T8 %]</th>
      <td>[% L.select_tag('filter.transferred:eq_ignore_empty', SELF.transferred, value_key = 'value', title_key = 'title', default=0) %]</td>
diff --git a/templates/webpages/shop_part/_filter.html b/templates/webpages/shop_part/_filter.html
index 27ae57859..1efedd379 100644
--- a/templates/webpages/shop_part/_filter.html
+++ b/templates/webpages/shop_part/_filter.html
@@ -7,7 +7,7 @@
 
     <tr>
      <th align="right">[% 'Shop' | $T8 %]</th>
-     <td>[% L.select_tag('filter.transferred:eq_ignore_empty', SELF.shop, value_key = 'value', title_key = 'title', default=SHOPS) %]</td>
+     <td>[% L.select_tag('filter.shop_id:eq_ignore_empty', SELF.shops, value_key = 'value', title_key = 'title', default=0) %]</td>
     </tr>
 
  </table>
