add a multi-select for tags to advanced customer search, RT6376
authorlevinse <levinse>
Fri, 5 Nov 2010 03:56:07 +0000 (03:56 +0000)
committerlevinse <levinse>
Fri, 5 Nov 2010 03:56:07 +0000 (03:56 +0000)
FS/FS/cust_main/Search.pm
httemplate/elements/tr-select-cust_tag.html
httemplate/search/cust_main.html
httemplate/search/report_cust_main.html

index ac170ff..ad24ff8 100644 (file)
@@ -658,6 +658,21 @@ sub search {
     push @where,
       "cust_main.custbatch = '$1'";
   }
+  
+  if ( $params->{'tagnum'} ) {
+    my @tagnums = ref( $params->{'tagnum'} ) ? @{ $params->{'tagnum'} } : ( $params->{'tagnum'} );
+
+    @tagnums = grep /^(\d+)$/, @tagnums;
+
+    if ( @tagnums ) {
+       my $tags_where = "0 < (select count(1) from cust_tag where " 
+               . " cust_tag.custnum = cust_main.custnum and tagnum in ("
+               . join(',', @tagnums) . "))";
+
+       push @where, $tags_where;
+    }
+  }
+
 
   ##
   # setup queries, subs, etc. for the search
index d88f3a8..b2b6d96 100644 (file)
@@ -1,4 +1,4 @@
-% if ( $curuser->access_right('Edit customer tags') && @part_tag ) {
+% if ( ($curuser->access_right('Edit customer tags') && @part_tag) || $is_report ) {
 
   <TR>
     <TD ALIGN="right"><% $opt{'label'} || 'Tags' %></TD>
@@ -25,6 +25,7 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 
 my %opt = @_;
 my $cgi = $opt{'cgi'};
+my $is_report = $opt{'is_report'};
 
 my @curr_tagnum = ();
 if ( $cgi->param('error') ) {
index 5bfdf17..04ecf89 100755 (executable)
@@ -56,7 +56,7 @@ for my $param ( @scalars ) {
 }
 
 #lists
-for my $param (qw( classnum payby )) {
+for my $param (qw( classnum payby tagnum )) {
   $search_hash{$param} = [ $cgi->param($param) ];
 }
 
index 03b3452..d6be4fb 100755 (executable)
 
 %   }
 
+    <% include( '/elements/tr-select-cust_tag.html',
+                 'cgi'          => $cgi,
+                 'is_report'    => 1,
+                  'multiple'     => 1,
+                  'all_selected' => 1,
+              )
+    %>
+
     <% include( '/elements/tr-select-payby.html',
                   'payby_type'   => 'cust',
                   'multiple'     => 1,