miss you, mark
[freeside.git] / httemplate / view / bill_batch.cgi
1 <% include('/search/elements/search.html', 
2               'title'     => $close ?
3                               "Batch $batchnum closed." :
4                               "Invoice Batch $batchnum",
5               'menubar'   => ['All batches' => $p.'search/bill_batch.cgi'],
6               'name'      => 'invoices',
7               'query'     => { 'table'   => 'cust_bill_batch',
8                                'select'  => join(', ',
9                                           'cust_bill.*',
10                                           FS::UI::Web::cust_sql_fields(),
11                                           'cust_main.custnum AS cust_main_custnum',
12                                 ),
13                                'hashref' => { },
14                                'addl_from' => 
15                                  'LEFT JOIN cust_bill USING ( invnum ) '.
16                                  FS::UI::Web::join_cust_main('cust_bill'),
17                                'extra_sql' => " WHERE batchnum = $batchnum",
18                              },
19               'count_query' => "SELECT COUNT(*) FROM cust_bill_batch WHERE batchnum = $batchnum",
20               'html_init' => $html_init,
21               'header'    => [ 'Invoice #',
22                                'Amount',
23                                'Date',
24                                'Customer',
25                              ],
26               'fields'    => [ sub { shift->cust_bill->display_invnum },
27                                sub { sprintf($money_char.'%.2f', 
28                                       shift->cust_bill->charged ) },
29                                sub { time2str('%b %d %Y', 
30                                       shift->cust_bill->_date ) },
31                                sub { shift->cust_bill->cust_main->name },
32                              ],
33               'align'     => 'rrll',
34               'links'     => [ ($link) x 3, $clink,
35                              ],
36               'really_disable_download' => 1,
37 ) %>
38 <%init>
39
40 die "access denied"
41   unless $FS::CurrentUser::CurrentUser->access_right('View invoices');
42
43 my $conf = new FS::Conf;
44 my $batch;
45 my $batchnum = $cgi->param('batchnum');
46
47 $batch = FS::bill_batch->by_key($batchnum);
48 die "Batch '$batchnum' not found!\n" if !$batch;
49
50 my $close = $cgi->param('close');
51 $batch->close if $close;
52
53 my $html_init = qq!<FORM NAME="OneTrueForm">
54   <INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">! .
55   include('/elements/progress-init.html',
56     'OneTrueForm',
57     [ 'batchnum' ],
58     $p.'misc/process/bill_batch-print.html',
59     { url => $p.'misc/download-bill_batch.html?'.$batchnum }
60   ) .
61   '<A HREF="#" onclick="process();">Download this batch</A></FORM><BR>';
62 if ( $batch->status eq 'O' ) {
63   $cgi->param('close' => 1);
64   $html_init .= '<A HREF="'.$cgi->self_url.'">Close this batch</A><BR>';
65 }
66 $html_init .= '<BR>';
67
68 my $link = [ "$p/view/cust_bill.cgi?", 'invnum' ];
69 my $clink = [ "$p/view/cust_main.cgi?", 'custnum' ];
70 my $money_char = $conf->config('money_char') || '$';
71
72 </%init>