X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_bill.cgi;h=38c57ec181539dbc3987476c9d2a48cfe253f671;hb=1045de52b8e6e9acc46bc9f250711929394ba1c7;hp=1e024f377f40cdf0da607c7e0577d904fcb6509e;hpb=fbcb45dfe5a1bce7981fe4527176b9fdf2ec54b7;p=freeside.git diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 1e024f377..38c57ec18 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -1,52 +1,111 @@ <% -# - -use strict; -use vars qw ( $cgi $query $invnum $cust_bill $custnum $printed $p ); -use IO::File; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl menubar); -use FS::Record qw(qsearchs); -use FS::cust_bill; - -$cgi = new CGI; -&cgisuidsetup($cgi); #untaint invnum -($query) = $cgi->keywords; -$query =~ /^(\d+)$/; -$invnum = $1; +my($query) = $cgi->keywords; +$query =~ /^((.+)-)?(\d+)$/; +my $templatename = $2; +my $invnum = $3; -$cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +my $conf = new FS::Conf; + +my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Invoice #$invnum not found!" unless $cust_bill; -$custnum = $cust_bill->getfield('custnum'); +my $custnum = $cust_bill->getfield('custnum'); + +#my $printed = $cust_bill->printed; -$printed = $cust_bill->printed; +my $link = $templatename ? "$templatename-$invnum" : $invnum; -$p = popurl(2); -print $cgi->header( '-expires' => 'now' ), header('Invoice View', menubar( +%> +<%= header('Invoice View', menubar( "Main Menu" => $p, "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", -)); +)) %> -print qq!Enter payments (check/cash) against this invoice | ! - if $cust_bill->owed > 0; +<% if ( $cust_bill->owed > 0 ) { %> + Enter payments (check/cash) against this invoice | +<% } %> -print <Reprint this invoice -

(Printed $printed times) -
-END
+Re-print this invoice
 
-print $cust_bill->print_text;
+<% if ( grep { $_ ne 'POST' } $cust_bill->cust_main->invoicing_list ) { %>
+  | Re-email
+      this invoice
+<% } %>
 
-	#formatting
-	print <
-  
-
-END
+<% if ( $conf->exists('hylafax') && length($cust_bill->cust_main->fax) ) { %>
+  | Re-fax
+      this invoice
+<% } %>
 
-%>
+

+ +<% if ( $conf->exists('invoice_latex') ) { %> + View typeset invoice +

+<% } %> + +<% #false laziness with search/cust_bill_event.cgi + unless ( $templatename ) { %> + + <%= table() %> + + Event + Date + Status + + + <% foreach my $cust_bill_event ( + sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event + ) { + + my $status = $cust_bill_event->status; + $status .= ': '. encode_entities($cust_bill_event->statustext) + if $cust_bill_event->statustext; + my $part_bill_event = $cust_bill_event->part_bill_event; + %> + + <%= $part_bill_event->event %> + + <% if ( + $part_bill_event->plan eq 'send_alternate' + && $part_bill_event->plandata =~ /^(agent_)?templatename (.*)$/m + ) { + my $alt_templatename = $2; + my $alt_link = "$alt_templatename-$invnum"; + %> + ( view + | view + typeset + | re-print + <% if ( grep { $_ ne 'POST' } + $cust_bill->cust_main->invoicing_list ) { %> + | re-email + <% } %> + + <% if ( $conf->exists('hylafax') + && length($cust_bill->cust_main->fax) ) { %> + | re-fax + <% } %> + + ) + <% } %> + + + <%= time2str("%a %b %e %T %Y", $cust_bill_event->_date) %> + <%= $status %> + + <% } %> + + +
+ +<% } %> + +<% if ( $conf->exists('invoice_html') ) { %> + <%= join('', $cust_bill->print_html('', $templatename) ) %> +<% } else { %> +
<%= join('', $cust_bill->print_text('', $templatename) ) %>
+<% } %> + +