2 #<!-- $Id: cust_pkg.cgi,v 1.2 2001-08-21 02:31:56 ivan Exp $ -->
5 use vars qw( $cgi %pkg %comment $custnum $p1 @cust_pkg
6 $cust_main $agent $type_pkgs $count %remove_pkg $pkgparts );
8 use CGI::Carp qw(fatalsToBrowser);
9 use FS::UID qw(cgisuidsetup);
10 use FS::Record qw(qsearch qsearchs);
11 use FS::CGI qw(header popurl);
20 foreach (qsearch('part_pkg', {})) {
21 $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg');
22 $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment');
25 if ( $cgi->param('error') ) {
26 $custnum = $cgi->param('custnum');
27 %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg');
29 my($query) = $cgi->keywords;
36 print $cgi->header( '-expires' => 'now' ), header("Add/Edit Packages", '');
38 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
40 if $cgi->param('error');
42 print qq!<FORM ACTION="${p1}process/cust_pkg.cgi" METHOD=POST>!;
44 print qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!;
47 @cust_pkg = qsearch('cust_pkg',{ 'custnum' => $custnum, 'cancel' => '' } );
51 Current packages - select to remove (services are moved to a new package below)
58 print '<TR>' if $count == 0;
59 my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') );
60 print qq!<TD><INPUT TYPE="checkbox" NAME="remove_pkg" VALUE="$pkgnum"!;
61 print " CHECKED" if $remove_pkg{$pkgnum};
62 print qq!>$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n!;
70 print qq!</TABLE><BR><BR>!;
74 Order new packages<BR><BR>
77 $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
78 $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
83 foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
85 my($pkgpart)=$type_pkgs->pkgpart;
86 print qq!<TR>! if ( $count == 0 );
87 my $value = $cgi->param("pkg$pkgpart") || 0;
90 <INPUT TYPE="text" NAME="pkg$pkgpart" VALUE="$value" SIZE="2" MAXLENGTH="2">
91 $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}</TD>\n
101 unless ( $pkgparts ) {
103 my $typenum = $agent->typenum;
104 my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } );
105 my $atype = $agent_type->atype;
107 (No <a href="${p2}browse/part_pkg.cgi">package definitions</a>, or agent type
108 <a href="${p2}edit/agent_type.cgi?$typenum">$atype</a> not allowed to purchase
115 <P><INPUT TYPE="submit" VALUE="Order">