From 304841a19ec309e2ee6c2cbdf56654c9b143e8bf Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 18 Sep 2012 11:50:44 -0400 Subject: [PATCH] Bug 5079 - Make display of shelving location and call number in XSLT results controlled by sysprefs Content-Type: text/plain; charset="utf-8" * 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 --- C4/XSLT.pm | 14 ++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++ .../prog/en/modules/admin/preferences/opac.pref | 8 +++ .../prog/en/xslt/MARC21slim2OPACResults.xsl | 56 +++++++++++++------- 5 files changed, 65 insertions(+), 21 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index d17b828..472d56e 100644 --- a/C4/XSLT.pm +++ b/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.= "$homebranch". + "$location". + "$ccode". "$status". "".$itemcallnumber."" . ""; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 4b4bf77..0de1dc8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -379,3 +379,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacMainUserBlockMobile','','Show the following HTML in its own column on the main page of the OPAC (mobile version):',NULL,'free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowLibrariesPulldownMobile','1','Show the libraries pulldown on the mobile version of the OPAC.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowFiltersPulldownMobile','1','Show the search filters pulldown on the mobile version of the OPAC.',NULL,'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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 158f25b..912df20 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5827,6 +5827,13 @@ if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.09.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($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 (Add OpacItemLocation syspref)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($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 e645785..692a2f1 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 @@ -266,6 +266,14 @@ OPAC: 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: 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 a524697..f018b59 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl @@ -27,6 +27,7 @@ + @@ -1039,7 +1040,7 @@ - [] + [] ( ) @@ -1058,24 +1059,6 @@ - - - - Copies available for reference: - - - - [] - ( - - ) - . , - - - - - Checked out ( @@ -1120,6 +1103,41 @@ ). + + + + Location(s): + + + + + + + + + + + . , + + + + + + + + + + + + + . , + + + + + + + -- 1.7.2.5