[Koha-patches] [PATCH 1/2] [SIGNED-OFF] Bug 5079 - Show location on opac results
Nicole C. Engard
nengard at bywatersolutions.com
Thu Jun 30 22:41:04 CEST 2011
From: Elliott Davis <tdavis at uttyler.edu>
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: run database update script to add syspref. Enable OpacItemLocation to show locations 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 |.
Signed-off-by: Nicole C. Engard <nengard at bywatersolutions.com>
---
C4/XSLT.pm | 16 ++++--
installer/data/mysql/en/mandatory/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 7 +++
.../prog/en/modules/admin/preferences/opac.pref | 6 ++
.../prog/en/xslt/MARC21slim2OPACResults.xsl | 57 +++++++++++++-------
5 files changed, 63 insertions(+), 24 deletions(-)
diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 28a70fc..37dea46 100755
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -183,8 +183,10 @@ sub XSLTParse4Display {
sub buildKohaItemsNamespace {
my ($biblionumber) = @_;
my @items = C4::Items::GetItemsInfo($biblionumber);
+ my $shelflocations =GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
my $branches = GetBranches();
my $itemtypes = GetItemTypes();
+ my $location = "";
my $xml = '';
for my $item (@items) {
my $status;
@@ -223,12 +225,16 @@ sub buildKohaItemsNamespace {
$status = "available";
}
my $homebranch = xml_escape($branches->{$item->{homebranch}}->{'branchname'});
- my $itemcallnumber = xml_escape($item->{itemcallnumber});
+ if(C4::Context->preference("OpacItemLocation") && defined $item->{'location'}) {
+ $location = xml_escape($shelflocations->{$item->{location}});
+ }
+ my $itemcallnumber = xml_escape($item->{itemcallnumber});
$xml.= "<item><homebranch>$homebranch</homebranch>".
- "<status>$status</status>".
- "<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
- . "</item>";
-
+ "<location>$location</location>".
+ "<status>$status</status>".
+ "<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
+ . "</item>";
+
}
$xml = "<items xmlns=\"http://www.koha-community.org/items\">".$xml."</items>";
return $xml;
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index f98b053..7419908 100755
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -92,6 +92,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacPublic',1,'Turn on/off public OPAC',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserjs','','Define custom javascript for inclusion in OPAC','70|10','Textarea');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacuserlogin',1,'Enable or disable display of user login features',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacItemLocation',1,'Show the shelving location of items in the opac',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('patronimages',0,'Enable patron images for the Staff Client',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('printcirculationslips',1,'If ON, enable printing circulation receipts','','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RequestOnOpac',1,'If ON, globally enables patron holds on OPAC',NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 3c7d043..c8bca2b 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4354,6 +4354,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = 'XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacItemLocation',1,'Show the shelving location of items in the opac',NULL,'YesNo');");
+ print "Upgrade to $DBversion done (Add OpacItemLocation syspref)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
index 71c9426..88aa7ca 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -192,6 +192,12 @@ OPAC:
no: "Don't allow"
- patrons to log in to their accounts on the OPAC.
-
+ - pref: OpacItemLocation
+ choices:
+ yes: Show
+ no: "Don't Show"
+ - Show the shelving location of items in opac results.
+ -
- pref: OpacPasswordChange
choices:
yes: Allow
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
index 97d83e2..5805aea 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
@@ -979,22 +979,21 @@
</xsl:for-each>
(<xsl:value-of select="$AlternateHoldingsCount"/>)
</xsl:when>
- <xsl:otherwise>No copies available</xsl:otherwise>
+ <xsl:otherwise>No copies available </xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="count(key('item-by-status', 'available'))>0">
- <span class="available">
- <b><xsl:text>Copies available for loan: </xsl:text></b>
- <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: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 class="available">
+ <b>
+ <xsl:value-of select="count(key('item-by-status', 'available'))"/>
+ <xsl:choose><xsl:when test="count(key('item-by-status', 'available')) = 1"><xsl:text> Copy available for loan at </xsl:text></xsl:when><xsl:otherwise><xsl:text> Copies available for loan at </xsl:text></xsl:otherwise></xsl:choose>
+ </b>
+ <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:value-of select="items:homebranch"/>
+ <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>
@@ -1002,15 +1001,14 @@
<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"
+ <b>
+ <xsl:value-of select="count(key('item-by-status', 'reference'))"/>
+ <xsl:choose><xsl:when test="count(key('item-by-status', 'reference')) = 1"><xsl:text> Copy available for reference at </xsl:text></xsl:when><xsl:otherwise><xsl:text> Copies available for reference at </xsl:text></xsl:otherwise></xsl:choose>
+ </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>
@@ -1061,6 +1059,27 @@
<xsl:text>). </xsl:text> </span>
</xsl:if>
</span>
+ <span class="results_summary" id="location">
+ <span class="label">Location(s): </span>
+ <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:value-of select="concat(items:location,' ')"/>
+ <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>
+ <xsl:choose><xsl:when test="count(key('item-by-status', 'available'))>0 and count(key('item-by-status', 'reference'))>0"><xsl:text> | </xsl:text></xsl:when></xsl:choose>
+ <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="concat(items:location,' ')"/>
+ <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:template>
<xsl:template name="nameABCDQ">
--
1.7.2.3
More information about the Koha-patches
mailing list