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