Bug 11216: fix bug where editing patron creates indefinite manual restriction
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 8 Nov 2013 13:50:38 +0000 (14:50 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 14 Nov 2013 15:39:39 +0000 (15:39 +0000)
Editing partron data results in unintended adding of indefinite manual
restriction to it. Reason for it is hidden field add_debarment which
is wrongly initialized to 1 instead of 0. Also JavaScript code seems
to want to toggle checkbox, and since this field is hidden correct
approach would be to change its value to 1.

Test scenario:

1. edit patron data
2. verify that debarrment is wrongly added
3. remove debarrment
3. apply this patch
4. edit patron again
5. verify that debarrment wasn't added
6. intentionally add debarrment and verify that it's saved
7. add debarment, enter something in comment but press cancel
   and verify that debarment isn't added

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

This fixes this blocker, however, with or without the patch, the date
is not saved correctly. I will file a new bug for that

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt

index b158556..4aa88cf 100644 (file)
@@ -59,7 +59,7 @@
         });
         $("#cancel_manual_restriction").on("click",function(e){
             $('#debarred_expiration').val('');
-            $('#add_debarment').prop('checked', false);
+            $('#add_debarment').val(0);
             $('#debarred_comment').val('');
             mrlink.show();
             mrform.hide();
                 [% END %]
                     <p><a href="#" id="add_manual_restriction">Add manual restriction</a></p>
                     <fieldset id="manual_restriction_form">
-                        <input type="hidden" id="add_debarment" name="add_debarment" value="1" />
+                        <input type="hidden" id="add_debarment" name="add_debarment" value="0" />
                         <legend>Add manual restriction</legend>
                         <ol>
-                            <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').prop('checked', true);" /></li>
-                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').prop('checked', true);" />
+                            <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').val(1);" /></li>
+                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').val(1);" />
                                     <a href='javascript:void(0)' onclick="$('#debarred_expiration').val('');">Clear date</a></li>
 
                         </ol>