Bug 12759: (follow-up) Using tabs for diff ways of adding records
[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 [% Asset.css("css/datatables.css") | $raw %]
9 </head>
10
11 <body id="tools_batch_delete_records" class="tools">
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'cat-search.inc' %]
14
15 <div id="breadcrumbs">
16     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
17     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
18     <a href="/cgi-bin/koha/tools/batch_delete_records.pl">Batch record deletion</a>
19 </div>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24             <main>
25
26   <h1>Batch record deletion</h1>
27   [% FOREACH message IN messages %]
28     [% IF message.type == 'success' %]
29       <div class="dialog message">
30     [% ELSIF message.type == 'warning' %]
31       <div class="dialog alert">
32     [% ELSIF message.type == 'error' %]
33       <div class="dialog alert" style="margin:auto;">
34     [% END %]
35     [% IF message.code == 'biblio_not_exists' %]
36       The biblionumber [% message.biblionumber | html %] does not exist in the database.
37     [% ELSIF message.code == 'authority_not_exists' %]
38       The authority id [% message.authid | html %] does not exist in the database.
39     [% ELSIF message.code == 'item_issued' %]
40       At least one item is checked out on bibliographic record [% message.biblionumber | html %].
41     [% ELSIF message.code == 'reserve_not_cancelled' %]
42       Bibliographic record [% message.biblionumber | html %] was not deleted. A hold could not be canceled (reserve_id [% message.reserve_id | html %]).
43     [% ELSIF message.code == 'item_not_deleted' %]
44       The bibliographic record [% message.biblionumber | html %] was not deleted. An error was encountered when deleting an item (itemnumber [% message.itemnumber | html %]).
45     [% ELSIF message.code == 'biblio_not_deleted' %]
46       Bibliographic record [% message.biblionumber | html %] was not deleted. An error occurred.
47     [% ELSIF message.code == 'authority_not_deleted' %]
48       Authority record [% message.authid | html %] was not deleted. An error occurred.
49     [% ELSIF message.code == 'biblio_deleted' %]
50       Bibliographic record [% message.biblionumber | html %] has been deleted successfully.
51     [% ELSIF message.code == 'authority_deleted' %]
52       Authority [% message.authid | html %] has been deleted successfully.
53     [% END %]
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">
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       <br><br>
70
71       <div id="batch_del_form" class="toptabs">
72         <ul>
73           <li><a href="#uploadfile">Upload a file</a></li>
74           [% IF lists.count %]<li id="show_list_option"><a href="#shelves">Select a list of records</a></li>[% END %]
75           <li><a href="#enterlist">Enter a list of record numbers</a></li>
76         </ul>
77
78         <div id="uploadfile">
79           <fieldset class="rows">
80             <legend>Use a file</legend>
81             <ol>
82               <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
83             </ol>
84           </fieldset>
85           &nbsp;
86         </div>
87
88         <div id="shelves">
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 %]">[% list.shelfname %]</option>
98                     [% END %]
99                   </option>
100                 </select>
101               </li>
102             </ol>
103           </fieldset>
104           &nbsp;
105         </div>
106
107         <div id="enterlist">
108           <fieldset class="rows">
109             <legend>Or enter a list of record numbers</legend>
110             <ol>
111               <li>
112                 <label for="recordnumber_list">List of biblionumbers or authority ids (one per line): </label>
113                 <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
114               </li>
115             </ol>
116           </fieldset>
117           &nbsp;
118         </div>
119
120       </div>
121
122       <fieldset class="action">
123         <input type="hidden" name="op" value="list" />
124         <input type="submit" value="Continue" class="button" />
125         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
126       </fieldset>
127     </form>
128   [% ELSIF op == 'list' %]
129     [% IF records %]
130       [% IF recordtype == 'biblio' %]
131         <div id="toolbar">
132           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
133           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
134           | <a id="selectwithoutitems" href="#">Select without items</a>
135           | <a id="selectnotreserved" href="#">Select without holds</a>
136         </div>
137         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectrecords">
138           <table id="biblios" class="records">
139             <thead>
140               <tr>
141                 <th></th>
142                 <th>Biblionumber</th>
143                 <th>Title</th>
144                 <th>Items</th>
145                 <th>Holds</th>
146                 <th>Checkouts</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 %]" /></td>
153                   <td><label for="record_id_[% biblio.biblionumber | html %]">[% biblio.biblionumber | html %]</label></td>
154                   <td>[% INCLUDE 'biblio-default-view.inc' biblionumber=biblio.biblionumber %][% biblio.title | html %][% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle %] [% subtitle.subfield | html %][% END %][% END %]</a></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                 </tr>
159               [% END %]
160             </tbody>
161           </table>
162           <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>
163       [% ELSE %]
164         <div id="toolbar">
165           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
166           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
167           | <a id="clearlinkedtobiblio" href="#">Clear used authorities</a>
168         </div>
169         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectauths">
170           <table id="authorities" class="records">
171             <thead>
172               <tr>
173                 <th></th>
174                 <th>Authid</th>
175                 <th>Summary</th>
176                 <th>Used in</th>
177               </tr>
178             </thead>
179             <tbody>
180               [% FOR authority IN records %]
181                 <tr>
182                   <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td>
183                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td>
184                   <td>[% PROCESS authresult summary=authority.summary %]</td>
185                   <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>
186                 </tr>
187               [% END %]
188             </tbody>
189           </table>
190           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will delete all selected authorities!</div>
191       [% END %]
192         <fieldset class="action">
193           <input type="hidden" name="op" value="delete" />
194           <input type="hidden" name="recordtype" value="[% recordtype | html %]" />
195           <input type="submit" value="Delete selected records" class="button" />
196           <a class="cancel" href="/cgi-bin/koha/tools/batch_delete_records.pl">Cancel</a>
197         </fieldset>
198       </form>
199     [% ELSE %]
200       There are no record ids defined.
201     [% END %]
202   [% ELSIF op == 'report' %]
203     [% IF report.total_records == report.total_success %]
204       All records have been deleted successfully!
205     [% ELSIF report.total_success == 0 %]
206       No record has been deleted. An error occurred.
207     [% ELSE %]
208       [% report.total_success | html %] / [% report.total_records | html %] records have been deleted successfully but some errors occurred.
209     [% END %]
210     <p><a href="/cgi-bin/koha/tools/batch_delete_records.pl" title="New batch record deletion">New batch record deletion</a></p>
211   [% ELSE %]
212     No action defined for the template.
213   [% END %]
214
215             </main>
216         </div> <!-- /.col-sm-10.col-sm-push-2 -->
217
218         <div class="col-sm-2 col-sm-pull-10">
219             <aside>
220                 [% INCLUDE 'tools-menu.inc' %]
221             </aside>
222         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
223      </div> <!-- /.row -->
224
225 [% MACRO jsinclude BLOCK %]
226     [% Asset.js("js/tools-menu.js") | $raw %]
227     [% INCLUDE 'datatables.inc' %]
228     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
229     <script>
230         var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
231         $(document).ready(function() {
232
233           $("#batch_del_form").tabs();
234
235           $("input[type='radio']").click(function(){
236             if ($(this).attr('id') == 'authority_type') {
237               $("#show_list_option").hide();
238             } else if ($(this).attr('id') == 'biblio_type') {
239               $("#show_list_option").show();
240             }
241           });
242           $("#selectall").click(function(e){
243             e.preventDefault();
244             $(".records").checkCheckboxes(":input[type='checkbox']:not(:disabled)");
245           });
246           $("#clearall").click(function(e){
247             e.preventDefault();
248             $(".records").unCheckCheckboxes(":input[type='checkbox']:not(:disabled)");
249           });
250           $("#selectwithoutitems").click(function(e){
251             e.preventDefault();
252             $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
253           });
254           $("#selectnotreserved").click(function(e){
255             e.preventDefault();
256             $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
257
258           });
259           $("#clearlinkedtobiblio").click(function(e){
260             e.preventDefault();
261             $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
262           });
263           $("#selectall").click();
264
265           [% IF recordtype == 'biblio' %]
266             $(".records input:checkbox[data-issues!='0']").each(function(){
267               $(this).attr('title', MSG_CANNOT_BE_DELETED)
268               $(this).prop('disabled', true);
269               $(this).prop('checked', false);
270               $(this).parents('tr').find('td').css('background-color', '#ffff99');
271             });
272           [% END %]
273
274           $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
275             "aoColumnDefs": [
276               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
277               { "aTargets": [ 3, 4 ], "sType": "num-html" }
278             ],
279             "sDom": 't',
280             "aaSorting": [],
281             "bPaginate": false
282           }));
283
284           $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
285             "aoColumnDefs": [
286               { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
287               { "aTargets": [ 3 ], "sType": "num-html" }
288             ],
289             "sDom": 't',
290             "aaSorting": [],
291             "bPaginate": false
292           }));
293
294           $("#selectrecords").on("submit",function(){
295             var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
296             if (nb_checked == 0){
297               alert(_("No records have been selected."));
298               return false;
299             }
300           });
301
302           $("#selectauths").on("submit",function(){
303             var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
304             if (checked == 0) {
305               alert(_("No authorities have been selected."));
306               return false;
307             }
308           });
309         });
310     </script>
311 [% END %]
312
313 [% INCLUDE 'intranet-bottom.inc' %]