disabling a taxclass, RT#5472
[freeside.git] / httemplate / elements / select-table.html
index 32a61e9..1a440f0 100644 (file)
@@ -24,6 +24,7 @@ Example:
     'extra_sql'        => '',
     'agent_virt'       => 0, #set true and make sure the result is JOINed to
                              #something with agentnum (usually cust_main)
+    'agent_null'       => 0, #set true to always show un-agented entries
     'agent_null_right' => '', #right to see un-agented entries
     #or
     'records'        => \@records, #instead of search params
@@ -63,8 +64,13 @@ Example:
 >
 
 % while ( @pre_options ) { 
-    <OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %>
-
+%   my $pre_opt   = shift(@pre_options);
+%   my $pre_label = shift(@pre_options);
+%   my $selected =    ( ref($value) && $value->{$pre_opt} )
+%                  || ( $value eq $pre_opt );
+    <OPTION VALUE="<% $pre_opt %>"
+            <% $selected ? 'SELECTED' : '' %>
+    ><% $pre_label %>
 % } 
 
 % unless ( $opt{'multiple'} || $opt{'disable_empty'} ) {
@@ -120,7 +126,8 @@ if ( $opt{'agent_virt'} ) {
   $extra_sql .=
     ( $extra_sql =~ /WHERE/i || scalar(keys %$hashref ) ? ' AND ' : ' WHERE ' ).
     $FS::CurrentUser::CurrentUser->agentnums_sql(
-                                    'null_right' => $opt{'agent_null_right'}
+                                    'null'       => $opt{'agent_null'},
+                                    'null_right' => $opt{'agent_null_right'},
                                    );
 }
 
@@ -137,7 +144,7 @@ if ( $opt{'records'} ) {
   });
 }
 
-unless (    ! $value
+unless (    $value < 1 # !$value #ignore negatives too
          or ref($value)
          or ! exists( $opt{hashref}->{disabled} ) #??
          or grep { $value == $_->$key() } @records