3 # $Id: cust_pkg.cgi,v 1.3 1999-01-18 09:41:28 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.3 1999-01-18 09:41:28 ivan
29 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
32 # Revision 1.2 1998/12/17 06:17:04 ivan
33 # fix double // in relative URLs, s/CGI::Base/CGI/;
38 use CGI::Carp qw(fatalsToBrowser);
39 use FS::UID qw(cgisuidsetup getotaker);
40 use FS::Record qw(qsearch qsearchs);
41 use FS::CGI qw(header popurl);
48 foreach (qsearch('part_pkg', {})) {
49 $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
50 $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
55 my($query) = $cgi->keywords;
59 my($otaker)=&getotaker;
62 print $cgi->header( '-expires' => 'now' ), header("Add/Edit Packages", ''), <<END;
63 <FORM ACTION="${p1}process/cust_pkg.cgi" METHOD=POST>
68 print qq!<INPUT TYPE="hidden" NAME="new_custnum" VALUE="$custnum">!;
70 #current packages (except cancelled packages)
71 my(@cust_pkg) = grep ! $_->getfield('cancel'),
72 qsearch('cust_pkg',{'custnum'=>$custnum});
76 <CENTER><FONT SIZE="+2">Current packages</FONT></CENTER>
77 These are packages the customer currently has. Select those packages you
78 wish to remove (if any).<BR><BR>
82 print qq!<CENTER><TABLE>! ;
84 print qq!<TR>! if ($count ==0) ;
85 my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
86 print qq!<TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="$pkgnum">!,
87 #qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!,
88 #now you've got to admit this bug was pretty cool
89 qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!;
97 print qq!</TABLE></CENTER>! ;
103 <CENTER><FONT SIZE="+2">New packages</FONT></CENTER>
104 These are packages the customer can purchase. Specify the quantity to add
105 of each package.<BR><BR>
108 my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
109 my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
113 print qq!<CENTER><TABLE>! ;
114 foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
115 my($pkgpart)=$type_pkgs->pkgpart;
116 print qq!<TR>! if ($count == 0) ;
119 <INPUT TYPE="text" NAME="pkg$pkgpart" VALUE="0" SIZE="2" MAXLENGTH="2">
120 $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n
129 print qq!</TABLE></CENTER>! ;
132 print qq!<INPUT TYPE="hidden" NAME="new_otaker" VALUE="$otaker">\n!;
135 print qq!<P><CENTER><INPUT TYPE="submit" VALUE="Order"></CENTER>\n!;