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')
71 or $curuser->access_right('View customer billing events')
72 && $cgi->param('invnum') =~ /^(\d+)$/;
74 my $title = $cgi->param('failed')
75 ? 'Failed invoice events'
80 if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {
81 push @search, "agentnum = $1";
82 #my $agent = qsearchs('agent', { 'agentnum' => $1 } );
83 #die "unknown agentnum $1" unless $agent;
86 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
87 push @search, "cust_bill_event._date >= $beginning",
88 "cust_bill_event._date <= $ending";
90 if ( $cgi->param('failed') ) {
91 push @search, "statustext != ''",
92 "statustext IS NOT NULL",
93 "statustext != 'N/A'";
96 if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) {
97 push @search, "part_bill_event.payby = '$1'";
100 if ( $cgi->param('invnum') =~ /^(\d+)$/ ) {
101 push @search, "cust_bill_event.invnum = '$1'";
104 #here is the agent virtualization
105 push @search, $FS::CurrentUser::CurrentUser->agentnums_sql;
107 my $where = 'WHERE '. join(' AND ', @search );
109 my $join = 'LEFT JOIN part_bill_event USING ( eventpart ) '.
110 'LEFT JOIN cust_bill USING ( invnum ) '.
111 'LEFT JOIN cust_main USING ( custnum ) ';
114 'table' => 'cust_bill_event',
115 'select' => join(', ',
117 'part_bill_event.event',
119 'cust_bill._date AS cust_bill_date',
120 'cust_main.custnum AS cust_main_custnum',
121 FS::UI::Web::cust_sql_fields(),
124 'extra_sql' => "$where ORDER BY _date ASC",
125 'addl_from' => $join,
128 my $count_sql = "SELECT COUNT(*) FROM cust_bill_event $join $where";
130 my $conf = new FS::Conf;
132 my $failed = $cgi->param('failed');
135 <FONT SIZE="+1">Invoice events are the deprecated, old-style actions taken o
136 n open invoices. See Reports->Billing events->Billing events for current event reports.</FONT><BR><BR>';
138 $html_init .= join("\n", map {
139 ( my $action = $_ ) =~ s/_$//;
140 include('/elements/progress-init.html',
142 [ 'action', 'beginning', 'ending', 'failed' ],
143 "../misc/${_}invoice_events.cgi",
144 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
147 qq!<FORM NAME="${_}form">!,
148 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
149 qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!,
150 qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!,
151 qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!,
153 } qw( print_ email_ fax_ ) );
156 'Re-print these events' =>
157 "javascript:print_process()",
158 'Re-email these events' =>
159 "javascript:email_process()",
162 push @$menubar, 'Re-fax these events' =>
163 "javascript:fax_process()"
164 if $conf->exists('hylafax');
166 my $link_cust = sub {
167 my $cust_bill_event = shift;
168 $cust_bill_event->cust_main_custnum
169 ? [ "${p}view/cust_main.cgi?", 'custnum' ]