fix top subtotals on refund reports
[freeside.git] / httemplate / search / report_svc_broadband.html
1 <% include('/elements/header.html', $title ) %>
2
3 <FORM ACTION="svc_broadband.cgi" METHOD="POST">
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     <tr>
30       <td></td>
31       <td><input type="checkbox" name="routernum" value="none" checked> Include services with no router</td>
32     </tr>
33
34     <% include( '/elements/tr-selectmultiple-part_pkg.html',
35                 %pkg_search,
36               )
37     %> 
38
39 %     if ( FS::tower_sector->count > 0 ) {
40     <& /elements/tr-select-tower_sector.html,
41           'multiple'    => 1,
42           'label'       => 'Tower/Sector',
43     &>
44 %     }
45
46 %   }
47     <TR>
48       <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
49     </TR>
50  
51     <TR>
52       <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
53     </TR>
54
55 %   #move to /elements/tr-select-cust_pkg-fields if anything else needs it...
56     <TR>
57       <TD ALIGN="right">Package fields</TD>
58       <TD>
59         <SELECT NAME="cust_pkg_fields">
60           <OPTION VALUE="">(none)
61           <OPTION VALUE="setup,last_bill,bill,cancel">Setup date | Last bill date | Next bill date | Cancel date
62           <OPTION VALUE="package,setup,last_bill,bill,cancel">Package Name | Setup date | Last bill date | Next bill date | Cancel date
63         </SELECT>
64       </TD>
65     </TR>
66
67     <% include( '/elements/tr-select-cust-fields.html' ) %>
68                        
69   </TABLE>
70
71 <BR>
72 <INPUT TYPE="submit" VALUE="Get Report">
73
74 </FORM>
75
76 <% include('/elements/footer.html') %>
77 <%init>
78
79 die "access denied"
80   unless $FS::CurrentUser::CurrentUser->access_right('Services: Wireless broadband services: Advanced search');
81
82 my $title = 'Broadband Service Report';
83 my $routernum = [ $cgi->param('routernum') || '' ];
84 $routernum = join(',', @$routernum);
85
86 #false laziness w/report_cust_pkg.html
87 my $custnum = '';
88 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
89   $custnum = $1;
90   my $cust_main = qsearchs({
91     'table'     => 'cust_main', 
92     'hashref'   => { 'custnum' => $custnum },
93     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
94   }) or die "unknown custnum $custnum";
95   $title .= ': '. $cust_main->name;
96 }
97
98 # exclude one-time charges, disabled packages, and packages with no 
99 # broadband services
100 my %pkg_search = (
101   'extra_sql'   => "
102 WHERE freq != '0' AND disabled IS NULL AND 0 < (
103   SELECT COUNT(*) FROM part_svc JOIN pkg_svc USING ( svcpart ) 
104   WHERE pkg_svc.pkgpart = part_pkg.pkgpart AND part_svc.svcdb = 'svc_broadband'
105   AND pkg_svc.quantity > 0
106 )",
107 );
108
109 </%init>
110 <%once>
111
112 </%once>