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