a0af9fa442512c160ba289ad5f0974d804e280dd
[freeside.git] / httemplate / edit / agent.cgi
1 <% include("/elements/header.html","$action Agent", menubar(
2   'View all agents' => $p. 'browse/agent.cgi',
3 )) %>
4
5 <% include('/elements/error.html') %>
6
7 <FORM ACTION="<%popurl(1)%>process/agent.cgi" METHOD=POST>
8 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>">
9 Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
10
11 <% &ntable("#cccccc", 2, '') %>
12
13   <TR>
14     <TH ALIGN="right">Agent</TH>
15     <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $agent->agent %>"></TD>
16   </TR>
17
18   <TR>
19     <TH ALIGN="right">Agent type</TH>
20     <TD>
21       <SELECT NAME="typenum" SIZE=1>
22 %       foreach my $agent_type (qsearch('agent_type',{})) { 
23
24           <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
25     <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
26 %       } 
27   
28       </SELECT>
29     </TD>
30   </TR>
31
32   <TR>
33     <TH ALIGN="right">Master customer</TH>
34     <TD>
35       <% include('/elements/search-cust_main.html',
36                    'field_name'  => 'agent_custnum',
37                    'curr_value'  => $agent->agent_custnum,
38                    'find_button' => 1,
39                 )
40       %>
41     </TD>
42   </TR>
43
44   <TR>
45     <TD ALIGN="right">Disable</TD>
46     <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
47   </TR>
48
49 % if ( $conf->exists('agent-invoice_template') ) {
50
51   <% include('/elements/tr-select-invoice_template.html',
52                'label'      => 'Invoice template',
53                'field'      => 'invoice_template',
54                'curr_value' => $agent->invoice_template,
55             )
56   %>
57
58 % } else {
59
60   <INPUT TYPE="hidden" NAME="invoice_template" VALUE="<% $agent->invoice_template %>">
61
62 % }
63
64 % if ( $conf->config('ticket_system') ) {
65 %    my $default_queueid = $conf->config('ticket_system-default_queueid');
66 %    my $default_queue = FS::TicketSystem->queue($default_queueid);
67 %    $default_queue = "(default) $default_queueid: $default_queue"
68 %      if $default_queueid;
69 %    my %queues = FS::TicketSystem->queues();
70 %    my @queueids = sort { $a <=> $b } keys %queues;
71 %  
72
73     <TR>
74       <TD ALIGN="right">Ticketing queue</TD>
75       <TD>
76         <SELECT NAME="ticketing_queueid">
77           <OPTION VALUE=""><% $default_queue %>
78 % foreach my $queueid ( @queueids ) { 
79
80             <OPTION VALUE="<% $queueid %>" <% $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><% $queueid %>: <% $queues{$queueid} %>
81 % } 
82
83         </SELECT>
84       </TD>
85     </TR>
86 % } 
87
88   <TR>
89     <TD ALIGN="right">Access Groups</TD>
90     <TD><% include('/elements/checkboxes-table.html',
91                      'source_obj'   => $agent,
92                      'link_table'   => 'access_groupagent',
93                      'target_table' => 'access_group',
94                      'name_col'     => 'groupname',
95                      'target_link'  => $p. 'edit/access_group.html?',
96                   )
97         %>
98     </TD>
99   </TR>
100
101 </TABLE>
102
103 <BR>
104 <INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">
105
106 </FORM>
107
108 <% include('/elements/footer.html') %>
109
110 <%init>
111
112 die "access denied"
113   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
114
115 my $agent;
116 if ( $cgi->param('error') ) {
117   $agent = new FS::agent ( {
118     map { $_, scalar($cgi->param($_)) } fields('agent')
119   } );
120 } elsif ( $cgi->keywords ) {
121   my($query) = $cgi->keywords;
122   $query =~ /^(\d+)$/;
123   $agent = qsearchs( 'agent', { 'agentnum' => $1 } );
124 } else { #adding
125   $agent = new FS::agent {};
126 }
127 my $action = $agent->agentnum ? 'Edit' : 'Add';
128
129 my $conf = new FS::Conf;
130
131 </%init>