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