Bug 11642: (follow-up) Improve Batch patron deletion and anonymization GUI to make...
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / cleanborrowers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Tools &rsaquo; Batch patron deletion and anonymization [% IF step == 2 %]&rsaquo; Confirm[% END %][% IF step == 3 %]&rsaquo; Finished[% END %]</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 </head>
11
12 <body id="tools_cleanborrowers" class="tools">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <div id="breadcrumbs">
17     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
18     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
19     [% IF step == 1 %]
20         Batch patron deletion and anonymization
21     [% ELSE %]
22         <a href="/cgi-bin/koha/tools/cleanborrowers.pl">Batch patron deletion and anonymization</a> &rsaquo;
23     [% END %]
24     [% IF step == 2 %] Confirm [% END %]
25     [% IF step == 3 %] Finished [% END %]
26 </div>
27
28 <div class="main container-fluid">
29     <div class="row">
30         <div class="col-sm-10 col-sm-push-2">
31             <main>
32
33 [% IF !OnlyMine %]
34   [% IF current_branch == '*' %]
35     <h1>Batch patron deletion and anonymization</h1>
36   [% ELSE %]
37     <h1>Batch patron deletion and anonymization for [% Branches.GetName( current_branch ) | html %]</h1>
38   [% END %]
39     [% IF step == 1 %]
40     <form method="get" action="/cgi-bin/koha/tools/cleanborrowers.pl" id="selectlibrary">
41     Select a library :
42         <select name="branch" id="branch" style="width:20em;">
43             <option value="*">All libraries</option>
44         [% FOREACH branch IN Branches.all( selected => current_branch ) %]
45           [% IF branch.selected %]
46             <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option>
47           [% ELSE %]
48             <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
49           [% END %]
50         [% END %]
51         </select>
52     </form>
53     [% END %]
54 [% ELSE %]
55     <h1>Batch patron deletion and anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) | html %]</h1>
56 [% END %]
57
58 [% IF step == 1 %]
59 <!-- step 1 START -->
60
61 <div class="help">
62     <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used.</p>
63 </div>
64 <div id="step1">
65     <form name="f1" id="delete_patrons_form" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
66     <fieldset>
67     <legend>Delete patrons</legend>
68         <h3><input id="checkborrower" type="checkbox" name="checkbox" value="borrower" /><label for="checkborrower"> Verify you want to delete patrons</label></h3>
69         <br />
70         <h5>Delete patrons who meet the following criteria:</h5>
71         <ul>
72                 <li>
73                     <label for="date1">who have not borrowed since:</label>
74                     <input size="10" id="date1" name="not_borrowed_since" type="text" class="datepicker" />
75                     <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
76                 </li>
77                 <li>
78                     <label for="borrower_dateexpiry">whose expiration date is before:</label>
79                     <input size="10" id="borrower_dateexpiry" name="borrower_dateexpiry" type="text" class="datepicker" />
80                     <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
81                 </li>
82                 [% IF Koha.Preference('TrackLastPatronActivity') %]
83                     <li>
84                         <label for="borrower_lastseen">who have not been connected since:</label>
85                         <input size="10" id="borrower_lastseen" name="borrower_lastseen" type="text" class="datepicker" />
86                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
87                     </li>
88                 [% END %]
89                 <li>
90                     <label for="borrower_categorycode">whose patron category is:</label>
91                     <select id="borrower_categorycode" name="borrower_categorycode">
92                         <option value="" selected="selected">Any</option>
93                         [% FOREACH bc IN borrower_categorycodes %]
94                             [% UNLESS bc.category_type == 'S' %]
95                                 <option value="[% bc.categorycode | html %]">[% bc.description | html %]</option>
96                             [% END %]
97                         [% END %]
98                     </select>
99                 </li>
100                 [% IF patron_lists %]
101                 <li>
102                     <label for="patron_list_id">who are in patron list: </label>
103                     <select id="patron_list_id" name="patron_list_id">
104                         <option value=""></option>
105                         [% FOREACH pl IN patron_lists %]
106                             <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
107                         [% END %]
108                     </select>
109                 </li>
110                 [% END %]
111             </ul>
112         </fieldset>
113
114         <fieldset>
115         <legend>Anonymize checkout history</legend>
116         [% UNLESS Koha.Preference('AnonymousPatron') %]
117             <div class="dialog message">The AnonymousPatron system preference is not defined. You can use this feature anyway but NULL will be used to update the checkout history.</div>
118         [% END %]
119         <h3><input id="checkissue" type="checkbox" name="checkbox" value="issue" /><label for="checkissue"> Verify you want to anonymize patron checkout history</label></h3>
120         <br />
121         <ul>
122             <li>
123                 <label for="date2">Permanently delete checkout history older than</label>
124                 <input size="10" id="date2" name="last_issue_date" type="text" class="datepicker" />
125                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
126             </li>
127         </ul>
128
129             <!-- hidden here -->
130             <input type="hidden" name="step" value="2" />
131             <input type="hidden" name="branch" value="[% current_branch | html %]" />
132             </fieldset>
133             <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
134     </form>
135 </div>
136 <!-- step 1 END -->
137 [% END %]
138
139 [% IF step == 2 %]
140 <!-- STEP 2 START -->
141 <div id="step2">
142         <form name="f2" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
143
144         <div class="dialog alert">
145             <h3>Warning</h3>
146             <ul>
147                 <li>[% patrons_to_delete.size || 0 | html %] patrons will be deleted</li>
148                 <li>[% patrons_to_anonymize.count || 0 | html %] patrons' checkout histories will be anonymized</li>
149             </ul>
150         </div>
151
152             [% IF patrons_to_delete.size %]
153                 <fieldset>
154                     <legend>How should patrons be deleted?</legend>
155                     <p>
156                         <input id="delete" type="radio" name="radio" value="delete" />
157                         <label for="delete">Permanently delete these patrons</label>
158                         <div class="hint">
159                             Delete patrons directly from the database. Patron data will not be recoverable.
160                         </div>
161                     </p>
162                     <p>
163                         <input id="trash" type="radio" name="radio" value="trash" />
164                         <label for="trash">Move these patrons to the trash</label>
165                         <div class="hint">
166                             Move patrons to the deleted patrons table. They can be deleted permanently by the <code>cleanup_database</code> script.
167                         </div>
168                     </p>
169                     <p>
170                         <input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
171                         <label for="testrun">Test run: Do not remove any patrons.</label>
172                         <input type="hidden" name="do_delete" value="[% patrons_to_delete.size | html %]" /></fieldset>
173                     </p>
174                 </fieldset>
175             [% END %]
176
177             [% IF patrons_to_anonymize.count %]
178                 <fieldset>
179                 Checkout history for [% patrons_to_anonymize.count | html %] patrons will be anonymized
180                 <input type="hidden" name="do_anonym" value="[% patrons_to_anonymize.count | html %]" />
181                 </fieldset>
182             [% END %]
183
184             <input type="hidden" name="step" value="3" />
185             <input type="hidden" name="not_borrowed_since" value="[% not_borrowed_since | $KohaDates %]" />
186             <input type="hidden" name="last_issue_date" value="[% last_issue_date | $KohaDates %]" />
187             <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" />
188             [% IF Koha.Preference('TrackLastPatronActivity') %]
189                 <input type="hidden" name="borrower_lastseen" value="[% borrower_lastseen | $KohaDates %]" />
190             [% END %]
191             <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode | html %]" />
192             <input type="hidden" name="patron_list_id" value="[% patron_list_id | html %]" />
193             <input type="hidden" name="branch" value="[% current_branch | html %]" />
194     <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
195         </form>
196 </div>
197 <!-- STEP 2 END -->
198 [% END %]
199
200 [% IF step == 3 %]
201 <!-- Step 3 START -->
202
203     <div id="step3">
204         [% IF ( testrun ) %]
205             <h4>[% TotalDel | html %] patrons would have been removed (if it wasn't a test run)</h4>
206             <h4>No patron records have been actually removed</h4>
207         [% ELSE %]
208             [% IF ( do_delete ) %]
209                 [% IF ( trash ) %]
210                     <h4>[% TotalDel | html %] patrons have been successfully moved to trash</h4>
211                 [% ELSE %]
212                     <h4>[% TotalDel | html %] patrons have been successfully deleted</h4>
213                 [% END %]
214             [% ELSE %]
215                 <h4>No patron records have been removed</h4>
216             [% END %]
217         [% END %]
218         [% IF do_anonym %]
219             <h4>All checkouts ([% do_anonym | html %]) older than [% last_issue_date | $KohaDates %] have been anonymized</h4>
220         [% ELSE %]
221             <h4>No patron records have been anonymized</h4>
222         [% END %]
223
224     </div>
225 <!-- Step 3 END -->
226 [% END %]
227
228             </main>
229         </div> <!-- /.col-sm-10.col-sm-push-2 -->
230
231         <div class="col-sm-2 col-sm-pull-10">
232             <aside>
233                 [% INCLUDE 'tools-menu.inc' %]
234             </aside>
235         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
236      </div> <!-- /.row -->
237
238 [% MACRO jsinclude BLOCK %]
239     [% Asset.js("js/tools-menu.js") | $raw %]
240     [% INCLUDE 'calendar.inc' %]
241     <script>
242         $(document).ready(function(){
243             $("#delete_patrons_form").on("submit",function(){
244                 return checkForm( this );
245             });
246
247             $('#branch').change(function() {
248                 $('#selectlibrary').submit();
249             });
250             $("form[name='f2']").on('submit',function(){
251                 if( $("#delete").prop("checked") ){
252                     if( !confirm(_("These patrons will be permanently removed from the database and cannot be recovered")) ){
253                         return false;
254                     }
255                 }
256             });
257         });
258
259         /**
260          *  checkForm(form)
261          *  This function check the form is correctly filled.
262          */
263         function checkForm(form) {
264             if((form.checkbox[0].checked)){
265                 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)){
266                   alert(_("Please enter at least one criterion for deletion!"));
267                   return false;
268                 }
269             }
270             if((form.checkbox[1].checked)){
271                 if(!(form.date2.value)){
272                     alert(_("Please enter a date!"));
273                     return false;
274                 }
275             }
276             if(!form.checkbox[0].checked && !form.checkbox[1].checked) {
277               alert( _("Please check at least one action") );
278               return false;
279             }
280             return true;
281         }
282     </script>
283 [% END %]
284
285 [% INCLUDE 'intranet-bottom.inc' %]