From 3211b4ee64f7693efe886da189ab31c1e8f24bb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radek=20=C5=A0iman?= <rbit@rbit.cz>
Date: Thu, 3 Nov 2016 01:07:00 +0100
Subject: [PATCH] Bug 17509: Added system preference to restrict recipients
 based on library

Test plan:
1) apply patch
2) go to System preferences / Circulation / Holds Policy
3) change which patrons will be contacted
4) compare your change against database value
NotifyToReturnItemFromLibrary
---
 .../bug_17509_add_NotifyToReturnItemWhenHoldIsPlaced_syspref.sql   | 3 ++-
 installer/data/mysql/sysprefs.sql                                  | 1 +
 .../prog/en/modules/admin/preferences/circulation.pref             | 7 ++++++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/installer/data/mysql/atomicupdate/bug_17509_add_NotifyToReturnItemWhenHoldIsPlaced_syspref.sql b/installer/data/mysql/atomicupdate/bug_17509_add_NotifyToReturnItemWhenHoldIsPlaced_syspref.sql
index 4c341c1..f4ff752 100644
--- a/installer/data/mysql/atomicupdate/bug_17509_add_NotifyToReturnItemWhenHoldIsPlaced_syspref.sql
+++ b/installer/data/mysql/atomicupdate/bug_17509_add_NotifyToReturnItemWhenHoldIsPlaced_syspref.sql
@@ -1 +1,2 @@
-INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('NotifyToReturnItemWhenHoldIsPlaced', '0', 'If ON, notifies the borrowers to return an item whenever a hold is placed on it', NULL, 'YesNo');
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('NotifyToReturnItemWhenHoldIsPlaced', '0', 'If ON, notifies the patrons to return an item whenever a hold is placed on it', NULL, 'YesNo');
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('NotifyToReturnItemFromLibrary', 'PatronLibrary', 'Restricts which libraries to take into consideration when notifying patrons to return items on hold', 'PatronLibrary|AnyLibrary', 'Choice');
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index f52116d..55e96fe 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -261,6 +261,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'),
 ('NoticeCSS','',NULL,'Notices CSS url.','free'),
 ('NotifyBorrowerDeparture','30',NULL,'Define number of days before expiry where circulation is warned about patron account expiry','Integer'),
+('NotifyToReturnItemFromLibrary','PatronLibrary','PatronLibrary|AnyLibrary','Restricts which libraries to take into consideration when notifying patrons to return items on hold','Choice'),
 ('NotifyToReturnItemWhenHoldIsPlaced','0',NULL,'If ON, notifies the borrowers to return an item whenever a hold is placed on it','YesNo'),
 ('NovelistSelectEnabled','0',NULL,'Enable Novelist Select content.  Requires Novelist Profile and Password','YesNo'),
 ('NovelistSelectPassword','',NULL,'Enable Novelist user Profile','free'),
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 13ca35f..1819f07 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
@@ -566,7 +566,12 @@ Circulation:
               choices:
                   yes: Enable
                   no:  "Don't enable"
-            - "sending an email to the borrowers to return an item whenever a hold request is placed on it."
+            - sending an email to the patrons to return an item whenever a hold request is placed on it. If enabled, contact patrons from
+            - pref: NotifyToReturnItemFromLibrary
+              choices:
+                  PatronLibrary: "patron's home library"
+                  AnyLibrary:    "any library"
+            - .
         -
             - pref: DisplayMultiPlaceHold
               choices:
-- 
2.1.4