ANY/ALL customer tag search option, #19166
authorMark Wells <mark@freeside.biz>
Mon, 25 Mar 2013 23:35:52 +0000 (16:35 -0700)
committerMark Wells <mark@freeside.biz>
Mon, 25 Mar 2013 23:35:52 +0000 (16:35 -0700)
FS/FS/cust_main/Search.pm
httemplate/search/cust_main.html
httemplate/search/report_cust_main.html

index 2c7c046..f799b51 100644 (file)
@@ -794,11 +794,19 @@ sub search {
     @tagnums = grep /^(\d+)$/, @tagnums;
 
     if ( @tagnums ) {
+      if ( $params->{'all_tags'} ) {
+        foreach ( @tagnums ) {
+          push @where, 'exists(select 1 from cust_tag where '.
+                       'cust_tag.custnum = cust_main.custnum and tagnum = '.
+                       $_ . ')';
+        }
+      } else { # matching any tag, not all
        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;
+      }
     }
   }
 
index 8b39ea9..af9e959 100755 (executable)
@@ -46,6 +46,7 @@ my @scalars = qw (
   custbatch usernum
   cancelled_pkgs
   cust_fields flattened_pkgs
+  all_tags
 );
 
 for my $param ( @scalars ) {
index acc49ae..13f9396 100755 (executable)
       </TR>
 %   }
 
-    <& /elements/tr-select-cust_tag.html,
-                  'cgi'                 => $cgi,
-                  'is_report'    => 1,
-                  'multiple'     => 1,
-    &>
+      <TR>
+        <TD ALIGN="right">Tags</TD>
+        <TD>
+            <& /elements/select-cust_tag.html,
+                          'cgi'                => $cgi,
+                          'is_report'   => 1,
+                          'multiple'    => 1,
+            &>
+          <DIV STYLE="display:inline-block; vertical-align:baseline">
+            <INPUT TYPE="radio" NAME="all_tags" VALUE="0" CHECKED> Any of these
+            <BR>
+            <INPUT TYPE="radio" NAME="all_tags" VALUE="1"> All of these
+          </DIV>
+        </TD>
+      </TR>
 
     <& /elements/tr-select-payby.html,
                   'payby_type'   => 'cust',