event refactor, landing on HEAD!
[freeside.git] / httemplate / elements / select-agent.html
index aa480a5..54069a5 100644 (file)
@@ -1,16 +1,21 @@
-<%
-  my( $agentnum, %opt ) = @_;
-
-  my %select_opt = ();
-  $select_opt{'records'} = $opt{'agents'}
-    if $opt{'agents'};
-
-%><%= include( '/elements/select-table.html',
+<% include( '/elements/select-table.html',
                  'table'       => 'agent',
                  'name_col'    => 'agent',
-                 'value'       => $agentnum,
+                 'value'       => $agentnum || '',
                  'empty_label' => 'all',
                  'hashref'     => { 'disabled' => '' },
-                 %select_opt,
+                 'extra_sql'   => ' AND '.
+                                  $FS::CurrentUser::CurrentUser->agentnums_sql.
+                                  ' ORDER BY agent',
+                 %opt,
              )
 %>
+<%init>
+
+my %opt = @_;
+my $agentnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'agents'}
+  if $opt{'agents'};
+
+</%init>