links to show alternate invoices also
authorivan <ivan>
Tue, 5 Oct 2004 13:52:28 +0000 (13:52 +0000)
committerivan <ivan>
Tue, 5 Oct 2004 13:52:28 +0000 (13:52 +0000)
httemplate/view/cust_bill.cgi

index 116cd6d..bda5d76 100755 (executable)
@@ -31,40 +31,47 @@ print '<BR><BR>';
 
 my $conf = new FS::Conf;
 if ( $conf->exists('invoice_latex') ) {
+  my $link = "${p}view/cust_bill-pdf.cgi?";
+  $link .= "$templatename-" if $templatename;
+  $link .= "$invnum.pdf";
   print menubar(
-    'View typeset invoice' => "${p}view/cust_bill-pdf.cgi?$invnum.pdf",
+    'View typeset invoice' => $link,
   ), '<BR><BR>';
 }
 
 #false laziness with search/cust_bill_event.cgi
 
-print table(). '<TR><TH>Event</TH><TH>Date</TH><TH>Status</TH></TR>';
-foreach my $cust_bill_event (
-  sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
-) {
-  my $status = $cust_bill_event->status;
-  $status .= ': '. $cust_bill_event->statustext if $cust_bill_event->statustext;
-  my $part_bill_event = $cust_bill_event->part_bill_event;
-  print '<TR><TD>'. $part_bill_event->event;
-
-  if (
-    $part_bill_event->plan eq 'send_alternate'
-    && $part_bill_event->plandata =~ /^templatename (.*)$/m
+unless ( $templatename ) {
+  print table(). '<TR><TH>Event</TH><TH>Date</TH><TH>Status</TH></TR>';
+  foreach my $cust_bill_event (
+    sort { $a->_date <=> $b->_date } $cust_bill->cust_bill_event
   ) {
-    my $templatename = $1;
-    print qq! ( <A HREF="${p}view/cust_bill.cgi?$templatename-$invnum">!.
-          'view text</A> | '.
-          qq!<A HREF="${p}view/cust_bill-pdf.cgi?$templatename-$invnum.pdf">!.
-          'view typeset</A> )';
+    my $status = $cust_bill_event->status;
+    $status .= ': '. $cust_bill_event->statustext
+      if $cust_bill_event->statustext;
+    my $part_bill_event = $cust_bill_event->part_bill_event;
+    print '<TR><TD>'. $part_bill_event->event;
+  
+    if (
+      $part_bill_event->plan eq 'send_alternate'
+      && $part_bill_event->plandata =~ /^templatename (.*)$/m
+    ) {
+      my $templatename = $1;
+      print qq! ( <A HREF="${p}view/cust_bill.cgi?$templatename-$invnum">!.
+            'view text</A> | '.
+            qq!<A HREF="${p}view/cust_bill-pdf.cgi?$templatename-$invnum.pdf">!.
+            'view typeset</A> )';
+    }
+  
+    print '</TD><TD>'.
+          time2str("%a %b %e %T %Y", $cust_bill_event->_date). '</TD><TD>'.
+          $status. '</TD></TR>';
   }
-
-  print '</TD><TD>'.
-        time2str("%a %b %e %T %Y", $cust_bill_event->_date). '</TD><TD>'.
-        $status. '</TD></TR>';
+  print '</TABLE><BR>';
 }
-print '</TABLE><BR><PRE>';
 
-print $cust_bill->print_text('', $templatename);
+
+print '<PRE>'. $cust_bill->print_text('', $templatename);
 
        #formatting
        print <<END;