improvements to bulk DID orders, RT11291
[freeside.git] / httemplate / search / report_svc_broadband.html
1 <% include('/elements/header.html', $title ) %>
2
3 <FORM ACTION="svc_broadband.cgi" METHOD="GET">
4 <INPUT TYPE="hidden" NAME="magic" VALUE="advanced">
5 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
6 %# extensive false laziness with svc_acct
7   <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
8
9     <TR>
10       <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH>
11     </TR>
12
13 % unless ( $custnum ) {
14     <% include( '/elements/tr-select-agent.html',
15                     'curr_value'    => scalar( $cgi->param('agentnum') ),
16                     'disable_empty' => 0,
17               )
18     %>
19
20     <% include( '/elements/tr-select-table.html',
21                     'label'         => 'Routers',
22                     'table'         => 'router',
23                     'name_col'      => 'routername',
24                     'curr_value'    => $routernum,
25                     'hashref'       => {},
26                     'multiple'      => 'multiple',
27               )
28     %>
29 % }
30
31     <% include( '/elements/tr-selectmultiple-part_pkg.html',
32                 %pkg_search,
33               )
34     %> 
35
36     <TR>
37       <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
38     </TR>
39  
40     <TR>
41       <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
42     </TR>
43
44 %   #move to /elements/tr-select-cust_pkg-fields if anything else needs it...
45     <TR>
46       <TD ALIGN="right">Package fields</TD>
47       <TD>
48         <SELECT NAME="cust_pkg_fields">
49           <OPTION VALUE="">(none)
50           <OPTION VALUE="setup,last_bill,bill,cancel">Setup date | Last bill date | Next bill date | Cancel date
51         </SELECT>
52       </TD>
53     </TR>
54
55     <% include( '/elements/tr-select-cust-fields.html' ) %>
56                        
57   </TABLE>
58
59 <BR>
60 <INPUT TYPE="submit" VALUE="Get Report">
61
62 </FORM>
63
64 <% include('/elements/footer.html') %>
65 <%init>
66
67 die "access denied"
68   unless $FS::CurrentUser::CurrentUser->access_right('List packages'); #?
69
70 my $title = 'Broadband Service Report';
71 my $routernum = [ $cgi->param('routernum') || '' ];
72 $routernum = join(',', @$routernum);
73
74 #false laziness w/report_cust_pkg.html
75 my $custnum = '';
76 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
77   $custnum = $1;
78   my $cust_main = qsearchs({
79     'table'     => 'cust_main', 
80     'hashref'   => { 'custnum' => $custnum },
81     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
82   }) or die "unknown custnum $custnum";
83   $title .= ': '. $cust_main->name;
84 }
85
86 # exclude one-time charges, disabled packages, and packages with no 
87 # broadband services
88 my %pkg_search = (
89   'extra_sql'   => "
90 WHERE freq != '0' AND disabled IS NULL AND 0 < (
91   SELECT COUNT(*) FROM part_svc JOIN pkg_svc USING ( svcpart ) 
92   WHERE pkg_svc.pkgpart = part_pkg.pkgpart AND part_svc.svcdb = 'svc_broadband'
93   AND pkg_svc.quantity > 0
94 )",
95 );
96
97 </%init>
98 <%once>
99
100 </%once>