add default_agentnum config, RT#13302
authorivan <ivan>
Thu, 16 Jun 2011 20:21:41 +0000 (20:21 +0000)
committerivan <ivan>
Thu, 16 Jun 2011 20:21:41 +0000 (20:21 +0000)
FS/FS/Conf.pm
httemplate/config/config-process.cgi
httemplate/config/config-view.cgi
httemplate/config/config.cgi
httemplate/edit/cust_main.cgi

index ab0e6b7..d5b89b7 100644 (file)
@@ -1836,22 +1836,17 @@ and customer address. Include units.',
   },
 
   {
   },
 
   {
+    'key'         => 'default_agentnum',
+    'section'     => 'UI',
+    'description' => 'Default agent for the backoffice',
+    'type'        => 'select-agent',
+  },
+
+  {
     'key'         => 'signup_server-default_agentnum',
     'section'     => 'self-service',
     'description' => 'Default agent for the signup server',
     'key'         => 'signup_server-default_agentnum',
     'section'     => 'self-service',
     'description' => 'Default agent for the signup server',
-    'type'        => 'select-sub',
-    'options_sub' => sub { require FS::Record;
-                           require FS::agent;
-                          map { $_->agentnum => $_->agent }
-                               FS::Record::qsearch('agent', { disabled=>'' } );
-                        },
-    'option_sub'  => sub { require FS::Record;
-                           require FS::agent;
-                          my $agent = FS::Record::qsearchs(
-                            'agent', { 'agentnum'=>shift }
-                          );
-                           $agent ? $agent->agent : '';
-                        },
+    'type'        => 'select-agent',
   },
 
   {
   },
 
   {
index 4e1c85a..4a84c0d 100644 (file)
@@ -65,7 +65,7 @@
 
 %     } elsif ( $type eq 'text' || $type eq 'select' ) {
         configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>;
 
 %     } elsif ( $type eq 'text' || $type eq 'select' ) {
         configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>;
-%     } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class)$/ && ! $i->multiple ) {
+%     } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class|agent)$/ && ! $i->multiple ) {
 %       my $table = $1;
 %       my $namecol = $namecol{$table};
 %       my $pkey = dbdef->table($table)->primary_key;
 %       my $table = $1;
 %       my $namecol = $namecol{$table};
 %       my $pkey = dbdef->table($table)->primary_key;
@@ -95,6 +95,7 @@ my %namecol = (
   'part_svc'  => 'svc',
   'part_pkg'  => 'pkg',
   'pkg_class' => 'classname',
   'part_svc'  => 'svc',
   'part_pkg'  => 'pkg',
   'pkg_class' => 'classname',
+  'agent'     => 'agent',
 );
 </%once>
 <%init>
 );
 </%once>
 <%init>
@@ -158,7 +159,7 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
     }
   } elsif (
     $type =~ /^(editlist|selectmultiple)$/
     }
   } elsif (
     $type =~ /^(editlist|selectmultiple)$/
-    or ( $type =~ /^select(-(sub|part_svc|part_pkg|pkg_class))?$/
+    or ( $type =~ /^select(-(sub|part_svc|part_pkg|pkg_class|agent))?$/
          || $i->multiple )
   ) {
     if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
          || $i->multiple )
   ) {
     if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
@@ -168,7 +169,7 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
     } else {
       $conf->delete($i->key, $agentnum);
     }
     } else {
       $conf->delete($i->key, $agentnum);
     }
-  } elsif ( $type =~ /^(text|select(-(sub|part_svc|part_pkg|pkg_class))?)$/ ) {
+  } elsif ( $type =~ /^(text|select(-(sub|part_svc|part_pkg|pkg_class|agent))?)$/ ) {
     if ( $cgi->param($i->key.$n) ne '' ) {
       my $error = &{$i->validate}($cgi->param($i->key.$n), $n) if $i->validate;
       push @error, $error if $error;
     if ( $cgi->param($i->key.$n) ne '' ) {
       my $error = &{$i->validate}($cgi->param($i->key.$n), $n) if $i->validate;
       push @error, $error if $error;
index 7516dab..10fcde3 100644 (file)
@@ -212,7 +212,7 @@ Click on a configuration value to change it.
               </td>
             </tr>
 
               </td>
             </tr>
 
-%   } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class)$/ ) {
+%   } elsif ( $type =~ /^select-(part_svc|part_pkg|pkg_class|agent)$/ ) {
 %
 %     my $table = $1;
 %     my $namecol = $namecol{$table};
 %
 %     my $table = $1;
 %     my $namecol = $namecol{$table};
@@ -318,6 +318,7 @@ my %namecol = (
   'part_svc'  => 'svc',
   'part_pkg'  => 'pkg',
   'pkg_class' => 'classname',
   'part_svc'  => 'svc',
   'part_pkg'  => 'pkg',
   'pkg_class' => 'classname',
+  'agent'     => 'agent',
 );
 </%once>
 <%init>
 );
 </%once>
 <%init>
index cde4838..040ed04 100644 (file)
@@ -323,7 +323,7 @@ my @config_items = $conf->config_items;
 my %confitems = map { $_->key => $_ } @config_items;
 
 my %element_types = map { $_ => 1 } qw(
 my %confitems = map { $_->key => $_ } @config_items;
 
 my %element_types = map { $_ => 1 } qw(
-  select-part_svc select-part_pkg select-pkg_class
+  select-part_svc select-part_pkg select-pkg_class select-agent
 );
 
 </%once>
 );
 
 </%once>
index 002fd57..5164238 100755 (executable)
@@ -308,6 +308,8 @@ if ( $cgi->param('error') ) {
 
   $custnum='';
   $cust_main = new FS::cust_main ( {} );
 
   $custnum='';
   $cust_main = new FS::cust_main ( {} );
+  $cust_main->agentnum( $conf->config('default_agentnum') )
+    if $conf->exists('default_agentnum');
   $cust_main->otaker( &getotaker );
   $cust_main->referral_custnum( $cgi->param('referral_custnum') );
   @invoicing_list = ();
   $cust_main->otaker( &getotaker );
   $cust_main->referral_custnum( $cgi->param('referral_custnum') );
   @invoicing_list = ();