1 <& elements/search.html,
3 name_singular => 'contact',
4 query => { select => $select,
6 addl_from => $addl_from,
8 extra_sql => $extra_sql,
10 count_query => "SELECT COUNT(*) FROM contact $extra_sql", #XXX
18 unless $FS::CurrentUser::CurrentUser->access_right('List contacts');
20 my $select = 'contact.*';
24 my @header = ( 'First', 'Last', 'Title', );
25 my @fields = ( 'first', 'last', 'title', );
26 my @links = ( '', '', '' );
28 my $company_link = '';
30 if ( $cgi->param('selfservice_access') eq 'Y' ) {
31 $hash{'selfservice_access'} = 'Y';
35 if ( $cgi->param('link') ) {
37 my $as = ') AS prospect_or_customer';
39 if ( $cgi->param('link') eq 'cust_main' ) {
40 push @header, 'Customer';
42 ", COALESCE( cust_main.company, cust_main.first||' '||cust_main.last $as";
43 $addl_from = ' LEFT JOIN cust_main USING ( custnum )';
44 $extra_sql = ' custnum IS NOT NULL ';
45 $company_link = [ $p.'view/cust_main.cgi?', 'custnum' ];
46 } elsif ( $cgi->param('link') eq 'prospect_main' ) {
47 push @header, 'Prospect';
49 ", COALESCE( prospect_main.company, contact.first||' '||contact.last $as";
50 $addl_from = ' LEFT JOIN prospect_main USING ( prospectnum )';
51 $extra_sql = ' prospectnum IS NOT NULL ';
52 $company_link = [ $p.'view/prospect_main.html?', 'prospectnum' ];
54 die "don't know how to report on contacts linked to specified table";
57 #because right now its harder to show it for both kinds of contacts
58 push @fields, 'prospect_or_customer';
59 push @links, $company_link;
63 push @header, 'Self-service';
64 push @fields, 'selfservice_access';
66 $extra_sql = (keys(%hash) ? ' AND ' : ' WHERE '). $extra_sql