move header() to include(/elements/header.html) so it can be changed in one place...
[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 %>
18
19 <%= include("/elements/header.html","$action Agent Type", menubar(
20   'Main Menu' => "$p",
21   'View all agent types' => "${p}browse/agent_type.cgi",
22 ))
23 %>
24
25 <% if ( $cgi->param('error') ) { %>
26   <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
27 <% } %>
28
29 <FORM ACTION="<%= popurl(1) %>process/agent_type.cgi" METHOD=POST>
30 <INPUT TYPE="hidden" NAME="typenum" VALUE="<%= $agent_type->typenum %>">
31 Agent Type #<%= $agent_type->typenum || "(NEW)" %>
32 <BR><BR>
33
34 Agent Type
35 <INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<%= $agent_type->atype %>">
36 <BR><BR>
37
38 Select which packages agents of this type may sell to customers<BR>
39
40 <% foreach my $part_pkg (
41      qsearch({ 'table'     => 'part_pkg',
42                'hashref'   => { 'disabled' => '' },
43                'select'    => 'part_pkg.*',
44                'addl_from' => 'LEFT JOIN type_pkgs USING ( pkgpart )',
45                'extra_sql' => ( $agent_type->typenum
46                                   ? 'OR typenum = '. $agent_type->typenum
47                                   : ''
48                               ),
49             })
50    ) {
51 %>
52
53   <BR>
54   <INPUT TYPE="checkbox" NAME="pkgpart<%= $part_pkg->pkgpart %>" <%=
55         qsearchs('type_pkgs',{
56           'typenum' => $agent_type->typenum,
57           'pkgpart' => $part_pkg->pkgpart,
58         })
59           ? 'CHECKED '
60           : ''
61   %> VALUE="ON">
62
63   <A HREF="<%= $p %>edit/part_pkg.cgi?<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkgpart %>: 
64   <%= $part_pkg->pkg %> - <%= $part_pkg->comment %></A>
65   <%= $part_pkg->disabled =~ /^Y/i ? ' (DISABLED)' : '' %>
66
67 <% } %>
68
69 <BR><BR>
70
71 <INPUT TYPE="submit" VALUE="<%= $agent_type->typenum ? "Apply changes" : "Add agent type" %>">
72
73     </FORM>
74   </BODY>
75 </HTML>