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