3 # $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 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 # started with /sales/add/cust_pkg.cgi, which added packages
11 # ivan@voicenet.com 97-jan-5, 97-mar-21
14 # ivan@voicenet.com 97-jul-7
16 # FS::Search is no more, &cgisuidsetup needs $cgi, ivan@sisd.com 98-mar-7
18 # Changes to allow page to work at a relative position in server
19 # Changed to display packages 2-wide in a table
20 # bmccane@maxbaud.net 98-apr-3
22 # fixed a pretty cool bug from above which caused a visual glitch ivan@sisd.com
25 # $Log: cust_pkg.cgi,v $
26 # Revision 1.1 2001-07-30 07:36:04 ivan
29 # Revision 1.8 1999/07/21 07:34:13 ivan
30 # links to package browse and agent type edit if there aren't any packages to
31 # order. thanks to "Tech Account" <techy@orac.hq.org>
33 # Revision 1.7 1999/04/14 01:03:01 ivan
34 # oops, in 1.2 tree, can't do searches until [cgi|admin]suidsetup,
35 # bug is hidden by mod_perl persistance
37 # Revision 1.6 1999/02/28 00:03:36 ivan
38 # removed misleading comments
40 # Revision 1.5 1999/02/07 09:59:18 ivan
41 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
43 # Revision 1.4 1999/01/19 05:13:38 ivan
44 # for mod_perl: no more top-level my() variables; use vars instead
45 # also the last s/create/new/;
47 # Revision 1.3 1999/01/18 09:41:28 ivan
48 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
51 # Revision 1.2 1998/12/17 06:17:04 ivan
52 # fix double // in relative URLs, s/CGI::Base/CGI/;
56 use vars qw( $cgi %pkg %comment $custnum $p1 @cust_pkg
57 $cust_main $agent $type_pkgs $count %remove_pkg $pkgparts );
59 use CGI::Carp qw(fatalsToBrowser);
60 use FS::UID qw(cgisuidsetup);
61 use FS::Record qw(qsearch qsearchs);
62 use FS::CGI qw(header popurl);
71 foreach (qsearch('part_pkg', {})) {
72 $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
73 $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
76 if ( $cgi->param('error') ) {
77 $custnum = $cgi->param('custnum');
78 %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg');
80 my($query) = $cgi->keywords;
87 print $cgi->header( '-expires' => 'now' ), header("Add/Edit Packages", '');
89 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
91 if $cgi->param('error');
93 print qq!<FORM ACTION="${p1}process/cust_pkg.cgi" METHOD=POST>!;
95 print qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
98 @cust_pkg = qsearch('cust_pkg',{ 'custnum' => $custnum, 'cancel' => '' } );
102 Current packages - select to remove (services are moved to a new package below)
108 foreach (@cust_pkg) {
109 print '<TR>' if $count == 0;
110 my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
111 print qq!<TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="$pkgnum"!;
112 print " CHECKED" if $remove_pkg{$pkgnum};
113 print qq!>$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!;
121 print qq!</TABLE><BR><BR>!;
125 Order new packages<BR><BR>
128 $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
129 $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
134 foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
136 my($pkgpart)=$type_pkgs->pkgpart;
137 print qq!<TR>! if ( $count == 0 );
138 my $value = $cgi->param("pkg$pkgpart") || 0;
141 <INPUT TYPE="text" NAME="pkg$pkgpart" VALUE="$value" SIZE="2" MAXLENGTH="2">
142 $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n
152 unless ( $pkgparts ) {
154 my $typenum = $agent->typenum;
155 my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } );
156 my $atype = $agent_type->atype;
158 (No <a href="${p2}browse/part_pkg.cgi">package definitions</a>, or agent type
159 <a href="${p2}edit/agent_type.cgi?$typenum">$atype</a> not allowed to purchase
166 <P><INPUT TYPE="submit" VALUE="Order">