1 package SL::Controller::Customer;
4 use parent qw(SL::Controller::Base);
9 __PACKAGE__->run_before(sub { $::auth->assert('customer_vendor_edit') });
11 sub action_ajax_autocomplete {
12 my ($self, %params) = @_;
14 my $limit = $::form->{limit} || 20;
15 my $type = $::form->{type} || {};
16 my $query = { ilike => "%$::form->{term}%" };
18 push @filter, ($::form->{column})
19 ? ($::form->{column} => $query)
20 : (or => [ customernumber => $query, name => $query ]);
22 $self->{customers} = SL::DB::Manager::Customer->get_all(query => [ @filter ], limit => $limit);
23 $self->{value} = $::form->{column} || 'name';
25 $self->render('ct/ajax_autocomplete2', { layout => 0, type => 'json' });