3 my $title = $cgi->param('failed') ? 'Failed invoice events' : 'Invoice events';
5 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
7 ##tie my %hash, 'Tie::DxHash',
9 # _date => { op=> '>=', value=>$beginning },
11 ## _date => { op=> '<=', value=>$ending },
13 #$hash{'statustext'} = { op=> '!=', value=>'' }
14 # if $cgi->param('failed');
16 my $where = " WHERE cust_bill_event._date >= $beginning".
17 " AND cust_bill_event._date <= $ending";
19 if ( $cgi->param('failed') ) {
20 $where .= " AND statustext != '' ".
21 " AND statustext IS NOT NULL ".
22 " AND statustext != 'N/A' "
25 if ( $cgi->param('part_bill_event.payby') =~ /^(\w+)$/ ) {
26 $where .= " AND part_bill_event.payby = '$1' ";
30 'table' => 'cust_bill_event',
33 'select' => join(', ',
35 'part_bill_event.event',
37 'cust_bill._date AS cust_bill_date',
38 'cust_main.custnum AS cust_main_custnum',
39 FS::UI::Web::cust_sql_fields(),
41 'extra_sql' => "$where ORDER BY _date ASC",
42 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '.
43 'LEFT JOIN cust_bill USING ( invnum ) '.
44 'LEFT JOIN cust_main USING ( custnum ) ',
47 my $count_sql = "SELECT COUNT(*) FROM cust_bill_event ".
48 "LEFT JOIN part_bill_event USING ( eventpart ) ".
51 my $conf = new FS::Conf;
53 my $failed = $cgi->param('failed');
55 my $html_init = join("\n", map {
56 ( my $action = $_ ) =~ s/_$//;
57 include('/elements/progress-init.html',
59 [ 'action', 'beginning', 'ending', 'failed' ],
60 "../misc/${_}invoice_events.cgi",
61 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
64 qq!<FORM NAME="${_}form">!,
65 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
66 qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!,
67 qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!,
68 qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!,
70 } qw( print_ email_ fax_ ) );
74 'Re-print these events' =>
75 "javascript:print_process()",
76 'Re-email these events' =>
77 "javascript:email_process()",
80 push @$menubar, 'Re-fax these events' =>
81 "javascript:fax_process()"
82 if $conf->exists('hylafax');
85 my $cust_bill_event = shift;
86 $cust_bill_event->cust_main_custnum
87 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
91 %><%= include( 'elements/search.html',
93 'html_init' => $html_init,
94 'menubar' => $menubar,
95 'name' => 'billing events',
96 'query' => $sql_query,
97 'count_query' => $count_sql,
98 'header' => [ 'Event',
101 #'Inv #', 'Inv Date', 'Cust #',
103 FS::UI::Web::cust_header(),
107 sub { time2str("%b %d %Y %T", $_[0]->_date) },
109 #my $cust_bill_event = shift;
110 my $status = $_[0]->status;
111 $status .= ': '.$_[0]->statustext
112 if $_[0]->statustext;
116 #my $cust_bill_event = shift;
117 'Invoice #'. $_[0]->invnum.
119 time2str("%D", $_[0]->cust_bill_date).
122 \&FS::UI::Web::cust_fields,
129 my $part_bill_event = shift;
130 my $template = $part_bill_event->templatename;
131 $template .= '-' if $template;
132 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
134 ( map { $link_cust } FS::UI::Web::cust_header() ),