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',
31 % #'hashref' => \%hash,
33 % 'select' => join(', ',
34 % 'cust_bill_event.*',
35 % 'part_bill_event.event',
36 % 'cust_bill.custnum',
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');
84 %my $link_cust = sub {
85 % my $cust_bill_event = shift;
86 % $cust_bill_event->cust_main_custnum
87 % ? [ "${p}view/cust_main.cgi?", 'custnum' ]
92 <% include( 'elements/search.html',
94 'html_init' => $html_init,
95 'menubar' => $menubar,
96 'name' => 'billing events',
97 'query' => $sql_query,
98 'count_query' => $count_sql,
99 'header' => [ 'Event',
102 #'Inv #', 'Inv Date', 'Cust #',
104 FS::UI::Web::cust_header(),
108 sub { time2str("%b %d %Y %T", $_[0]->_date) },
110 #my $cust_bill_event = shift;
111 my $status = $_[0]->status;
112 $status .= ': '.$_[0]->statustext
113 if $_[0]->statustext;
117 #my $cust_bill_event = shift;
118 'Invoice #'. $_[0]->invnum.
120 time2str("%D", $_[0]->cust_bill_date).
123 \&FS::UI::Web::cust_fields,
130 my $part_bill_event = shift;
131 my $template = $part_bill_event->templatename;
132 $template .= '-' if $template;
133 [ "${p}view/cust_bill.cgi?$template", 'invnum'];
135 ( map { $link_cust } FS::UI::Web::cust_header() ),