1 package SL::Controller::Part;
4 use parent qw(SL::Controller::Base);
9 __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_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, SL::DB::Manager::Part->type_filter($type);
19 push @filter, ($::form->{column})
20 ? ($::form->{column} => $query)
21 : (or => [ partnumber => $query, description => $query ]);
23 $self->{parts} = SL::DB::Manager::Part->get_all(query => [ @filter ], limit => $limit);
24 $self->{value} = $::form->{column} || 'description';
26 $self->render('part/ajax_autocomplete', { layout => 0, type => 'json' });