bug 2248 [2/2]: import item status display in search results
The in transit status now displays as such in the OPAC search results. In the non-XSLT version, the status is checked only for bibs having 20 or fewer items to avoid extra hits on the database during result set presentation. In the XSLT version, all items are checked. Note that because an item's transfer status is not stored in the MARC record, the transfer status has no effect when limiting a search by item availability. For a future version, the transit status should be added to the Zebra index. Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
6a8ca7fbd1
commit
556538e101
6 changed files with 64 additions and 16 deletions
60
C4/Search.pm
60
C4/Search.pm
|
@ -1354,17 +1354,18 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
|
|||
my $onloan_items;
|
||||
my $other_items;
|
||||
|
||||
my $ordered_count = 0;
|
||||
my $available_count = 0;
|
||||
my $onloan_count = 0;
|
||||
my $longoverdue_count = 0;
|
||||
my $other_count = 0;
|
||||
my $wthdrawn_count = 0;
|
||||
my $itemlost_count = 0;
|
||||
my $itembinding_count = 0;
|
||||
my $itemdamaged_count = 0;
|
||||
my $can_place_holds = 0;
|
||||
my $items_count = scalar(@fields);
|
||||
my $ordered_count = 0;
|
||||
my $available_count = 0;
|
||||
my $onloan_count = 0;
|
||||
my $longoverdue_count = 0;
|
||||
my $other_count = 0;
|
||||
my $wthdrawn_count = 0;
|
||||
my $itemlost_count = 0;
|
||||
my $itembinding_count = 0;
|
||||
my $itemdamaged_count = 0;
|
||||
my $item_in_transit_count = 0;
|
||||
my $can_place_holds = 0;
|
||||
my $items_count = scalar(@fields);
|
||||
my $items_counter;
|
||||
my $maxitems =
|
||||
( C4::Context->preference('maxItemsinSearchResults') )
|
||||
|
@ -1418,15 +1419,42 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
|
|||
$ordered_count++;
|
||||
}
|
||||
|
||||
# is item in transit?
|
||||
my $transfertwhen = '';
|
||||
my ($transfertfrom, $transfertto);
|
||||
|
||||
unless ($item->{wthdrawn}
|
||||
|| $item->{itemlost}
|
||||
|| $item->{damaged}
|
||||
|| $item->{notforloan}
|
||||
|| $items_count > 20) {
|
||||
|
||||
# A couple heuristics to limit how many times
|
||||
# we query the database for item transfer information, sacrificing
|
||||
# accuracy in some cases for speed;
|
||||
#
|
||||
# 1. don't query if item has one of the other statuses
|
||||
# 2. don't check transit status if the bib has
|
||||
# more than 20 items
|
||||
#
|
||||
# FIXME: to avoid having the query the database like this, and to make
|
||||
# the in transit status count as unavailable for search limiting,
|
||||
# should map transit status to record indexed in Zebra.
|
||||
#
|
||||
($transfertwhen, $transfertfrom, $transfertto) = C4::Circulation::GetTransfers($item->{itemnumber});
|
||||
}
|
||||
|
||||
# item is withdrawn, lost or damaged
|
||||
if ( $item->{wthdrawn}
|
||||
|| $item->{itemlost}
|
||||
|| $item->{damaged}
|
||||
|| $item->{notforloan} )
|
||||
|| $item->{notforloan}
|
||||
|| ($transfertwhen ne ''))
|
||||
{
|
||||
$wthdrawn_count++ if $item->{wthdrawn};
|
||||
$itemlost_count++ if $item->{itemlost};
|
||||
$itemdamaged_count++ if $item->{damaged};
|
||||
$wthdrawn_count++ if $item->{wthdrawn};
|
||||
$itemlost_count++ if $item->{itemlost};
|
||||
$itemdamaged_count++ if $item->{damaged};
|
||||
$item_in_transit_count++ if $transfertwhen ne '';
|
||||
$item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
|
||||
$other_count++;
|
||||
|
||||
|
@ -1434,6 +1462,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
|
|||
foreach (qw(wthdrawn itemlost damaged branchname itemcallnumber)) {
|
||||
$other_items->{$key}->{$_} = $item->{$_};
|
||||
}
|
||||
$other_items->{$key}->{intransit} = ($transfertwhen ne '') ? 1 : 0;
|
||||
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
|
||||
$other_items->{$key}->{count}++ if $item->{homebranch};
|
||||
$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
|
||||
|
@ -1494,6 +1523,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
|
|||
$oldbiblio->{wthdrawncount} = $wthdrawn_count;
|
||||
$oldbiblio->{itemlostcount} = $itemlost_count;
|
||||
$oldbiblio->{damagedcount} = $itemdamaged_count;
|
||||
$oldbiblio->{intransitcount} = $item_in_transit_count;
|
||||
$oldbiblio->{orderedcount} = $ordered_count;
|
||||
$oldbiblio->{isbn} =~
|
||||
s/-//g; # deleting - in isbn to enable amazon content
|
||||
|
|
11
C4/XSLT.pm
11
C4/XSLT.pm
|
@ -22,6 +22,7 @@ use C4::Branch;
|
|||
use C4::Items;
|
||||
use C4::Koha;
|
||||
use C4::Biblio;
|
||||
use C4::Circulation;
|
||||
use XML::LibXML;
|
||||
use XML::LibXSLT;
|
||||
|
||||
|
@ -132,9 +133,14 @@ sub buildKohaItemsNamespace {
|
|||
my $xml;
|
||||
for my $item (@items) {
|
||||
my $status;
|
||||
if ( $item->{notforloan} == -1 || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged}) {
|
||||
my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
|
||||
if ( $item->{notforloan} == -1 || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} ||
|
||||
($transfertwhen ne '') || $item->{itemnotforloan} ) {
|
||||
if ( $item->{notforloan} == -1) {
|
||||
$status = "On order";
|
||||
}
|
||||
if ( $item->{itemnotforloan} ) {
|
||||
$status = "Not for loan";
|
||||
}
|
||||
if ($item->{onloan}) {
|
||||
$status = "Checked out";
|
||||
|
@ -148,6 +154,9 @@ sub buildKohaItemsNamespace {
|
|||
if ($item->{damaged}) {
|
||||
$status = "Damaged";
|
||||
}
|
||||
if ($transfertwhen ne '') {
|
||||
$status = 'In transit';
|
||||
}
|
||||
} else {
|
||||
$status = "available";
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ $(window).load(function() {
|
|||
<!-- TMPL_IF NAME="wthdrawn" -->(Withdrawn)<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="itemlost" -->(Lost)<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="damaged" -->(Damaged)<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="intransit" -->(In transit)<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="notforloan" --><!-- TMPL_VAR name="notforloan" --><!-- /TMPL_IF -->
|
||||
(<!-- TMPL_VAR NAME="count" -->)</li>
|
||||
<!-- /TMPL_LOOP --></ul>
|
||||
|
|
|
@ -220,6 +220,7 @@ $(document).ready(function(){
|
|||
<!-- TMPL_IF NAME="itemlostcount" --> Lost (<!-- TMPL_VAR NAME="itemlostcount" -->),<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="damagedcount" --> Damaged (<!-- TMPL_VAR NAME="damagedcount" -->),<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="orderedcount" --> On order (<!-- TMPL_VAR NAME="orderedcount" -->),<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="intransitcount" --> In transit (<!-- TMPL_VAR NAME="intransitcount" -->),<!-- /TMPL_IF -->
|
||||
</span>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -246,6 +246,7 @@ $(document).ready(function(){
|
|||
<!-- TMPL_UNLESS NAME="hidelostitems" --><!-- TMPL_IF NAME="itemlostcount" --> Lost (<!-- TMPL_VAR NAME="itemlostcount" -->),<!-- /TMPL_IF --><!-- /TMPL_UNLESS -->
|
||||
<!-- TMPL_IF NAME="damagedcount" --> Damaged (<!-- TMPL_VAR NAME="damagedcount" -->),<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="orderedcount" --> On order (<!-- TMPL_VAR NAME="orderedcount" -->),<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="intransitcount" --> In transit (<!-- TMPL_VAR NAME="intransitcount" -->),<!-- /TMPL_IF -->
|
||||
</span>
|
||||
</span>
|
||||
|
||||
|
|
|
@ -881,6 +881,12 @@
|
|||
<xsl:value-of select="count(key('item-by-status', 'On order'))"/>
|
||||
<xsl:text>) </xsl:text> </span>
|
||||
</xsl:if>
|
||||
<xsl:if test="count(key('item-by-status', 'In transit'))>0">
|
||||
<span class="unavailable">
|
||||
<xsl:text>In transit (</xsl:text>
|
||||
<xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
|
||||
<xsl:text>) </xsl:text> </span>
|
||||
</xsl:if>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
|
|
Loading…
Reference in a new issue