Bug 15758: Koha::Libraries - Remove GetBranches
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / cleanborrowers.tt
index 266583c..ae7df4e 100644 (file)
@@ -1,5 +1,6 @@
 [% USE Koha %]
 [% USE KohaDates %]
+[% USE Branches %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Batch patron deletion/anonymization [% IF step == 2 %]&rsaquo; Confirm[% END %][% IF step == 3 %]&rsaquo; Finished[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
          */
           function checkForm(form) {
               if((form.checkbox[0].checked)){
-                  if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) && (!form.borrower_categorycode.value) ){
+                  if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) && (!form.borrower_categorycode.value) && (!form.patron_list_id.value)){
                     alert(_("Please enter at least one criterion for deletion!"));
                     return false;
                   }
               }
               if((form.checkbox[1].checked)){
                   if(!(form.date2.value)){
-                      alert(_("please enter a date !"));
+                      alert(_("please enter a date!"));
                       return false;
                   }
               }
           function checkForm2(form) {
               return true;
           }
+
+          $(document).ready(function() {
+              $('#selectlibrary').find("input:submit").hide();
+              $('#branch').change(function() {
+                $('#selectlibrary').submit();
+              });
+          });
      // ]]>
 </script>
 
    <div id="bd">
     <div id="yui-main">
     <div class="yui-b">
+[% IF !Branches.OnlyMine %]
+    <form method="get" action="/cgi-bin/koha/tools/cleanborrowers.pl" id="selectlibrary">
+    Select a library :
+        <select name="branch" id="branch" style="width:20em;">
+            <option value="*">All libraries</option>
+        [% FOREACH branch IN Branches.all( selected => current_branch ) %]
+          [% IF branch.selected %]
+            <option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option>
+          [% ELSE %]
+            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
+          [% END %]
+        [% END %]
+        </select>
+    </form>
+  [% IF current_branch == '*' %]
+    <h1>Batch patron deletion/anonymization</h1>
+  [% ELSE %]
+    <h1>Batch patron deletion/anonymization for [% Branches.GetName( current_branch ) %]</h1>
+  [% END %]
+[% ELSE %]
+    <h1>Batch patron deletion/anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) %]</h1>
+[% END %]
+
+[% IF step == 1 %]
+<!-- step 1 START -->
 
-<h1>Batch patron deletion/anonymization</h1>
 <div class="help">
     <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used.</p>
 </div>
-[% IF step == 1 %]
-<!-- step 1 START -->
 <div id="step1">
     <form name="f1" onsubmit="return checkForm(this);" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
     <fieldset>
                         [% END %]
                     </select>
                 </li>
+                [% IF patron_lists %]
+                <li>
+                    <label for="patron_list_id">who are in patron list: </label>
+                    <select id="patron_list_id" name="patron_list_id">
+                        <option value=""></option>
+                        [% FOREACH pl IN patron_lists %]
+                            <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
+                        [% END %]
+                    </select>
+                </li>
+                [% END %]
             </ul>
         </fieldset>
+
         <fieldset>
         <legend>Anonymize checkout history</legend>
         [% UNLESS Koha.Preference('AnonymousPatron') %]
 
             <!-- hidden here -->
             <input type="hidden" name="step" value="2" />
+            <input type="hidden" name="branch" value="[% current_branch %]" />
             </fieldset>
             <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
     </form>
     <fieldset>
         <legend>Warnings</legend>
         <ul>
-            <li>[% IF ( totalToDelete ) %][% totalToDelete %] [% ELSE %]0 [% END %] patrons will be deleted</li>
-            <li>[% IF ( totalToAnonymize ) %][% totalToAnonymize %] [% ELSE %]0 [% END %] checkout history will be anonymized</li>
+            <li>[% patrons_to_delete.size || 0 %] patrons will be deleted</li>
+            <li>[% patrons_to_anonymize.size || 0 %] patron's checkout histories will be anonymized</li>
         </ul>
 
         <br />
-            [% IF ( totalToDelete ) %]
+            [% IF patrons_to_delete.size %]
                 <fieldset><legend>What do you want to do for deleted patrons?</legend>
                 <input id="delete" type="radio" name="radio" value="delete" />
                 <label for="delete">Permanently delete these patrons</label>
 
                 <br /><input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
                 <label for="testrun">Do not remove any patrons (test run)</label>
-                <input type="hidden" name="do_delete" value="[% totalToDelete %]" /></fieldset>
+                <input type="hidden" name="do_delete" value="[% patrons_to_delete.size %]" /></fieldset>
 
             [% END %]
-            [% IF ( totalToAnonymize ) %]
-                Checkout history for [% totalToAnonymize %] patrons will be anonymized
-                <input type="hidden" name="do_anonym" value="[% totalToAnonymize %]" />
+            [% IF patrons_to_anonymize.size %]
+                Checkout history for [% patrons_to_anonymize.size %] patrons will be anonymized
+                <input type="hidden" name="do_anonym" value="[% patrons_to_anonymize.size %]" />
             [% END %]
 
             <input type="hidden" name="step" value="3" />
             <input type="hidden" name="last_issue_date" value="[% last_issue_date | $KohaDates %]" />
             <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" />
             <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode %]" />
+            <input type="hidden" name="patron_list_id" value="[% patron_list_id %]" />
+            <input type="hidden" name="branch" value="[% current_branch %]" />
     </fieldset>
     <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
         </form>