From 6a96373df290bbd91898b939ddeec61b07f30e7c Mon Sep 17 00:00:00 2001
From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
Date: Fri, 21 Jun 2019 10:17:03 +0100
Subject: [PATCH] Bug 23173: Add ILLCheckAvailability syspref

This patch adds the new syspref "ILLCheckAvailability"

Sponsored-by: Public Health England
---
 .../atomicupdate/bug_23173_add_ILLCheckAvailability_syspref.perl | 9 +++++++++
 installer/data/mysql/sysprefs.sql                                | 1 +
 .../prog/en/modules/admin/preferences/circulation.pref           | 7 +++++++
 3 files changed, 17 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/bug_23173_add_ILLCheckAvailability_syspref.perl

diff --git a/installer/data/mysql/atomicupdate/bug_23173_add_ILLCheckAvailability_syspref.perl b/installer/data/mysql/atomicupdate/bug_23173_add_ILLCheckAvailability_syspref.perl
new file mode 100644
index 0000000000..a20ebfa52e
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_23173_add_ILLCheckAvailability_syspref.perl
@@ -0,0 +1,9 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    # you can use $dbh here like:
+    # $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('ILLCheckAvailability', '0', 'If enabled, during the ILL request process third party sources will be checked for current availability', '', 'YesNo'); | );
+
+    # Always end with this (adjust the bug info)
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 23173 - Add ILLCheckAvailability syspref)\n";
+}
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index f1ace4b088..c109f82cb3 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -223,6 +223,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
 ('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
 ('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'),
+('IllCheckAvailability', 0, '', 'If ON, during the ILL request process third party sources will be checked for current availability', 'YesNo'),
 ('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'),
 ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'),
 ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'),
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 4ff6a8331d..0060e9a288 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
@@ -831,6 +831,13 @@ Circulation:
                   yes: Enable
                   no: Disable
             - unmediated Interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend.
+        -
+            - pref: ILLCheckAvailability
+              default: 0
+              choices:
+                  yes: Check
+                  no: Don't check
+            - external sources for availability during the request process
     Fines Policy:
         -
             - Calculate fines based on days overdue
-- 
2.11.0