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