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