Option to ignore old CDRs, RT#81480
[freeside.git] / httemplate / elements / select-cust_pkg-status.html
index 71aaa84..2114c07 100644 (file)
@@ -1,21 +1,35 @@
-<SELECT NAME="status" <% $opt{'onchange'} %>>
+<SELECT NAME="<% $opt{'field'} || 'status' %>"
+        <% $opt{'multiple'} ? 'MULTIPLE' : '' %>
+        <% $onchange %>
+>
 
+% if ( !$opt{'disable_empty'} ) {
   <OPTION VALUE="">all
+% }
 
 % foreach my $option ( @{ $opt{'statuses'} } ) { 
-       <OPTION VALUE="<% $option %>" <% $option eq $status ? 'SELECTED' : '' %>><% $option %>
+
+    <OPTION VALUE="<% $option %>"
+            <% ref($value) && $value->{$option} || $option eq $value
+               ? 'SELECTED' : ''
+            %>
+    ><% $option %>
+
 % } 
 
 </SELECT>
+
 <%init>
-  my( $status, %opt ) = @_;
 
-  $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
+my %opt = @_;
+
+$opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
+
+my $onchange = $opt{'onchange'}
+                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
+                 : '';
 
-  if ( exists $opt{'onchange'} && $opt{'onchange'} ) {
-    $opt{'onchange'} = ' onChange="' . $opt{'onchange'}. '"';
-  } else {
-    $opt{'onchange'} = '';
-  }
+my $value = $opt{'curr_value'} || $opt{'value'};
+$value = [ split(/\s*,\s*/, $value) ] if $opt{'multiple'} && $value =~ /,/;
 
 </%init>