@@ -, +, @@
- Checkout an item
- Place hold on this item,
- Return the item
- Make sure the hold is waiting (found W) and AllowOnShelfHolds is
not to 'Allow'
- Check that the button "Place hold" appears in opac detail page of
the biblio
- do the samewith items/reserves in transit
- t/db_dependent/Reserves.t
- t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t
---
C4/Reserves.pm | 12 +++++-
.../bootstrap/en/includes/opac-detail-sidebar.inc | 2 +-
opac/opac-detail.pl | 17 +++++++-
.../Holds/DisallowHoldIfItemsAvailable.t | 49 +++++++++++++++++++++-
4 files changed, 75 insertions(+), 5 deletions(-)
--- a/C4/Reserves.pm
+++ a/C4/Reserves.pm
@@ -1080,6 +1080,7 @@ item-level hold request. An item is available if
* it is not lost AND
* it is not damaged AND
* it is not withdrawn AND
+* a waiting or in transit reserve is placed on
* does not have a not for loan value > 0
Need to check the issuingrules onshelfholds column,
@@ -1144,7 +1145,16 @@ sub IsAvailableForItemLevelRequest {
return $any_available ? 0 : 1;
}
- return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
+ if ($item->{onloan}) {
+ return 1;
+ }
+
+ if ( Koha::Holds->search({itemnumber => $item->{itemnumber},
+ found => ['W', 'T']})->count ) {
+ return 1;
+ }
+
+ return 0;
}
=head2 OnShelfHoldsAllowed
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
@@ -3,7 +3,7 @@
[% UNLESS ( norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
- [% IF ( AllowOnShelfHolds OR ItemsIssued ) %]
+ [% IF ( AllowOnShelfHolds OR ItemsIssued OR ItemsWaitingOrInTransit ) %]
Place hold
[% END %]
[% END %]
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -458,9 +458,22 @@ if ($session->param('busc')) {
}
}
+my $itemsWaitingOrInTransit = Koha::Holds->search(
+ {
+ biblionumber => $biblionumber,
+ found => ['W', 'T']
+ })->count();
+unless ($itemsWaitingOrInTransit) {
+ foreach my $item ( Koha::Items->search(biblionumber => $biblionumber) ) {
+ $itemsWaitingOrInTransit = 1 if $item->get_transfer;
+ }
+}
-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
-$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
+$template->param(
+ ItemsIssued => CountItemsIssued( $biblionumber ),
+ ItemsWaitingOrInTransit => $itemsWaitingOrInTransit,
+ OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"),
+);
# adding items linked via host biblios
--- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t
+++ a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t
@@ -7,7 +7,7 @@ use C4::Items;
use C4::Circulation;
use Koha::IssuingRule;
-use Test::More tests => 5;
+use Test::More tests => 7;
use t::lib::TestBuilder;
use t::lib::Mocks;
@@ -213,5 +213,52 @@ AddReturn( $item1->{barcode} );
};
}
+my $biblio = $builder->build({
+ source => 'Biblio',
+});
+
+my $item3 = $builder->build({
+ source => 'Item',
+ value => {
+ biblionumber => $biblio->{biblionumber},
+ itemlost => 0,
+ notforloan => 0,
+ withdrawn => 0,
+ damaged => 0,
+ onloan => 0
+ }
+});
+
+my $hold = $builder->build({
+ source => 'Reserve',
+ value =>{
+ itemnumber => $item3->{itemnumber},
+ found => 'T'
+ }
+});
+
+$dbh->do("DELETE FROM issuingrules");
+$rule = Koha::IssuingRule->new(
+ {
+ categorycode => '*',
+ itemtype => '*',
+ branchcode => '*',
+ maxissueqty => 99,
+ issuelength => 7,
+ lengthunit => 8,
+ reservesallowed => 99,
+ onshelfholds => 0,
+ }
+);
+$rule->store();
+
+$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
+is( $is, 1, "Item can be held, items in transit are not available" );
+
+Koha::Holds->find($hold->{reserve_id})->found('F')->store;
+
+$is = IsAvailableForItemLevelRequest( $item3, $borrower1);
+is( $is, 0, "Item is neither waiting nor in transit." );
+
# Cleanup
$schema->storage->txn_rollback;
--