Select-all checkboxes for fine payment
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 25 Jul 2011 21:55:58 +0000 (17:55 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 25 Jul 2011 21:55:58 +0000 (17:55 -0400)
In the process, had to change the checkbox/cgi param name of the misc
fees to xact_misc and tell the middle layer to lump xact together with
xact_misc.  Should test carefully.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/js/ui/default/opac/simple.js
Open-ILS/web/templates/default/opac/myopac/main.tt2
Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2

index 213965d..d1c1658 100644 (file)
@@ -777,7 +777,7 @@ sub load_myopac_payment_form {
     my $self = shift;
     my $r;
 
-    $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact')]) and return $r;
+    $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact'), $self->cgi->param('xact_misc')]) and return $r;
     $r = $self->prepare_extended_user_info and return $r;
 
     return Apache2::Const::OK;
@@ -820,7 +820,7 @@ sub load_myopac_pay {
     my $self = shift;
     my $r;
 
-    $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact')]) and
+    $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact'), $self->cgi->param('xact_misc')]) and
         return $r;
 
     # balance_owed is computed specifically from the fines we're trying
@@ -828,7 +828,7 @@ sub load_myopac_pay {
     if ($self->ctx->{fines}->{balance_owed} <= 0) {
         $self->apache->log->info(
             sprintf("Can't pay non-positive balance. xacts selected: (%s)",
-                join(", ", map(int, $self->cgi->param("xact"))))
+                join(", ", map(int, $self->cgi->param("xact"), $self->cgi->param('xact_misc'))))
         );
         return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
     }
index d71c98a..d80b108 100644 (file)
@@ -48,3 +48,11 @@ function print_node(node_id) {
     try { iframe.print(); } catch (e) { iwin.print(); }
     setTimeout(function() { iframe.style.display = "none"; }, 3500);
 }
+function select_all_checkboxes(name, checked) {
+    var all = document.getElementsByTagName("input");
+    for (var i = 0; i < all.length; i++) {
+        if (all[i].type == "checkbox" && all[i].name == name) {
+            all[i].checked = checked;
+        }
+    }
+}
index 674e097..354b5b0 100644 (file)
@@ -22,8 +22,9 @@
                     <td>[% l("Date Returned") %]</td>
                     <td>[% l("Balance Owed") %]</td>
                     <td nowrap="nowrap" style="white-space:nowrap;">
-                        <!-- XXX TODO select all js --><input id="pay_fines_box1" checked="checked"
-                            type="checkbox" title="[% l('Click to (un)select all fines') %]" />
+                        <input id="pay_fines_box1" checked="checked"
+                            type="checkbox" onchange="select_all_checkboxes('xact', this.checked)"
+                            title="[% l('Click to (un)select all fines') %]" />
                         <label for="pay_fines_box1">[% l('Pay Fines') %]</label>
                     </td>
                 </tr>
@@ -78,7 +79,8 @@
                     </td>
                     <td>
                         <input type="checkbox" checked="checked" 
-                            title="[% l('Pay this fine') %]" name="xact" value="[% f.xact.id %]" />
+                            title="[% l('Pay this fine') %]" name="xact"
+                            value="[% f.xact.id %]" />
                     </td>
                 </tr>
                 [% END %]
                     <td width='4%' align="center" nowrap="nowrap"
                         style="white-space:nowrap;">
                         <input id="pay_fines_box2" checked="checked"
-                            type="checkbox"
+                            type="checkbox" onchange="select_all_checkboxes('xact_misc', this.checked)"
                             title="[% l('Click to (un)select all fines') %]" />
                         <label for="pay_fines_box2">[% l("Pay Fines") %]</label>
                     </td>
                     <td>[% f.xact.last_billing_type %]</td>
                     <td>
                         <input type="checkbox" title='[% l("Pay this fine") %]'
-                            name="xact" value="[% f.xact.id %]" />
+                            name="xact_misc" value="[% f.xact.id %]"
+                            checked="checked" />
                     </td>
                 </tr>
                 [% END %]
index c10d5a2..f5345d5 100644 (file)
@@ -16,6 +16,9 @@
         [% FOR xact IN CGI.param('xact') %]
         <input type="hidden" name="xact" value="[% xact | html %]" />
         [% END %]
+        [% FOR xact IN CGI.param('xact_misc') %]
+        <input type="hidden" name="xact_misc" value="[% xact | html %]" />
+        [% END %]
         <table>
             <tbody>
                 <tr>
@@ -47,8 +50,8 @@
                             [%
                             END;
                             FOR f IN ctx.fines.grocery;
-                                NEXT IF CGI.param('xact').size &&
-                                    !CGI.param('xact').grep(f.xact.id).size %]
+                                NEXT IF CGI.param('xact_misc').size &&
+                                    !CGI.param('xact_misc').grep(f.xact.id).size %]
                                 <tr>
                                     <td>[% f.xact.last_billing_type %]</td>
                                     <td class="text-right">[% money(f.xact.balance_owed) %]</td>