summaryrefslogtreecommitdiff
path: root/httemplate/edit/agent.cgi
blob: c4963e4701a1cc36384759b89026450f954f0d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<% include("/elements/header.html","$action Agent", menubar(
  'View all agents' => $p. 'browse/agent.cgi',
)) %>

<% include('/elements/error.html') %>

<FORM METHOD   = POST
      ACTION   = "<%popurl(1)%>process/agent.cgi"
      onSubmit = "return check_agent_custnum_search(this)"
>

<SCRIPT TYPE="text/javascript">
  function check_agent_custnum_search(what) {
    while ( agent_custnum_search_active ) {
      // javascript needs ambien
    }
    return true;
  }
</SCRIPT>

<INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>">

<FONT CLASS="fsinnerbox-title">
  Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
</FONT>

<TABLE CLASS="fsinnerbox">

  <TR>
    <TH ALIGN="right">Agent</TH>
    <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<% $agent->agent %>"></TD>
  </TR>

  <TR>
    <TH ALIGN="right">Agent type</TH>
    <TD>
      <SELECT NAME="typenum" SIZE=1>
%       foreach my $agent_type ( qsearch('agent_type', { 'disabled'=>'' }) ) { 

          <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>>
    <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %>
%       } 
  
      </SELECT>
    </TD>
  </TR>

  <TR>
    <TH ALIGN="right">Master customer</TH>
    <TD>
      <% include('/elements/search-cust_main.html',
                   'field_name'  => 'agent_custnum',
                   'curr_value'  => $agent->agent_custnum,
                   'find_button' => 1,
                )
      %>
    </TD>
  </TR>

% if ( $conf->exists('selfservice-agent_login') ) {

    <TR>
      <TH ALIGN="right">Username</TH>
      <TD><INPUT TYPE="text" NAME="username" SIZE=16 VALUE="<% $agent->username %>"></TD>
    </TR>

    <TR>
      <TH ALIGN="right">Password</TH>
      <TD><INPUT TYPE="password" NAME="_password" SIZE=16 VALUE="<% $agent->_password %>"></TD>
    </TR>

% } else {

    <INPUT TYPE="hidden" NAME="username" VALUE="<% $agent->username |h %>">
    <INPUT TYPE="hidden" NAME="_password" VALUE="<% $agent->_password |h %>">

% }

  <TR>
    <TD ALIGN="right">Disable</TD>
    <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
  </TR>

% if ( $conf->exists('agent-invoice_template') ) {

  <% include('/elements/tr-select-invoice_template.html',
               'label'      => 'Invoice template',
               'field'      => 'invoice_template',
               'curr_value' => $agent->invoice_template,
            )
  %>

% } else {

  <INPUT TYPE="hidden" NAME="invoice_template" VALUE="<% $agent->invoice_template %>">

% }

% if ( $conf->config('ticket_system') ) {
%    my $default_queueid = $conf->config('ticket_system-default_queueid');
%    my $default_queue = FS::TicketSystem->queue($default_queueid);
%    $default_queue = "(default) $default_queueid: $default_queue"
%      if $default_queueid;
%    my %queues = FS::TicketSystem->queues();
%    my @queueids = sort { $a <=> $b } keys %queues;
%  

    <TR>
      <TD ALIGN="right">Ticketing queue</TD>
      <TD>
        <SELECT NAME="ticketing_queueid">
          <OPTION VALUE=""><% $default_queue %>
% foreach my $queueid ( @queueids ) { 

            <OPTION VALUE="<% $queueid %>" <% $agent->ticketing_queueid == $queueid ? ' SELECTED' : '' %>><% $queueid %>: <% $queues{$queueid} %>
% } 

        </SELECT>
      </TD>
    </TR>
% } 

</TABLE>
<BR>

<FONT CLASS="fsinnerbox-title"><% mt('Access Groups') |h %></FONT>
<TABLE CLASS="fsinnerbox">

  <TR>
    <TD><% include('/elements/checkboxes-table.html',
                     'source_obj'   => $agent,
                     'link_table'   => 'access_groupagent',
                     'target_table' => 'access_group',
                     'name_col'     => 'groupname',
                     'target_link'  => $p. 'edit/access_group.html?',
                  )
        %>
    </TD>
  </TR>

</TABLE>
<BR>

<& /elements/table-commissions.html,
     'source_obj'   => $agent,
     'link_table'   => 'agent_pkg_class',
     #'target_table' => 'pkg_class',
&>
<BR>

% if ( $conf->config('currencies') ) {

    <FONT CLASS="fsinnerbox-title"><% mt('Currencies') |h %></FONT>
    <TABLE CLASS="fsinnerbox">
      <TR>
        <TD>
          <& /elements/checkboxes-table-name.html,
               'link_table' => 'agent_currency',
               'name_col'   => 'currency',
               'names_list' => [ map [ $_, {label=>"$_: ".code2currency($_)} ],
                                   $conf->config('currencies')
                               ],
          &>
        </TD>
      </TR>
    </TABLE>

% }

<BR>


<INPUT TYPE="submit" VALUE="<% $agent->agentnum ? "Apply changes" : "Add agent" %>">

</FORM>

<% include('/elements/footer.html') %>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $agent;
if ( $cgi->param('error') ) {
  $agent = new FS::agent ( {
    map { $_, scalar($cgi->param($_)) } fields('agent')
  } );
} elsif ( $cgi->keywords ) {
  my($query) = $cgi->keywords;
  $query =~ /^(\d+)$/;
  $agent = qsearchs( 'agent', { 'agentnum' => $1 } );
} else { #adding
  $agent = new FS::agent {};
}
my $action = $agent->agentnum ? 'Edit' : 'Add';

my $conf = new FS::Conf;

</%init>