TopQuickSearch für den Benutzer konfigurierbar gemacht.
[kivitendo-erp.git] / SL / Controller / TopQuickSearch.pm
index d4367ce..8b47080 100644 (file)
@@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base);
 use SL::ClientJS;
 use SL::JSON;
 use SL::Locale::String qw(t8);
+use SL::Helper::UserPreferences;
 
 use Rose::Object::MakeMethods::Generic (
  'scalar --get_set_init' => [ qw(module js) ],
@@ -16,12 +17,15 @@ my @available_modules = (
   'SL::Controller::TopQuickSearch::Part',
   'SL::Controller::TopQuickSearch::Service',
   'SL::Controller::TopQuickSearch::Assembly',
+  'SL::Controller::TopQuickSearch::Assortment',
   'SL::Controller::TopQuickSearch::Contact',
   'SL::Controller::TopQuickSearch::SalesQuotation',
   'SL::Controller::TopQuickSearch::SalesOrder',
   'SL::Controller::TopQuickSearch::RequestForQuotation',
   'SL::Controller::TopQuickSearch::PurchaseOrder',
   'SL::Controller::TopQuickSearch::GLTransaction',
+  'SL::Controller::TopQuickSearch::Customer',
+  'SL::Controller::TopQuickSearch::Vendor',
 );
 my %modules_by_name;
 
@@ -62,9 +66,23 @@ sub available_modules {
 }
 
 sub enabled_modules {
-  my %enabled_names = map {
-    $_ => 1
-  } @{ $::instance_conf->get_quick_search_modules };
+  my $user_prefs = SL::Helper::UserPreferences->new(
+    namespace         => 'TopQuickSearch',
+  );
+
+  my %enabled_names;
+  if ($user_prefs) {
+    my $prefs_val            = $user_prefs->get('quick_search_modules');
+    my @quick_search_modules = split ',', $prefs_val;
+
+    %enabled_names = map {
+      $_ => 1
+    } @quick_search_modules ;
+  } else {
+    %enabled_names = map {
+      $_ => 1
+    } @{ $::instance_conf->get_quick_search_modules };
+  }
 
   grep {
     $enabled_names{$_->name}
@@ -185,7 +203,6 @@ The full interface is described in L<SL::Controller::TopQuickSeach::Base>
 =head1 TODO
 
   * user configuration
-  * searches for orders, customers, vendors
 
 =head1 BUGS