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