From 7776b36cf941c853b373b7d018f123d72f6f04ef Mon Sep 17 00:00:00 2001 From: Elliott Davis Date: Thu, 19 Jan 2012 14:52:37 -0500 Subject: [PATCH] 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. '|' ). Signed-off-by: Jared Camins-Esakov Rebased on latest master, removed the reformatting, and changed the syspref to be a choice between showing the call number only, the location, and the collection code. Signed-off-by: Elliott Davis Works as Advertised. I would like to see the logic added to differenciate between multiple locations and a single location for the word 'location(s)' but that goes beyond the scope of this ticket. --- C4/XSLT.pm | 22 +++- 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 | 111 +++++++++++++------- 5 files changed, 105 insertions(+), 44 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index cbe1ff0..3888ff2 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -187,7 +187,7 @@ sub XSLTParse4Display { OPACBaseURL TraceCompleteSubfields UseICU UseAuthoritiesForTracings TraceSubjectSubdivisions Display856uAsImage OPACDisplay856uAsImage - UseControlNumber + UseControlNumber OPACItemLocation AlternateHoldingsField AlternateHoldingsSeparator / ) { my $sp = C4::Context->preference( $syspref ); @@ -227,12 +227,19 @@ sub buildKohaItemsNamespace { my ($biblionumber, $hidden_items) = @_; my @items = C4::Items::GetItemsInfo($biblionumber); + if ($hidden_items && @$hidden_items) { 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; @@ -271,11 +278,16 @@ 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". - "$status". - "".$itemcallnumber."" - . ""; + "$location". + "$ccode". + "$status". + "".$itemcallnumber."". + ""; } $xml = "".$xml.""; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 7009155..0419a94 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -375,3 +375,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free'); +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 bb96644..cfd8e51 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5536,6 +5536,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 4a4d4de..40ed3d3 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 @@ -249,6 +249,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 2b5aacc..bdee24d 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 @@ + @@ -1020,46 +1021,43 @@ No copies available - - - Copies available for loan: - - - - [] - ( - - ) -. , - - - - + + + + + copy available for loan at + copies available for loan at + + + + + [] + . , + + + + - - -
-
-
+ + + + + + copy available for reference at + copies available for reference at + + + + + [] + . , + + + + - - - - Copies available for reference: - - - - [] - ( - - ) - . , - - - - @@ -1105,7 +1103,42 @@ ). - + + + + Location(s): + + + + + + + + + + + . , + + + + + + + + + + + + + . , + + + + + + + + -- 1.7.2.5