From 90495431e477db799ac92d4ab807d327bb7f4026 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 4 Mar 2020 11:52:11 +0000
Subject: [PATCH] Bug 23112: (QA follow-up) Fix database update, add filters,
 remove tabs

Looks like the atomicupdate and sysprefs.sql changes were lost at some point.

Don't forget to run QA tools on your patches before submitting
---
 C4/Circulation.pm                                      | 16 ++++++++--------
 Koha/Illrequest.pm                                     | 18 +++++++++---------
 .../bug_23112_add_CirculateILL_syspref.perl            |  6 ++++++
 installer/data/mysql/sysprefs.sql                      |  1 +
 .../prog/en/modules/admin/preferences/circulation.pref | 14 +++++++-------
 .../intranet-tmpl/prog/en/modules/ill/ill-requests.tt  | 14 +++++++-------
 6 files changed, 38 insertions(+), 31 deletions(-)
 create mode 100644 installer/data/mysql/atomicupdate/bug_23112_add_CirculateILL_syspref.perl

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index ee6c420158..3f70b236f6 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -2131,14 +2131,14 @@ sub AddReturn {
         DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
     }
 
-	# Check if this item belongs to a biblio record that is attached to an
-	# ILL request, if it is we need to update the ILL request's status
-	if (C4::Context->preference('CirculateILL')) {
-		my $request = Koha::Illrequests->find(
-			{ biblio_id => $item->biblio->biblionumber }
-		);
-		$request->status('RET') if $request;
-	}
+    # Check if this item belongs to a biblio record that is attached to an
+    # ILL request, if it is we need to update the ILL request's status
+    if (C4::Context->preference('CirculateILL')) {
+        my $request = Koha::Illrequests->find(
+            { biblio_id => $item->biblio->biblionumber }
+        );
+        $request->status('RET') if $request;
+    }
 
     # Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer
     if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){
diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm
index e81997f8ce..c6280d2057 100644
--- a/Koha/Illrequest.pm
+++ b/Koha/Illrequest.pm
@@ -499,15 +499,15 @@ sub _core_status_graph {
             next_actions   => [ ],
             ui_method_icon => 'fa-upload',
         },
-		RET => {
-			prev_actions   => [ 'CHK' ],
-			id             => 'RET',
-			name           => 'Returned to library',
-			ui_method_name => 'Check in',
-			method         => 'check_in',
-			next_actions   => [ 'COMP' ],
-			ui_method_icon => 'fa-download',
-		}
+        RET => {
+            prev_actions   => [ 'CHK' ],
+            id             => 'RET',
+            name           => 'Returned to library',
+            ui_method_name => 'Check in',
+            method         => 'check_in',
+            next_actions   => [ 'COMP' ],
+            ui_method_icon => 'fa-download',
+        }
     };
 }
 
diff --git a/installer/data/mysql/atomicupdate/bug_23112_add_CirculateILL_syspref.perl b/installer/data/mysql/atomicupdate/bug_23112_add_CirculateILL_syspref.perl
new file mode 100644
index 0000000000..075e9142d2
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_23112_add_CirculateILL_syspref.perl
@@ -0,0 +1,6 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CirculateILL', '0', 'If enabled, it is possible to circulate ILL requested items from within ILL', '', 'YesNo'); | );
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 23112  - Add CirculateILL syspref)\n";
+}
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 40f7a4740f..401420ba20 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -119,6 +119,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
 ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'),
 ('CircSidebar','0',NULL,'Activate or deactivate the navigation sidebar on all Circulation pages','YesNo'),
+('CirculateILL','0','','If enabled, it is possible to circulate ILL items from within ILL','YesNo'),
 ('ClaimsBccCopy','0','','Bcc the ClaimAcquisition and ClaimIssues alerts','YesNo'),
 ('ClaimReturnedChargeFee', 'ask', 'ask|charge|no_charge', 'Controls whether or not a lost item fee is charged for return claims', 'Choice'),
 ('ClaimReturnedLostValue', '', '', 'Sets the LOST AV value that represents "Claims returned" as a lost value', '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 7f5335a6f7..4da08f7976 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
@@ -841,13 +841,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: CirculateILL
-			  default: 0
-			  choices:
-			      yes: Enable
-			      no: Disable
-			- the circulation of ILL requested items
+        -
+            - pref: CirculateILL
+              default: 0
+              choices:
+                  yes: Enable
+                  no: Disable
+            - the circulation of ILL requested items
     Fines Policy:
         -
             - pref: finesCalendar
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt
index b6d736e127..413e4a190a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt
@@ -133,7 +133,7 @@
                             </div>
                             [% ELSE %]
                             <div class="alert">
-                                There was a problem checking this item out, please check for problems with the <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% whole.value.patron.borrowernumber %]">patron's account</a>
+                                There was a problem checking this item out, please check for problems with the <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% whole.value.patron.borrowernumber | uri %]">patron's account</a>
                             </div>
                             [% END %]
                         [% END %]
@@ -154,9 +154,9 @@
                                                 <option value=""></option>
                                                 [% FOREACH stat IN whole.value.statistical %]
                                                     [% IF stat.borrowernumber == params.inhouse %]
-                                                        <option value="[% stat.cardnumber %]" selected>[% stat.firstname %] [% stat.surname %]</option>
+                                                        <option value="[% stat.cardnumber | html %]" selected>[% INCLUDE 'patron-title.inc' patron = stat %]</option>
                                                     [% ELSE %]
-                                                        <option value="[% stat.cardnumber %]">[% stat.firstname %] [% stat.surname %]</option>
+                                                        <option value="[% stat.cardnumber | html %]">[% INCLUDE 'patron-title.inc' patron = stat %]</option>
                                                     [% END %]
                                                 [% END %]
                                             </select>
@@ -193,7 +193,7 @@
                                         [% IF items.size == 1 %]
                                             <li>
                                                 <label for="barcode" class="ill_checkout_barcode_label">Item barcode:</label>
-                                                [% items.0.barcode %]
+                                                [% items.0.barcode | html %]
                                             </li>
                                         [% END %]
                                         <li class="ill_checkout_branchcode">
@@ -206,7 +206,7 @@
                                             [% ELSE %]
                                                 [% FOREACH branch IN whole.value.libraries.unblessed %]
                                                     [% IF branch.branchcode == branchcode %]
-                                                        [% branch.branchname %]
+                                                        [% branch.branchname | html %]
                                                     [% END %]
                                                 [% END %]
                                             [% END %]
@@ -225,8 +225,8 @@
                                     <input type="hidden" value="check_out" name="method">
                                     <input type="hidden" value="form" name="stage">
                                     [% IF items.size == 1 %]
-                                        <input name="branchcode" type="hidden" value="[% branchcode  %]">
-                                        <input name="item_type" type="hidden" value="[% items.0.itype %]">
+                                        <input name="branchcode" type="hidden" value="[% branchcode | html %]">
+                                        <input name="item_type" type="hidden" value="[% items.0.itype | html %]">
                                     [% END %]
                                     <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
                                     <input type="submit" value="Submit">
-- 
2.11.0