3 # $Id: cust_pkg.cgi,v 1.4 1999-01-19 05:13:38 ivan Exp $
5 # this is for changing packages around, not editing things within the package
7 # Usage: cust_pkg.cgi custnum
8 # http://server.name/path/cust_pkg.cgi?custnum
10 # Note: Should be run setuid freeside as user nobody
12 # started with /sales/add/cust_pkg.cgi, which added packages
13 # ivan@voicenet.com 97-jan-5, 97-mar-21
16 # ivan@voicenet.com 97-jul-7
18 # FS::Search is no more, &cgisuidsetup needs $cgi, ivan@sisd.com 98-mar-7
20 # Changes to allow page to work at a relative position in server
21 # Changed to display packages 2-wide in a table
22 # bmccane@maxbaud.net 98-apr-3
24 # fixed a pretty cool bug from above which caused a visual glitch ivan@sisd.com
27 # $Log: cust_pkg.cgi,v $
28 # Revision 1.4 1999-01-19 05:13:38 ivan
29 # for mod_perl: no more top-level my() variables; use vars instead
30 # also the last s/create/new/;
32 # Revision 1.3 1999/01/18 09:41:28 ivan
33 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
36 # Revision 1.2 1998/12/17 06:17:04 ivan
37 # fix double // in relative URLs, s/CGI::Base/CGI/;
41 use vars qw( $cgi %pkg %comment $query $custnum $otaker $p1 @cust_pkg
42 $cust_main $agent $type_pkgs $count );
44 use CGI::Carp qw(fatalsToBrowser);
45 use FS::UID qw(cgisuidsetup getotaker);
46 use FS::Record qw(qsearch qsearchs);
47 use FS::CGI qw(header popurl);
53 foreach (qsearch('part_pkg', {})) {
54 $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
55 $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
60 ($query) = $cgi->keywords;
67 print $cgi->header( '-expires' => 'now' ), header("Add/Edit Packages", ''), <<END;
68 <FORM ACTION="${p1}process/cust_pkg.cgi" METHOD=POST>
73 print qq!<INPUT TYPE="hidden" NAME="new_custnum" VALUE="$custnum">!;
75 #current packages (except cancelled packages)
76 @cust_pkg = grep ! $_->getfield('cancel'),
77 qsearch('cust_pkg',{'custnum'=>$custnum});
81 <CENTER><FONT SIZE="+2">Current packages</FONT></CENTER>
82 These are packages the customer currently has. Select those packages you
83 wish to remove (if any).<BR><BR>
87 print qq!<CENTER><TABLE>! ;
89 print qq!<TR>! if ($count ==0) ;
90 my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
91 print qq!<TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="$pkgnum">!,
92 #qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!,
93 #now you've got to admit this bug was pretty cool
94 qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!;
102 print qq!</TABLE></CENTER>! ;
108 <CENTER><FONT SIZE="+2">New packages</FONT></CENTER>
109 These are packages the customer can purchase. Specify the quantity to add
110 of each package.<BR><BR>
113 $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
114 $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
117 print qq!<CENTER><TABLE>! ;
118 foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
119 my($pkgpart)=$type_pkgs->pkgpart;
120 print qq!<TR>! if ($count == 0) ;
123 <INPUT TYPE="text" NAME="pkg$pkgpart" VALUE="0" SIZE="2" MAXLENGTH="2">
124 $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n
133 print qq!</TABLE></CENTER>! ;
136 print qq!<INPUT TYPE="hidden" NAME="new_otaker" VALUE="$otaker">\n!;
139 print qq!<P><CENTER><INPUT TYPE="submit" VALUE="Order"></CENTER>\n!;