import torrus 1.0.9
[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 METHOD   = POST
8       ACTION   = "<%popurl(1)%>process/agent.cgi"
9       onSubmit = "return check_agent_custnum_search(this)"
10 >
11
12 <SCRIPT TYPE="text/javascript">
13   function check_agent_custnum_search(what) {
14     while ( agent_custnum_search_active ) {
15       // javascript needs ambien
16     }
17     return true;
18   }
19 </SCRIPT>
20
21 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>">
22 Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
23
24 <% &ntable("#cccccc", 2, '') %>
25
26   <TR>
27     <TH ALIGN="right">Agent</TH>
28     <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $agent->agent %>"></TD>
29   </TR>
30
31   <TR>
32     <TH ALIGN="right">Agent type</TH>
33     <TD>
34       <SELECT NAME="typenum" SIZE=1>
35 %       foreach my $agent_type (qsearch('agent_type',{})) { 
36
37           <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
38     <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
39 %       } 
40   
41       </SELECT>
42     </TD>
43   </TR>
44
45   <TR>
46     <TH ALIGN="right">Master customer</TH>
47     <TD>
48       <% include('/elements/search-cust_main.html',
49                    'field_name'  => 'agent_custnum',
50                    'curr_value'  => $agent->agent_custnum,
51                    'find_button' => 1,
52                 )
53       %>
54     </TD>
55   </TR>
56
57 % if ( $conf->exists('selfservice-agent_login') ) {
58
59     <TR>
60       <TH ALIGN="right">Username</TH>
61       <TD><INPUT TYPE="text" NAME="username" SIZE=16 VALUE="<% $agent->username %>"></TD>
62     </TR>
63
64     <TR>
65       <TH ALIGN="right">Password</TH>
66       <TD><INPUT TYPE="password" NAME="_password" SIZE=16 VALUE="<% $agent->_password %>"></TD>
67     </TR>
68
69 % } else {
70
71     <INPUT TYPE="hidden" NAME="username" VALUE="<% $agent->username |h %>">
72     <INPUT TYPE="hidden" NAME="_password" VALUE="<% $agent->_password |h %>">
73
74 % }
75
76   <TR>
77     <TD ALIGN="right">Disable</TD>
78     <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
79   </TR>
80
81 % if ( $conf->exists('agent-invoice_template') ) {
82
83   <% include('/elements/tr-select-invoice_template.html',
84                'label'      => 'Invoice template',
85                'field'      => 'invoice_template',
86                'curr_value' => $agent->invoice_template,
87             )
88   %>
89
90 % } else {
91
92   <INPUT TYPE="hidden" NAME="invoice_template" VALUE="<% $agent->invoice_template %>">
93
94 % }
95
96 % if ( $conf->config('ticket_system') ) {
97 %    my $default_queueid = $conf->config('ticket_system-default_queueid');
98 %    my $default_queue = FS::TicketSystem->queue($default_queueid);
99 %    $default_queue = "(default) $default_queueid: $default_queue"
100 %      if $default_queueid;
101 %    my %queues = FS::TicketSystem->queues();
102 %    my @queueids = sort { $a <=> $b } keys %queues;
103 %  
104
105     <TR>
106       <TD ALIGN="right">Ticketing queue</TD>
107       <TD>
108         <SELECT NAME="ticketing_queueid">
109           <OPTION VALUE=""><% $default_queue %>
110 % foreach my $queueid ( @queueids ) { 
111
112             <OPTION VALUE="<% $queueid %>" <% $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><% $queueid %>: <% $queues{$queueid} %>
113 % } 
114
115         </SELECT>
116       </TD>
117     </TR>
118 % } 
119
120   <TR>
121     <TD ALIGN="right">Access Groups</TD>
122     <TD><% include('/elements/checkboxes-table.html',
123                      'source_obj'   => $agent,
124                      'link_table'   => 'access_groupagent',
125                      'target_table' => 'access_group',
126                      'name_col'     => 'groupname',
127                      'target_link'  => $p. 'edit/access_group.html?',
128                   )
129         %>
130     </TD>
131   </TR>
132
133 </TABLE>
134
135 <BR>
136 <INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">
137
138 </FORM>
139
140 <% include('/elements/footer.html') %>
141
142 <%init>
143
144 die "access denied"
145   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
146
147 my $agent;
148 if ( $cgi->param('error') ) {
149   $agent = new FS::agent ( {
150     map { $_, scalar($cgi->param($_)) } fields('agent')
151   } );
152 } elsif ( $cgi->keywords ) {
153   my($query) = $cgi->keywords;
154   $query =~ /^(\d+)$/;
155   $agent = qsearchs( 'agent', { 'agentnum' => $1 } );
156 } else { #adding
157   $agent = new FS::agent {};
158 }
159 my $action = $agent->agentnum ? 'Edit' : 'Add';
160
161 my $conf = new FS::Conf;
162
163 </%init>