initial checkin of module files for proper perl installation
[freeside.git] / htdocs / search / cust_pkg.cgi
index 967068f..033bc25 100755 (executable)
@@ -1,29 +1,61 @@
 #!/usr/bin/perl -Tw
 #
-# cust_pkg.cgi: search/browse for packages
+# $Id: cust_pkg.cgi,v 1.9 1999-07-17 10:38:52 ivan Exp $
 #
 # based on search/svc_acct.cgi ivan@sisd.com 98-jul-17
+#
+# $Log: cust_pkg.cgi,v $
+# Revision 1.9  1999-07-17 10:38:52  ivan
+# scott nelson <scott@ultimanet.com> noticed this mod_perl-triggered bug and
+# gave me a great bugreport at the last rhythmethod
+#
+# Revision 1.8  1999/02/09 09:22:57  ivan
+# visual and bugfixes
+#
+# Revision 1.7  1999/02/07 09:59:37  ivan
+# more mod_perl fixes, and bugfixes Peter Wemm sent via email
+#
+# Revision 1.6  1999/01/19 05:14:13  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:38  ivan
+# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
+# (good idea anyway)
+#
+# Revision 1.4  1999/01/18 09:22:33  ivan
+# changes to track email addresses for email invoicing
+#
+# Revision 1.3  1998/12/23 03:05:59  ivan
+# $cgi->keywords instead of $cgi->query_string
+#
+# Revision 1.2  1998/12/17 09:41:09  ivan
+# s/CGI::(Base|Request)/CGI.pm/;
+#
 
 use strict;
-use CGI::Request;
+use vars qw ( $cgi @cust_pkg $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);
-
-my($req)=new CGI::Request;
-&cgisuidsetup($req->cgi);
+use FS::CGI qw(header eidiot popurl);
+use FS::cust_pkg;
+use FS::pkg_svc;
+use FS::cust_svc;
+use FS::cust_main;
 
-my(@cust_pkg,$sortby);
+$cgi = new CGI;
+&cgisuidsetup($cgi);
 
-my($query)=$req->cgi->var('QUERY_STRING');
+($query) = $cgi->keywords;
 #this tree is a little bit redundant
 if ( $query eq 'pkgnum' ) {
   $sortby=\*pkgnum_sort;
   @cust_pkg=qsearch('cust_pkg',{});
 } elsif ( $query eq 'APKG_pkgnum' ) {
   $sortby=\*pkgnum_sort;
-
+  @cust_pkg=();
   #perhaps this should go in cust_pkg as a qsearch-like constructor?
   my($cust_pkg);
   foreach $cust_pkg (qsearch('cust_pkg',{})) {
@@ -50,27 +82,23 @@ if ( $query eq 'pkgnum' ) {
 
 if ( scalar(@cust_pkg) == 1 ) {
   my($pkgnum)=$cust_pkg[0]->pkgnum;
-  $req->cgi->redirect("../view/cust_pkg.cgi?$pkgnum");
+  print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum");
   exit;
 } elsif ( scalar(@cust_pkg) == 0 ) { #error
-  &idiot("No packages found");
-  exit;
+  eidiot("No packages found");
 } else {
   my($total)=scalar(@cust_pkg);
-  CGI::Base::SendHeaders(); # one guess
-  print header('Package Search Results',''), <<END;
+  print $cgi->header( '-expires' => 'now' ), header('Package Search Results',''), <<END;
     $total matching packages found
     <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
       <TR>
         <TH>Package #</TH>
         <TH>Customer #</TH>
-        <TH>Name</TH>
+        <TH>Contact name</TH>
         <TH>Company</TH>
       </TR>
 END
 
-  my($lines)=16;
-  my($lcount)=$lines;
   my(%saw,$cust_pkg);
   foreach $cust_pkg (
     sort $sortby grep(!$saw{$_->pkgnum}++, @cust_pkg)
@@ -82,33 +110,20 @@ END
       $cust_main->last. ', '. $cust_main->first,
       $cust_main->company,
     );
+    my $p = popurl(2);
     print <<END;
     <TR>
-      <TD><A HREF="../view/cust_pkg.cgi?$pkgnum"><FONT SIZE=-1>$pkgnum</FONT></A></TD>
-      <TD><FONT SIZE=-1>$custnum</FONT></TD>
-      <TD><FONT SIZE=-1>$name</FONT></TD>
-      <TD><FONT SIZE=-1>$company</FONT></TD>
-    </TR>
-END
-    if ($lcount-- == 0) { # lots of little tables instead of one big one
-      $lcount=$lines;
-      print <<END;   
-  </TABLE>
-  <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
-    <TR>
-        <TH>Package #</TH>
-        <TH>Customer #</TH>
-        <TH>Name</TH>
-        <TH>Company</TH>
-      <TH>
+      <TD><A HREF="${p}view/cust_pkg.cgi?$pkgnum"><FONT SIZE=-1>$pkgnum</FONT></A></TD>
+      <TD><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$custnum</A></FONT></TD>
+      <TD><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$name</A></FONT></TD>
+      <TD><FONT SIZE=-1><A HREF="${p}view/cust_main.cgi?$custnum">$company</A></FONT></TD>
     </TR>
 END
-    }
+
   }
  
   print <<END;
     </TABLE>
-    </CENTER>
   </BODY>
 </HTML>
 END