Bugzilla – Attachment 69725 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 - [QA fix] Create Koha::Biblio->hasItemswaitingOrInTransit
Bug-4319---QA-fix-Create-KohaBiblio-hasItemswaitin.patch (text/plain), 5.52 KB, created by
Alex Arnaud
on 2017-12-12 09:16:23 UTC
(
hide
)
Description:
Bug 4319 - [QA fix] Create Koha::Biblio->hasItemswaitingOrInTransit
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2017-12-12 09:16:23 UTC
Size:
5.52 KB
patch
obsolete
>From 236681bfa9724eee17bb25acec7d294b2b7b85f7 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 30 Nov 2017 14:48:25 +0000 >Subject: [PATCH] Bug 4319 - [QA fix] Create > Koha::Biblio->hasItemswaitingOrInTransit > >--- > Koha/Biblio.pm | 18 ++++++++++ > .../bootstrap/en/includes/opac-detail-sidebar.inc | 2 +- > opac/opac-detail.pl | 20 +++-------- > t/db_dependent/Koha/Biblios.t | 42 +++++++++++++++++++++- > 4 files changed, 65 insertions(+), 17 deletions(-) > >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 a94180c..3892fa9 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 OR ItemsWaitingOrInTransit ) %] >+ [% IF ( ReservableItems ) %] > <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% biblionumber | html %]">Place hold</a></li> > [% END %] > [% END %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index deb141d..3f99eda 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -458,20 +458,7 @@ 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 ), >- ItemsWaitingOrInTransit => $itemsWaitingOrInTransit, > OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), > ); > >@@ -664,13 +651,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} }; >@@ -729,9 +716,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/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.7.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