From 8af11ee2e92dbfb99bf845c72650d34e4f4a42b8 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 16 Jul 2014 07:44:12 -0400 Subject: [PATCH] Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch Some libraries would like the ability choose to display the home branch on search results while having circulation rules based on the holding branch. This is currently impossible because both the display of the branch in search results, and the selection of the home or holding branch for circulation rules are controlled by the same system preference: HomeOrHoldingBranch. This preference is described as being used only for circulation rules, and makes no mention of its use for display control. The display control should be split off into a separate preference. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Note the value of the new system preference StaffSearchResultsDisplayBranch matches the current value of HomeOrHoldingBranch 4) Set the preference to home branch 5) Perform a staff catalog search with results having items with differing home and holding branches. 6) Note the home branch displays 7) Set the preference to holding branch 8) Repeat step 5 9) Note the holding branch displays --- C4/Search.pm | 5 +++-- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../en/modules/admin/preferences/circulation.pref | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 1b5c6fa..2a7e586 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1900,8 +1900,9 @@ sub searchResults { } } - my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch' : 'holdingbranch'; - my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch'; + my $display_branch = C4::Context->preference('StaffSearchResultsDisplayBranch'); + my $hbranch = $display_branch eq 'homebranch' ? 'homebranch' : 'holdingbranch'; + my $otherbranch = $display_branch eq 'homebranch' ? 'holdingbranch' : 'homebranch'; # set item's branch name, use HomeOrHoldingBranch syspref first, fall back to the other one if ($item->{$hbranch}) { diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ed427ea..fff76e5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -373,6 +373,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('StaffAuthorisedValueImages','1',NULL,'','YesNo'), ('staffClientBaseURL','',NULL,'Specify the base URL of the staff client','free'), ('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'), +('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'), ('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'), ('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 1030454..14a363d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8570,6 +8570,15 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.17.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + my $pref = C4::Context->preference('HomeOrHoldingBranch'); + $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) + VALUES ('StaffSearchResultsDisplayBranch', ?,'homebranch|holdingbranch','Controls the display of the home or holding branch for staff search results','choice')", undef, $pref); + print "Upgrade to $DBversion done (Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 55d8a78..2332a66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -240,6 +240,13 @@ Circulation: holdingbranch: only the library the item was checked out from. homeorholdingbranch: either the library the item is from or the library it was checked out from. - + - For search results in the staff client, display the branch of + - pref: StaffSearchResultsDisplayBranch + type: choice + choices: + homebranch: the library the item is from. + holdingbranch: the library the item is held by. + - - Calculate the due date using - pref: useDaysMode choices: -- 1.7.2.5