Bug 26159: Remove the use of jquery.checkboxes plugin from batch record delete page
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_delete_records.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% PROCESS 'authorities-search-results.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Tools &rsaquo; Batch record deletion</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 </head>
9
10 <body id="tools_batch_delete_records" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
13
14 <div id="breadcrumbs">
15     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
16     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
17     <a href="/cgi-bin/koha/tools/batch_delete_records.pl">Batch record deletion</a>
18 </div>
19
20 <div class="main container-fluid">
21     <div class="row">
22         <div class="col-sm-10 col-sm-push-2">
23             <main>
24
25   <h1>Batch record deletion</h1>
26   [% FOREACH message IN messages %]
27     [% IF message.type == 'success' %]
28       <div class="dialog message">
29     [% ELSIF message.type == 'warning' %]
30       <div class="dialog alert">
31     [% ELSIF message.type == 'error' %]
32       <div class="dialog alert" style="margin:auto;">
33     [% END %]
34     [% IF message.code == 'biblio_not_exists' %]
35       The biblionumber [% message.biblionumber | html %] does not exist in the database.
36     [% ELSIF message.code == 'authority_not_exists' %]
37       The authority id [% message.authid | html %] does not exist in the database.
38     [% ELSIF message.code == 'item_issued' %]
39       At least one item is checked out on bibliographic record [% message.biblionumber | html %].
40     [% ELSIF message.code == 'reserve_not_cancelled' %]
41       Bibliographic record [% message.biblionumber | html %] was not deleted. A hold could not be canceled (reserve_id [% message.reserve_id | html %]).
42     [% ELSIF message.code == 'item_not_deleted' %]
43       The bibliographic record [% message.biblionumber | html %] was not deleted. An error was encountered when deleting an item (itemnumber [% message.itemnumber | html %]).
44     [% ELSIF message.code == 'biblio_not_deleted' %]
45       Bibliographic record [% message.biblionumber | html %] was not deleted. An error occurred.
46     [% ELSIF message.code == 'authority_not_deleted' %]
47       Authority record [% message.authid | html %] was not deleted. An error occurred.
48     [% ELSIF message.code == 'biblio_deleted' %]
49       Bibliographic record [% message.biblionumber | html %] has been deleted successfully.
50     [% ELSIF message.code == 'authority_deleted' %]
51       Authority [% message.authid | html %] has been deleted successfully.
52     [% END %]
53     [% IF message.error %]
54       (The error was: [% message.error | html %], see the Koha log file for more information).
55     [% END %]
56     </div>
57   [% END %]
58   [% IF op == 'form' %]
59     <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="record_ids_selection">
60       <fieldset class="rows">
61         <legend>Record type</legend>
62         <ol>
63           <li><label for="biblio_type">Bibliographic: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
64           <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
65         </ol>
66       </fieldset>
67
68       <div id="batch_del_form" class="toptabs" style="clear:both">
69         <ul>
70           <li><a href="#uploadfile_tab">Upload a file</a></li>
71           [% IF lists.count %]<li id="show_list_option"><a href="#shelves_tab">Select a list of records</a></li>[% END %]
72           <li><a href="#enterlist_tab">Enter a list of record numbers</a></li>
73         </ul>
74
75         <div id="uploadfile_tab">
76           <fieldset class="rows">
77             <legend>Use a file</legend>
78             <ol>
79               <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
80             </ol>
81           </fieldset>
82           &nbsp;
83         </div>
84
85         [% IF lists.count %]
86             <div id="shelves_tab">
87               <fieldset class="rows">
88                 <legend>Or select a list of records</legend>
89                 <ol>
90                   <li>
91                     <label for="shelf_number">Use records from the following list: </label>
92                     <select name="shelf_number" id="shelf_number">
93                       <option value="">Select a list</option>
94                         [% FOREACH list IN lists %]
95                           <option value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
96                         [% END %]
97                       </option>
98                     </select>
99                   </li>
100                 </ol>
101               </fieldset>
102               &nbsp;
103             </div>
104         [% END %]
105
106         <div id="enterlist_tab">
107           <fieldset class="rows">
108             <legend>Or enter a list of record numbers</legend>
109             <ol>
110               <li>
111                 <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
112                 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
113               </li>
114             </ol>
115           </fieldset>
116           &nbsp;
117         </div>
118
119       </div>
120
121       <fieldset class="action">
122         <input type="hidden" name="op" value="list" />
123         <input type="submit" value="Continue" class="button" />
124         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
125       </fieldset>
126     </form>
127   [% ELSIF op == 'list' %]
128     [% IF records %]
129       [% IF recordtype == 'biblio' %]
130         <div id="toolbar">
131           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
132           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
133           | <a id="selectwithoutitems" href="#">Select without items</a>
134           | <a id="selectnotreserved" href="#">Select without holds</a>
135         </div>
136         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectrecords">
137           <table id="biblios" class="records">
138             <thead>
139               <tr>
140                 <th></th>
141                 <th>Biblionumber</th>
142                 <th>Title</th>
143                 <th>Items</th>
144                 <th>Holds</th>
145                 <th>Checkouts</th>
146               </tr>
147             </thead>
148             <tbody>
149               [% FOR biblio IN records %]
150                 <tr>
151                   <td><input type="checkbox" name="record_id" id="record_id_[% biblio.biblionumber | html %]" value="[% biblio.biblionumber | html %]" data-items="[% biblio.itemnumbers.size | html %]" data-issues="[% biblio.issues_count | html %]" data-reserves="[% biblio.holds_count | html %]" /></td>
152                   <td><label for="record_id_[% biblio.biblionumber | html %]">[% biblio.biblionumber | html %]</label></td>
153                   <td>[% INCLUDE 'biblio-default-view.inc' biblionumber=biblio.biblionumber %][% INCLUDE 'biblio-title.inc' %]</a></td>
154                   <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.itemnumbers.size | html %]</a></td>
155                   <td><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.holds_count | html %]</a></td>
156                   <td><a href="/cgi-bin/koha/catalogue/issuehistory.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.issues_count | html %]</a></td>
157                 </tr>
158               [% END %]
159             </tbody>
160           </table>
161           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will delete all selected bibliographic records, attached subscriptions, existing holds, and attached items!</div>
162       [% ELSE %]
163         <div id="toolbar">
164           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
165           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
166           | <a id="clearlinkedtobiblio" href="#">Clear used authorities</a>
167         </div>
168         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectauths">
169           <table id="authorities" class="records">
170             <thead>
171               <tr>
172                 <th></th>
173                 <th>Authid</th>
174                 <th>Summary</th>
175                 <th>Used in</th>
176               </tr>
177             </thead>
178             <tbody>
179               [% FOR authority IN records %]
180                 <tr>
181                   <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
182                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
183                   <td>[% PROCESS authresult summary=authority.summary %]</td>
184                   <td><a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&amp;op=do_search&amp;idx=an,phr&amp;q=[% authority.authid | uri %]">[% authority.count_usage | html %] record(s)</a></td>
185                 </tr>
186               [% END %]
187             </tbody>
188           </table>
189           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will delete all selected authorities!</div>
190       [% END %]
191         <fieldset class="action">
192           <input type="hidden" name="op" value="delete" />
193           <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
194           <input type="submit" value="Delete selected records" class="button" />
195           <a class="cancel" href="/cgi-bin/koha/tools/batch_delete_records.pl">Cancel</a>
196         </fieldset>
197       </form>
198     [% ELSE %]
199       There are no record ids defined.
200     [% END %]
201   [% ELSIF op == 'report' %]
202     [% IF report.total_records == report.total_success %]
203       All records have been deleted successfully!
204     [% ELSIF report.total_success == 0 %]
205       No record has been deleted. An error occurred.
206     [% ELSE %]
207       [% report.total_success | html %] / [% report.total_records | html %] records have been deleted successfully but some errors occurred.
208     [% END %]
209     <p><a href="/cgi-bin/koha/tools/batch_delete_records.pl" title="New batch record deletion">New batch record deletion</a></p>
210   [% ELSE %]
211     No action defined for the template.
212   [% END %]
213
214             </main>
215         </div> <!-- /.col-sm-10.col-sm-push-2 -->
216
217         <div class="col-sm-2 col-sm-pull-10">
218             <aside>
219                 [% INCLUDE 'tools-menu.inc' %]
220             </aside>
221         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
222      </div> <!-- /.row -->
223
224 [% MACRO jsinclude BLOCK %]
225     [% Asset.js("js/tools-menu.js") | $raw %]
226     [% INCLUDE 'datatables.inc' %]
227     <script>
228         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
229         $(document).ready(function() {
230
231           $("#batch_del_form").tabs();
232
233           $("input[type='radio']").click(function(){
234             if ($(this).attr('id') == 'authority_type') {
235               $("#show_list_option").hide();
236             } else if ($(this).attr('id') == 'biblio_type') {
237               $("#show_list_option").show();
238             }
239           });
240             $("#selectall").click(function(e){
241                 e.preventDefault();
242                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
243                     $(this).prop("checked", true);
244                 });
245             });
246
247             $("#clearall").click(function(e){
248                 e.preventDefault();
249                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
250                     $(this).prop("checked", false);
251                 });
252             });
253
254             $("#selectwithoutitems").click(function(e){
255                 e.preventDefault();
256                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
257                     if( $(this).data("items") == 0 ){
258                         $(this).prop("checked", true );
259                     } else {
260                         $(this).prop("checked", false );
261                     }
262                 });
263             });
264
265             $("#selectnotreserved").click(function(e){
266                 e.preventDefault();
267                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
268                     if( $(this).data("reserves") == 0 ){
269                         $(this).prop("checked", true );
270                     } else {
271                         $(this).prop("checked", false );
272                     }
273                 });
274             });
275
276             $("#clearlinkedtobiblio").click(function(e){
277                 e.preventDefault();
278                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
279                     if( $(this).data("usage") == 0 ){
280                         $(this).prop("checked", true );
281                     } else {
282                         $(this).prop("checked", false );
283                     }
284                 });
285             });
286
287           $("#selectall").click();
288
289           [% IF recordtype == 'biblio' %]
290             $(".records input:checkbox[data-issues!='0']").each(function(){
291               $(this).attr('title', MSG_CANNOT_BE_DELETED)
292               $(this).prop('disabled', true);
293               $(this).prop('checked', false);
294               $(this).parents('tr').find('td').css('background-color', '#ffff99');
295             });
296           [% END %]
297
298           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
299             "aoColumnDefs": [
300               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
301               { "aTargets": [ 3, 4 ], "sType": "num-html" }
302             ],
303             "sDom": 't',
304             "aaSorting": [],
305             "bPaginate": false
306           }));
307
308           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
309             "aoColumnDefs": [
310               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
311               { "aTargets": [ 3 ], "sType": "num-html" }
312             ],
313             "sDom": 't',
314             "aaSorting": [],
315             "bPaginate": false
316           }));
317
318           $("#selectrecords").on("submit",function(){
319             var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
320             if (nb_checked == 0){
321               alert(_("No records have been selected."));
322               return false;
323             }
324           });
325
326           $("#selectauths").on("submit",function(){
327             var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
328             if (checked == 0) {
329               alert(_("No authorities have been selected."));
330               return false;
331             }
332           });
333
334           $("#record_ids_selection").on("submit", function(e){
335             var tab = $(this).find('.ui-tabs-active:first a').attr('href');
336             if ( tab == '#uploadfile_tab' ) {
337                 $("#shelf_number").empty('');
338                 $("#recordnumber_list").val('');
339             } else if ( tab == '#shelves_tab' ) {
340                 $("#uploadfile").val('')
341                 $("#recordnumber_list").val('');
342             } else { // enterlist
343                 $("#uploadfile").val('')
344                 $("#shelf_number").empty('');
345             }
346           });
347
348         });
349     </script>
350 [% END %]
351
352 [% INCLUDE 'intranet-bottom.inc' %]