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