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