Koha/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
Jonathan Druart 52c82407fd Bug 28353: Display a list of items that cannot be deleted
We used to display a list of items that cannot be deleted (checked out
or on hold) on the Batch item deletion tool.
With bug 8132 we improve the error handling, but the info is spread in
the table.

This patch adds, at the top of the page, the list of items (barcode)
that cannot be removed.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-06-04 12:04:42 +02:00

337 lines
16 KiB
Text

[% USE raw %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% PROCESS 'i18n.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Batch item deletion &rsaquo; Tools &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
<!--[if IE]>
<style>#selections { display: none; }</style>
<![endif]-->
</head>
<body id="tools_batchMod-del" class="tools">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
</li>
<li>
<a href="#" aria-current="page">Batch item deletion</a>
</li>
</ol>
</nav>
<div class="main container-fluid">
[% IF ( show ) %]<h1>Batch item deletion</h1>[% ELSE %]<h1>Batch item deletion results</h1>[% END %]
[% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
[% 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 %]
[% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
[% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
[% UNLESS ( action ) %]
[% IF ( notfoundbarcodes.size ) %]
<div class="dialog alert">
[% IF ( itemresults ) %]<p>Warning, the following barcodes were not found:</p>[% ELSE %]<p>Warning: no barcodes were found</p>[% END %]
</div>
<table style="margin:auto;">
<thead>
<tr><th>Barcodes not found</th></tr>
</thead>
<tbody>
[% FOREACH notfoundbarcode IN notfoundbarcodes %]
<tr><td>[% notfoundbarcode |html %]</td></td>
[% END %]
</tbody>
</table>
[% END %] <!-- /notfoundbarcodes -->
[% IF ( notfounditemnumbers.size ) %]
<div class="dialog alert">
[% IF ( itemresults ) %]<p>Warning, the following itemnumbers were not found:</p>[% ELSE %]<p>Warning: no itemnumbers were found</p>[% END %]
</div>
<table style="margin:auto;">
<thead>
<tr><th>Itemnumbers not found</th></tr>
</thead>
<tbody>
[% FOREACH notfounditemnumber IN notfounditemnumbers %]
<tr><td>[% notfounditemnumber |html %]</td></td>
[% END %]
</tbody>
</table>
[% END %] <!-- /notfounditemnumbers -->
[% IF cannot_be_deleted.size %]
<div class="dialog alert">
<p>Warning, the following items cannot be deleted: </p>
</div>
<table style="margin:auto;">
<thead>
<tr><th>Cannot be deleted</th></tr>
</thead>
<tbody>
[% FOREACH barcode IN cannot_be_deleted %]
<tr><td>[% barcode | html %]</td></td>
[% END %]
</tbody>
</table>
[% END %]
[% IF ( notfoundbarcodes.size || notfounditemnumbers.size || cannot_be_deleted.size ) && !too_many_items_display && item_loop %]
<h4>The following barcodes were found: </h4>
[% END %]
<form name="f" action="batchMod.pl" method="post">
<input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
<input type="hidden" name="op" value="[% op | html %]" />
<input type="hidden" name="searchid" value="[% searchid | html %]" />
<input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
<input type="hidden" name="completedJobID" id="completedJobID" value="" />
<input type="hidden" name="src" id="src" value="[% src | html %]" />
[% IF biblionumber %]
<input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber | html %]" />
[% END %]
[% IF ( item_loop ) %]
[% 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 %]
<div id="cataloguing_additem_itemlist">
<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>
[% FOREACH item_header_loo IN item_header_loop %]
<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>
[% END %]
</p>
<table id="itemst">
<thead>
<tr>
[% IF ( show ) %]<th>&nbsp;</th>[% END %]
<th class="anti-the">Title</th>
<th class="holds_count" title="Item holds / Total holds">Holds</th>
[% FOREACH item_header_loo IN item_header_loop %]
<th> [% item_header_loo.header_value | html %] </th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH item_loo IN item_loop %]
<tr>
[% IF show %]
[% IF item_loo.nomod %]
<td class="error">Cannot delete</td>
[% ELSE %]
[% IF item_loo.safe_to_delete == 1 %]
<td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber | html %]" id="row[% item_loo.itemnumber | html %]" checked="checked" /></td>
[% ELSE %]
[% SWITCH item_loo.safe_to_delete%]
[% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %]
[% CASE "not_same_branch" %][% SET cannot_delete_reason = t("Item does not belong to your library") %]
[% CASE "book_reserved" %][% SET cannot_delete_reason = t("Item has a waiting hold") %]
[% CASE "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %]
[% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %]
[% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ item_loo.safe_to_delete _ ')' %]
[% END %]
<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>
[% END %]
[% END %]
[% ELSE %]
<td>&nbsp;</td>
[% END %]
<td>
<label for="row[% item_loo.itemnumber | html %]">
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber | uri %]">
[% item_loo.title | html %]
</a>
[% IF ( item_loo.author ) %], by [% item_loo.author | html %][% END %]
</label>
</td>
<td class="holds_count">
[% IF item_loo.holds %]
[% IF item_loo.item_holds %]
<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 -%]" >
[% ELSE %]
<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 -%]" >
[% END %]
[% ELSE %]
[% IF item_loo.holds %]
<a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="Holds on this record: [% item_loo.holds | html -%]" >
[% ELSE %]
<a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% item_loo.biblionumber | uri %]" title="No holds on this record" >
[% END %]
[% END %]
[% IF item_loo.holds %]
[% item_loo.item_holds | html %]/[% item_loo.holds | html %]
[% ELSE %]
[% item_loo.holds | html %]
[% END %]
</a>
</td>
[% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field | html %]</td>
[% END %] </tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
[% IF ( simple_items_display ) %]
<ul>
[% FOREACH simple_items_displa IN simple_items_display %]
<li>
<a href="[% simple_items_displa.itemnumber | url %]">[% simple_items_displa.barcode | html %]</a>
</li>
[% END %]
</ul>
[% END %]
[% IF ( show ) %]
[% IF ( too_many_items_display ) %]
<p>Too many items ([% too_many_items_display | html %]) to display individually.</p>
[% FOREACH itemnumber IN itemnumbers_array %]
<input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
[% END %]
[% END %]
[% IF ( itemresults ) %]
<div id="cataloguing_additem_newitem">
<input type="hidden" name="op" value="[% op | html %]" />
<p>This will delete [% IF ( too_many_items_display ) %]all the[% ELSE %]the selected[% END %] items.</p>
<input type="hidden" name="del" value="1" />
<fieldset class="action">
<input type="checkbox" name="del_records" id="del_records" /> <label for="del_records">Delete records if no items remain.</label>
[% IF too_many_items_display %]
<input type="submit" name="mainformsubmit" value="Delete ALL submitted items" />
[% ELSE %]
<input type="submit" name="mainformsubmit" value="Delete selected items" />
[% END %]
<a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a>
</fieldset>
</div>
[% ELSE %]
<p><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a></p>
[% END %]
[% END %]
</form>
[% END %]
[% IF ( action ) %]
[% IF deletion_failed %]
<div class="dialog alert">
At least one item blocked the deletion. The operation rolled back and nothing happened!
</div>
[% ELSE %]
<div class="dialog message">
<p>[% deleted_items | html %] item(s) deleted.</p>
[% IF delete_records %] <p>[% deleted_records | html %] record(s) deleted.</p> [% END %]
[% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
[% IF biblio_deleted %]
[% IF searchid %]
<div id="previous_search_link"></div>
[% END %]
<a href="/cgi-bin/koha/cataloguing/addbooks.pl">Return to the cataloging module</a>
[% ELSE %]
[% IF searchid %]
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]&searchid=[% searchid | uri %]">Return to the record</a>
[% ELSE %]
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Return to the record</a>
[% END %]
[% END %]
[% ELSIF src %]
<a href="[% src | url %]">Return to where you were</a>
[% ELSE %]
<a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a>
[% END %]
</div>
[% END %]
[% IF ( not_deleted_items ) %]
<div style="width:55%;margin:auto;">
<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>
[% IF ( not_deleted_loop ) %]
<table id="itemst">
<thead>
<tr>
<th>Itemnumber</th>
<th>Barcode</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
[% FOREACH not_deleted_loo IN not_deleted_loop %]
<tr>
<td>[% not_deleted_loo.itemnumber | html %]</td>
<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>
<td>
[% SWITCH not_deleted_loo.reason %]
[% CASE "book_on_loan" %][% SET cannot_delete_reason = t("Item is checked out") %]
[% CASE "not_same_branch" %][% SET cannot_delete_reason = t("Item does not belong to your library") %]
[% CASE "book_reserved" %][% SET cannot_delete_reason = t("Item has a waiting hold") %]
[% CASE "linked_analytics" %][% SET cannot_delete_reason = t("Item has linked analytics") %]
[% CASE "last_item_for_hold" %][% SET cannot_delete_reason = t("Last item for bibliographic record with biblio-level hold on it") %]
[% CASE %][% SET cannot_delete_reason = t("Unknown reason") _ '(' _ can_be_deleted _ ')' %]
[% END %]
[% cannot_delete_reason | html %]
</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]
</div>
[% END %]
<p>
[% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
[% IF biblio_deleted %]
<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>
[% ELSIF searchid %]
<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>
[% ELSE %]
<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>
[% END %]
[% ELSIF src %]
<a class="btn btn-default" href="[% src | url %]"><i class="fa fa-check-square-o"></i> Return to where you were</a>
[% ELSE %]
<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>
[% END %]
</p>
[% END %]
</div>
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/pages/batchMod.js") | $raw %]
[% Asset.js("js/browser.js") | $raw %]
<script>
// Prepare array of all column headers, incrementing each index by
// two to accommodate control and title columns
var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count | html %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
for( x=0; x<allColumns.length; x++ ){
allColumns[x] = Number(allColumns[x]) + 2;
}
$(document).ready(function(){
$("#mainformsubmit").on("click",function(){
return submitBackgroundJob(this.form);
});
});
[% IF searchid %]
browser = KOHA.browser('[% searchid | html %]');
browser.show_back_link();
[% END %]
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]