Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / edit / router.cgi
index fdcd7b3..a756c61 100755 (executable)
@@ -29,19 +29,26 @@ die "access denied"
   unless $curuser->access_right('Broadband configuration')
     || $curuser->access_right('Broadband global configuration');
 
+my @svc_x = 'svc_broadband';
+if ( FS::Conf->new->exists('svc_acct-ip_addr') ) {
+  push @svc_x, 'svc_acct';
+}
+
 my $callback = sub {
   my ($cgi, $object, $fields) = (shift, shift, shift);
+
+  my $extra_sql = ' AND svcdb IN(' . join(',', map { "'$_'" } @svc_x) . ')';
   unless ($object->svcnum) {
     push @{$fields},
       { 'type'          => 'tablebreak-tr-title',
         'value'         => 'Select the service types available on this router',
       },
-      { 'field'         => 'svc_part',
-        'type'          => 'checkboxes-table',
+      { 'type'          => 'checkboxes-table',
         'target_table'  => 'part_svc',
         'link_table'    => 'part_svc_router',
         'name_col'      => 'svc',
-        'hashref'       => { 'svcdb' => 'svc_broadband', 'disabled' => '' },
+        'hashref'       => { 'disabled' => '' },
+        'extra_sql'     => $extra_sql,
       };
   }
 };