f5afd3a96dd44897348fc989de643af36d70fac4
[freeside.git] / httemplate / edit / agent_type.cgi
1 <%
2
3 my($agent_type);
4 if ( $cgi->param('error') ) {
5   $agent_type = new FS::agent_type ( {
6     map { $_, scalar($cgi->param($_)) } fields('agent')
7   } );
8 } elsif ( $cgi->keywords ) { #editing
9   my( $query ) = $cgi->keywords;
10   $query =~ /^(\d+)$/;
11   $agent_type=qsearchs('agent_type',{'typenum'=>$1});
12 } else { #adding
13   $agent_type = new FS::agent_type {};
14 }
15 my $action = $agent_type->typenum ? 'Edit' : 'Add';
16
17 %><%= include("/elements/header.html","$action Agent Type", menubar(
18   'Main Menu' => "$p",
19   'View all agent types' => "${p}browse/agent_type.cgi",
20 ))
21 %>
22
23 <% if ( $cgi->param('error') ) { %>
24   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
25 <% } %>
26
27 <FORM ACTION="<%= popurl(1) %>process/agent_type.cgi" METHOD=POST>
28 <INPUT TYPE="hidden" NAME="typenum" VALUE="<%= $agent_type->typenum %>">
29 Agent Type #<%= $agent_type->typenum || "(NEW)" %>
30 <BR>
31
32 Agent Type
33 <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<%= $agent_type->atype %>">
34 <BR><BR>
35
36 Select which packages agents of this type may sell to customers<BR>
37 <%= ntable("#cccccc", 2) %><TR><TD>
38 <%= include('/elements/checkboxes-table.html',
39               'source_obj'    => $agent_type,
40               'link_table'    => 'type_pkgs',
41               'target_table'  => 'part_pkg',
42               'name_callback' => sub { $_[0]->pkg. ' - '. $_[0]->comment; },
43               'target_link'   => $p.'edit/part_pkg.cgi?',
44               'disable-able'  => 1,
45
46            )
47 %>
48 </TD></TR></TABLE>
49 <BR>
50
51 <INPUT TYPE="submit" VALUE="<%= $agent_type->typenum ? "Apply changes" : "Add agent type" %>">
52
53     </FORM>
54
55 <%= include('/elements/footer.html') %>