RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / elements / tr-select-cust_tag.html
1 % if ( ($curuser->access_right('Edit customer tags') && @part_tag) || $is_report ) {
2
3   <TR>
4     <TH ALIGN="right"><% $opt{'label'} || 'Tags' %></TD>
5     <TD>
6       <% include( '/elements/select-cust_tag.html',
7                      %opt,
8                  )
9       %>
10     </TD>
11   </TR>
12
13 % } else {
14
15 %   foreach my $tagnum (@curr_tagnum) {
16       <INPUT TYPE="hidden" NAME="tagnum" VALUE="<% $tagnum %>">
17 %   }
18
19 % }
20 <%init>
21
22 my $curuser = $FS::CurrentUser::CurrentUser;
23
24 my %opt = @_;
25 my $cgi = $opt{'cgi'};
26 my $is_report = $opt{'is_report'};
27
28 my @curr_tagnum = ();
29 if ( $cgi && $cgi->param('tagnum') ) {
30   @curr_tagnum = $cgi->param('tagnum');
31 } elsif ( $opt{'custnum'} ) {
32   @curr_tagnum = map $_->tagnum,
33                      qsearch('cust_tag', { 'custnum' => $opt{'custnum'} } );
34 }
35
36 my $extra_sql = "WHERE disabled IS NULL OR disabled = '' ";
37 $extra_sql .= ' OR tagnum IN ('. join(',', @curr_tagnum). ')' if @curr_tagnum;
38
39 #now kind of inefficient (we only want to know if there are any), but since
40 # its an edit control its not significant
41 my @part_tag = qsearch({
42   'table'     => 'part_tag',
43   'hashref'   => {},
44   'extra_sql' => $extra_sql,
45 });
46
47 </%init>