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