From 1270ec78ccefc86ff192f5de3f32ff243de03362 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 27 Dec 2016 17:07:20 +0000 Subject: [PATCH] Bug 15505 - Mark Hold Items 'On hold' instead of 'Available' This patch adds a 'pending hold' column to C4::Items:GetItemsInfo to allow for displaying status of an item when it has been selected for a hold by the holdsqueue. To test: 01 - Place a hold on an item 02 - Build the holdsqueue (kohadevbox example below) sudo koha-shell kohadev perl misc/cronjobs/holds/build_holds_queue.pl 03 - Search for the item on the OPAC 04 - Note item shows as 'Available' in results and details 05 - Apply Patch 06 - Search for the item on the OPAC 07 - Note that item now shows as 'Pending hold' --- C4/Items.pm | 4 +++- C4/Search.pm | 2 +- C4/XSLT.pm | 6 +++++- koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc | 5 +++++ koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl | 6 ++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index e02da3b..5a328d3 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1338,7 +1338,8 @@ sub GetItemsInfo { holding.branchcode, holding.branchname, holding.opac_info as holding_branch_opac_info, - home.opac_info as home_branch_opac_info + home.opac_info as home_branch_opac_info, + tmp_holdsqueue.itemnumber AS pending_hold "; $query .= " FROM items @@ -1350,6 +1351,7 @@ sub GetItemsInfo { LEFT JOIN borrowers USING (borrowernumber) LEFT JOIN serialitems USING (itemnumber) LEFT JOIN serial USING (serialid) + LEFT JOIN tmp_holdsqueue USING (itemnumber) LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); $query .= q| diff --git a/C4/Search.pm b/C4/Search.pm index 4d89d23..d3a95e6 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2232,7 +2232,7 @@ sub searchResults { # XSLT processing of some stuff # we fetched the sysprefs already before the loop through all retrieved record! if (!$scan && $xslfile) { - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang); + $oldbiblio->{XSLTResultsRecord} = C4::XSLT::XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang); # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs } diff --git a/C4/XSLT.pm b/C4/XSLT.pm index a829402..6a3308c 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -27,6 +27,7 @@ use C4::Context; use C4::Items; use C4::Koha; use C4::Biblio; +use C4::HoldsQueue; use C4::Circulation; use C4::Reserves; use Koha::AuthorisedValues; @@ -292,7 +293,7 @@ sub buildKohaItemsNamespace { my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} ); if ( $itemtypes->{ $item->{itype} }->{notforloan} || $item->{notforloan} || $item->{onloan} || $item->{withdrawn} || $item->{itemlost} || $item->{damaged} || - (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") ){ + (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") || $item->{pending_hold} ){ if ( $item->{notforloan} < 0) { $status = "On order"; } @@ -317,6 +318,9 @@ sub buildKohaItemsNamespace { if (defined $reservestatus && $reservestatus eq "Waiting") { $status = 'Waiting'; } + if ($item->{pending_hold}) { + $status = 'Pending hold'; + } } else { $status = "available"; } 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 843fcf6..ac635f2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc @@ -78,6 +78,11 @@ not use an API to fetch items that populates item.datedue. On order [% END %] +[% IF item.pending_hold %] + [% SET itemavailable = 0 %] + Pending hold +[% END %] + [% IF ( itemavailable ) %] Available [% IF ( item.restrictedopac ) %]([% item.restrictedopac %])[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index 353b08e..7c73ab3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -1280,6 +1280,12 @@ ). + + + Pending hold ( + + ). + In transit ( -- 2.1.4