Bug 5079 - Make display of shelving location and call number in XSLT results controlled by sysprefs
* Don't show the Location line if there are no copies available, since it will inevitably be blank * Also, don't show locations for Checked Out, Lost, Damaged, Withdrawn, On Hold or In transit items; it doesn't really make sense, since the items aren't actually there, and it results in repetitive listing of the shelving location * Added system preference to display shelving location of an item on opac results. The system preference is called OpacItemLocation. I also moved the call number to a new line called Location along with the shelving location if it is enabled. To Test: 1) Run database update script to add syspref. 2) Set OpacItemLocation to show locations or collection codes on the opac-search page. If it is working you should see the shelving location of the item before the call number. Multiple home branch shelving locations are seperated by a pipe character ( i.e. '|' ). Based on code by Elliot Davis <tdavis@uttyler.edu> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> Works as advertised. Signed-off-by: Ed Veal <ed.veal@bywatersolutions.com> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
parent
9aba512cee
commit
43c875b683
5 changed files with 65 additions and 21 deletions
14
C4/XSLT.pm
14
C4/XSLT.pm
|
@ -188,7 +188,7 @@ sub XSLTParse4Display {
|
|||
UseAuthoritiesForTracings TraceSubjectSubdivisions
|
||||
Display856uAsImage OPACDisplay856uAsImage
|
||||
UseControlNumber IntranetBiblioDefaultView BiblioDefaultView
|
||||
singleBranchMode
|
||||
singleBranchMode OPACItemLocation
|
||||
AlternateHoldingsField AlternateHoldingsSeparator / )
|
||||
{
|
||||
my $sp = C4::Context->preference( $syspref );
|
||||
|
@ -232,8 +232,14 @@ sub buildKohaItemsNamespace {
|
|||
my %hi = map {$_ => 1} @$hidden_items;
|
||||
@items = grep { !$hi{$_->{itemnumber}} } @items;
|
||||
}
|
||||
|
||||
my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
|
||||
my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
|
||||
|
||||
my $branches = GetBranches();
|
||||
my $itemtypes = GetItemTypes();
|
||||
my $location = "";
|
||||
my $ccode = "";
|
||||
my $xml = '';
|
||||
for my $item (@items) {
|
||||
my $status;
|
||||
|
@ -272,8 +278,12 @@ sub buildKohaItemsNamespace {
|
|||
$status = "available";
|
||||
}
|
||||
my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):'';
|
||||
my $itemcallnumber = xml_escape($item->{itemcallnumber});
|
||||
$location = xml_escape($shelflocations->{$item->{location}});
|
||||
$ccode = xml_escape($ccodes->{$item->{ccode}});
|
||||
my $itemcallnumber = xml_escape($item->{itemcallnumber});
|
||||
$xml.= "<item><homebranch>$homebranch</homebranch>".
|
||||
"<location>$location</location>".
|
||||
"<ccode>$ccode</ccode>".
|
||||
"<status>$status</status>".
|
||||
"<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
|
||||
. "</item>";
|
||||
|
|
|
@ -416,3 +416,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES (
|
|||
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo');
|
||||
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short');
|
||||
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('Persona',0,'Use Mozilla Persona for login','','YesNo');
|
||||
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice');
|
||||
|
|
|
@ -6445,6 +6445,13 @@ if ( CheckVersion($DBversion) ) {
|
|||
}
|
||||
|
||||
|
||||
$DBversion = "3.11.00.XXX";
|
||||
if ( CheckVersion($DBversion) ) {
|
||||
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice');");
|
||||
print "Upgrade to $DBversion done (Bug 5079: Add OpacItemLocation syspref)\n";
|
||||
SetVersion ($DBversion);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 TableExists($table)
|
||||
|
|
|
@ -277,6 +277,14 @@ OPAC:
|
|||
yes: Allow
|
||||
no: "Don't allow"
|
||||
- patrons to log in to their accounts on the OPAC.
|
||||
-
|
||||
- Show
|
||||
- pref: OpacItemLocation
|
||||
choices:
|
||||
location: location
|
||||
ccode: "collection code"
|
||||
callnum: "call number only"
|
||||
- for items on the OPAC search results.
|
||||
-
|
||||
- pref: OpacPasswordChange
|
||||
choices:
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<xsl:variable name="AlternateHoldingsField" select="substring(marc:sysprefs/marc:syspref[@name='AlternateHoldingsField'], 1, 3)"/>
|
||||
<xsl:variable name="AlternateHoldingsSubfields" select="substring(marc:sysprefs/marc:syspref[@name='AlternateHoldingsField'], 4)"/>
|
||||
<xsl:variable name="AlternateHoldingsSeparator" select="marc:sysprefs/marc:syspref[@name='AlternateHoldingsSeparator']"/>
|
||||
<xsl:variable name="OPACItemLocation" select="marc:sysprefs/marc:syspref[@name='OPACItemLocation']"/>
|
||||
<xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
|
||||
<xsl:variable name="leader" select="marc:leader"/>
|
||||
<xsl:variable name="leader6" select="substring($leader,7,1)"/>
|
||||
|
@ -1039,7 +1040,7 @@
|
|||
<xsl:otherwise>
|
||||
<xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
|
||||
<xsl:value-of select="items:homebranch"/>
|
||||
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
|
||||
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber and $OPACItemLocation='callnum'"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
|
@ -1058,24 +1059,6 @@
|
|||
</xsl:when></xsl:choose>
|
||||
</xsl:when> </xsl:choose>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(key('item-by-status', 'reference'))>0">
|
||||
<span class="available">
|
||||
<b><xsl:text>Copies available for reference: </xsl:text></b>
|
||||
<xsl:variable name="reference_items"
|
||||
select="key('item-by-status', 'reference')"/>
|
||||
<xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
|
||||
<xsl:value-of select="items:homebranch"/>
|
||||
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
<xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
|
||||
</xsl:for-each>
|
||||
</span>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
<xsl:if test="count(key('item-by-status', 'Checked out'))>0">
|
||||
<span class="unavailable">
|
||||
<xsl:text>Checked out (</xsl:text>
|
||||
|
@ -1120,6 +1103,41 @@
|
|||
<xsl:text>). </xsl:text> </span>
|
||||
</xsl:if>
|
||||
</span>
|
||||
<xsl:choose>
|
||||
<xsl:when test="($OPACItemLocation='location' or $OPACItemLocation='ccode') and (count(key('item-by-status', 'available'))!=0 or count(key('item-by-status', 'reference'))!=0)">
|
||||
<span class="results_summary" id="location">
|
||||
<span class="label">Location(s): </span>
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(key('item-by-status', 'available'))>0">
|
||||
<span class="available">
|
||||
<xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
|
||||
<xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when>
|
||||
<xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if>
|
||||
<xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
|
||||
</xsl:for-each>
|
||||
</span>
|
||||
</xsl:when>
|
||||
<xsl:when test="count(key('item-by-status', 'reference'))>0">
|
||||
<span class="available">
|
||||
<xsl:variable name="reference_items" select="key('item-by-status', 'reference')"/>
|
||||
<xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$OPACItemLocation='location'"><b><xsl:value-of select="concat(items:location,' ')"/></b></xsl:when>
|
||||
<xsl:when test="$OPACItemLocation='ccode'"><b><xsl:value-of select="concat(items:ccode,' ')"/></b></xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> <xsl:value-of select="items:itemcallnumber"/></xsl:if>
|
||||
<xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
|
||||
</xsl:for-each>
|
||||
</span>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</span>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="nameABCDQ">
|
||||
|
|
Loading…
Reference in a new issue