Bugzilla – Attachment 138441 Details for
Bug 27272
Move C4::Items::GetItemsInfo to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27272: Fix availability - OPAC
Bug-27272-Fix-availability---OPAC.patch (text/plain), 7.29 KB, created by
Jonathan Druart
on 2022-08-01 07:12:37 UTC
(
hide
)
Description:
Bug 27272: Fix availability - OPAC
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-01 07:12:37 UTC
Size:
7.29 KB
patch
obsolete
>From a9fd20e713e532eb83837e33fa381ff769922810 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 1 Aug 2022 08:59:53 +0200 >Subject: [PATCH] Bug 27272: Fix availability - OPAC > >Has to move some code to a method >--- > Koha/Item.pm | 21 +++++++++++++++++++ > .../en/includes/item-status-schema-org.inc | 2 +- > .../bootstrap/en/includes/item-status.inc | 9 ++++---- > .../bootstrap/en/modules/opac-detail.tt | 2 +- > opac/opac-detail.pl | 12 +---------- > t/db_dependent/Koha/Item.t | 5 ++++- > 6 files changed, 33 insertions(+), 18 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 23a66dc5343..b90cad42e4d 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -44,6 +44,7 @@ use Koha::ItemTypes; > use Koha::Libraries; > use Koha::Patrons; > use Koha::Plugins; >+use Koha::Recalls; > use Koha::Result::Boolean; > use Koha::SearchEngine::Indexer; > use Koha::StockRotationItem; >@@ -924,6 +925,26 @@ sub has_pending_hold { > return $pending_hold->count ? 1: 0; > } > >+=head3 has_pending_recall { >+ >+ my $has_pending_recall >+ >+Return if whether has pending recall of not. >+ >+=cut >+ >+sub has_pending_recall { >+ my ( $self ) = @_; >+ >+ # FIXME Must be moved to $self->recalls >+ return Koha::Recalls->search( >+ { >+ item_id => $self->itemnumber, >+ status => 'waiting', >+ } >+ )->count; >+} >+ > =head3 as_marc_field > > my $field = $item->as_marc_field; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status-schema-org.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status-schema-org.inc >index cd01e72fb6d..66e4f3656e9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status-schema-org.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status-schema-org.inc >@@ -1,4 +1,4 @@ >-[% IF ( item.damaged or item.datedue or item.itemlost or item.transfertwhen or item.waiting ) %] >+[% IF ( item.damaged or item.checkout.date_due or item.itemlost or item.transfertwhen or item.waiting ) %] > <link property="availability" href="http://schema.org/OutOfStock" /> > [% ELSIF ( item.withdrawn ) %] > <link property="availability" href="http://schema.org/Discontinued" /> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc >index 314798f9283..febdda5a15b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc >@@ -18,8 +18,8 @@ > [% END %] > > [% IF item.isa('Koha::Item') %] >- [% SET datedue = issue.date_due %] >- [% SET onsite_checkout = issue.onsite_checkout %] >+ [% SET datedue = item.checkout.date_due %] >+ [% SET onsite_checkout = item.checkout.onsite_checkout %] > [% ELSE %] > [% SET datedue = item.datedue || issue.date_due %] > [% SET onsite_checkout = item.onsite_checkout %] >@@ -39,7 +39,8 @@ > <span class="item-status checkedout">Checked out</span> > [% END %] > [% END %] >- [% IF item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>[% END %] >+ [%# FIXME We should move avail_for_recall to a Koha::Item method %] >+ [% IF !item.isa('Koha::Item') AND item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>[% END %] > [% END %] > > [% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %] >@@ -100,7 +101,7 @@ > <span class="item-status pendinghold">Pending hold</span> > [% END %] > >-[% IF item.has_pending_recall %] >+[% IF Koha.Preference('UseRecalls') && item.has_pending_recall %] > [% SET itemavailable = 0 %] > <span class="item-status pendingrecall">Pending recall</span> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 673bc22c0de..26e38a57292 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1342,7 +1342,7 @@ > </td> > [% END # /IF itemdata_uri %] > [% IF ( itemdata_copynumber ) %]<td class="copynumber">[% ITEM_RESULT.copynumber | html %]</td>[% END %] >- <td class="status">[% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT %][% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td> >+ <td class="status">[% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT.object %][% INCLUDE 'item-status.inc' item = ITEM_RESULT.object %]</td> > [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes | $raw %]</td>[% END %] > [% IF ITEM_RESULT.checkout %] > <td class="date_due" data-order="[% ITEM_RESULT.checkout.date_due | html %]">[% ITEM_RESULT.checkout.date_due | $KohaDates as_due_date => 1 %]</td> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 4590c1dbdce..7bb7f192ebf 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -79,7 +79,6 @@ use Koha::Virtualshelves; > use Koha::Patrons; > use Koha::Plugins; > use Koha::Ratings; >-use Koha::Recalls; > use Koha::Reviews; > use Koha::Serial::Items; > use Koha::SearchEngine::Search; >@@ -729,22 +728,13 @@ else { > } > > $item_info->{checkout} = $item->checkout; >+ $item_info->{object} = $item; > > my $reserve_status = > C4::Reserves::GetReserveStatus( $item->itemnumber ); > if ( $reserve_status eq "Waiting" ) { $item_info->{'waiting'} = 1; } > if ( $reserve_status eq "Reserved" ) { $item_info->{'onhold'} = 1; } > >- if ( C4::Context->preference('UseRecalls') ) { >- my $pending_recall_count = Koha::Recalls->search( >- { >- item_id => $item->itemnumber, >- status => 'waiting', >- } >- )->count; >- if ( $pending_recall_count ) { $item_info->has_pending_recall = 1; } >- } >- > my ( $transfertwhen, $transfertfrom, $transfertto ) = > GetTransfers( $item->itemnumber ); > if ( defined($transfertwhen) && $transfertwhen ne '' ) { >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index b13fe57e68b..7b59a2eb733 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -1478,7 +1478,7 @@ subtest 'store() tests' => sub { > > subtest 'Recalls tests' => sub { > >- plan tests => 20; >+ plan tests => 22; > > $schema->storage->txn_begin; > >@@ -1649,6 +1649,7 @@ subtest 'Recalls tests' => sub { > } > )->store; > $recall2->set_waiting( { item => $item1 } ); >+ is( $item1->has_pending_recall, 1, 'Item has pending recall' ); > > # return a waiting recall > my $check_recall = $item1->check_recalls; >@@ -1656,6 +1657,8 @@ subtest 'Recalls tests' => sub { > > $recall2->revert_waiting; > >+ is( $item1->has_pending_recall, 0, 'Item does not have pending recall' ); >+ > # return recall based on recalldate > $check_recall = $item1->check_recalls; > is( $check_recall->patron_id, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" ); >-- >2.25.1
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 27272
:
128230
|
128231
|
135640
|
135641
|
135642
|
135643
|
135644
|
135645
|
135646
|
135647
|
135648
|
135649
|
135650
|
135651
|
135652
|
135653
|
135654
|
135655
|
135656
|
135657
|
135658
|
135659
|
137966
|
137967
|
137968
|
137969
|
137970
|
137971
|
137972
|
137973
|
137974
|
137975
|
137976
|
137977
|
137978
|
137979
|
137980
|
137981
|
137982
|
138109
|
138296
|
138297
|
138298
|
138303
|
138304
|
138305
|
138306
|
138307
|
138308
|
138437
|
138438
|
138439
|
138440
|
138441
|
138442
|
138553
|
138554
|
138555
|
138556
|
138557
|
138558
|
138559
|
138560
|
138561
|
138562
|
138563
|
138564
|
138565
|
138566
|
138567
|
138568
|
138569
|
138570
|
138571
|
138572
|
138573
|
138574
|
138575
|
138614
|
138615
|
138616
|
138617
|
138618
|
138619
|
138620
|
138621
|
138622
|
138623
|
138624
|
138625
|
138626
|
138627
|
138628
|
138629
|
138630
|
138631
|
138632
|
138633
|
138634
|
138635
|
138636
|
138714
|
138715
|
138716
|
138717
|
138718
|
138719
|
138720
|
138721
|
138722
|
138723
|
138724
|
138725
|
138726
|
138727
|
138728
|
138729
|
138730
|
138731
|
138732
|
138733
|
138734
|
138735
|
138736
|
138773
|
138774
|
138775
|
138776
|
138777
|
138778
|
138779
|
138780
|
138781
|
138782
|
138783
|
138784
|
138785
|
138786
|
138787
|
138788
|
138789
|
138790
|
138791
|
138792
|
138793
|
138794
|
138832
|
139928