don't redirect to a GET with sensitive data, RT#26099
[freeside.git] / httemplate / edit / cust_main / top_misc.html
1 <% &ntable("#cccccc") %>
2
3 %# tags
4 <& /elements/tr-select-cust_tag.html,
5              'custnum' => $custnum,
6              'cgi'     => $cgi,
7 &>
8
9 <SCRIPT TYPE="text/javascript">
10 var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
11 var ship_fields = ['address1', 'city', 'state', 
12   'zip', 'country', 'latitude', 'longitude'];
13 function agent_changed(what) {
14   var agentnum = what.value;
15   var f = what.form;
16   if ( ship_locked_agents[agentnum] ) {
17     f['same'].checked = false;
18     samechanged(f['same']); // enable everything, then...
19     f['same'].disabled = true;
20     for(var x in ship_locked_agents[agentnum]) {
21       f['ship_'+x].value = ship_locked_agents[agentnum][x];
22       f['ship_'+x].disabled = true;
23       f['ship_'+x].style.backgroundColor = '#dddddd';
24     }
25     f['ship_address2'].disabled = false;
26     f['ship_address2'].style.backgroundColor = '#ffffff';
27   } else {
28     if ( f['same'].disabled ) { // only if switching from a locked agent
29       f['same'].disabled = false;
30       f['same'].checked = true;
31       samechanged(f['same']); // re-enable everything
32     }
33   }
34 }
35 window.onload = function() {
36   samechanged(document.getElementById('same'));
37   agent_changed(document.getElementById('agentnum'));
38 };
39 </SCRIPT>
40 %# agent
41 % if ( $cgi->param('lock_agentnum') =~ /^(\d+)$/ && $curuser->agentnum($1) ) {
42 %
43 %   my $agentnum = $1;
44 %   $cust_main->agentnum($agentnum);
45
46     <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
47     <INPUT TYPE="hidden" NAME="agentnum"      ID="agentnum" 
48       VALUE="<% $agentnum %>">
49     <TR>
50       <TD ALIGN="right"><% mt('Agent') |h %></TD>
51       <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
52     </TR>
53
54 % } else {
55
56   <& /elements/tr-select-agent.html, 
57                 'curr_value'    => $cust_main->agentnum,
58                 'label'         => "<B>${r}".emt('Agent')."</B>",
59                 'empty_label'   => emt('Select agent'),
60                 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
61                 'viewall_right' => emt('None'), 
62                 'onchange'      => 'agent_changed(this)',
63   &>
64
65 % }
66
67 %# agent_custid
68 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
69
70     <TR>
71       <TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
72       <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
73     </TR>
74
75 % } else {
76
77     <INPUT TYPE="hidden" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>">
78
79 % }
80
81 %# class
82 <& /elements/tr-select-cust_class.html,
83              'curr_value'  => $cust_main->classnum,
84              'label'       => emt("Class"),
85 &>
86
87 %# referral (advertising source)
88 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
89 %if ( $custnum && ! $conf->exists('editreferrals') ) {
90
91   <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $refnum %>">
92
93 % } else { 
94
95    <& /elements/tr-select-part_referral.html,
96                 'curr_value' => $refnum
97    &>
98 % } 
99
100
101 %# referring customer
102 %my $referring_cust_main = '';
103 %if ( $cust_main->referral_custnum
104 %     and $referring_cust_main =
105 %           qsearchs('cust_main', { custnum => $cust_main->referral_custnum } )
106 %     and ! $curuser->access_right('Edit referring customer')
107 %) {
108
109   <TR>
110     <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
111     <TD>
112       <A HREF="<% popurl(1) %>/cust_main.cgi?<% $cust_main->referral_custnum %>"><% $cust_main->referral_custnum %>: <% $referring_cust_main->name |h %></A>
113     </TD>
114   </TR>
115   <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->referral_custnum %>">
116
117 % } elsif ( ! $conf->exists('disable_customer_referrals') ) { 
118
119   <TR>
120     <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
121     <TD>
122       <& /elements/search-cust_main.html,
123                     'field_name' => 'referral_custnum',
124                     'curr_value' => $cust_main->referral_custnum,
125       &>
126     </TD>
127   </TR>
128
129 % } else { 
130   <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="">
131 % } 
132
133 %# signup date
134 % if ( $conf->exists('cust_main-edit_signupdate') ) {
135     <& /elements/tr-input-date-field.html, {
136                   'name'        => 'signupdate',
137                   'value'       => $cust_main->signupdate,
138                   'label'       => emt('Signup date'),
139                   'format'      => ( $conf->config('date_format') || "%m/%d/%Y" ),
140               }
141     &>
142 % }
143
144 % # permission to edit ticket subjects
145 % if ( $conf->exists('ticket_system-selfservice_edit_subject') ) {
146   <TR>
147     <TD ALIGN="right">
148       <INPUT TYPE="checkbox" NAME="edit_subject" VALUE="Y" <% 
149         $cust_main->edit_subject ? 'CHECKED' : '' %>></TD>
150     <TD ALIGN="left"><% mt('Can edit ticket subjects') |h %></TD>
151   </TR>
152 % } else {
153   <INPUT TYPE="hidden" NAME="edit_subject" VALUE="<% $cust_main->edit_subject %>">
154 % }
155
156 % # permission to edit
157 % if ( $conf->exists('cust_main-edit_calling_list_exempt') ) {
158   <TR>
159     <TD ALIGN="right">
160       <INPUT TYPE="checkbox" NAME="calling_list_exempt" VALUE="Y" <% 
161         $cust_main->calling_list_exempt ? 'CHECKED' : '' %>></TD>
162     <TD ALIGN="left"><% mt('Calling list exempt') |h %></TD>
163   </TR>
164 % } else {
165   <INPUT TYPE="hidden" NAME="calling_list_exempt" VALUE="<% $cust_main->calling_list_exempt %>">
166 % }
167
168 </TABLE>
169
170 <%init>
171
172 my( $cust_main, %opt ) = @_;
173
174 my $custnum = $opt{'custnum'};
175
176 my $conf = new FS::Conf;
177
178 my $curuser = $FS::CurrentUser::CurrentUser;
179
180 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
181
182 # which agents lock the service address, if any
183 my %ship_locked_agents;
184 foreach (qsearch('agent',{})) {
185   my $agentnum = $_->agentnum;
186   next unless $conf->exists('agent-ship_address', $_->agentnum);
187   my $agent_cust_main = $_->agent_cust_main or next;
188   my $pre = '';
189   $pre = 'ship_' if $agent_cust_main->has_ship_address;
190   $ship_locked_agents{$agentnum} = +{
191     map { $_ => $agent_cust_main->get($pre.$_) }
192     qw(address1 city state zip country latitude longitude)
193   };
194 }
195
196 </%init>