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