Bug 28840: (QA follow-up) Update id to ID
[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; Tools &rsaquo; Koha</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 == 'cannot_enqueue_job' %]
47         Cannot enqueue this job.
48     [% ELSIF message.code == 'biblio_not_exists' %]
49         Bibliographic record [% message.biblionumber | html %] does not exist in the database.
50     [% ELSIF message.code == 'authority_not_exists' %]
51         Authority record [% message.authid | html %] does not exist in the database.
52     [% END %]
53
54     [% IF message.error %]
55       (The error was: [% message.error | html %], see the Koha log file for more information).
56     [% END %]
57     </div>
58   [% END %]
59   [% IF op == 'form' %]
60     <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_delete_records.pl" id="record_ids_selection">
61       <fieldset class="rows">
62         <legend>Record type</legend>
63         <ol>
64           <li><label for="biblio_type">Bibliographic: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
65           <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
66         </ol>
67       </fieldset>
68
69       <div id="batch_del_form" class="toptabs" style="clear:both">
70         <ul>
71           <li><a href="#uploadfile_tab">Upload a file</a></li>
72           [% IF lists.count %]<li id="show_list_option"><a href="#shelves_tab">Select a list of records</a></li>[% END %]
73           <li><a href="#enterlist_tab">Enter a list of record IDs</a></li>
74         </ul>
75
76         <div id="uploadfile_tab">
77           <fieldset class="rows">
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                 <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                       </option>
97                     </select>
98                   </li>
99                 </ol>
100               </fieldset>
101               &nbsp;
102             </div>
103         [% END %]
104
105         <div id="enterlist_tab">
106           <fieldset class="rows">
107             <ol>
108               <li>
109                 <label for="recordnumber_list">IDs: </label>
110                 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
111                 <div class="hint">Enter a list of biblionumbers or authority IDs, one per line.</div>
112               </li>
113             </ol>
114           </fieldset>
115           &nbsp;
116         </div>
117
118       </div>
119
120       <fieldset class="action">
121         <input type="hidden" name="op" value="list" />
122         <input type="submit" value="Continue" class="button" />
123         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
124       </fieldset>
125     </form>
126   [% ELSIF op == 'list' %]
127     [% IF records %]
128       [% IF recordtype == 'biblio' %]
129         <div id="toolbar">
130           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
131           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
132           | <a id="selectwithoutitems" href="#">Select without items</a>
133           | <a id="selectnotreserved" href="#">Select without holds</a>
134           | <a id="selectwithoutsubscriptions" href="#">Select without subscriptions</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                 <th>Subscriptions</th>
147               </tr>
148             </thead>
149             <tbody>
150               [% FOR biblio IN records %]
151                 <tr>
152                   <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>
153                   <td><label for="record_id_[% biblio.biblionumber | html %]">[% biblio.biblionumber | html %]</label></td>
154                   <td>[% INCLUDE 'biblio-title.inc' link = 1 %]</td>
155                   <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.itemnumbers.size | html %]</a></td>
156                   <td><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.holds_count | html %]</a></td>
157                   <td><a href="/cgi-bin/koha/catalogue/issuehistory.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.issues_count | html %]</a></td>
158                   <td><a href="/cgi-bin/koha/serials/serials-search.pl?searched=1&biblionumber=[% biblio.biblionumber | uri %]">[% biblio.subscriptions_count | html %]</a></td>
159                 </tr>
160               [% END %]
161             </tbody>
162           </table>
163           <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>
164       [% ELSE %]
165         <div id="toolbar">
166           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
167           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
168           | <a id="clearlinkedtobiblio" href="#">Clear used authorities</a>
169         </div>
170         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectauths">
171           <table id="authorities" class="records">
172             <thead>
173               <tr>
174                 <th></th>
175                 <th>AuthID</th>
176                 <th>Summary</th>
177                 <th>Used in</th>
178               </tr>
179             </thead>
180             <tbody>
181               [% FOR authority IN records %]
182                 <tr>
183                   <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
184                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
185                   <td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td>
186                   <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>
187                 </tr>
188               [% END %]
189             </tbody>
190           </table>
191           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will delete all selected authorities!</div>
192       [% END %]
193         <fieldset class="action">
194           <input type="hidden" name="op" value="delete" />
195           <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
196           <input type="submit" value="Delete selected records" class="button" />
197           <a class="cancel" href="/cgi-bin/koha/tools/batch_delete_records.pl">Cancel</a>
198         </fieldset>
199       </form>
200     [% ELSE %]
201       There are no record IDs defined.
202     [% END %]
203   [% ELSIF op == 'enqueued' %]
204     <div class="dialog message">
205       <p>The job has been enqueued! It will be processed as soon as possible.</p>
206       <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>
207       | <a href="/cgi-bin/koha/tools/batch_delete_records.pl" title="New batch record deletion">New batch record deletion</a></p>
208     </div>
209   [% ELSE %]
210     No action defined for the template.
211   [% END %]
212
213             </main>
214         </div> <!-- /.col-sm-10.col-sm-push-2 -->
215
216         <div class="col-sm-2 col-sm-pull-10">
217             <aside>
218                 [% INCLUDE 'tools-menu.inc' %]
219             </aside>
220         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
221      </div> <!-- /.row -->
222
223 [% MACRO jsinclude BLOCK %]
224     [% Asset.js("js/tools-menu.js") | $raw %]
225     [% INCLUDE 'datatables.inc' %]
226     <script>
227         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
228         $(document).ready(function() {
229
230           $("#batch_del_form").tabs();
231
232           $("input[type='radio']").click(function(){
233             if ($(this).attr('id') == 'authority_type') {
234               $("#show_list_option").hide();
235             } else if ($(this).attr('id') == 'biblio_type') {
236               $("#show_list_option").show();
237             }
238           });
239             $("#selectall").click(function(e){
240                 e.preventDefault();
241                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
242                     $(this).prop("checked", true);
243                 });
244             });
245
246             $("#clearall").click(function(e){
247                 e.preventDefault();
248                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
249                     $(this).prop("checked", false);
250                 });
251             });
252
253             $("#selectwithoutitems").click(function(e){
254                 e.preventDefault();
255                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
256                     if( $(this).data("items") == 0 ){
257                         $(this).prop("checked", true );
258                     } else {
259                         $(this).prop("checked", false );
260                     }
261                 });
262             });
263
264             $("#selectnotreserved").click(function(e){
265                 e.preventDefault();
266                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
267                     if( $(this).data("reserves") == 0 ){
268                         $(this).prop("checked", true );
269                     } else {
270                         $(this).prop("checked", false );
271                     }
272                 });
273             });
274
275             $("#selectwithoutsubscriptions").click(function(e){
276                 e.preventDefault();
277                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
278                     if( $(this).data("subscriptions") == 0 ){
279                         $(this).prop("checked", true );
280                     } else {
281                         $(this).prop("checked", false );
282                     }
283                 });
284             });
285
286             $("#clearlinkedtobiblio").click(function(e){
287                 e.preventDefault();
288                 $(".records input[type='checkbox']:not(:disabled)").each(function(){
289                     if( $(this).data("usage") == 0 ){
290                         $(this).prop("checked", true );
291                     } else {
292                         $(this).prop("checked", false );
293                     }
294                 });
295             });
296
297           $("#selectall").click();
298
299           [% IF recordtype == 'biblio' %]
300             $(".records input:checkbox[data-issues!='0']").each(function(){
301               $(this).attr('title', MSG_CANNOT_BE_DELETED)
302               $(this).prop('disabled', true);
303               $(this).prop('checked', false);
304               $(this).parents('tr').find('td').css('background-color', '#ffff99');
305             });
306           [% END %]
307
308           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
309             "aoColumnDefs": [
310               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
311               { "aTargets": [ 3, 4 ], "sType": "num-html" }
312             ],
313             "sDom": 't',
314             "aaSorting": [],
315             "bPaginate": false
316           }));
317
318           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
319             "aoColumnDefs": [
320               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
321               { "aTargets": [ 3 ], "sType": "num-html" }
322             ],
323             "sDom": 't',
324             "aaSorting": [],
325             "bPaginate": false
326           }));
327
328           $("#selectrecords").on("submit",function(){
329             var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
330             if (nb_checked == 0){
331               alert(_("No records have been selected."));
332               return false;
333             }
334           });
335
336           $("#selectauths").on("submit",function(){
337             var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
338             if (checked == 0) {
339               alert(_("No authorities have been selected."));
340               return false;
341             }
342           });
343
344           $("#record_ids_selection").on("submit", function(e){
345             var tab = $(this).find('.ui-tabs-active:first a').attr('href');
346             if ( tab == '#uploadfile_tab' ) {
347                 $("#shelf_number").empty('');
348                 $("#recordnumber_list").val('');
349             } else if ( tab == '#shelves_tab' ) {
350                 $("#uploadfile").val('')
351                 $("#recordnumber_list").val('');
352             } else { // enterlist
353                 $("#uploadfile").val('')
354                 $("#shelf_number").empty('');
355             }
356           });
357
358         });
359     </script>
360 [% END %]
361
362 [% INCLUDE 'intranet-bottom.inc' %]