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