show a better message when no results are found
[freeside.git] / httemplate / view / cust_pkg.cgi
index e9670cd..5f0e6bf 100755 (executable)
@@ -1,6 +1,8 @@
 <!-- mason kludge -->
 <%
 
+my $conf = new FS::Conf;
+
 my %uiview = ();
 my %uiadd = ();
 foreach my $part_svc ( qsearch('part_svc',{}) ) {
@@ -36,7 +38,7 @@ my $otaker = $cust_pkg->getfield('otaker');
 print <<END;
 <SCRIPT>
 function areyousure(href) {
-    if (confirm("Permanantly delete included services and cancel this package?") == true)
+    if (confirm("Permanently delete included services and cancel this package?") == true)
         window.location.href = href;
 }
 </SCRIPT>
@@ -66,10 +68,16 @@ print &ntable("#cccccc"), '<TR><TD>', &ntable("#cccccc",2),
       '<TR><TD ALIGN="right">Comment</TD><TD BGCOLOR="#ffffff">',
       $comment,  '</TD></TR>',
       '<TR><TD ALIGN="right">Setup date</TD><TD BGCOLOR="#ffffff">',
-      ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>',
-      '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">',
-      ( $bill ? time2str("%D",$bill) : "&nbsp;" ), '</TD></TR>',
-;
+      ( $setup ? time2str("%D",$setup) : "(Not setup)" ), '</TD></TR>';
+
+print '<TR><TD ALIGN="right">Last bill date</TD><TD BGCOLOR="#ffffff">',
+      ( $cust_pkg->get('last_bill') ? time2str("%D",$cust_pkg->get('last_bill')) : "&nbsp;" ),
+      '</TD></TR>'
+  if $cust_pkg->dbdef_table->column('last_bill');
+
+print '<TR><TD ALIGN="right">Next bill date</TD><TD BGCOLOR="#ffffff">',
+      ( $bill ? time2str("%D",$bill) : "&nbsp;" ), '</TD></TR>';
+      
 print '<TR><TD ALIGN="right">Suspension date</TD><TD BGCOLOR="#ffffff">',
        time2str("%D",$susp), '</TD></TR>' if $susp;
 print '<TR><TD ALIGN="right">Expiration date</TD><TD BGCOLOR="#ffffff">',
@@ -78,15 +86,16 @@ print '<TR><TD ALIGN="right">Cancellation date</TD><TD BGCOLOR="#ffffff">',
        time2str("%D",$cancel), '</TD></TR>' if $cancel;
 print  '<TR><TD ALIGN="right">Order taker</TD><TD BGCOLOR="#ffffff">',
       $otaker,  '</TD></TR>',
-      '</TABLE></TD></TR></TABLE>'
-;
-
-#  print <<END;
-#<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post">
-#<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
-#Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" >
-#<INPUT TYPE="submit" VALUE="Cancel later">
-#END
+      '</TABLE></TD></TR></TABLE>';
+
+unless ($expire) {
+  print <<END;
+<FORM ACTION="../misc/expire_pkg.cgi" METHOD="post">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
+Expire (date): <INPUT TYPE="text" NAME="date" VALUE="" >
+<INPUT TYPE="submit" VALUE="Cancel later">
+END
+}
 
 unless ($cancel) {
 
@@ -118,18 +127,18 @@ unless ($cancel) {
         my($svcnum)=$cust_svc->svcnum;
         my($label, $value, $svcdb) = $cust_svc->label;
         print <<END;
-<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View) $svc: $value<A></TD></TR>
+<TR><TD><A HREF="$uiview{$svcpart}?$svcnum">(View/Edit) $svc: $value<A></TD></TR>
 END
       } else {
-        print <<END;
-<TR>
-  <TD><A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">
-      (Add) $svc</A>
-   or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">
-      (Link to existing) $svc</A>
-  </TD>
-</TR>
-END
+        print qq!<TR><TD>!.
+              qq!<A HREF="$uiadd{$svcpart}?pkgnum$pkgnum-svcpart$svcpart">!.
+              qq!(Provision) $svc</A>!;
+
+        print qq! or <A HREF="../misc/link.cgi?pkgnum$pkgnum-svcpart$svcpart">!.
+              qq!(Link to legacy) $svc</A>!
+          if $conf->exists('legacy_link');
+
+        print '</TD></TR>';
       }
 
     }
@@ -137,11 +146,13 @@ END
   }
 
   print "</TABLE><FONT SIZE=-1>",
-        "Choose (View) to view or edit an existing service<BR>",
-        "Choose (Add) to setup a new service<BR>",
-        "Choose (Link to existing) to link to a legacy (pre-Freeside) service",
-        "</FONT>"
-  ;
+        "Choose (View/Edit) to view or edit an existing service<BR>",
+        "Choose (Provision) to setup a new service<BR>";
+
+  print "Choose (Link to legacy) to link to a legacy (pre-Freeside) service"
+    if $conf->exists('legacy_link');
+
+  print "</FONT>";
 }
 
 #formatting