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";
18 $where .= " AND statustext != '' AND statustext IS NOT NULL"
19 if $cgi->param('failed');
22 'table' => 'cust_bill_event',
25 'select' => join(', ',
27 'part_bill_event.event',
29 'cust_bill._date AS cust_bill_date',
30 'cust_main.custnum AS cust_main_custnum',
31 FS::UI::Web::cust_sql_fields(),
33 'extra_sql' => "$where ORDER BY _date ASC",
34 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '.
35 'LEFT JOIN cust_bill USING ( invnum ) '.
36 'LEFT JOIN cust_main USING ( custnum ) ',
39 my $count_sql = "select count(*) from cust_bill_event $where";
41 my $conf = new FS::Conf;
43 my $failed = $cgi->param('failed');
45 my $html_init = join("\n", map {
46 ( my $action = $_ ) =~ s/_$//;
47 include('/elements/progress-init.html',
49 [ 'action', 'beginning', 'ending', 'failed' ],
50 "../misc/${_}invoice_events.cgi",
51 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
54 qq!<FORM NAME="${_}form">!,
55 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
56 qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!,
57 qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!,
58 qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!,
60 } qw( print_ email_ fax_ ) );
64 'Re-print these events' =>
65 "javascript:print_process()",
66 'Re-email these events' =>
67 "javascript:email_process()",
70 push @$menubar, 'Re-fax these events' =>
71 "javascript:fax_process()"
72 if $conf->exists('hylafax');
75 my $cust_bill_event = shift;
76 $cust_bill_event->cust_main_custnum
77 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
81 %><%= include( 'elements/search.html',
83 'html_init' => $html_init,
84 'menubar' => $menubar,
85 'name' => 'billing events',
86 'query' => $sql_query,
87 'count_query' => $count_sql,
88 'header' => [ 'Event',
91 #'Inv #', 'Inv Date', 'Cust #',
93 FS::UI::Web::cust_header(),
97 sub { time2str("%b %d %Y %T", $_[0]->_date) },
99 #my $cust_bill_event = shift;
100 my $status = $_[0]->status;
101 $status .= ': '.$_[0]->statustext
102 if $_[0]->statustext;
106 #my $cust_bill_event = shift;
107 'Invoice #'. $_[0]->invnum.
109 time2str("%D", $_[0]->cust_bill_date).
112 \&FS::UI::Web::cust_fields,
119 my $part_bill_event = shift;
120 my $template = $part_bill_event->templatename;
121 $template .= '-' if $template;
122 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
124 ( map { $link_cust } FS::UI::Web::cust_header() ),