<% # use strict; use vars qw( $cgi $agent_type $action $hashref $p $part_pkg ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); use FS::Record qw(qsearch qsearchs fields); use FS::agent_type; use FS::CGI qw(header menubar popurl); use FS::agent_type; use FS::part_pkg; use FS::type_pkgs; $cgi = new CGI; &cgisuidsetup($cgi); if ( $cgi->param('error') ) { $agent_type = new FS::agent_type ( { map { $_, scalar($cgi->param($_)) } fields('agent') } ); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; $agent_type=qsearchs('agent_type',{'typenum'=>$1}); } else { #adding $agent_type = new FS::agent_type {}; } $action = $agent_type->typenum ? 'Edit' : 'Add'; $hashref = $agent_type->hashref; $p = popurl(2); print $cgi->header( @FS::CGI::header ), header("$action Agent Type", menubar( 'Main Menu' => "$p", 'View all agent types' => "${p}browse/agent_type.cgi", )); print qq!Error: !, $cgi->param('error'), "" if $cgi->param('error'); print '
', qq!!, "Agent Type #", $hashref->{typenum} ? $hashref->{typenum} : "(NEW)"; print <
Agent Type

Select which packages agents of this type may sell to customers
END foreach $part_pkg ( qsearch('part_pkg',{}) ) { print qq!
$agent_type->getfield('typenum'), 'pkgpart' => $part_pkg->getfield('pkgpart'), }) ? 'CHECKED ' : '', qq!VALUE="ON"> !, qq!', $part_pkg->getfield('pkg'), '', ; } print qq!

!; print < END %>