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