summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2010-11-05 03:56:07 +0000
committerlevinse <levinse>2010-11-05 03:56:07 +0000
commit042d37f557e3ad0cf2f02753d20e70dfbd1f73a9 (patch)
tree6378701fc2924e3233ce72cc61f95c3d5e9f1eb0
parentd86c2687d55370e9aee258b7ed9b34ab181ffbf1 (diff)
add a multi-select for tags to advanced customer search, RT6376
-rw-r--r--FS/FS/cust_main/Search.pm15
-rw-r--r--httemplate/elements/tr-select-cust_tag.html3
-rwxr-xr-xhttemplate/search/cust_main.html2
-rwxr-xr-xhttemplate/search/report_cust_main.html8
4 files changed, 26 insertions, 2 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index ac170ff1f..ad24ff86e 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -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
diff --git a/httemplate/elements/tr-select-cust_tag.html b/httemplate/elements/tr-select-cust_tag.html
index d88f3a894..b2b6d967e 100644
--- a/httemplate/elements/tr-select-cust_tag.html
+++ b/httemplate/elements/tr-select-cust_tag.html
@@ -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') ) {
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html
index 5bfdf170b..04ecf894a 100755
--- a/httemplate/search/cust_main.html
+++ b/httemplate/search/cust_main.html
@@ -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) ];
}
diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html
index 03b3452d6..d6be4fbc6 100755
--- a/httemplate/search/report_cust_main.html
+++ b/httemplate/search/report_cust_main.html
@@ -50,6 +50,14 @@
% }
+ <% 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,