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 != '' ".
19 " AND statustext IS NOT NULL ".
20 " AND statustext != 'N/A' "
21 if $cgi->param('failed');
24 'table' => 'cust_bill_event',
27 'select' => join(', ',
29 'part_bill_event.event',
31 'cust_bill._date AS cust_bill_date',
32 'cust_main.custnum AS cust_main_custnum',
33 FS::UI::Web::cust_sql_fields(),
35 'extra_sql' => "$where ORDER BY _date ASC",
36 'addl_from' => 'LEFT JOIN part_bill_event USING ( eventpart ) '.
37 'LEFT JOIN cust_bill USING ( invnum ) '.
38 'LEFT JOIN cust_main USING ( custnum ) ',
41 my $count_sql = "select count(*) from cust_bill_event $where";
43 my $conf = new FS::Conf;
45 my $failed = $cgi->param('failed');
47 my $html_init = join("\n", map {
48 ( my $action = $_ ) =~ s/_$//;
49 include('/elements/progress-init.html',
51 [ 'action', 'beginning', 'ending', 'failed' ],
52 "../misc/${_}invoice_events.cgi",
53 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
56 qq!<FORM NAME="${_}form">!,
57 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
58 qq!<INPUT TYPE="hidden" NAME="beginning" VALUE="$beginning">!,
59 qq!<INPUT TYPE="hidden" NAME="ending" VALUE="$ending">!,
60 qq!<INPUT TYPE="hidden" NAME="failed" VALUE="$failed">!,
62 } qw( print_ email_ fax_ ) );
66 'Re-print these events' =>
67 "javascript:print_process()",
68 'Re-email these events' =>
69 "javascript:email_process()",
72 push @$menubar, 'Re-fax these events' =>
73 "javascript:fax_process()"
74 if $conf->exists('hylafax');
77 my $cust_bill_event = shift;
78 $cust_bill_event->cust_main_custnum
79 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
83 %><%= include( 'elements/search.html',
85 'html_init' => $html_init,
86 'menubar' => $menubar,
87 'name' => 'billing events',
88 'query' => $sql_query,
89 'count_query' => $count_sql,
90 'header' => [ 'Event',
93 #'Inv #', 'Inv Date', 'Cust #',
95 FS::UI::Web::cust_header(),
99 sub { time2str("%b %d %Y %T", $_[0]->_date) },
101 #my $cust_bill_event = shift;
102 my $status = $_[0]->status;
103 $status .= ': '.$_[0]->statustext
104 if $_[0]->statustext;
108 #my $cust_bill_event = shift;
109 'Invoice #'. $_[0]->invnum.
111 time2str("%D", $_[0]->cust_bill_date).
114 \&FS::UI::Web::cust_fields,
121 my $part_bill_event = shift;
122 my $template = $part_bill_event->templatename;
123 $template .= '-' if $template;
124 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
126 ( map { $link_cust } FS::UI::Web::cust_header() ),