Bug 24163: Allow to define CSV profile for late orders export
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / cleanborrowers.tt
index ae7df4e..df223c7 100644 (file)
@@ -1,96 +1,74 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE Koha %]
 [% USE KohaDates %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% 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>
+<title>Koha &rsaquo; Tools &rsaquo; Batch patron deletion and anonymization [% IF step == 2 %]&rsaquo; Confirm[% END %][% IF step == 3 %]&rsaquo; Finished[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-// <![CDATA[
-        /**
-         *  checkForm(form)
-         *  This function check the form is correctly filled.
-         */
-          function checkForm(form) {
-              if((form.checkbox[0].checked)){
-                  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!"));
-                      return false;
-                  }
-              }
-              if(!form.checkbox[0].checked && !form.checkbox[1].checked) {
-                alert( _("Please check at least one action") );
-                return false;
-              }
-              return true;
-          }
-
-        /**
-         *  checkForm2(form)
-         *  This function check the form2 is correctly filled.
-         */
-          function checkForm2(form) {
-              return true;
-          }
-
-          $(document).ready(function() {
-              $('#selectlibrary').find("input:submit").hide();
-              $('#branch').change(function() {
-                $('#selectlibrary').submit();
-              });
-          });
-     // ]]>
-</script>
-
 </head>
+
 <body id="tools_cleanborrowers" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>  &rsaquo; [% IF step == 1 %]Clean Patron Records[% ELSE %]<a href="/cgi-bin/koha/tools/cleanborrowers.pl">Clean patron records</a> &rsaquo; [% END %][% IF step == 2 %]Confirm[% END %][% IF step == 3 %]Finished[% END %]</div>
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
+    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
+    [% IF step == 1 %]
+        Batch patron deletion and anonymization
+    [% ELSE %]
+        <a href="/cgi-bin/koha/tools/cleanborrowers.pl">Batch patron deletion and anonymization</a> &rsaquo;
+    [% END %]
+    [% IF step == 2 %] Confirm [% END %]
+    [% IF step == 3 %] Finished [% END %]
+</div>
 
-<div id="doc3" class="yui-t2">
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
 
-   <div id="bd">
-    <div id="yui-main">
-    <div class="yui-b">
-[% IF !Branches.OnlyMine %]
+[% IF !OnlyMine %]
+  [% IF current_branch == '*' %]
+    <h1>Batch patron deletion and anonymization</h1>
+  [% ELSE %]
+    <h1>Batch patron deletion and anonymization for [% Branches.GetName( current_branch ) | html %]</h1>
+  [% END %]
+    [% IF step == 1 %]
     <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>
+            <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option>
           [% ELSE %]
-            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
+            <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</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 %]
+    [% END %]
 [% ELSE %]
-    <h1>Batch patron deletion/anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) %]</h1>
+    <h1>Batch patron deletion and anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) | html %]</h1>
 [% END %]
 
 [% IF step == 1 %]
 <!-- step 1 START -->
 
 <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>
+    <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used. Patrons will not be deleted if they meet one or more of the following conditions:</p>
+<ul>
+<li>They have items currently checked out.</li>
+<li>They have a non-zero account balance.</li>
+<li>They are the guarantor to another patron.</li>
+<li>They are in a patron category of type staff.</li>
+</ul>
 </div>
 <div id="step1">
-    <form name="f1" onsubmit="return checkForm(this);" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
+    <form name="f1" id="delete_patrons_form" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
     <fieldset>
     <legend>Delete patrons</legend>
         <h3><input id="checkborrower" type="checkbox" name="checkbox" value="borrower" /><label for="checkborrower"> Verify you want to delete patrons</label></h3>
                     <input size="10" id="borrower_dateexpiry" name="borrower_dateexpiry" type="text" class="datepicker" />
                     <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
                 </li>
+                [% IF Koha.Preference('TrackLastPatronActivity') %]
+                    <li>
+                        <label for="borrower_lastseen">who have not been connected since:</label>
+                        <input size="10" id="borrower_lastseen" name="borrower_lastseen" type="text" class="datepicker" />
+                        <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
+                    </li>
+                [% END %]
                 <li>
                     <label for="borrower_categorycode">whose patron category is:</label>
                     <select id="borrower_categorycode" name="borrower_categorycode">
                         <option value="" selected="selected">Any</option>
                         [% FOREACH bc IN borrower_categorycodes %]
                             [% UNLESS bc.category_type == 'S' %]
-                                <option value="[% bc.categorycode %]">[% bc.description %]</option>
+                                <option value="[% bc.categorycode | html %]">[% bc.description | html %]</option>
                             [% END %]
                         [% END %]
                     </select>
                     <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>
+                            <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
                         [% END %]
                     </select>
                 </li>
 
             <!-- hidden here -->
             <input type="hidden" name="step" value="2" />
-            <input type="hidden" name="branch" value="[% current_branch %]" />
+            <input type="hidden" name="branch" value="[% current_branch | html %]" />
             </fieldset>
             <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
     </form>
 [% IF step == 2 %]
 <!-- STEP 2 START -->
 <div id="step2">
-        <form name="f2" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post" onsubmit="return checkForm2(this);">
-    <fieldset>
-        <legend>Warnings</legend>
-        <ul>
-            <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>
+        <form name="f2" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
 
-        <br />
-            [% 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="trash" type="radio" name="radio" value="trash" />
-                <label for="trash">Move these patrons to the trash</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="[% patrons_to_delete.size %]" /></fieldset>
+        <div class="dialog alert">
+            <h3>Warning</h3>
+            <ul>
+                <li>[% patrons_to_delete.size || 0 | html %] patrons will be deleted</li>
+                <li>[% patrons_to_anonymize.count || 0 | html %] patrons' checkout histories will be anonymized</li>
+            </ul>
+        </div>
 
+            [% IF patrons_to_delete.size %]
+                <fieldset>
+                    <legend>How should patrons be deleted?</legend>
+                    <p>
+                        <input id="delete" type="radio" name="radio" value="delete" />
+                        <label for="delete">Permanently delete these patrons</label>
+                        <div class="hint">
+                            Delete patrons directly from the database. Patron data will not be recoverable.
+                        </div>
+                    </p>
+                    <p>
+                        <input id="trash" type="radio" name="radio" value="trash" />
+                        <label for="trash">Move these patrons to the trash</label>
+                        <div class="hint">
+                            Move patrons to the deleted patrons table. They can be deleted permanently by the <code>cleanup_database</code> script.
+                        </div>
+                    </p>
+                    <p>
+                        <input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
+                        <label for="testrun">Test run: Do not remove any patrons.</label>
+                        <input type="hidden" name="do_delete" value="[% patrons_to_delete.size | html %]" /></fieldset>
+                    </p>
+                </fieldset>
             [% END %]
-            [% 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 %]" />
+
+            [% IF patrons_to_anonymize.count %]
+                <fieldset>
+                Checkout history for [% patrons_to_anonymize.count | html %] patrons will be anonymized
+                <input type="hidden" name="do_anonym" value="[% patrons_to_anonymize.count | html %]" />
+                </fieldset>
             [% END %]
 
             <input type="hidden" name="step" value="3" />
             <input type="hidden" name="not_borrowed_since" value="[% not_borrowed_since | $KohaDates %]" />
             <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>
+            [% IF Koha.Preference('TrackLastPatronActivity') %]
+                <input type="hidden" name="borrower_lastseen" value="[% borrower_lastseen | $KohaDates %]" />
+            [% END %]
+            <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode | html %]" />
+            <input type="hidden" name="patron_list_id" value="[% patron_list_id | html %]" />
+            <input type="hidden" name="branch" value="[% current_branch | html %]" />
     <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
         </form>
 </div>
 
     <div id="step3">
         [% IF ( testrun ) %]
-            <h4>[% TotalDel %] patrons would have been removed (if it wasn't a test run)</h4>
+            <h4>[% TotalDel | html %] patrons would have been removed (if it wasn't a test run)</h4>
             <h4>No patron records have been actually removed</h4>
         [% ELSE %]
             [% IF ( do_delete ) %]
                 [% IF ( trash ) %]
-                    <h4>[% TotalDel %] patrons have been successfully moved to trash</h4>
+                    <h4>[% TotalDel | html %] patrons have been successfully moved to trash</h4>
                 [% ELSE %]
-                    <h4>[% TotalDel %] patrons have been successfully deleted</h4>
+                    <h4>[% TotalDel | html %] patrons have been successfully deleted</h4>
                 [% END %]
             [% ELSE %]
                 <h4>No patron records have been removed</h4>
             [% END %]
         [% END %]
-        [% IF ( do_anonym ) %]
-            <h4>All checkouts older than [% last_issue_date | $KohaDates %] have been anonymized</h4>
+        [% IF do_anonym %]
+            <h4>All checkouts ([% do_anonym | html %]) older than [% last_issue_date | $KohaDates %] have been anonymized</h4>
         [% ELSE %]
             <h4>No patron records have been anonymized</h4>
         [% END %]
 <!-- Step 3 END -->
 [% END %]
 
-</div>
-</div>
-<div class="yui-b noprint">
-[% INCLUDE 'tools-menu.inc' %]
-</div>
-</div>
+            </main>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+                [% INCLUDE 'tools-menu.inc' %]
+            </aside>
+        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("js/tools-menu.js") | $raw %]
+    [% INCLUDE 'calendar.inc' %]
+    <script>
+        $(document).ready(function(){
+            $("#delete_patrons_form").on("submit",function(){
+                return checkForm( this );
+            });
+
+            $('#branch').change(function() {
+                $('#selectlibrary').submit();
+            });
+            $("form[name='f2']").on('submit',function(){
+                if( $("#delete").prop("checked") ){
+                    if( !confirm(_("These patrons will be permanently removed from the database and cannot be recovered")) ){
+                        return false;
+                    }
+                }
+            });
+        });
+
+        /**
+         *  checkForm(form)
+         *  This function check the form is correctly filled.
+         */
+        function checkForm(form) {
+            if((form.checkbox[0].checked)){
+                if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) [% IF Koha.Preference('TrackLastPatronActivity') %]&& (!form.borrower_lastseen.value) [% END %]&& (!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!"));
+                    return false;
+                }
+            }
+            if(!form.checkbox[0].checked && !form.checkbox[1].checked) {
+              alert( _("Please check at least one action") );
+              return false;
+            }
+            return true;
+        }
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]