1 <% include( 'elements/search.html',
3 'html_init' => $html_init,
5 'name' => 'billing events',
7 'count_query' => $count_sql,
12 #'Inv #', 'Inv Date', 'Cust #',
15 FS::UI::Web::cust_header(), #'cust_main_custnum',
19 sub { time2str("%b %d %Y %T", $_[0]->_date) },
23 # #my $cust_event = shift;
24 # 'Invoice #'. $_[0]->invnum.
26 # time2str("%D", $_[0]->cust_bill_date).
29 \&FS::UI::Web::cust_fields,
31 'align' => 'lrll'.FS::UI::Web::cust_aligns(),
38 # my $part_event = shift;
40 # my $template = $part_event->templatename;
41 # $template .= '-' if $template;
42 # [ "${p}view/cust_bill.cgi?$template", 'invnum'];
45 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
46 FS::UI::Web::cust_header()
55 FS::UI::Web::cust_colors(),
63 FS::UI::Web::cust_styles(),
69 my $status_sub = sub {
70 my $cust_event = shift;
72 my $status = $cust_event->status;
73 $status .= ': '.$cust_event->statustext
74 if $cust_event->statustext;
76 my $part_event = $cust_event->part_event;
78 if ( $part_event->eventtable eq 'cust_bill' && $part_event->templatename ) {
79 my $alt_templatename = $part_event->templatename;
80 my $alt_link = "$alt_templatename-". $cust_event->tablenum;
82 my $conf = new FS::Conf;
83 my $cust_bill = $cust_event->cust_X;
86 ( <A HREF="${p}view/cust_bill.cgi?$alt_link">view</A>
87 | <A HREF="${p}view/cust_bill-pdf.cgi?$alt_link.pdf">view
89 | <A HREF="${p}misc/print-invoice.cgi?$alt_link">re-print</A>
92 if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) {
94 | <A HREF="${p}misc/email-invoice.cgi?$alt_link">re-email</A>
98 if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) {
100 | <A HREF="${p}misc/fax-invoice.cgi?$alt_link">re-fax</A>
111 my $trigger_sub = sub {
112 my $cust_event = shift;
113 my $eventtable = $cust_event->eventtable;
114 my $label = FS::part_event->eventtable_labels->{$eventtable};
115 #if ( $eventtable eq 'cust_pkg' || $eventtable eq 'cust_bill' ) {
116 "$label #". $cust_event->tablenum;
122 my $trigger_link = sub {
123 my $cust_event = shift;
124 my $eventtable = $cust_event->eventtable;
125 if ( $eventtable eq 'cust_pkg' ) {
126 my $custnum = $cust_event->cust_main_custnum;
127 my $show = $FS::CurrentUser::CurrentUser->default_customer_view =~ /^(jumbo|packages)$/
130 my $pkgnum = $cust_event->tablenum;
131 my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
132 [ "${p}view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#cust_pkg", 'tablenum' ];
134 [ "${p}view/$eventtable.cgi?", 'tablenum' ];
141 my $curuser = $FS::CurrentUser::CurrentUser;
144 unless $curuser->access_right('Billing event reports')
145 or $curuser->access_right('View customer billing events')
146 && ( $cgi->param('custnum') =~ /^(\d+)$/
147 || $cgi->param('invnum') =~ /^(\d+)$/
148 || $cgi->param('pkgnum') =~ /^(\d+)$/
151 my $title = $cgi->param('failed') ? 'Failed billing events' : 'Billing events';
155 my @scalars = qw ( agentnum custnum invnum pkgnum failed );
156 for my $param ( @scalars ) {
157 $search{$param} = scalar( $cgi->param($param) )
158 if $cgi->param($param);
161 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
162 $search{'beginning'} = $beginning;
163 $search{'ending'} = $ending;
165 my $where = ' WHERE '. FS::cust_event->search_sql( \%search );
167 my $join = FS::cust_event->join_sql();
170 'table' => 'cust_event',
171 'select' => join(', ',
174 #'cust_bill.custnum',
175 #'cust_bill._date AS cust_bill_date',
176 'cust_main.custnum AS cust_main_custnum',
177 FS::UI::Web::cust_sql_fields(),
180 'extra_sql' => "$where ORDER BY _date ASC",
181 'addl_from' => $join,
184 my $count_sql = "SELECT COUNT(*) FROM cust_event $join $where";
186 my $conf = new FS::Conf;
188 my @params = ( @scalars, qw( beginning ending ) );
190 my $html_init = join("\n", map {
191 ( my $action = $_ ) =~ s/_$//;
192 include('/elements/progress-init.html',
194 [ 'action', @params ],
195 "../misc/${_}events.cgi",
196 { 'message' => "Invoices re-${action}ed" }, #would be nice to show the number of them, but...
199 qq!<FORM NAME="${_}form">!,
200 qq!<INPUT TYPE="hidden" NAME="action" VALUE="$_">!, #not used though
201 ( map { my $value = encode_entities( $search{$_} );
202 qq(<INPUT TYPE="hidden" NAME="$_" VALUE="$value">);
204 @params #keys %search
207 } qw( print_ email_ fax_ ) ).
209 '<SCRIPT TYPE="text/javascript">
211 function confirm_print_process() {
212 if ( ! confirm("Are you sure you want to reprint these invoices?") ) {
217 function confirm_email_process() {
218 if ( ! confirm("Are you sure you want to re-email these invoices?") ) {
223 function confirm_fax_process() {
224 if ( ! confirm("Are you sure you want to re-fax these invoices?") ) {
234 if ( $curuser->access_right('Resend invoices') ) {
236 push @$menubar, 'Re-print these events' =>
237 "javascript:confirm_print_process()",
238 'Re-email these events' =>
239 "javascript:confirm_email_process()",
242 push @$menubar, 'Re-fax these events' =>
243 "javascript:confirm_fax_process()"
244 if $conf->exists('hylafax');
248 my $link_cust = sub {
249 my $cust_event = shift;
250 $cust_event->cust_main_custnum
251 ? [ "${p}view/cust_main.cgi?", 'cust_main_custnum' ]