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
|
<% &ntable("#cccccc") %>
%# tags
<& /elements/tr-select-cust_tag.html,
'custnum' => $custnum,
'cgi' => $cgi,
&>
<SCRIPT TYPE="text/javascript">
var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
var ship_fields = ['address1', 'city', 'state',
'zip', 'country', 'latitude', 'longitude'];
function agent_changed(what) {
var agentnum = what.value;
var f = what.form;
if ( ship_locked_agents[agentnum] ) {
f['same'].checked = false;
samechanged(f['same']); // enable everything, then...
f['same'].disabled = true;
for(var x in ship_locked_agents[agentnum]) {
f['ship_'+x].value = ship_locked_agents[agentnum][x];
f['ship_'+x].disabled = true;
f['ship_'+x].style.backgroundColor = '#dddddd';
}
f['ship_address2'].disabled = false;
f['ship_address2'].style.backgroundColor = '#ffffff';
} else {
if ( f['same'].disabled ) { // only if switching from a locked agent
f['same'].disabled = false;
f['same'].checked = true;
samechanged(f['same']); // re-enable everything
}
}
}
window.onload = function() {
samechanged(document.getElementById('same'));
agent_changed(document.getElementById('agentnum'));
};
</SCRIPT>
%# agent
% if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
%
% my $agentnum = $1;
% $cust_main->agentnum($agentnum);
<INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
<INPUT TYPE="hidden" NAME="agentnum" ID="agentnum"
VALUE="<% $agentnum %>">
<TR>
<TD ALIGN="right"><% mt('Agent') |h %></TD>
<TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
</TR>
% } else {
<& /elements/tr-select-agent.html,
'curr_value' => $cust_main->agentnum,
'label' => "<B>${r}".emt('Agent')."</B>",
'empty_label' => emt('Select agent'),
'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
'viewall_right' => emt('None'),
'onchange' => 'agent_changed(this)',
&>
% }
%# agent_custid
% if ( $conf->exists('cust_main-edit_agent_custid') ) {
<TR>
<TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
<TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
</TR>
% } else {
<INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
% }
%# class
<& /elements/tr-select-cust_class.html,
'curr_value' => $cust_main->classnum,
'label' => emt("Class"),
&>
%# referral (advertising source)
%my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
%if ( $custnum && ! $conf->exists('editreferrals') ) {
<INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
% } else {
<& /elements/tr-select-part_referral.html,
'curr_value' => $refnum
&>
% }
%# referring customer
%my $referring_cust_main = '';
%if ( $cust_main->referral_custnum
% and $referring_cust_main =
% qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
% and ! $curuser->access_right('Edit referring customer')
%) {
<TR>
<TD ALIGN="right"><% mt('Referring customer') |h %></TD>
<TD>
<A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
</TD>
</TR>
<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
% } elsif ( ! $conf->exists('disable_customer_referrals') ) {
<TR>
<TD ALIGN="right"><% mt('Referring customer') |h %></TD>
<TD>
<& /elements/search-cust_main.html,
'field_name' => 'referral_custnum',
'curr_value' => $cust_main->referral_custnum,
&>
</TD>
</TR>
% } else {
<INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
% }
%# signup date
% if ( $conf->exists('cust_main-edit_signupdate') ) {
<& /elements/tr-input-date-field.html, {
'name' => 'signupdate',
'value' => $cust_main->signupdate,
'label' => emt('Signup date'),
'format' => ( $conf->config('date_format') || "%m/%d/%Y" ),
}
&>
% }
% # permission to edit ticket subjects
% if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
<TR>
<TD ALIGN="right">
<INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <%
$cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
<TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
</TR>
% } else {
<INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
% }
% # permission to edit
% if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
<TR>
<TD ALIGN="right">
<INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <%
$cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
<TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
</TR>
% } else {
<INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
% }
</TABLE>
<%init>
my( $cust_main, %opt ) = @_;
my $custnum = $opt{'custnum'};
my $conf = new FS::Conf;
my $curuser = $FS::CurrentUser::CurrentUser;
my $r = qq!<font color="#ff0000">*</font> !;
# which agents lock the service address, if any
my %ship_locked_agents;
foreach (qsearch('agent',{})) {
my $agentnum = $_->agentnum;
next unless $conf->exists('agent-ship_address', $_->agentnum);
my $agent_cust_main = $_->agent_cust_main or next;
my $pre = '';
$pre = 'ship_' if $agent_cust_main->has_ship_address;
$ship_locked_agents{$agentnum} = +{
map { $_ => $agent_cust_main->get($pre.$_) }
qw(address1 city state zip country latitude longitude)
};
}
</%init>
|