more mod_perl fixes, and bugfixes Peter Wemm sent via email
[freeside.git] / htdocs / search / svc_acct.cgi
index 0afdb1a..93b03e5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: svc_acct.cgi,v 1.3 1998-12-23 03:06:28 ivan Exp $
+# $Id: svc_acct.cgi,v 1.7 1999-02-07 09:59:38 ivan Exp $
 #
 # Usage: post form to:
 #        http://server.name/path/svc_acct.cgi
 # give service and customer info too ivan@sisd.com 98-aug-16
 #
 # $Log: svc_acct.cgi,v $
-# Revision 1.3  1998-12-23 03:06:28  ivan
+# Revision 1.7  1999-02-07 09:59:38  ivan
+# more mod_perl fixes, and bugfixes Peter Wemm sent via email
+#
+# Revision 1.6  1999/01/19 05:14:14  ivan
+# for mod_perl: no more top-level my() variables; use vars instead
+# also the last s/create/new/;
+#
+# Revision 1.5  1999/01/18 09:41:39  ivan
+# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
+# (good idea anyway)
+#
+# Revision 1.4  1999/01/18 09:22:34  ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.3  1998/12/23 03:06:28  ivan
 # $cgi->keywords instead of $cgi->query_string
 #
 # Revision 1.2  1998/12/17 09:41:10  ivan
 #
 
 use strict;
+use vars qw( $cgi @svc_acct $sortby $query );
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearch qsearchs);
-use FS::CGI qw(header idiot popurl);
+use FS::CGI qw(header eidiot popurl);
+use FS::svc_acct;
+use FS::cust_main;
 
-my($cgi)=new CGI;
+$cgi = new CGI;
 &cgisuidsetup($cgi);
 
-my(@svc_acct,$sortby);
-
-my($query)=$cgi->keywords;
+($query)=$cgi->keywords;
+$query ||= ''; #to avoid use of unitialized value errors
 #this tree is a little bit redundant
 if ( $query eq 'svcnum' ) {
   $sortby=\*svcnum_sort;
@@ -80,11 +96,10 @@ if ( scalar(@svc_acct) == 1 ) {
   print $cgi->redirect(popurl(2). "view/svc_acct.cgi?$svcnum");  #redirect
   exit;
 } elsif ( scalar(@svc_acct) == 0 ) { #error
-  idiot("Account not found");
-  exit;
+  eidiot("Account not found");
 } else {
   my($total)=scalar(@svc_acct);
-  print $cgi->header("Account Search Results",''), <<END;
+  print $cgi->header( '-expires' => 'now' ), header("Account Search Results",''), <<END;
     $total matching accounts found
     <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
       <TR>
@@ -128,7 +143,8 @@ END
       ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\"><FONT SIZE=-1>$custnum</FONT></A>"
       : "<I>(unlinked)</I>"
     ;
-    my($pname) = $custnum ? "$last, $first" : '';
+    my($pname) = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$last, $first</A>" : '';
+    my $pcompany = $custnum ? "<A HREF=\"${p}view/cust_main.cgi?$custnum\">$company</A>" : '';
     print <<END;
     <TR>
       <TD><A HREF="${p}view/svc_acct.cgi?$svcnum"><FONT SIZE=-1>$svcnum</FONT></A></TD>
@@ -137,7 +153,7 @@ END
       <TD><FONT SIZE=-1>$svc</FONT></TH>
       <TD><FONT SIZE=-1>$pcustnum</FONT></TH>
       <TD><FONT SIZE=-1>$pname<FONT></TH>
-      <TD><FONT SIZE=-1>$company</FONT></TH>
+      <TD><FONT SIZE=-1>$pcompany</FONT></TH>
     </TR>
 END