Bug 28353: Display a list of items that cannot be deleted
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batchMod-del.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% PROCESS 'i18n.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Batch item deletion &rsaquo; Tools &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 <!--[if IE]>
9 <style>#selections { display: none; }</style>
10 <![endif]-->
11 </head>
12 <body id="tools_batchMod-del" class="tools">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
17     <ol>
18         <li>
19             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
20         </li>
21         <li>
22             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
23         </li>
24         <li>
25             <a href="#" aria-current="page">Batch item deletion</a>
26         </li>
27     </ol>
28 </nav>
29
30 <div class="main container-fluid">
31
32                 [% IF ( show ) %]<h1>Batch item deletion</h1>[% ELSE %]<h1>Batch item deletion results</h1>[% END %]
33         [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
34         [% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
35         [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
36         [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
37
38     [% UNLESS ( action ) %]
39
40     [% IF ( notfoundbarcodes.size ) %]
41         <div class="dialog alert">
42             [% IF ( itemresults ) %]<p>Warning, the following barcodes were not found:</p>[% ELSE %]<p>Warning: no barcodes were found</p>[% END %]
43         </div>
44         <table style="margin:auto;">
45             <thead>
46                 <tr><th>Barcodes not found</th></tr>
47             </thead>
48             <tbody>
49                 [% FOREACH notfoundbarcode IN notfoundbarcodes %]
50                     <tr><td>[% notfoundbarcode |html %]</td></td>
51                 [% END %]
52             </tbody>
53         </table>
54     [% END %] <!-- /notfoundbarcodes -->
55     [% IF ( notfounditemnumbers.size ) %]
56         <div class="dialog alert">
57             [% IF ( itemresults ) %]<p>Warning, the following itemnumbers were not found:</p>[% ELSE %]<p>Warning: no itemnumbers were found</p>[% END %]
58         </div>
59         <table style="margin:auto;">
60             <thead>
61                 <tr><th>Itemnumbers not found</th></tr>
62             </thead>
63             <tbody>
64                 [% FOREACH notfounditemnumber IN notfounditemnumbers %]
65                     <tr><td>[% notfounditemnumber |html %]</td></td>
66                 [% END %]
67             </tbody>
68         </table>
69     [% END %] <!-- /notfounditemnumbers -->
70
71     [% IF cannot_be_deleted.size %]
72         <div class="dialog alert">
73             <p>Warning, the following items cannot be deleted: </p>
74         </div>
75         <table style="margin:auto;">
76             <thead>
77                 <tr><th>Cannot be deleted</th></tr>
78             </thead>
79             <tbody>
80                 [% FOREACH barcode IN cannot_be_deleted %]
81                     <tr><td>[% barcode | html %]</td></td>
82                 [% END %]
83             </tbody>
84         </table>
85     [% END %]
86
87     [% IF ( notfoundbarcodes.size || notfounditemnumbers.size || cannot_be_deleted.size ) && !too_many_items_display && item_loop %]
88         <h4>The following barcodes were found: </h4>
89     [% END %]
90
91
92 <form name="f" action="batchMod.pl" method="post">
93      <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
94      <input type="hidden" name="op" value="[% op | html %]" />
95      <input type="hidden" name="searchid" value="[% searchid | html %]" />
96      <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
97      <input type="hidden" name="completedJobID" id="completedJobID" value="" />
98      <input type="hidden" name="src" id="src" value="[% src | html %]" />
99      [% IF biblionumber %]
100         <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
101      [% END %]
102
103 [% IF ( item_loop ) %]
104     [% IF ( show ) %]<div id="toolbar"><a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-remove"></i> Clear all</a></div>[% END %]
105     <div id="cataloguing_additem_itemlist">
106
107     <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span>
108         [% FOREACH item_header_loo IN item_header_loop %]
109         <span class="selected"><input id="checkheader[% loop.count | html %]" type="checkbox" checked="checked" /> <label for="checkheader[% loop.count | html %]">[% item_header_loo.header_value | html %]</label> </span>
110         [% END %]
111     </p>
112
113         <table id="itemst">
114             <thead>
115             <tr>
116                 [% IF ( show ) %]<th>&nbsp;</th>[% END %]
117                 <th class="anti-the">Title</th>
118                 <th class="holds_count" title="Item holds / Total holds">Holds</th>
119                 [% FOREACH item_header_loo IN item_header_loop %]
120                 <th> [% item_header_loo.header_value | html %] </th>
121                 [% END %]
122             </tr>
123             </thead>
124             <tbody>
125             [% FOREACH item_loo IN item_loop %]
126               <tr>
127                 [% IF show %]
128                   [% IF item_loo.nomod %]
129                     <td class="error">Cannot delete</td>
130                 [% ELSE %]
131                     [% IF item_loo.safe_to_delete == 1 %]
132                         <td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber | html %]" id="row[% item_loo.itemnumber | html %]" checked="checked" /></td>
133                     [% ELSE %]
134                         [% SWITCH item_loo.safe_to_delete%]
135                         [% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %]
136                         [% CASE "not_same_branch" %][% SET cannot_delete_reason = t("Item does not belong to your library") %]
137                         [% CASE "book_reserved" %][% SET cannot_delete_reason = t("Item has a waiting hold") %]
138                         [% CASE "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %]
139                         [% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %]
140                         [% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ item_loo.safe_to_delete _ ')' %]
141                         [% END %]
142
143                         <td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber | html %]" id="row[% item_loo.itemnumber | html %]" disabled="disabled" title="[% cannot_delete_reason | html %]"/></td>
144                     [% END %]
145                   [% END %]
146                 [% ELSE %]
147                   <td>&nbsp;</td>
148                 [% END %]
149                 <td>
150                     <label for="row[% item_loo.itemnumber | html %]">
151                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber | uri %]">
152                             [% item_loo.title | html %]
153                         </a>
154                         [% IF ( item_loo.author ) %], by [% item_loo.author | html %][% END %]
155                     </label>
156                 </td>
157                 <td class="holds_count">
158                     [% IF item_loo.holds %]
159                         [% IF item_loo.item_holds %]
160                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this item: [% item_loo.item_holds | html %] / Total holds on this record: [% item_loo.holds | html -%]" >
161                         [% ELSE %]
162                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this item / Total holds on this record: [% item_loo.holds | html -%]" >
163                         [% END %]
164                     [% ELSE %]
165                         [% IF item_loo.holds %]
166                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this record: [% item_loo.holds | html -%]" >
167                         [% ELSE %]
168                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this record" >
169                         [% END %]
170                     [% END %]
171                                 [% IF item_loo.holds %]
172                                     [% item_loo.item_holds | html %]/[% item_loo.holds | html %]
173                                 [% ELSE %]
174                                     [% item_loo.holds | html %]
175                                 [% END %]
176                             </a>
177                 </td>
178             [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field | html %]</td>
179                     [% END %] </tr>
180             [% END %]
181             </tbody>
182         </table>
183     </div>
184 [% END %]
185
186 [% IF ( simple_items_display ) %]
187     <ul>
188     [% FOREACH simple_items_displa IN simple_items_display %]
189         <li>
190             <a href="[% simple_items_displa.itemnumber | url %]">[% simple_items_displa.barcode | html %]</a>
191         </li>
192     [% END %]
193     </ul>
194 [% END %]
195
196
197 [% IF ( show ) %]
198
199 [% IF ( too_many_items_display ) %]
200     <p>Too many items ([% too_many_items_display | html %]) to display individually.</p>
201     [% FOREACH itemnumber IN itemnumbers_array %]
202         <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
203     [% END %]
204 [% END %]
205
206 [% IF ( itemresults ) %]
207         <div id="cataloguing_additem_newitem">
208          <input type="hidden" name="op" value="[% op | html %]" />
209          <p>This will delete [% IF ( too_many_items_display ) %]all the[% ELSE %]the selected[% END %] items.</p>
210          <input type="hidden" name="del" value="1" />
211          <fieldset class="action">
212         <input type="checkbox" name="del_records" id="del_records" /> <label for="del_records">Delete records if no items remain.</label>
213         [% IF too_many_items_display %]
214             <input type="submit" name="mainformsubmit" value="Delete ALL submitted items" />
215         [% ELSE %]
216             <input type="submit" name="mainformsubmit" value="Delete selected items" />
217         [% END %]
218
219         <a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a>
220         </fieldset>
221     </div>
222     [% ELSE %]
223     <p><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a></p>
224     [% END %]
225     [% END %]
226     </form>
227     [% END %]
228
229 [% IF ( action ) %]
230     [% IF deletion_failed %]
231         <div class="dialog alert">
232             At least one item blocked the deletion. The operation rolled back and nothing happened!
233         </div>
234     [% ELSE %]
235         <div class="dialog message">
236             <p>[% deleted_items | html %] item(s) deleted.</p>
237             [% IF delete_records %] <p>[% deleted_records | html %] record(s) deleted.</p> [% END %]
238             [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
239                 [% IF biblio_deleted %]
240                     [% IF searchid %]
241                         <div id="previous_search_link"></div>
242                     [% END %]
243                     <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Return to the cataloging module</a>
244                 [% ELSE %]
245                     [% IF searchid %]
246                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&searchid=[% searchid | uri %]">Return to the record</a>
247                     [% ELSE %]
248                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
249                     [% END %]
250                 [% END %]
251             [% ELSIF src %]
252                 <a href="[% src | url %]">Return to where you were</a>
253             [% ELSE %]
254                 <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a>
255             [% END %]
256         </div>
257     [% END %]
258     [% IF ( not_deleted_items ) %]
259     <div style="width:55%;margin:auto;">
260         <p>[% not_deleted_items | html %] item(s) could not be deleted: [% FOREACH not_deleted_itemnumber IN not_deleted_itemnumbers %][% not_deleted_itemnumber.itemnumber | html %][% END %]</p>
261     [% IF ( not_deleted_loop ) %]
262     <table id="itemst">
263         <thead>
264             <tr>
265             <th>Itemnumber</th>
266             <th>Barcode</th>
267             <th>Reason</th>
268             </tr>
269         </thead>
270         <tbody>
271             [% FOREACH not_deleted_loo IN not_deleted_loop %]
272             <tr>
273                 <td>[% not_deleted_loo.itemnumber | html %]</td>
274                 <td>[% IF ( CAN_user_editcatalogue_edit_items ) %]<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% not_deleted_loo.biblionumber | uri %]&amp;itemnumber=[% not_deleted_loo.itemnumber | uri %]">[% not_deleted_loo.barcode | html %]</a>[% ELSE %][% not_deleted_loo.barcode | html %][% END %]</td>
275                 <td>
276                     [% SWITCH not_deleted_loo.reason %]
277                     [% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %]
278                     [% CASE "not_same_branch" %][% SET cannot_delete_reason = t("Item does not belong to your library") %]
279                     [% CASE "book_reserved" %][% SET cannot_delete_reason = t("Item has a waiting hold") %]
280                     [% CASE "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %]
281                     [% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %]
282                     [% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ can_be_deleted _ ')' %]
283                     [% END %]
284                     [% cannot_delete_reason | html %]
285                 </td>
286             </tr>
287             [% END %]
288         </tbody>
289         </table>
290     [% END %]
291     </div>
292     [% END %]
293
294     <p>
295         [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
296             [% IF biblio_deleted %]
297                 <a class="btn btn-default" href="/cgi-bin/koha/cataloguing/addbooks.pl"><i class="fa fa-check-square-o"></i> Return to the cataloging module</a>
298             [% ELSIF searchid %]
299                <a class="btn btn-default" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&searchid=[% searchid | uri %]"><i class="fa fa-check-square-o"></i> Return to the record</a>
300             [% ELSE %]
301                <a class="btn btn-default" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]"><i class="fa fa-check-square-o"></i> Return to the record</a>
302             [% END %]
303         [% ELSIF src %]
304            <a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
305         [% ELSE %]
306            <a class="btn btn-default" href="/cgi-bin/koha/tools/batchMod.pl?del=1"><i class="fa fa-check-square-o"></i> Return to batch item deletion</a>
307         [% END %]
308     </p>
309 [% END %]
310     </div>
311
312 [% MACRO jsinclude BLOCK %]
313     [% Asset.js("js/tools-menu.js") | $raw %]
314     [% INCLUDE 'datatables.inc' %]
315     [% Asset.js("js/pages/batchMod.js") | $raw %]
316     [% Asset.js("js/browser.js") | $raw %]
317     <script>
318         // Prepare array of all column headers, incrementing each index by
319         // two to accommodate control and title columns
320         var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count | html %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
321         for( x=0; x<allColumns.length; x++ ){
322           allColumns[x] = Number(allColumns[x]) + 2;
323         }
324         $(document).ready(function(){
325             $("#mainformsubmit").on("click",function(){
326                 return submitBackgroundJob(this.form);
327             });
328         });
329
330         [% IF searchid %]
331             browser = KOHA.browser('[% searchid | html %]');
332             browser.show_back_link();
333         [% END %]
334     </script>
335 [% END %]
336
337 [% INCLUDE 'intranet-bottom.inc' %]