diff options
author | mark <mark> | 2010-09-17 18:12:08 +0000 |
---|---|---|
committer | mark <mark> | 2010-09-17 18:12:08 +0000 |
commit | 6c9cd1c36adbb9fc950fcf0a0b269fa6f16838a1 (patch) | |
tree | 1c90e0377b37a98bd7a1757532648a9e966f291a /httemplate/search | |
parent | 853fca259ec006d4a5f3ce046e5334210412baac (diff) |
email_search_result for cust_pkg and svc_broadband, RT#8736
Diffstat (limited to 'httemplate/search')
-rwxr-xr-x | httemplate/search/cust_main.html | 2 | ||||
-rwxr-xr-x | httemplate/search/cust_pkg.cgi | 4 | ||||
-rwxr-xr-x | httemplate/search/report_svc_broadband.html | 100 | ||||
-rwxr-xr-x | httemplate/search/svc_broadband.cgi | 75 |
4 files changed, 127 insertions, 54 deletions
diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 270fc38cc..4465c3324 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -104,7 +104,7 @@ if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) my $query = $uri->query; push @$menubar, 'Email a notice to these customers' => - "${p}misc/email-customers.html?$query", + "${p}misc/email-customers.html?table=cust_main&$query", } diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index bd8ea9aa6..da4371f5e 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -290,6 +290,10 @@ my $html_init = sub { 'height' => 210, ). '<BR>'; } + $text .= include( '/elements/email-link.html', + 'search_hash' => \%search_hash, + 'table' => 'cust_pkg', + ); } return $text; }; diff --git a/httemplate/search/report_svc_broadband.html b/httemplate/search/report_svc_broadband.html new file mode 100755 index 000000000..8571ef184 --- /dev/null +++ b/httemplate/search/report_svc_broadband.html @@ -0,0 +1,100 @@ +<% include('/elements/header.html', $title ) %> + +<FORM ACTION="svc_broadband.cgi" METHOD="GET"> +<INPUT TYPE="hidden" NAME="magic" VALUE="advanced"> +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> +%# extensive false laziness with svc_acct + <TABLE BGCOLOR="#cccccc" CELLSPACING=0> + + <TR> + <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH> + </TR> + +% unless ( $custnum ) { + <% include( '/elements/tr-select-agent.html', + 'curr_value' => scalar( $cgi->param('agentnum') ), + 'disable_empty' => 0, + ) + %> + + <% include( '/elements/tr-select-table.html', + 'label' => 'Routers', + 'table' => 'router', + 'name_col' => 'routername', + 'curr_value' => $routernum, + 'hashref' => {}, + 'multiple' => 'multiple', + ) + %> +% } + + <% include( '/elements/tr-selectmultiple-part_pkg.html', + %pkg_search, + ) + %> + + <TR> + <TH CLASS="background" COLSPAN=2> </TH> + </TR> + + <TR> + <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH> + </TR> + +% #move to /elements/tr-select-cust_pkg-fields if anything else needs it... + <TR> + <TD ALIGN="right">Package fields</TD> + <TD> + <SELECT NAME="cust_pkg_fields"> + <OPTION VALUE="">(none) + <OPTION VALUE="setup,last_bill,bill,cancel">Setup date | Last bill date | Next bill date | Cancel date + </SELECT> + </TD> + </TR> + + <% include( '/elements/tr-select-cust-fields.html' ) %> + + </TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Get Report"> + +</FORM> + +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List packages'); #? + +my $title = 'Broadband Service Report'; +my $routernum = [ $cgi->param('routernum') || '' ]; +$routernum = join(',', @$routernum); + +#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 .= ': '. $cust_main->name; +} + +# exclude one-time charges, disabled packages, and packages with no +# broadband services +my %pkg_search = ( + 'extra_sql' => " +WHERE freq != '0' AND disabled IS NULL AND 0 < ( + SELECT COUNT(*) FROM part_svc JOIN pkg_svc USING ( svcpart ) + WHERE pkg_svc.pkgpart = part_pkg.pkgpart AND part_svc.svcdb = 'svc_broadband' + AND pkg_svc.quantity > 0 +)", +); + +</%init> +<%once> + +</%once> diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi index d0b102957..7026f52e3 100755 --- a/httemplate/search/svc_broadband.cgi +++ b/httemplate/search/svc_broadband.cgi @@ -1,8 +1,9 @@ <% include( 'elements/search.html', 'title' => 'Broadband Search Results', 'name' => 'broadband services', + 'html_init' => $html_init, 'query' => $sql_query, - 'count_query' => $count_query, + 'count_query' => $sql_query->{'count_query'}, 'redirect' => [ popurl(2). "view/svc_broadband.cgi?", 'svcnum' ], 'header' => [ '#', 'Service', @@ -43,66 +44,29 @@ %> <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('List services'); +die "access denied" unless + $FS::CurrentUser::CurrentUser->access_right('List services'); my $conf = new FS::Conf; -my $orderby = 'ORDER BY svcnum'; -my %svc_broadband = (); -my @extra_sql = (); -if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { - - push @extra_sql, 'pkgnum IS NULL' - if $cgi->param('magic') eq 'unlinked'; - - if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { - my $sortby = $1; - $orderby = "ORDER BY $sortby"; +my %search_hash; +if ( $cgi->param('magic') eq 'unlinked' ) { + %search_hash = ( 'unlinked' => 1 ); +} +else { + foreach (qw(custnum agentnum svcpart)) { + $search_hash{$_} = $cgi->param($_) if $cgi->param($_); + } + foreach (qw(pkgpart routernum)) { + $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_); } - -} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { - push @extra_sql, "svcpart = $1"; -} elsif ( $cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/ ) { - push @extra_sql, "ip_addr = '$1'"; } -my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. - ' LEFT JOIN part_svc USING ( svcpart ) '. - ' LEFT JOIN cust_pkg USING ( pkgnum ) '. - ' LEFT JOIN cust_main USING ( custnum ) '; - -push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql( - 'null_right' => 'View/link unlinked services' - ); - -my $extra_sql = ''; -if ( @extra_sql ) { - $extra_sql = ( keys(%svc_broadband) ? ' AND ' : ' WHERE ' ). - join(' AND ', @extra_sql ); +if ( $cgi->param('sortby') =~ /^(\w+)$/ ) { + $search_hash{'order_by'} = $1; } -my $count_query = "SELECT COUNT(*) FROM svc_broadband $addl_from "; -#if ( keys %svc_broadband ) { -# $count_query .= ' WHERE '. -# join(' AND ', map "$_ = ". dbh->quote($svc_broadband{$_}), -# keys %svc_broadband -# ); -#} -$count_query .= $extra_sql; - -my $sql_query = { - 'table' => 'svc_broadband', - 'hashref' => {}, #\%svc_broadband, - 'select' => join(', ', - 'svc_broadband.*', - 'part_svc.svc', - 'cust_main.custnum', - FS::UI::Web::cust_sql_fields(), - ), - 'extra_sql' => $extra_sql, - 'addl_from' => $addl_from, -}; +my $sql_query = FS::svc_broadband->search(\%search_hash); my %routerbyblock = (); foreach my $router (qsearch('router', {})) { @@ -120,4 +84,9 @@ my $link_router = sub { my $routernum = $routerbyblock{shift->blocknum}->routern my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ]; +my $html_init = include('/elements/email-link.html', + 'search_hash' => \%search_hash, + 'table' => 'svc_broadband' + ); + </%init> |