1 package SL::Controller::TopQuickSearch::CustomerVendor;
4 use parent qw(Rose::Object);
6 use SL::Locale::String qw(t8);
7 use SL::Controller::Helper::GetModels;
8 use SL::Controller::Base;
10 use Rose::Object::MakeMethods::Generic (
11 'scalar --get_set_init' => [ qw(models) ],
14 # nope. this is only for subclassing
15 sub auth { 'NOT ALLOWED' }
19 sub description_config { ... }
21 sub description_field { ... }
23 sub query_autocomplete {
26 my $objects = $self->models->get;
30 value => $_->displayable_name,
31 label => $_->displayable_name,
37 sub select_autocomplete {
38 $_[0]->redirect_to_object($::form->{id});
44 my $objects = $self->models->get;
46 return !@$objects ? ()
47 : @$objects == 1 ? $self->redirect_to_object($objects->[0]->id)
48 : $self->redirect_to_search($::form->{term});
51 sub redirect_to_search {
52 SL::Controller::Base->new->url_for(
53 controller => 'ct.pl',
54 action => 'list_names',
60 (map {; "l_$_" => 'Y' } $_[0]->db . "number", qw(name street contact phone zipcode email city country gln)),
65 sub redirect_to_object {
66 SL::Controller::Base->new->url_for(
67 controller => 'CustomerVendor',
76 my $cvnumber = $self->db eq 'customer' ? 'customernumber' : 'vendornumber';
78 SL::Controller::Helper::GetModels->new(
80 model => $self->model,
83 'all:substr:multi::ilike' => $::form->{term}, # all filter spec is set in SL::DB::Manager::Customer
91 $cvnumber => $self->db eq 'customer' ? t8('Customer Number') : t8('Vendor Number'),