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 map "cust_main.$_", qw(last first company)
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');
74 %><%= include( 'elements/search.html',
76 'html_init' => $html_init,
77 'menubar' => $menubar,
78 'name' => 'billing events',
79 'query' => $sql_query,
80 'count_query' => $count_sql,
81 'header' => [ qw( Event Date Status ),
82 #'Inv #', 'Inv Date', 'Cust #',
87 sub { time2str("%b %d %Y %T", $_[0]->_date) },
89 #my $cust_bill_event = shift;
90 my $status = $_[0]->status;
91 $status .= ': '.$_[0]->statustext
96 #my $cust_bill_event = shift;
97 'Invoice #'. $_[0]->invnum.
99 time2str("%D", $_[0]->cust_bill_date).
102 sub { FS::cust_main::name($_[0]) },
111 my $part_bill_event = shift;
112 my $template = $part_bill_event->templatename;
113 $template .= '-' if $template;
114 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
116 [ "${p}view/cust_main.cgi?", 'custnum' ],
117 [ "${p}view/cust_main.cgi?", 'custnum' ],