svc_cable label, RT#26013
[freeside.git] / httemplate / edit / cust_main / top_misc.html
index a2381f3..4d2f24b 100644 (file)
@@ -1,12 +1,42 @@
 <% &ntable("#cccccc") %>
 
 %# tags
-<% include('/elements/tr-select-cust_tag.html',
+<& /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) ) {
 %
 %   $cust_main->agentnum($agentnum);
 
     <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
-    <INPUT TYPE="hidden" NAME="agentnum"      VALUE="<% $agentnum %>">
+    <INPUT TYPE="hidden" NAME="agentnum"      ID="agentnum" 
+      VALUE="<% $agentnum %>">
     <TR>
-      <TD ALIGN="right">Agent</TD>
+      <TD ALIGN="right"><% mt('Agent') |h %></TD>
       <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
     </TR>
+
 % } else {
 
-  <% include('/elements/tr-select-agent.html'
+  <& /elements/tr-select-agent.html
                 'curr_value'    => $cust_main->agentnum,
-                'label'         => "<B>${r}Agent</B>",
-                'empty_label'   => 'Select agent',
+                'label'         => "<B>${r}".emt('Agent')."</B>",
+                'empty_label'   => emt('Select agent'),
                 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
-                'viewall_right' => 'None', #override default 'View customers of all agents'
-             )
-  %>
+                'viewall_right' => emt('None'), 
+                'onchange'      => 'agent_changed(this)',
+  &>
 
 % }
 
@@ -37,7 +68,7 @@
 % if ( $conf->exists('cust_main-edit_agent_custid') ) {
 
     <TR>
-      <TD ALIGN="right">Customer identifier</TD>
+      <TD ALIGN="right"><% mt('Customer identifier') |h %></TD>
       <TD><INPUT TYPE="text" NAME="agent_custid" VALUE="<% $cust_main->agent_custid %>"></TD>
     </TR>
 
 % }
 
 %# class
-<% include('/elements/tr-select-cust_class.html',
+<& /elements/tr-select-cust_class.html,
              'curr_value'  => $cust_main->classnum,
-             'label'       => "Class",
-             #'empty_label' => '(none)',
-             #'disable_empty' => 
-          )
-%>
+             'label'       => emt("Class"),
+&>
 
 %# referral (advertising source)
 %my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
 
 % } else { 
 
-   <% include('/elements/tr-select-part_referral.html',
+   <& /elements/tr-select-part_referral.html,
                 'curr_value' => $refnum
-             )
-   %>
+   &>
 % } 
 
 
 %) {
 
   <TR>
-    <TD ALIGN="right">Referring customer</TD>
+    <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 %></A>
+      <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">Referring customer</TD>
+    <TD ALIGN="right"><% mt('Referring customer') |h %></TD>
     <TD>
-      <!-- <INPUT TYPE="text" NAME="referral_custnum" VALUE=""> -->
-      <% include('/elements/search-cust_main.html',
+      <& /elements/search-cust_main.html,
                     'field_name' => 'referral_custnum',
                     'curr_value' => $cust_main->referral_custnum,
-                 )
-      %>
+      &>
     </TD>
   </TR>
 
 
 %# signup date
 % if ( $conf->exists('cust_main-edit_signupdate') ) {
-    <% include('/elements/tr-input-date-field.html', {
+    <& /elements/tr-input-date-field.html, {
                   'name'        => 'signupdate',
                   'value'       => $cust_main->signupdate,
-                  'label'       => 'Signup date',
+                  '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>
@@ -130,4 +179,18 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 
 my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
 
+# 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>