% if ( ($curuser->access_right('Edit customer tags') && @part_tag) || $is_report ) { <% $opt{'label'} || 'Tags' %> <% include( '/elements/select-cust_tag.html', %opt, ) %> % } else { % foreach my $tagnum (@curr_tagnum) { % } % } <%init> my $curuser = $FS::CurrentUser::CurrentUser; my %opt = @_; my $cgi = $opt{'cgi'}; my $is_report = $opt{'is_report'}; my @curr_tagnum = (); if ( $cgi && $cgi->param('tagnum') ) { @curr_tagnum = $cgi->param('tagnum'); } elsif ( $opt{'custnum'} ) { @curr_tagnum = map $_->tagnum, qsearch('cust_tag', { 'custnum' => $opt{'custnum'} } ); } my $extra_sql = "WHERE disabled IS NULL OR disabled = '' "; $extra_sql .= ' OR tagnum IN ('. join(',', @curr_tagnum). ')' if @curr_tagnum; #now kind of inefficient (we only want to know if there are any), but since # its an edit control its not significant my @part_tag = qsearch({ 'table' => 'part_tag', 'hashref' => {}, 'extra_sql' => $extra_sql, });