add per-customer "Invoice reports" link, RT#13802
[freeside.git] / httemplate / search / report_cust_bill.html
1 <% include('/elements/header.html', $title ) %>
2
3 <FORM ACTION="cust_bill.html" METHOD="GET">
4 <INPUT TYPE="hidden" NAME="magic" VALUE="_date">
5 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
6
7 <TABLE BGCOLOR="#cccccc" CELLSPACING=0
8
9 % unless ( $custnum ) {
10   <% include( '/elements/tr-select-agent.html',
11                  'curr_value'    => scalar( $cgi->param('agentnum') ),
12                  'label'         => 'Invoices for agent: ',
13                  'disable_empty' => 0,
14              )
15   %>
16 % }
17
18   <% include( '/elements/tr-input-beginning_ending.html' ) %>
19
20   <% include( '/elements/tr-input-lessthan_greaterthan.html',
21                 label   => 'Charged',
22                 field   => 'charged',
23             )
24   %>
25
26   <% include( '/elements/tr-input-lessthan_greaterthan.html',
27                 label   => 'Owed',
28                 field   => 'owed',
29             )
30   %>
31
32 % if ( $cust_main ) {
33   <INPUT TYPE="hidden" NAME="payby" VALUE="<% $cust_main->payby %>">
34 % } else {
35   <% include( '/elements/tr-select-payby.html',
36                 label   => 'Payment method:',
37                 payby_type   => 'cust',
38                 multiple     => 1,
39                 all_selected => 1,
40             )
41   %>
42 % }
43
44   <TR>
45     <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="open" VALUE="1" CHECKED></TD>
46     <TD>Show only open invoices</TD>
47   </TR>
48
49 % unless ( $custnum ) {
50   <TR>
51     <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="newest_percust" VALUE="1"></TD>
52     <TD>Show only the single most recent invoice per-customer</TD>
53   </TR>
54 % }
55
56 </TABLE>
57
58 <BR>
59 <INPUT TYPE="submit" VALUE="Get Report">
60
61 </FORM>
62
63 <% include('/elements/footer.html') %>
64 <%init>
65
66 die "access denied"
67   unless $FS::CurrentUser::CurrentUser->access_right('List invoices');
68
69 my $title = 'Invoice Report';
70
71 #false laziness w/report_cust_pkg.html
72 my $custnum = '';
73 my $cust_main = '';
74 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
75   $custnum = $1;
76   $cust_main = qsearchs({
77     'table'     => 'cust_main', 
78     'hashref'   => { 'custnum' => $custnum },
79     'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
80   }) or die "unknown custnum $custnum";
81   $title .= ': '. $cust_main->name;
82 }
83
84 </%init>