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