[freeside-commits] freeside/httemplate/search cust_main.html, 1.20, 1.21 cust_pkg.cgi, 1.67, 1.68 svc_broadband.cgi, 1.10, 1.11 report_svc_broadband.html, NONE, 1.1
Mark Wells
mark at wavetail.420.am
Fri Sep 17 11:07:10 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv685/httemplate/search
Modified Files:
cust_main.html cust_pkg.cgi svc_broadband.cgi
Added Files:
report_svc_broadband.html
Log Message:
email_search_result for cust_pkg and svc_broadband, RT#8736
Index: svc_broadband.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_broadband.cgi,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- svc_broadband.cgi 26 Jul 2009 20:23:31 -0000 1.10
+++ svc_broadband.cgi 17 Sep 2010 18:07:08 -0000 1.11
@@ -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 );
}
-
-} 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'";
+else {
+ foreach (qw(custnum agentnum svcpart)) {
+ $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
+ }
+ foreach (qw(pkgpart routernum)) {
+ $search_hash{$_} = [ $cgi->param($_) ] if $cgi->param($_);
}
-
-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 );
}
-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;
+if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
+ $search_hash{'order_by'} = $1;
+}
-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_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
+my $html_init = include('/elements/email-link.html',
+ 'search_hash' => \%search_hash,
+ 'table' => 'svc_broadband'
+ );
+
</%init>
Index: cust_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_pkg.cgi,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -w -d -r1.67 -r1.68
--- cust_pkg.cgi 9 Aug 2010 01:03:49 -0000 1.67
+++ cust_pkg.cgi 17 Sep 2010 18:07:08 -0000 1.68
@@ -290,6 +290,10 @@
'height' => 210,
). '<BR>';
}
+ $text .= include( '/elements/email-link.html',
+ 'search_hash' => \%search_hash,
+ 'table' => 'cust_pkg',
+ );
}
return $text;
};
Index: cust_main.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_main.html,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -d -r1.20 -r1.21
--- cust_main.html 29 Mar 2010 09:18:23 -0000 1.20
+++ cust_main.html 17 Sep 2010 18:07:08 -0000 1.21
@@ -104,7 +104,7 @@
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",
}
--- NEW FILE: report_svc_broadband.html ---
<% 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>
More information about the freeside-commits
mailing list