summaryrefslogtreecommitdiff
path: root/httemplate/search
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-02-01 02:51:54 -0800
committerIvan Kohler <ivan@freeside.biz>2013-02-01 02:51:54 -0800
commiteb26deab89a94f5ba7a2d21fa2a5a98cb7bb8885 (patch)
treed4dde7fff57a6880a716fe102573483c3f8e6e7b /httemplate/search
parent206b339a530130306e65d05cff1bbe87eab4df1b (diff)
add advanced phone number search, RT#21054
Diffstat (limited to 'httemplate/search')
-rw-r--r--httemplate/search/elements/report_svc_Common.html94
-rw-r--r--httemplate/search/report_svc_phone.html36
-rw-r--r--httemplate/search/report_svc_phone_usage.html32
-rw-r--r--httemplate/search/svc_phone.cgi22
4 files changed, 151 insertions, 33 deletions
diff --git a/httemplate/search/elements/report_svc_Common.html b/httemplate/search/elements/report_svc_Common.html
new file mode 100644
index 000000000..04feb9e45
--- /dev/null
+++ b/httemplate/search/elements/report_svc_Common.html
@@ -0,0 +1,94 @@
+<%doc>
+
+Example:
+
+ <& elements/report_svc_Common.html,
+
+ #required
+ 'table' => 'svc_something',
+ 'title' => 'Page title',
+
+ #optional
+ 'action' => 'svc_tablename.html', #defaults to svc_tablename.html
+
+ &>
+
+</%doc>
+<& /elements/header.html, $title &>
+
+<FORM ACTION="<% $opt{'action'} || $opt{'table'}. '.html' %>" METHOD="GET">
+<INPUT TYPE="hidden" NAME="magic" VALUE="advanced">
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
+
+ <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
+ <TR>
+ <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH>
+ </TR>
+
+% unless ( $custnum ) {
+ <& /elements/tr-select-agent.html,
+ 'curr_value' => scalar( $cgi->param('agentnum') ),
+ 'disable_empty' => 0,
+ &>
+
+% # just this customer's domains?
+%# <& /elements/tr-select-domain.html,
+%# 'element_name' => 'domsvc',
+%# 'curr_value' => scalar( $cgi->param('domsvc') ),
+%# 'disable_empty' => 0,
+%# &>
+% }
+
+ <& /elements/tr-selectmultiple-part_pkg.html &>
+
+ <& /elements/tr-select-part_svc.html, 'svcdb'=>$svcdb &>
+
+ <TR>
+ <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
+ </TR>
+
+ <TR>
+ <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Display options') |h %></FONT></TH>
+ </TR>
+
+% #"package fields" ala advanced svc_acct search?
+% #move to /elements/tr-select-cust_pkg-fields and use it from there if so...
+
+ <& /elements/tr-select-cust-fields.html &>
+
+ </TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
+
+</FORM>
+
+<& /elements/footer.html &>
+<%init>
+
+my(%opt) = @_;
+
+my $svcdb = $opt{'table'};
+
+my $name = "FS::$svcdb"->table_info->{'name_plural'}
+ || PL( "FS::$svcdb"->table_info->{'name'} );
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right("Services: $name: Advanced search");
+
+my $title = $opt{'title'};
+
+#false laziness w/report_cust_pkg.html
+my $custnum = '';
+if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+ $custnum = $1;
+ my $cust_main = qsearchs({
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => $custnum },
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+ }) or die "unknown custnum $custnum";
+ $title = mt("$title: [_1]", $cust_main->name);
+}
+
+</%init>
diff --git a/httemplate/search/report_svc_phone.html b/httemplate/search/report_svc_phone.html
index 9f1042608..63ca03e16 100644
--- a/httemplate/search/report_svc_phone.html
+++ b/httemplate/search/report_svc_phone.html
@@ -1,32 +1,6 @@
-<% include('/elements/header.html', 'Phone number total usage' ) %>
+<& elements/report_svc_Common.html,
+ 'table' => 'svc_phone',
+ 'title' => 'Phone number report',
-<FORM ACTION="svc_phone.cgi" METHOD="GET">
-
-<INPUT TYPE="hidden" NAME="magic" VALUE="all">
-<INPUT TYPE="hidden" NAME="usage_total" VALUE="1">
-
-<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
-
-%# <TR>
-%# <TH CLASS="background" COLSPAN=2 ALIGN="left">
-%# <FONT SIZE="+1">Search options</FONT>
-%# </TH>
-%# </TR>
-
- <% include ( '/elements/tr-input-beginning_ending.html', prefix=>'usage' ) %>
-
-</TABLE>
-
-<BR>
-<INPUT TYPE="submit" VALUE="Search phone numbers">
-
-</FORM>
-
-<% include('/elements/footer.html') %>
-<%init>
-
-#? 'List services' ? something new?
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
-
-</%init>
+ 'action' => 'svc_phone.cgi',
+&>
diff --git a/httemplate/search/report_svc_phone_usage.html b/httemplate/search/report_svc_phone_usage.html
new file mode 100644
index 000000000..9f1042608
--- /dev/null
+++ b/httemplate/search/report_svc_phone_usage.html
@@ -0,0 +1,32 @@
+<% include('/elements/header.html', 'Phone number total usage' ) %>
+
+<FORM ACTION="svc_phone.cgi" METHOD="GET">
+
+<INPUT TYPE="hidden" NAME="magic" VALUE="all">
+<INPUT TYPE="hidden" NAME="usage_total" VALUE="1">
+
+<TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+
+%# <TR>
+%# <TH CLASS="background" COLSPAN=2 ALIGN="left">
+%# <FONT SIZE="+1">Search options</FONT>
+%# </TH>
+%# </TR>
+
+ <% include ( '/elements/tr-input-beginning_ending.html', prefix=>'usage' ) %>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="Search phone numbers">
+
+</FORM>
+
+<% include('/elements/footer.html') %>
+<%init>
+
+#? 'List services' ? something new?
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
+
+</%init>
diff --git a/httemplate/search/svc_phone.cgi b/httemplate/search/svc_phone.cgi
index 29434083f..7fadbbbb7 100644
--- a/httemplate/search/svc_phone.cgi
+++ b/httemplate/search/svc_phone.cgi
@@ -9,7 +9,7 @@
'Country code',
'Phone number',
@header,
- FS::UI::Web::cust_header(),
+ FS::UI::Web::cust_header($cgi->param('cust_fields')),
],
'fields' => [ 'svcnum',
'svc',
@@ -24,7 +24,7 @@
$link,
( map '', @header ),
( map { $_ ne 'Cust. Status' ? $link_cust : '' }
- FS::UI::Web::cust_header()
+ FS::UI::Web::cust_header($cgi->param('cust_fields'))
),
],
'align' => 'rlrr'.
@@ -119,6 +119,24 @@ if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
}
+} elsif ( $cgi->param('magic') =~ /^advanced$/ ) {
+
+ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+ push @extra_sql, "agentnum = $1";
+ }
+
+ my $pkgpart = [ grep /^(\d+)$/, $cgi->param('pkgpart') ];
+ if ( @$pkgpart ) {
+ push @extra_sql,
+ 'cust_pkg.pkgpart IN ('. join(',', @$pkgpart ). ')';
+ }
+
+ my $svcpart = [ grep /^(\d+)$/, $cgi->param('svcpart') ];
+ if ( @$svcpart ) {
+ push @extra_sql,
+ 'svcpart IN ('. join(',', @$svcpart ). ')';
+ }
+
} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
push @extra_sql, "svcpart = $1";
} else {