4.x style
[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
23 <FONT CLASS="fsinnerbox-title">
24   Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
25 </FONT>
26
27 <TABLE CLASS="fsinnerbox">
28
29   <TR>
30     <TH ALIGN="right">Agent</TH>
31     <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $agent->agent %>"></TD>
32   </TR>
33
34   <TR>
35     <TH ALIGN="right">Agent type</TH>
36     <TD>
37       <SELECT NAME="typenum" SIZE=1>
38 %       foreach my $agent_type ( qsearch('agent_type', { 'disabled'=>'' }) ) { 
39
40           <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
41     <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
42 %       } 
43   
44       </SELECT>
45     </TD>
46   </TR>
47
48   <TR>
49     <TH ALIGN="right">Master customer</TH>
50     <TD>
51       <% include('/elements/search-cust_main.html',
52                    'field_name'  => 'agent_custnum',
53                    'curr_value'  => $agent->agent_custnum,
54                    'find_button' => 1,
55                 )
56       %>
57     </TD>
58   </TR>
59
60 % if ( $conf->exists('selfservice-agent_login') ) {
61
62     <TR>
63       <TH ALIGN="right">Username</TH>
64       <TD><INPUT TYPE="text" NAME="username" SIZE=16 VALUE="<% $agent->username %>"></TD>
65     </TR>
66
67     <TR>
68       <TH ALIGN="right">Password</TH>
69       <TD><INPUT TYPE="password" NAME="_password" SIZE=16 VALUE="<% $agent->_password %>"></TD>
70     </TR>
71
72 % } else {
73
74     <INPUT TYPE="hidden" NAME="username" VALUE="<% $agent->username |h %>">
75     <INPUT TYPE="hidden" NAME="_password" VALUE="<% $agent->_password |h %>">
76
77 % }
78
79   <TR>
80     <TD ALIGN="right">Disable</TD>
81     <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
82   </TR>
83
84 % if ( $conf->exists('agent-invoice_template') ) {
85
86   <% include('/elements/tr-select-invoice_template.html',
87                'label'      => 'Invoice template',
88                'field'      => 'invoice_template',
89                'curr_value' => $agent->invoice_template,
90             )
91   %>
92
93 % } else {
94
95   <INPUT TYPE="hidden" NAME="invoice_template" VALUE="<% $agent->invoice_template %>">
96
97 % }
98
99 % if ( $conf->config('ticket_system') ) {
100 %    my $default_queueid = $conf->config('ticket_system-default_queueid');
101 %    my $default_queue = FS::TicketSystem->queue($default_queueid);
102 %    $default_queue = "(default) $default_queueid: $default_queue"
103 %      if $default_queueid;
104 %    my %queues = FS::TicketSystem->queues();
105 %    my @queueids = sort { $a <=> $b } keys %queues;
106 %  
107
108     <TR>
109       <TD ALIGN="right">Ticketing queue</TD>
110       <TD>
111         <SELECT NAME="ticketing_queueid">
112           <OPTION VALUE=""><% $default_queue %>
113 % foreach my $queueid ( @queueids ) { 
114
115             <OPTION VALUE="<% $queueid %>" <% $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><% $queueid %>: <% $queues{$queueid} %>
116 % } 
117
118         </SELECT>
119       </TD>
120     </TR>
121 % } 
122
123 </TABLE>
124 <BR>
125
126 <FONT CLASS="fsinnerbox-title"><% mt('Access Groups') |h %></FONT>
127 <TABLE CLASS="fsinnerbox">
128
129   <TR>
130     <TD><% include('/elements/checkboxes-table.html',
131                      'source_obj'   => $agent,
132                      'link_table'   => 'access_groupagent',
133                      'target_table' => 'access_group',
134                      'name_col'     => 'groupname',
135                      'target_link'  => $p. 'edit/access_group.html?',
136                   )
137         %>
138     </TD>
139   </TR>
140
141 </TABLE>
142 <BR>
143
144 <& /elements/table-commissions.html,
145      'source_obj'   => $agent,
146      'link_table'   => 'agent_pkg_class',
147      #'target_table' => 'pkg_class',
148 &>
149 <BR>
150
151 % if ( $conf->config('currencies') ) {
152
153     <FONT CLASS="fsinnerbox-title"><% mt('Currencies') |h %></FONT>
154     <TABLE CLASS="fsinnerbox">
155       <TR>
156         <TD>
157           <& /elements/checkboxes-table-name.html,
158                'link_table' => 'agent_currency',
159                'name_col'   => 'currency',
160                'names_list' => [ map [ $_, {label=>"$_: ".code2currency($_)} ],
161                                    $conf->config('currencies')
162                                ],
163           &>
164         </TD>
165       </TR>
166     </TABLE>
167
168 % }
169
170 <BR>
171
172
173 <INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">
174
175 </FORM>
176
177 <% include('/elements/footer.html') %>
178
179 <%init>
180
181 die "access denied"
182   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
183
184 my $agent;
185 if ( $cgi->param('error') ) {
186   $agent = new FS::agent ( {
187     map { $_, scalar($cgi->param($_)) } fields('agent')
188   } );
189 } elsif ( $cgi->keywords ) {
190   my($query) = $cgi->keywords;
191   $query =~ /^(\d+)$/;
192   $agent = qsearchs( 'agent', { 'agentnum' => $1 } );
193 } else { #adding
194   $agent = new FS::agent {};
195 }
196 my $action = $agent->agentnum ? 'Edit' : 'Add';
197
198 my $conf = new FS::Conf;
199
200 </%init>