Bugzilla – Attachment 69815 Details for
Bug 4319
waiting and in transit items cannot be reserved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4319: [OPAC] Allow holds on waiting/transit items
Bug-4319-OPAC-Allow-holds-on-waitingtransit-items.patch (text/plain), 8.59 KB, created by
Marcel de Rooy
on 2017-12-15 10:26:02 UTC
(
hide
)
Description:
Bug 4319: [OPAC] Allow holds on waiting/transit items
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-12-15 10:26:02 UTC
Size:
8.59 KB
patch
obsolete
>From 041484300d65b9efb54873091e3243c5e7a24563 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 3 Oct 2017 14:50:36 +0000 >Subject: [PATCH] Bug 4319: [OPAC] Allow holds on waiting/transit items >Content-Type: text/plain; charset=utf-8 > >Test plan: > > - 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 > >Changes on C4::Reserves::IsAvailableForItemLevelRequest > >Make sure this tests pass: > - t/db_dependent/Reserves.t > - t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t > >Rebased - 2017-12-12 - Alex Arnaud > >Bug 4319 - [QA fix] Create Koha::Biblio->hasItemswaitingOrInTransit > >Signed-off-by: Jon Knight <J.P.Knight@lboro.ac.uk> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Reserves.pm | 12 +++++- > Koha/Biblio.pm | 18 ++++++++ > .../bootstrap/en/includes/opac-detail-sidebar.inc | 2 +- > opac/opac-detail.pl | 13 +++--- > .../Holds/DisallowHoldIfItemsAvailable.t | 49 +++++++++++++++++++++- > t/db_dependent/Koha/Biblios.t | 42 ++++++++++++++++++- > 6 files changed, 127 insertions(+), 9 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 06cde18..7ceaaf2 100644 >--- a/C4/Reserves.pm >+++ b/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 >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index f4e5e2f..9a4937d 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -318,6 +318,24 @@ sub subscriptions { > return $self->{_subscriptions}; > } > >+=head3 hasItemswaitingOrInTransit >+ >+=cut >+ >+sub hasItemswaitingOrInTransit { >+ my ( $self ) = @_; >+ >+ if ( Koha::Holds->search({ biblionumber => $self->id, >+ found => ['W', 'T'] })->count ) { >+ return 1; >+ } >+ >+ foreach my $item ( $self->items ) { >+ return 1 if $item->get_transfer; >+ } >+ >+ return 0; >+} > > =head3 type > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >index 7ceaa95..e408d0a 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >+++ b/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 ( ReservableItems ) %] > <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblio.biblionumber %]">Place hold</a></li> > [% END %] > [% END %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 2e4afdd..c069924 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -460,9 +460,9 @@ if ($session->param('busc')) { > } > } > >- >-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); >-$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); >+$template->param( >+ OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), >+); > > # adding items linked via host biblios > >@@ -652,13 +652,13 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { > }; > } > >+my $allow_onshelf_holds; > if ( not $viewallitems and @items > $max_items_to_display ) { > $template->param( > too_many_items => 1, > items_count => scalar( @items ), > ); > } else { >- my $allow_onshelf_holds; > my $patron = Koha::Patrons->find( $borrowernumber ); > for my $itm (@items) { > $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; >@@ -717,9 +717,12 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > push @itemloop, $itm; > } > } >- $template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds ); > } > >+my $itemsWaitingOrInTransit = Koha::Biblios->find($biblionumber)->hasItemswaitingOrInTransit || 0; >+my $itemsIssued = CountItemsIssued( $biblionumber ); >+$template->param( 'ReservableItems' => $itemsWaitingOrInTransit || $itemsIssued || $allow_onshelf_holds ); >+ > # Display only one tab if one items list is empty > if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { > $template->param(SeparateHoldings => 0); >diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >index 3c5fd72..3abba34 100755 >--- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >+++ b/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; >diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t >index 9f6a14a..9d41531 100644 >--- a/t/db_dependent/Koha/Biblios.t >+++ b/t/db_dependent/Koha/Biblios.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use C4::Reserves; > >@@ -80,5 +80,45 @@ subtest 'subscriptions' => sub { > is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions'); > }; > >+subtest 'waiting_or_in_transit' => sub { >+ plan tests => 4; >+ my $biblio = $builder->build( { source => 'Biblio' } ); >+ my $item = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber} >+ } >+ }); >+ my $reserve = $builder->build({ >+ source => 'Reserve', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ found => undef >+ } >+ }); >+ >+ $reserve = Koha::Holds->find($reserve->{reserve_id}); >+ $biblio = Koha::Biblios->find($biblio->{biblionumber}); >+ >+ is($biblio->hasItemswaitingOrInTransit, 0, 'Item is neither waiting nor in transit'); >+ >+ $reserve->found('W')->store; >+ is($biblio->hasItemswaitingOrInTransit, 1, 'Item is waiting'); >+ >+ $reserve->found('T')->store; >+ is($biblio->hasItemswaitingOrInTransit, 1, 'Item is in transit'); >+ >+ my $transfer = $builder->build({ >+ source => 'Branchtransfer', >+ value => { >+ itemnumber => $item->{itemnumber}, >+ datearrived => undef >+ } >+ }); >+ my $t = Koha::Database->new()->schema()->resultset( 'Branchtransfer' )->find($transfer->{branchtransfer_id}); >+ $reserve->found(undef)->store; >+ is($biblio->hasItemswaitingOrInTransit, 1, 'Item has transfer'); >+}; >+ > $schema->storage->txn_rollback; > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 4319
:
3740
|
4099
|
4110
|
4327
|
4329
|
16965
|
67558
|
67584
|
67637
|
67704
|
67970
|
68194
|
68197
|
68198
|
68199
|
68531
|
68782
|
68786
|
69724
|
69725
|
69728
| 69815 |
69816
|
69817
|
70457