use SL::DBUtils qw(selectfirst_array_query like);
use SL::Locale::String qw(t8);
-sub auth { 'customer_vendor_edit' }
+sub auth { undef }
sub name { 'contact' }
sub query_autocomplete {
my ($self) = @_;
+ my $cv_query = <<SQL;
+ SELECT id FROM customer
+ WHERE (obsolete IS NULL)
+ OR (obsolete = FALSE)
+
+ UNION
+
+ SELECT id FROM vendor
+ WHERE (obsolete IS NULL)
+ OR (obsolete = FALSE)
+SQL
+
my $result = SL::DB::Manager::Contact->get_all(
query => [
or => [
cp_givenname => { ilike => like($::form->{term}) },
cp_email => { ilike => like($::form->{term}) },
],
- cp_cv_id => [ \'SELECT id FROM customer UNION SELECT id FROM vendor' ],
+ cp_cv_id => [ \$cv_query ],
],
limit => 10,
sort_by => 'cp_name',
my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{id});
- SL::Controller::CustomerVendor->new->url_for(action => 'edit', id => $contact->cp_cv_id, db => db_for_contact($contact));
+ SL::Controller::CustomerVendor->new->url_for(action => 'edit', id => $contact->cp_cv_id, contact_id => $contact->cp_id, db => db_for_contact($contact), fragment => 'contacts');
}
sub do_search {