From 485f13ca6d5bceaefdab4653aa8fc9fb2536b3f9 Mon Sep 17 00:00:00 2001
From: Josef Moravec <josef.moravec@gmail.com>
Date: Fri, 18 Aug 2017 10:58:51 +0000
Subject: [PATCH] Bug 15752: QA followup - inform user that patron was
 automatically switched

Test plan:

1) Start checking out to some patron - there should be no message about
auto switching
2) read the another patrons card - note the patron is switched and there
is a message about it at top of the main page content
---
 circ/circulation.pl                                         | 3 ++-
 koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/circ/circulation.pl b/circ/circulation.pl
index 627306d..a0bc5b9 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -87,7 +87,7 @@ my $barcode =  $query->param('barcode');
 
 if (C4::Context->preference("AutoSwitchPatron") && $barcode) {
     if (Koha::Patrons->search( { cardnumber => $barcode} )->count() > 0) {
-        print $query->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=".$barcode);
+        print $query->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$barcode&amp;autoswitched=1");
     }
 }
 
@@ -664,6 +664,7 @@ $template->param(
     has_modifications         => $has_modifications,
     override_high_holds       => $override_high_holds,
     nopermission              => scalar $query->param('nopermission'),
+    autoswitched              => $query->param("autoswitched"),
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
index ffe414b..4c2aaf4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -159,6 +159,10 @@ $(document).ready(function() {
 <!--  INITIAL BLOC : PARAMETERS & BORROWER INFO -->
 [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% expiry | $KohaDates %]</div>[% END %]
 
+[% IF autoswitched %]
+    <div id="autoswitched" class="dialog message">Patron was automatically switched by reading the patron card during checking out. Ensure you are working with the right patron.</div>
+[% END %]
+
 [% IF additional_materials %]
     <div id="materials" class="dialog message">Note about the accompanying materials: <br />
     [% additional_materials %]
-- 
2.1.4