Bug 17736: Replace GetReservesFromBiblionumber with Koha::Biblio->holds
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_delete_records.tt
1 [% PROCESS 'authorities-search-results.inc' %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Batch record deletion</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6 [% INCLUDE 'datatables.inc' %]
7 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8 <script type="text/javascript">
9 //<![CDATA[
10 var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
11 $(document).ready(function() {
12   $("#selectall").click(function(e){
13     e.preventDefault();
14     $(".records").checkCheckboxes();
15   });
16   $("#clearall").click(function(e){
17     e.preventDefault();
18     $(".records").unCheckCheckboxes();
19   });
20   $("#selectwithoutitems").click(function(e){
21     e.preventDefault();
22     $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
23   });
24   $("#selectnotreserved").click(function(e){
25     e.preventDefault();
26     $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
27
28   });
29   $("#clearlinkedtobiblio").click(function(e){
30     e.preventDefault();
31     $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
32   });
33   $("#selectall").click();
34
35   [% IF recordtype == 'biblio' %]
36     $(".records input:checkbox[data-issues!='0']").each(function(){
37       $(this).attr('title', MSG_CANNOT_BE_DELETED)
38       $(this).prop('disabled', true);
39       $(this).prop('checked', false);
40       $(this).parents('tr').find('td').css('background-color', '#ffff99');
41     });
42   [% END %]
43
44   $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
45     "aoColumnDefs": [
46       { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
47       { "aTargets": [ 3, 4 ], "sType": "num-html" }
48     ],
49     "sDom": 't',
50     "aaSorting": [],
51     "bPaginate": false
52   }));
53
54   $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
55     "aoColumnDefs": [
56       { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
57       { "aTargets": [ 3 ], "sType": "num-html" }
58     ],
59     "sDom": 't',
60     "aaSorting": [],
61     "bPaginate": false
62   }));
63
64   $("#selectrecords").on("submit",function(){
65     var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
66     if (nb_checked == 0){
67       alert(_("No records have been selected."));
68       return false;
69     }
70   });
71
72   $("#selectauths").on("submit",function(){
73     var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
74     if (checked == 0) {
75       alert(_("No authorities have been selected."));
76       return false;
77     }
78   });
79 });
80 //]]>
81 </script>
82 </head>
83 <body id="tools_batch_delete_records" class="tools">
84 [% INCLUDE 'header.inc' %]
85 [% INCLUDE 'cat-search.inc' %]
86
87 <div id="breadcrumbs">
88     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
89     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
90     <a href="/cgi-bin/koha/tools/batch_delete_records.pl">Batch record deletion</a>
91 </div>
92
93 <div id="doc3" class="yui-t2">
94 <div id="bd">
95 <div id="yui-main">
96 <div class="yui-b">
97   <h1>Batch record deletion</h1>
98   [% FOREACH message IN messages %]
99     [% IF message.type == 'success' %]
100       <div class="dialog message">
101     [% ELSIF message.type == 'warning' %]
102       <div class="dialog alert">
103     [% ELSIF message.type == 'error' %]
104       <div class="dialog error" style="margin:auto;">
105     [% END %]
106     [% IF message.code == 'biblio_not_exists' %]
107       The biblionumber [% message.biblionumber %] does not exist in the database.
108     [% ELSIF message.code == 'authority_not_exists' %]
109       The authority id [% message.authid %] does not exist in the database.
110     [% ELSIF message.code == 'item_issued' %]
111       At least one item is checked out on bibliographic record [% message.biblionumber %].
112     [% ELSIF message.code == 'reserve_not_cancelled' %]
113       Bibliographic record [% message.biblionumber %] was not deleted. A hold could not be canceled (reserve_id [% message.reserve_id %]).
114     [% ELSIF message.code == 'item_not_deleted' %]
115       The bibliographic record [% message.biblionumber %] was not deleted. An error was encountered when deleting an item (itemnumber [% message.itemnumber %]).
116     [% ELSIF message.code == 'biblio_not_deleted' %]
117       Bibliographic record [% message.biblionumber %] was not deleted. An error occurred.
118     [% ELSIF message.code == 'authority_not_deleted' %]
119       Authority record [% message.authid %] was not deleted. An error occurred.
120     [% ELSIF message.code == 'biblio_deleted' %]
121       Bibliographic record [% message.biblionumber %] has been deleted successfully.
122     [% ELSIF message.code == 'authority_deleted' %]
123       Authority [% message.authid %] has been deleted successfully.
124     [% END %]
125     [% IF message.error %]
126       (The error was: [% message.error%], see the Koha log file for more information).
127     [% END %]
128     </div>
129   [% END %]
130   [% IF op == 'form' %]
131     <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_delete_records.pl">
132       <fieldset class="rows">
133         <legend>Record type</legend>
134         <ol>
135           <li><label for="biblio_type">Bibliographic: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
136           <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
137         </ol>
138       </fieldset>
139       <fieldset class="rows">
140         <legend>Use a file</legend>
141         <ol>
142           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
143         </ol>
144       </fieldset>
145       <fieldset class="rows">
146         <legend>Or enter a list of record numbers</legend>
147         <ol>
148           <li>
149             <label for="recordnumber_list">Record number list (one per line): </label>
150             <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
151           </li>
152         </ol>
153       </fieldset>
154       <fieldset class="action">
155         <input type="hidden" name="op" value="list" />
156         <input type="submit" value="Continue" class="button" />
157         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
158       </fieldset>
159     </form>
160   [% ELSIF op == 'list' %]
161     [% IF records %]
162       [% IF recordtype == 'biblio' %]
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="selectwithoutitems" href="#">Select without items</a>
167           | <a id="selectnotreserved" href="#">Select without holds</a>
168         </div>
169         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectrecords">
170           <table id="biblios" class="records">
171             <thead>
172               <tr>
173                 <th></th>
174                 <th>Biblionumber</th>
175                 <th>Title</th>
176                 <th>Items</th>
177                 <th>Holds</th>
178                 <th>Checkouts</th>
179               </tr>
180             </thead>
181             <tbody>
182               [% FOR biblio IN records %]
183                 <tr>
184                   <td><input type="checkbox" name="record_id" id="record_id_[% biblio.biblionumber %]" value="[% biblio.biblionumber %]" data-items="[% biblio.itemnumbers.size %]" data-issues="[% biblio.issues_count %]" data-reserves="[% biblio.holds_count %]" /></td>
185                   <td><label for="record_id_[% biblio.biblionumber %]">[% biblio.biblionumber %]</label></td>
186                   <td>[% INCLUDE 'biblio-default-view.inc' biblionumber=biblio.biblionumber %][% biblio.title %][% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle %] [% subtitle.subfield |html %][% END %][% END %]</a></td>
187                   <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.itemnumbers.size %]</a></td>
188                   <td><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.holds_count %]</a></td>
189                   <td><a href="/cgi-bin/koha/catalogue/issuehistory.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.issues_count %]</a></td>
190                 </tr>
191               [% END %]
192             </tbody>
193           </table>
194           <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>
195       [% ELSE %]
196         <div id="toolbar">
197           <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
198           | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
199           | <a id="clearlinkedtobiblio" href="#">Clear used authorities</a>
200         </div>
201         <form action="/cgi-bin/koha/tools/batch_delete_records.pl" method="post" id="selectauths">
202           <table id="authorities" class="records">
203             <thead>
204               <tr>
205                 <th></th>
206                 <th>Authid</th>
207                 <th>Summary</th>
208                 <th>Used in</th>
209               </tr>
210             </thead>
211             <tbody>
212               [% FOR authority IN records %]
213                 <tr>
214                   <td><input type="checkbox" name="record_id" value="[% authority.authid %]" data-usage="[% authority.count_usage %]" /></td>
215                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid %]">[% authority.authid %]</a></td>
216                   <td>[% PROCESS authresult summary=authority.summary %]</td>
217                   <td><a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&amp;op=do_search&amp;idx=an,phr&amp;q=[% authority.authid %]">[% authority.count_usage %] record(s)</a></td>
218                 </tr>
219               [% END %]
220             </tbody>
221           </table>
222           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will delete all selected authorities!</div>
223       [% END %]
224         <fieldset class="action">
225           <input type="hidden" name="op" value="delete" />
226           <input type="hidden" name="recordtype" value="[% recordtype %]" />
227           <input type="submit" value="Delete selected records" class="button" />
228           <a class="cancel" href="/cgi-bin/koha/tools/batch_delete_records.pl">Cancel</a>
229         </fieldset>
230       </form>
231     [% ELSE %]
232       There are no record ids defined.
233     [% END %]
234   [% ELSIF op == 'report' %]
235     [% IF report.total_records == report.total_success %]
236       All records have been deleted successfully!
237     [% ELSIF report.total_success == 0 %]
238       No record has been deleted. An error occurred.
239     [% ELSE %]
240       [% report.total_success %] / [% report.total_records %] records have been deleted successfully but some errors occurred.
241     [% END %]
242     <p><a href="/cgi-bin/koha/tools/batch_delete_records.pl" title="New batch record deletion">New batch record deletion</a></p>
243   [% ELSE %]
244     No action defined for the template.
245   [% END %]
246 </div>
247 </div>
248 <div class="yui-b">
249   [% INCLUDE 'tools-menu.inc' %]
250 </div>
251 </div>
252 [% INCLUDE 'intranet-bottom.inc' %]