no need for scalar
[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     <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         </SELECT>
63       </TD>
64     </TR>
65
66     <% include( '/elements/tr-select-cust-fields.html' ) %>
67                        
68   </TABLE>
69
70 <BR>
71 <INPUT TYPE="submit" VALUE="Get Report">
72
73 </FORM>
74
75 <% include('/elements/footer.html') %>
76 <%init>
77
78 die "access denied"
79   unless $FS::CurrentUser::CurrentUser->access_right('Services: Wireless broadband services: Advanced search');
80
81 my $title = 'Broadband Service Report';
82 my $routernum = [ $cgi->param('routernum') || '' ];
83 $routernum = join(',', @$routernum);
84
85 #false laziness w/report_cust_pkg.html
86 my $custnum = '';
87 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
88   $custnum = $1;
89   my $cust_main = qsearchs({
90     'table'     => 'cust_main', 
91     'hashref'   => { 'custnum' => $custnum },
92     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
93   }) or die "unknown custnum $custnum";
94   $title .= ': '. $cust_main->name;
95 }
96
97 # exclude one-time charges, disabled packages, and packages with no 
98 # broadband services
99 my %pkg_search = (
100   'extra_sql'   => "
101 WHERE freq != '0' AND disabled IS NULL AND 0 < (
102   SELECT COUNT(*) FROM part_svc JOIN pkg_svc USING ( svcpart ) 
103   WHERE pkg_svc.pkgpart = part_pkg.pkgpart AND part_svc.svcdb = 'svc_broadband'
104   AND pkg_svc.quantity > 0
105 )",
106 );
107
108 </%init>
109 <%once>
110
111 </%once>