Bug 11529: Add templates for biblio title display. Unify display.
[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 <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       <br><br>
69
70       <div id="batch_del_form" class="toptabs">
71         <ul>
72           <li><a href="#uploadfile_tab">Upload a file</a></li>
73           [% IF lists.count %]<li id="show_list_option"><a href="#shelves_tab">Select a list of records</a></li>[% END %]
74           <li><a href="#enterlist_tab">Enter a list of record numbers</a></li>
75         </ul>
76
77         <div id="uploadfile_tab">
78           <fieldset class="rows">
79             <legend>Use a file</legend>
80             <ol>
81               <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
82             </ol>
83           </fieldset>
84           &nbsp;
85         </div>
86
87         [% IF lists.count %]
88             <div id="shelves_tab">
89               <fieldset class="rows">
90                 <legend>Or select a list of records</legend>
91                 <ol>
92                   <li>
93                     <label for="shelf_number">Use records from the following list: </label>
94                     <select name="shelf_number" id="shelf_number">
95                       <option value="">Select a list</option>
96                         [% FOREACH list IN lists %]
97                           <option value="[% list.shelfnumber | html %]">[% list.shelfname | html %]</option>
98                         [% END %]
99                       </option>
100                     </select>
101                   </li>
102                 </ol>
103               </fieldset>
104               &nbsp;
105             </div>
106         [% END %]
107
108         <div id="enterlist_tab">
109           <fieldset class="rows">
110             <legend>Or enter a list of record numbers</legend>
111             <ol>
112               <li>
113                 <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
114                 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
115               </li>
116             </ol>
117           </fieldset>
118           &nbsp;
119         </div>
120
121       </div>
122
123       <fieldset class="action">
124         <input type="hidden" name="op" value="list" />
125         <input type="submit" value="Continue" class="button" />
126         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
127       </fieldset>
128     </form>
129   [% ELSIF op == 'list' %]
130     [% IF records %]
131       [% IF recordtype == 'biblio' %]
132         <div id="toolbar">
133           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
134           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
135           | <a id="selectwithoutitems" href="#">Select without items</a>
136           | <a id="selectnotreserved" href="#">Select without holds</a>
137         </div>
138         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectrecords">
139           <table id="biblios" class="records">
140             <thead>
141               <tr>
142                 <th></th>
143                 <th>Biblionumber</th>
144                 <th>Title</th>
145                 <th>Items</th>
146                 <th>Holds</th>
147                 <th>Checkouts</th>
148               </tr>
149             </thead>
150             <tbody>
151               [% FOR biblio IN records %]
152                 <tr>
153                   <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>
154                   <td><label for="record_id_[% biblio.biblionumber | html %]">[% biblio.biblionumber | html %]</label></td>
155                   <td>[% INCLUDE 'biblio-default-view.inc' biblionumber=biblio.biblionumber %][% INCLUDE 'biblio-title.inc' %]</a></td>
156                   <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.itemnumbers.size | html %]</a></td>
157                   <td><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.holds_count | html %]</a></td>
158                   <td><a href="/cgi-bin/koha/catalogue/issuehistory.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.issues_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 %]</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 == 'report' %]
204     [% IF report.total_records == report.total_success %]
205       All records have been deleted successfully!
206     [% ELSIF report.total_success == 0 %]
207       No record has been deleted. An error occurred.
208     [% ELSE %]
209       [% report.total_success | html %] / [% report.total_records | html %] records have been deleted successfully but some errors occurred.
210     [% END %]
211     <p><a href="/cgi-bin/koha/tools/batch_delete_records.pl" title="New batch record deletion">New batch record deletion</a></p>
212   [% ELSE %]
213     No action defined for the template.
214   [% END %]
215
216             </main>
217         </div> <!-- /.col-sm-10.col-sm-push-2 -->
218
219         <div class="col-sm-2 col-sm-pull-10">
220             <aside>
221                 [% INCLUDE 'tools-menu.inc' %]
222             </aside>
223         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
224      </div> <!-- /.row -->
225
226 [% MACRO jsinclude BLOCK %]
227     [% Asset.js("js/tools-menu.js") | $raw %]
228     [% INCLUDE 'datatables.inc' %]
229     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
230     <script>
231         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
232         $(document).ready(function() {
233
234           $("#batch_del_form").tabs();
235
236           $("input[type='radio']").click(function(){
237             if ($(this).attr('id') == 'authority_type') {
238               $("#show_list_option").hide();
239             } else if ($(this).attr('id') == 'biblio_type') {
240               $("#show_list_option").show();
241             }
242           });
243           $("#selectall").click(function(e){
244             e.preventDefault();
245             $(".records").checkCheckboxes(":input[type='checkbox']:not(:disabled)");
246           });
247           $("#clearall").click(function(e){
248             e.preventDefault();
249             $(".records").unCheckCheckboxes(":input[type='checkbox']:not(:disabled)");
250           });
251           $("#selectwithoutitems").click(function(e){
252             e.preventDefault();
253             $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
254           });
255           $("#selectnotreserved").click(function(e){
256             e.preventDefault();
257             $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
258
259           });
260           $("#clearlinkedtobiblio").click(function(e){
261             e.preventDefault();
262             $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
263           });
264           $("#selectall").click();
265
266           [% IF recordtype == 'biblio' %]
267             $(".records input:checkbox[data-issues!='0']").each(function(){
268               $(this).attr('title', MSG_CANNOT_BE_DELETED)
269               $(this).prop('disabled', true);
270               $(this).prop('checked', false);
271               $(this).parents('tr').find('td').css('background-color', '#ffff99');
272             });
273           [% END %]
274
275           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
276             "aoColumnDefs": [
277               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
278               { "aTargets": [ 3, 4 ], "sType": "num-html" }
279             ],
280             "sDom": 't',
281             "aaSorting": [],
282             "bPaginate": false
283           }));
284
285           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
286             "aoColumnDefs": [
287               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
288               { "aTargets": [ 3 ], "sType": "num-html" }
289             ],
290             "sDom": 't',
291             "aaSorting": [],
292             "bPaginate": false
293           }));
294
295           $("#selectrecords").on("submit",function(){
296             var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
297             if (nb_checked == 0){
298               alert(_("No records have been selected."));
299               return false;
300             }
301           });
302
303           $("#selectauths").on("submit",function(){
304             var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
305             if (checked == 0) {
306               alert(_("No authorities have been selected."));
307               return false;
308             }
309           });
310
311           $("#record_ids_selection").on("submit", function(e){
312             var tab = $(this).find('.ui-tabs-active:first a').attr('href');
313             if ( tab == '#uploadfile_tab' ) {
314                 $("#shelf_number").empty('');
315                 $("#recordnumber_list").val('');
316             } else if ( tab == '#shelves_tab' ) {
317                 $("#uploadfile").val('')
318                 $("#recordnumber_list").val('');
319             } else { // enterlist
320                 $("#uploadfile").val('')
321                 $("#shelf_number").empty('');
322             }
323           });
324
325         });
326     </script>
327 [% END %]
328
329 [% INCLUDE 'intranet-bottom.inc' %]