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