Bug 17016: Button to clear all fields in budget planning
authorAleisha Amohia <aleishaamohia@hotmail.com>
Tue, 2 Aug 2016 05:47:28 +0000 (05:47 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 2 Mar 2020 10:21:51 +0000 (10:21 +0000)
Currently there is no way to undo the 'auto-fill'. This
patch adds a 'clear' option that resets the row.

To test:
1) Go to Admin --> Budgets
2) Click a budget
3) Click Planning -> any option
4) Test the Auto-fill button to see what it does
5) Apply patch and refresh page
6) Should now be a Clear button
7) Auto-fill the row then click Clear button. Confirm it clears all
fields and sets the fund remaining back to the original amount and
styles.
8) Add another fund and confirm that this still works with multiple
funds.

Sponsored-by: Catalyst IT
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqplan.tt

index 7fff2ce..768393f 100644 (file)
@@ -6,6 +6,8 @@
 <title>Koha &rsaquo; Administration &rsaquo; Budgets &rsaquo; Funds &rsaquo; Planning for [% budget_period_description | html %] by [% authcat | html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <style>td.locked { background-image: url('[% interface | html %]/[% theme | html %]/img/locked.png'); padding-left : 20px; background-repeat: no-repeat; background-position: 5px 5px; } a.control { font-size:85%;text-decoration:none; } .plan_entry { text-align: right; width:90%; }</style>
+<script>
+</script>
 </head>
 
 <body id="admin_aqplan" class="admin">
     [% authvals_ro.code | html %]</th>
     [% END %]
 
-    <th class="remaining">Fund remaining</th><th>&nbsp;</th>
+    <th class="remaining">Fund remaining</th>
+    <th>Actions</th>
     </tr>
     </thead>
 
     <tbody>
     [% FOREACH budget_line IN budget_lines %]
-    <tr>
+    <tr id="[% budget_line.budget_id | html %]">
         [% IF ( budget_line.budget_lock ) %]
             <td class="locked" title="Fund locked">
         [% ELSE %]
         </table>
         </td>
 
-        <td>
+        <td class="actions">
              [% UNLESS ( budget_line.budget_lock ) %]
                     <input type="button" class="auto_fill_row" data-budget-id="[% budget_line.budget_id | html %]" value="Auto-fill row"/>
+                    <input type="button" class="clear_fields" data-budget-id="[% budget_line.budget_id | html %]" value="Clear">
             [% ELSE %]
              <div style="color:red;">not owned</div>
             [% END %]
                 var budget_id = $(this).data("budget-id");
                 autoFillRow( budget_id );
             });
+            $(".clear_fields").on("click",function(){
+                var budget_id = $(this).data("budget-id");
+                var edit_row = $("#"+budget_id);
+                $(edit_row).find("input").each(function(){
+                    var type = $(this).attr("type");
+                    if (type != "button" && type != "submit" ) {
+                      $(this).val("");
+                      $(this).prop('disabled', false);
+                    }
+                    if ( type == "checkbox" ) {
+                      $(this).prop('checked', false);
+                    }
+                });
+                $("#budget_est_"+budget_id).text($("#budget_tot_"+budget_id).prev().text());
+                $("#budget_est_"+budget_id).css("color","green");
+            });
         });
     </script>
 [% END %]