X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e7d2012dd91644d84e9c2b281f1c7b9836180682..cb3a2467f28049de15810f7ddf1b04632639e530:/SL/Controller/Customer.pm diff --git a/SL/Controller/Customer.pm b/SL/Controller/Customer.pm new file mode 100644 index 000000000..4358080fe --- /dev/null +++ b/SL/Controller/Customer.pm @@ -0,0 +1,27 @@ +package SL::Controller::Customer; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Customer; + +# safety +__PACKAGE__->run_before(sub { $::auth->assert('customer_vendor_edit') }); + +sub action_ajax_autocomplete { + my ($self, %params) = @_; + + my $limit = $::form->{limit} || 20; + my $type = $::form->{type} || {}; + my $query = { ilike => "%$::form->{term}%" }; + my @filter; + push @filter, ($::form->{column}) + ? ($::form->{column} => $query) + : (or => [ customernumber => $query, name => $query ]); + + $self->{customers} = SL::DB::Manager::Customer->get_all(query => [ @filter ], limit => $limit); + $self->{value} = $::form->{column} || 'name'; + + $self->render('ct/ajax_autocomplete2', { no_layout => 1 }); +} +