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