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