Lines 31-36
use C4::Branch;
Link Here
|
31 |
use C4::Reserves; # CheckReserves |
31 |
use C4::Reserves; # CheckReserves |
32 |
use C4::Debug; |
32 |
use C4::Debug; |
33 |
use C4::Items; |
33 |
use C4::Items; |
|
|
34 |
use C4::Charset; |
34 |
use YAML; |
35 |
use YAML; |
35 |
use URI::Escape; |
36 |
use URI::Escape; |
36 |
|
37 |
|
Lines 1413-1423
Format results in a form suitable for passing to the template
Link Here
|
1413 |
# IMO this subroutine is pretty messy still -- it's responsible for |
1414 |
# IMO this subroutine is pretty messy still -- it's responsible for |
1414 |
# building the HTML output for the template |
1415 |
# building the HTML output for the template |
1415 |
sub searchResults { |
1416 |
sub searchResults { |
1416 |
my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_; |
1417 |
my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults ) = @_; |
1417 |
my $dbh = C4::Context->dbh; |
1418 |
my $dbh = C4::Context->dbh; |
1418 |
my @newresults; |
1419 |
my @newresults; |
1419 |
|
1420 |
|
1420 |
$search_context = 'opac' unless $search_context eq 'opac' or $search_context eq 'intranet'; |
1421 |
$search_context = 'opac' if !$search_context || $search_context ne 'intranet'; |
|
|
1422 |
my ($is_opac, $hidelostitems); |
1423 |
if ($search_context eq 'opac') { |
1424 |
$hidelostitems = C4::Context->preference('hidelostitems'); |
1425 |
$is_opac = 1; |
1426 |
} |
1421 |
|
1427 |
|
1422 |
#Build branchnames hash |
1428 |
#Build branchnames hash |
1423 |
#find branchname |
1429 |
#find branchname |
Lines 1480-1491
sub searchResults {
Link Here
|
1480 |
my $marcflavour = C4::Context->preference("marcflavour"); |
1486 |
my $marcflavour = C4::Context->preference("marcflavour"); |
1481 |
# We get the biblionumber position in MARC |
1487 |
# We get the biblionumber position in MARC |
1482 |
my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber',''); |
1488 |
my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber',''); |
1483 |
my $fw; |
|
|
1484 |
|
1489 |
|
1485 |
# loop through all of the records we've retrieved |
1490 |
# loop through all of the records we've retrieved |
1486 |
for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) { |
1491 |
for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) { |
1487 |
my $marcrecord = MARC::File::USMARC::decode( $marcresults[$i] ); |
1492 |
my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] ); |
1488 |
$fw = $scan |
1493 |
my $fw = $scan |
1489 |
? undef |
1494 |
? undef |
1490 |
: $bibliotag < 10 |
1495 |
: $bibliotag < 10 |
1491 |
? GetFrameworkCode($marcrecord->field($bibliotag)->data) |
1496 |
? GetFrameworkCode($marcrecord->field($bibliotag)->data) |
Lines 1603-1620
sub searchResults {
Link Here
|
1603 |
my $other_count = 0; |
1608 |
my $other_count = 0; |
1604 |
my $wthdrawn_count = 0; |
1609 |
my $wthdrawn_count = 0; |
1605 |
my $itemlost_count = 0; |
1610 |
my $itemlost_count = 0; |
|
|
1611 |
my $hideatopac_count = 0; |
1606 |
my $itembinding_count = 0; |
1612 |
my $itembinding_count = 0; |
1607 |
my $itemdamaged_count = 0; |
1613 |
my $itemdamaged_count = 0; |
1608 |
my $item_in_transit_count = 0; |
1614 |
my $item_in_transit_count = 0; |
1609 |
my $can_place_holds = 0; |
1615 |
my $can_place_holds = 0; |
1610 |
my $item_onhold_count = 0; |
1616 |
my $item_onhold_count = 0; |
1611 |
my $items_count = scalar(@fields); |
1617 |
my $items_count = scalar(@fields); |
1612 |
my $maxitems = |
1618 |
my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults'); |
1613 |
( C4::Context->preference('maxItemsinSearchResults') ) |
1619 |
my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; |
1614 |
? C4::Context->preference('maxItemsinSearchResults') - 1 |
|
|
1615 |
: 1; |
1616 |
|
1620 |
|
1617 |
# loop through every item |
1621 |
# loop through every item |
|
|
1622 |
my @hiddenitems; |
1618 |
foreach my $field (@fields) { |
1623 |
foreach my $field (@fields) { |
1619 |
my $item; |
1624 |
my $item; |
1620 |
|
1625 |
|
Lines 1624-1632
sub searchResults {
Link Here
|
1624 |
} |
1629 |
} |
1625 |
|
1630 |
|
1626 |
# Hidden items |
1631 |
# Hidden items |
1627 |
my @items = ($item); |
1632 |
if ($is_opac) { |
1628 |
my (@hiddenitems) = GetHiddenItemnumbers(@items); |
1633 |
my @hi = GetHiddenItemnumbers($item); |
1629 |
$item->{'hideatopac'} = 1 if (@hiddenitems); |
1634 |
$item->{'hideatopac'} = @hi; |
|
|
1635 |
push @hiddenitems, @hi; |
1636 |
} |
1630 |
|
1637 |
|
1631 |
my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch' : 'holdingbranch'; |
1638 |
my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch' : 'holdingbranch'; |
1632 |
my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch'; |
1639 |
my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch'; |
Lines 1710-1715
sub searchResults {
Link Here
|
1710 |
$wthdrawn_count++ if $item->{wthdrawn}; |
1717 |
$wthdrawn_count++ if $item->{wthdrawn}; |
1711 |
$itemlost_count++ if $item->{itemlost}; |
1718 |
$itemlost_count++ if $item->{itemlost}; |
1712 |
$itemdamaged_count++ if $item->{damaged}; |
1719 |
$itemdamaged_count++ if $item->{damaged}; |
|
|
1720 |
$hideatopac_count++ if $item->{hideatopac}; |
1713 |
$item_in_transit_count++ if $transfertwhen ne ''; |
1721 |
$item_in_transit_count++ if $transfertwhen ne ''; |
1714 |
$item_onhold_count++ if $reservestatus eq 'Waiting'; |
1722 |
$item_onhold_count++ if $reservestatus eq 'Waiting'; |
1715 |
$item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; |
1723 |
$item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; |
Lines 1748-1758
sub searchResults {
Link Here
|
1748 |
} |
1756 |
} |
1749 |
} |
1757 |
} |
1750 |
} # notforloan, item level and biblioitem level |
1758 |
} # notforloan, item level and biblioitem level |
|
|
1759 |
|
1760 |
next if $is_opac && $hideatopac_count >= $items_count; |
1761 |
next if $hidelostitems && $itemlost_count >= $items_count; |
1762 |
|
1751 |
my ( $availableitemscount, $onloanitemscount, $otheritemscount ); |
1763 |
my ( $availableitemscount, $onloanitemscount, $otheritemscount ); |
1752 |
$maxitems = |
|
|
1753 |
( C4::Context->preference('maxItemsinSearchResults') ) |
1754 |
? C4::Context->preference('maxItemsinSearchResults') - 1 |
1755 |
: 1; |
1756 |
for my $key ( sort keys %$onloan_items ) { |
1764 |
for my $key ( sort keys %$onloan_items ) { |
1757 |
(++$onloanitemscount > $maxitems) and last; |
1765 |
(++$onloanitemscount > $maxitems) and last; |
1758 |
push @onloan_items_loop, $onloan_items->{$key}; |
1766 |
push @onloan_items_loop, $onloan_items->{$key}; |
Lines 1766-1785
sub searchResults {
Link Here
|
1766 |
push @available_items_loop, $available_items->{$key} |
1774 |
push @available_items_loop, $available_items->{$key} |
1767 |
} |
1775 |
} |
1768 |
|
1776 |
|
1769 |
# XSLT processing of some stuff |
1777 |
# if biblio level itypes are used and itemtype is notforloan, it can't be reserved either |
1770 |
use C4::Charset; |
|
|
1771 |
SetUTF8Flag($marcrecord); |
1772 |
$debug && warn $marcrecord->as_formatted; |
1773 |
if (!$scan && $search_context eq 'opac' && C4::Context->preference("OPACXSLTResultsDisplay")) { |
1774 |
# FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search results) |
1775 |
# is not implemented yet |
1776 |
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results', |
1777 |
$search_context, 1); |
1778 |
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs |
1779 |
|
1780 |
} |
1781 |
|
1782 |
# if biblio level itypes are used and itemtype is notforloan, it can't be reserved either |
1783 |
if (!C4::Context->preference("item-level_itypes")) { |
1778 |
if (!C4::Context->preference("item-level_itypes")) { |
1784 |
if ($itemtypes{ $oldbiblio->{itemtype} }->{notforloan}) { |
1779 |
if ($itemtypes{ $oldbiblio->{itemtype} }->{notforloan}) { |
1785 |
$can_place_holds = 0; |
1780 |
$can_place_holds = 0; |
Lines 1803-1810
sub searchResults {
Link Here
|
1803 |
$oldbiblio->{intransitcount} = $item_in_transit_count; |
1798 |
$oldbiblio->{intransitcount} = $item_in_transit_count; |
1804 |
$oldbiblio->{onholdcount} = $item_onhold_count; |
1799 |
$oldbiblio->{onholdcount} = $item_onhold_count; |
1805 |
$oldbiblio->{orderedcount} = $ordered_count; |
1800 |
$oldbiblio->{orderedcount} = $ordered_count; |
1806 |
$oldbiblio->{isbn} =~ |
1801 |
# deleting - in isbn to enable amazon content |
1807 |
s/-//g; # deleting - in isbn to enable amazon content |
1802 |
$oldbiblio->{isbn} =~ s/-//g; |
1808 |
|
1803 |
|
1809 |
if (C4::Context->preference("AlternateHoldingsField") && $items_count == 0) { |
1804 |
if (C4::Context->preference("AlternateHoldingsField") && $items_count == 0) { |
1810 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
1805 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
Lines 1834-1843
sub searchResults {
Link Here
|
1834 |
$oldbiblio->{'alternateholdings_count'} = $alternateholdingscount; |
1829 |
$oldbiblio->{'alternateholdings_count'} = $alternateholdingscount; |
1835 |
} |
1830 |
} |
1836 |
|
1831 |
|
1837 |
push( @newresults, $oldbiblio ) |
1832 |
# XSLT processing of some stuff |
1838 |
if(not $hidelostitems |
1833 |
if (!$scan && $search_context eq 'opac' && C4::Context->preference("OPACXSLTResultsDisplay")) { |
1839 |
or (($items_count > $itemlost_count ) |
1834 |
SetUTF8Flag($marcrecord); |
1840 |
&& $hidelostitems)); |
1835 |
$debug && warn $marcrecord->as_formatted; |
|
|
1836 |
# FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search results) |
1837 |
# is not implemented yet |
1838 |
$oldbiblio->{XSLTResultsRecord} |
1839 |
= XSLTParse4Display($oldbiblio->{biblionumber}, |
1840 |
$marcrecord, |
1841 |
'Results', |
1842 |
$search_context, |
1843 |
1, # clean up the problematic ampersand entities that Zebra outputs |
1844 |
\@hiddenitems |
1845 |
); |
1846 |
|
1847 |
} |
1848 |
|
1849 |
push( @newresults, $oldbiblio ); |
1841 |
} |
1850 |
} |
1842 |
|
1851 |
|
1843 |
return @newresults; |
1852 |
return @newresults; |