5 if ( $cgi->param('error') ) {
6 $agent = new FS::agent ( {
7 map { $_, scalar($cgi->param($_)) } fields('agent')
9 } elsif ( $cgi->keywords ) {
10 my($query) = $cgi->keywords;
12 $agent = qsearchs( 'agent', { 'agentnum' => $1 } );
14 $agent = new FS::agent {};
16 my $action = $agent->agentnum ? 'Edit' : 'Add';
17 my $hashref = $agent->hashref;
19 print header("$action Agent", menubar(
21 'View all agents' => $p. 'browse/agent.cgi',
24 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
26 if $cgi->param('error');
28 print '<FORM ACTION="', popurl(1), 'process/agent.cgi" METHOD=POST>',
29 qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$hashref->{agentnum}">!,
30 "Agent #", $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)";
32 print &ntable("#cccccc", 2, ''), <<END;
34 <TH ALIGN="right">Agent</TH>
35 <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="$hashref->{agent}"></TD>
38 <TH ALIGN="right">Agent type</TH>
39 <TD><SELECT NAME="typenum" SIZE=1>
42 foreach my $agent_type (qsearch('agent_type',{})) {
43 print "<OPTION VALUE=". $agent_type->typenum;
45 if $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum );
46 print ">", $agent_type->getfield('typenum'), ": ",
47 $agent_type->getfield('atype'),"\n";
54 <TD ALIGN="right"><!--Frequency--></TD>
55 <TD><INPUT TYPE="hidden" NAME="freq" VALUE="$hashref->{freq}"></TD>
58 <TD ALIGN="right"><!--Program--></TD>
59 <TD><INPUT TYPE="hidden" NAME="prog" VALUE="$hashref->{prog}"></TD>
64 print qq!<BR><INPUT TYPE="submit" VALUE="!,
65 $hashref->{agentnum} ? "Apply changes" : "Add agent",