1 <% include( 'elements/search.html',
3 'html_init' => $html_init,
5 'name' => 'billing events',
7 'count_query' => $count_sql,
11 #'Inv #', 'Inv Date', 'Cust #',
13 FS::UI::Web::cust_header(),
17 sub { time2str("%b %d %Y %T", $_[0]->_date) },
19 #my $cust_bill_event = shift;
20 my $status = $_[0]->status;
21 $status .= ': '.$_[0]->statustext
26 #my $cust_bill_event = shift;
27 'Invoice #'. $_[0]->invnum.
29 time2str("%D", $_[0]->cust_bill_date).
32 \&FS::UI::Web::cust_fields,
34 'align' => 'lrlr'.FS::UI::Web::cust_aligns(),
40 my $part_bill_event = shift;
41 my $template = $part_bill_event->templatename;
42 $template .= '-' if $template;
43 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
45 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
46 FS::UI::Web::cust_header()
54 FS::UI::Web::cust_colors(),
61 FS::UI::Web::cust_styles(),
67 my $curuser = $FS::CurrentUser::CurrentUser;
70 unless $curuser->access_right('Billing event reports');
72 my $title = $cgi->param('failed')
73 ? 'Failed invoice events'
78 if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {
79 $search{agentnum} = $1;
82 ($search{beginning}, $search{ending})
83 = FS::UI::Web::parse_beginning_ending($cgi);
85 if ( $cgi->param('failed') ) {
86 $search{failed} = '1';
89 if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) {
93 my $where = 'WHERE '. FS::cust_bill_event->search_sql(\%search);
95 my $join = 'LEFT JOIN part_bill_event USING ( eventpart ) '.
96 'LEFT JOIN cust_bill USING ( invnum ) '.
97 'LEFT JOIN cust_main USING ( custnum ) ';
100 'table' => 'cust_bill_event',
101 'select' => join(', ',
103 'part_bill_event.event',
105 'cust_bill._date AS cust_bill_date',
106 'cust_main.custnum AS cust_main_custnum',
107 FS::UI::Web::cust_sql_fields(),
110 'extra_sql' => "$where ORDER BY _date ASC",
111 'addl_from' => $join,
114 my $count_sql = "SELECT COUNT(*) FROM cust_bill_event $join $where";
116 my $conf = new FS::Conf;
118 my $html_init = join("\n", map {
119 ( my $action = $_ ) =~ s/_$//;
120 include('/elements/progress-init.html',
123 "../misc/${_}invoice_events.cgi",
124 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
127 qq!<FORM NAME="${_}form">!,
128 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
129 (map {qq!<INPUT TYPE="hidden" NAME="$_" VALUE="$search{$_}">!} keys(%search)),
131 } qw( print_ email_ fax_ ) );
135 if ( $curuser->access_right('Resend invoices') ) {
137 push @$menubar, 'Re-print these events' =>
138 "javascript:print_process()",
139 'Re-email these events' =>
140 "javascript:email_process()",
143 push @$menubar, 'Re-fax these events' =>
144 "javascript:fax_process()"
145 if $conf->exists('hylafax');
149 my $link_cust = sub {
150 my $cust_bill_event = shift;
151 $cust_bill_event->cust_main_custnum
152 ? [ "${p}view/cust_main.cgi?", 'custnum' ]