fix unapplied payment report, RT#73048, fallout from #25944
[freeside.git] / httemplate / search / elements / checkbox-foot.html
index be1caab..ae8b794 100644 (file)
@@ -11,6 +11,7 @@
                     },
                   ],
                   filter        => '.name = "pkgpart"', # see below
                     },
                   ],
                   filter        => '.name = "pkgpart"', # see below
+                  minboxes      => 2, #will remove checkboxes if there aren't at least this many
                ),
 &>
 
                ),
 &>
 
@@ -26,7 +27,8 @@ array is a hashref of either:
 of "submit" becomes the "value" property of the button (and thus its label).
 If "confirm" is specified, the button will have an onclick handler that 
 displays the value of "confirm" in a popup message box and asks the user to 
 of "submit" becomes the "value" property of the button (and thus its label).
 If "confirm" is specified, the button will have an onclick handler that 
 displays the value of "confirm" in a popup message box and asks the user to 
-confirm the choice.
+confirm the choice.  The hashref may also have a "name" property, which 
+sets the name of the submit button.
 
 - "onclick" and "label".  Creates a non-submit button that executes the 
 Javascript code in "onclick".  "label" is used as the text of the button.
 
 - "onclick" and "label".  Creates a non-submit button that executes the 
 Javascript code in "onclick".  "label" is used as the text of the button.
@@ -66,6 +68,14 @@ for (var i = 0; i < inputs.length; i++) {
   }
 }
 %# avoid the need for "$areboxes" late-evaluation hackery
   }
 }
 %# avoid the need for "$areboxes" late-evaluation hackery
+% if ($opt{'minboxes'}) {
+if ( checkboxes.length < <% $opt{'minboxes'} %> ) {
+  for (i = 0; i < checkboxes.length; i++) {
+    checkboxes[i].parentNode.removeChild(checkboxes[i]);
+  }
+  checkboxes = [];
+}
+% }
 if ( checkboxes.length == 0 ) {
   document.getElementById('checkbox_footer').style.display = 'none';
 }
 if ( checkboxes.length == 0 ) {
   document.getElementById('checkbox_footer').style.display = 'none';
 }
@@ -74,6 +84,15 @@ function setAll(setTo) {
     checkboxes[i].checked = setTo;
   }
 }
     checkboxes[i].checked = setTo;
   }
 }
+function toCGIString() {
+  var out = '';
+  for (var i = 0; i < checkboxes.length; i++) {
+    if (checkboxes[i].checked) {
+      out += '&' + checkboxes[i].name + '=' + checkboxes[i].value;
+    }
+  }
+  return out;
+}
 </SCRIPT>
 <%init>
 my %opt = @_;
 </SCRIPT>
 <%init>
 my %opt = @_;