Bug 28170: Fix upload.tt search result buttons for page two onwards
[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 </ul>
102 </div>
103 <div id="step1">
104     <form name="f1" id="delete_patrons_form" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
105     <fieldset>
106     <legend>Delete patrons</legend>
107         <h3><input id="checkborrower" type="checkbox" name="checkbox" value="borrower" /><label for="checkborrower"> Verify you want to delete patrons</label></h3>
108         <br />
109         <h5>Delete patrons who meet the following criteria:</h5>
110         <ul>
111                 <li>
112                     <label for="date1">who have not borrowed since:</label>
113                     <input size="10" id="date1" name="not_borrowed_since" type="text" class="datepicker" />
114                     <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
115                 </li>
116                 <li>
117                     <label for="borrower_dateexpiry">whose expiration date is before:</label>
118                     <input size="10" id="borrower_dateexpiry" name="borrower_dateexpiry" type="text" class="datepicker" />
119                     <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
120                 </li>
121                 [% IF Koha.Preference('TrackLastPatronActivity') %]
122                     <li>
123                         <label for="borrower_lastseen">who have not been connected since:</label>
124                         <input size="10" id="borrower_lastseen" name="borrower_lastseen" type="text" class="datepicker" />
125                         <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
126                     </li>
127                 [% END %]
128                 <li>
129                     <label for="borrower_categorycode">whose patron category is:</label>
130                     <select id="borrower_categorycode" name="borrower_categorycode">
131                         <option value="" selected="selected">Any</option>
132                         [% FOREACH bc IN borrower_categorycodes %]
133                             [% UNLESS bc.category_type == 'S' %]
134                                 <option value="[% bc.categorycode | html %]">[% bc.description | html %]</option>
135                             [% END %]
136                         [% END %]
137                     </select>
138                 </li>
139                 [% IF patron_lists %]
140                 <li>
141                     <label for="patron_list_id">who are in patron list: </label>
142                     <select id="patron_list_id" name="patron_list_id">
143                         <option value=""></option>
144                         [% FOREACH pl IN patron_lists %]
145                             <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
146                         [% END %]
147                     </select>
148                 </li>
149                 [% END %]
150             </ul>
151         </fieldset>
152
153         <fieldset>
154         <legend>Anonymize checkout history</legend>
155         [% UNLESS Koha.Preference('AnonymousPatron') %]
156             <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>
157         [% END %]
158         <h3><input id="checkissue" type="checkbox" name="checkbox" value="issue" /><label for="checkissue"> Verify you want to anonymize patron checkout history</label></h3>
159         <br />
160         <ul>
161             <li>
162                 <label for="date2">Permanently delete checkout history older than</label>
163                 <input size="10" id="date2" name="last_issue_date" type="text" class="datepicker" />
164                 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
165             </li>
166         </ul>
167
168             <!-- hidden here -->
169             <input type="hidden" name="step" value="2" />
170             <input type="hidden" name="branch" value="[% current_branch | html %]" />
171             </fieldset>
172             <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
173     </form>
174 </div>
175 <!-- step 1 END -->
176 [% END %]
177
178 [% IF step == 2 %]
179 <!-- STEP 2 START -->
180 <div id="step2">
181         <form name="f2" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
182
183         <div class="dialog alert">
184             <h3>Warning</h3>
185             <ul>
186                 <li>[% patrons_to_delete.size || 0 | html %] patrons will be deleted</li>
187                 <li>[% patrons_to_anonymize.count || 0 | html %] patrons' checkout histories will be anonymized</li>
188             </ul>
189         </div>
190
191             [% IF patrons_to_delete.size %]
192                 <fieldset>
193                     <legend>How should patrons be deleted?</legend>
194                     <p>
195                         <input id="delete" type="radio" name="radio" value="delete" />
196                         <label for="delete">Permanently delete these patrons</label>
197                         <div class="hint">
198                             Delete patrons directly from the database. Patron data will not be recoverable.
199                         </div>
200                     </p>
201                     <p>
202                         <input id="trash" type="radio" name="radio" value="trash" />
203                         <label for="trash">Move these patrons to the trash</label>
204                         <div class="hint">
205                             Move patrons to the deleted patrons table. They can be deleted permanently by the <code>cleanup_database</code> script.
206                         </div>
207                     </p>
208                     <p>
209                         <input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
210                         <label for="testrun">Test run: Do not remove any patrons.</label>
211                         <input type="hidden" name="do_delete" value="[% patrons_to_delete.size | html %]" /></fieldset>
212                     </p>
213                 </fieldset>
214             [% END %]
215
216             [% IF patrons_to_anonymize.count %]
217                 <fieldset>
218                 Checkout history for [% patrons_to_anonymize.count | html %] patrons will be anonymized
219                 <input type="hidden" name="do_anonym" value="[% patrons_to_anonymize.count | html %]" />
220                 </fieldset>
221             [% END %]
222
223             <input type="hidden" name="step" value="3" />
224             <input type="hidden" name="not_borrowed_since" value="[% not_borrowed_since | $KohaDates %]" />
225             <input type="hidden" name="last_issue_date" value="[% last_issue_date | $KohaDates %]" />
226             <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" />
227             [% IF Koha.Preference('TrackLastPatronActivity') %]
228                 <input type="hidden" name="borrower_lastseen" value="[% borrower_lastseen | $KohaDates %]" />
229             [% END %]
230             <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode | html %]" />
231             <input type="hidden" name="patron_list_id" value="[% patron_list_id | html %]" />
232             <input type="hidden" name="branch" value="[% current_branch | html %]" />
233     <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
234         </form>
235 </div>
236 <!-- STEP 2 END -->
237 [% END %]
238
239 [% IF step == 3 %]
240 <!-- Step 3 START -->
241
242     <div id="step3">
243         [% IF ( testrun ) %]
244             <h4>[% TotalDel | html %] patrons would have been removed (if it wasn't a test run)</h4>
245             <h4>No patron records have been actually removed</h4>
246         [% ELSE %]
247             [% IF ( do_delete ) %]
248                 [% IF ( trash ) %]
249                     <h4>[% TotalDel | html %] patrons have been successfully moved to trash</h4>
250                 [% ELSE %]
251                     <h4>[% TotalDel | html %] patrons have been successfully deleted</h4>
252                 [% END %]
253             [% ELSE %]
254                 <h4>No patron records have been removed</h4>
255             [% END %]
256         [% END %]
257         [% IF do_anonym %]
258             <h4>All checkouts ([% do_anonym | html %]) older than [% last_issue_date | $KohaDates %] have been anonymized</h4>
259         [% ELSE %]
260             <h4>No patron records have been anonymized</h4>
261         [% END %]
262
263     </div>
264 <!-- Step 3 END -->
265 [% END %]
266
267             </main>
268         </div> <!-- /.col-sm-10.col-sm-push-2 -->
269
270         <div class="col-sm-2 col-sm-pull-10">
271             <aside>
272                 [% INCLUDE 'tools-menu.inc' %]
273             </aside>
274         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
275      </div> <!-- /.row -->
276
277 [% MACRO jsinclude BLOCK %]
278     [% Asset.js("js/tools-menu.js") | $raw %]
279     [% INCLUDE 'calendar.inc' %]
280     <script>
281         $(document).ready(function(){
282             $("#delete_patrons_form").on("submit",function(){
283                 return checkForm( this );
284             });
285
286             $('#branch').change(function() {
287                 $('#selectlibrary').submit();
288             });
289             $("form[name='f2']").on('submit',function(){
290                 if( $("#delete").prop("checked") ){
291                     if( !confirm(_("These patrons will be permanently removed from the database and cannot be recovered")) ){
292                         return false;
293                     }
294                 }
295             });
296         });
297
298         /**
299          *  checkForm(form)
300          *  This function check the form is correctly filled.
301          */
302         function checkForm(form) {
303             if((form.checkbox[0].checked)){
304                 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)){
305                   alert(_("Please enter at least one criterion for deletion!"));
306                   return false;
307                 }
308             }
309             if((form.checkbox[1].checked)){
310                 if(!(form.date2.value)){
311                     alert(_("Please enter a date!"));
312                     return false;
313                 }
314             }
315             if(!form.checkbox[0].checked && !form.checkbox[1].checked) {
316               alert( _("Please check at least one action") );
317               return false;
318             }
319             return true;
320         }
321     </script>
322 [% END %]
323
324 [% INCLUDE 'intranet-bottom.inc' %]