clean up select-agent agent virtualization, RT#1405
authorivan <ivan>
Sat, 14 Feb 2009 00:41:24 +0000 (00:41 +0000)
committerivan <ivan>
Sat, 14 Feb 2009 00:41:24 +0000 (00:41 +0000)
httemplate/browse/addr_block.cgi
httemplate/elements/select-agent.html
httemplate/elements/tr-select-agent.html

index 241bb93..1bbcdcb 100644 (file)
@@ -92,8 +92,7 @@ my $html_foot = qq(
   <INPUT TYPE="text" NAME="ip_gateway" SIZE="15">/<INPUT TYPE="text" NAME="ip_netmask" SIZE="2">
 );
 $html_foot .= include( '/elements/select-agent.html',
-                       'agent_virt'       => 1,
-                       'agent_null_right' => 'Broadband global configuration',
+                         'agent_null_right' => 'Broadband global configuration',
                      );
 $html_foot .= qq(
   <INPUT TYPE="submit" NAME="submit" VALUE="Add">
index d8ab500..897c982 100644 (file)
@@ -1,10 +1,11 @@
 <% include( '/elements/select-table.html',
-                 'table'       => 'agent',
-                 'name_col'    => 'agent',
-                 'value'       => $agentnum || '',
-                 'empty_label' => 'all',
-                 'hashref'     => { 'disabled' => '' },
-                 'order_by'    => ' ORDER BY agent',
+                 'table'         => 'agent',
+                 'name_col'      => 'agent',
+                 'value'         => $agentnum || '',
+                 'agent_virt'    => 1,
+                 'empty_label'   => 'all',
+                 'hashref'       => { 'disabled' => '' },
+                 'order_by'      => ' ORDER BY agent',
                  'disable_empty' => $disable_empty,
                  %opt,
              )
@@ -18,12 +19,13 @@ $opt{'records'} = delete $opt{'agents'}
   if $opt{'agents'};
 
 my $curuser = $FS::CurrentUser::CurrentUser;
-my $disable_empty = 1;
-if ( $opt{'agent_null_right'} &&
-     $curuser->access_right($opt{'agent_null_right'})
-   )
-{
-  $disable_empty--;
+my $disable_empty = 0;
+if ( $opt{'agent_null_right'} ) {
+  if ( $curuser->access_right($opt{'agent_null_right'}) ) {
+    $disable_empty = 0;
+  } else {
+    $disable_empty = 1;
+  }
 }
 
 </%init>
index 44df3fc..fcfa9f3 100644 (file)
 my %opt = @_;
 my $agentnum = $opt{'curr_value'} || $opt{'value'};
 
-my @agents;
-if ( $opt{'agents'} ) {
-  #@agents = @{ $opt{'agents'} };
-  #here is the agent virtualization
-  my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
-  @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} };
-  delete $opt{'agents'};
-} else {
-  @agents = $FS::CurrentUser::CurrentUser->agents;
-}
+my @agents = $opt{'agents'}
+               ? @{ $opt{'agents'} }
+               : $FS::CurrentUser::CurrentUser->agents;
 
 </%init>