diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
index 17fe75c134..adbb851dcd 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
@@ -67,7 +67,51 @@
[% IF failed_holds %]
Notice:
-
One or more holds were not placed due to existing holds.
+
One or more holds were not placed due to following errors:
+
+ [% FOREACH fail IN failed_holds.split('\|') %]
+ -
+ [% SWITCH fail %]
+ [% CASE 'damaged' %]
+ Item damaged
+ [% CASE 'ageRestricted' %]
+ Age restricted
+ [% CASE 'tooManyHoldsForThisRecord' %]
+ Exceeded max holds per record
+ [% CASE 'tooManyReservesToday' %]
+ Daily hold limit reached for patron
+ [% CASE 'tooManyReserves' %]
+ Too many holds
+ [% CASE 'notReservable' %]
+ Not holdable
+ [% CASE 'cannotReserveFromOtherBranches' %]
+ Patron is from different library
+ [% CASE 'branchNotInHoldGroup' %]
+ Cannot place hold from patron's library
+ [% CASE 'itemAlreadyOnHold' %]
+ Patron already has hold for this item
+ [% CASE 'cannotBeTransferred' %]
+ Cannot be transferred to pickup library
+ [% CASE 'pickupNotInHoldGroup' %]
+ Only pickup locations within the same hold group are allowed
+ [% CASE 'noReservesAllowed' %]
+ No holds are allowed on this item
+ [% CASE 'libraryNotPickupLocation' %]
+ Library is not a pickup location
+ [% CASE 'no_valid_pickup_location' %]
+ No valid pickup location
+ [% CASE 'notforloan' %]
+ Not for loan
+ [% CASE 'items_available' %]
+ There are items available in the library, please visit to check them out
+ [% CASE 'not_placed' %]
+ Error when placing hold, please report this to the library
+ [% CASE %]
+ Error: [% fail | html %]
+ [% END %]
+
+ [% END %]
+
[% END %]
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 07440efa6a..0778ac5d04 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -212,7 +212,7 @@ if ( $query->param('place_reserve') ) {
exit;
}
- my $failed_holds = 0;
+ my @failed_holds;
while (@selectedItems) {
my $biblioNum = shift(@selectedItems);
my $itemNum = shift(@selectedItems);
@@ -264,11 +264,21 @@ if ( $query->param('place_reserve') ) {
my $biblio = Koha::Biblios->find($biblioNum);
my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1;
if ( $item ) {
- $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
+ my $status = CanItemBeReserved( $patron, $item, $branch )->{status};
+ if( $status eq 'OK' ){
+ $canreserve = 1;
+ } else {
+ push @failed_holds, $status;
+ }
+
}
else {
- $canreserve = 1
- if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
+ my $status = CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status};
+ if( $status eq 'OK'){
+ $canreserve = 1;
+ } else {
+ push @failed_holds, $status;
+ }
# Inserts a null into the 'itemnumber' field of 'reserves' table.
$itemNum = undef;
@@ -279,6 +289,7 @@ if ( $query->param('place_reserve') ) {
if ( $maxreserves
&& $reserve_cnt >= $maxreserves )
{
+ push @failed_holds, 'tooManyReserves';
$canreserve = 0;
}
@@ -287,7 +298,8 @@ if ( $query->param('place_reserve') ) {
my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } });
if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
- $canreserve = 0
+ $canreserve = 0;
+ push @failed_holds, 'items_available';
}
}
@@ -309,12 +321,15 @@ if ( $query->param('place_reserve') ) {
item_group_id => $item_group_id,
}
);
- $failed_holds++ unless $reserve_id;
- ++$reserve_cnt;
+ if( $reserve_id ){
+ ++$reserve_cnt;
+ } else {
+ push @failed_holds, 'not_placed';
+ }
}
}
- print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
+ print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( @failed_holds ? "failed_holds=" . join('|',@failed_holds) : q|| ) . "#opac-user-holds");
exit;
}