Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 16 Jul 2014 11:44:12 +0000 (07:44 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Fri, 5 Sep 2014 15:15:57 +0000 (12:15 -0300)
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

Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, logic is now tied to a new system preference.
Passes tests and QA script.

C4/Search.pm
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref

index c704c63..c58692b 100644 (file)
@@ -1900,8 +1900,8 @@ sub searchResults {
                 }
             }
 
-            my $hbranch     = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch'    : 'holdingbranch';
-            my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch';
+            my $hbranch     = C4::Context->preference('StaffSearchResultsDisplayBranch');
+            my $otherbranch = $hbranch eq 'homebranch' ? 'holdingbranch' : 'homebranch';
 
             # set item's branch name, use HomeOrHoldingBranch syspref first, fall back to the other one
             if ($item->{$hbranch}) {
index 164ee1d..1754c1c 100644 (file)
@@ -374,6 +374,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'),
index c1acc02..00ed05b 100755 (executable)
@@ -8719,6 +8719,15 @@ if(C4::Context->preference("Version") < TransformToNum($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)
index 3c8b387..5c17494 100644 (file)
@@ -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: