3 # cust_pkg.cgi: Add/edit packages (output form)
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
28 use CGI::Base qw(:DEFAULT :CGI); # CGI module
29 use CGI::Carp qw(fatalsToBrowser);
30 use FS::UID qw(cgisuidsetup getotaker);
31 use FS::Record qw(qsearch qsearchs);
33 my($cgi) = new CGI::Base;
38 foreach (qsearch('part_pkg', {})) {
39 $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
40 $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
44 $QUERY_STRING =~ /^(\d+)$/;
47 my($otaker)=&getotaker;
53 <TITLE>Add/Edit Packages</TITLE>
57 <H1>Add/Edit Packages</H1>
59 <FORM ACTION="process/cust_pkg.cgi" METHOD=POST>
64 print qq!<INPUT TYPE="hidden" NAME="new_custnum" VALUE="$custnum">!;
66 #current packages (except cancelled packages)
67 my(@cust_pkg) = grep ! $_->getfield('cancel'),
68 qsearch('cust_pkg',{'custnum'=>$custnum});
72 <CENTER><FONT SIZE="+2">Current packages</FONT></CENTER>
73 These are packages the customer currently has. Select those packages you
74 wish to remove (if any).<BR><BR>
78 print qq!<CENTER><TABLE>! ;
80 print qq!<TR>! if ($count ==0) ;
81 my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
82 print qq!<TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="$pkgnum">!,
83 #qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!,
84 #now you've got to admit this bug was pretty cool
85 qq!$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!;
93 print qq!</TABLE></CENTER>! ;
99 <CENTER><FONT SIZE="+2">New packages</FONT></CENTER>
100 These are packages the customer can purchase. Specify the quantity to add
101 of each package.<BR><BR>
104 my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
105 my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
109 print qq!<CENTER><TABLE>! ;
110 foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
111 my($pkgpart)=$type_pkgs->pkgpart;
112 print qq!<TR>! if ($count == 0) ;
115 <INPUT TYPE="text" NAME="pkg$pkgpart" VALUE="0" SIZE="2" MAXLENGTH="2">
116 $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n
125 print qq!</TABLE></CENTER>! ;
128 print qq!<INPUT TYPE="hidden" NAME="new_otaker" VALUE="$otaker">\n!;
131 print qq!<P><CENTER><INPUT TYPE="submit" VALUE="Order"></CENTER>\n!;