From ef36a55fd7b3a773d16cebe2536b3c366baf6255 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Thu, 23 Feb 2017 12:30:15 +0000
Subject: [PATCH] Bug 12461 - Revert changes to circulation.pl

---
 C4/Members.pm                                               |  2 +-
 Koha/Patron.pm                                              |  8 ++++----
 circ/circulation.pl                                         | 12 ++++--------
 koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt |  4 ++--
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/C4/Members.pm b/C4/Members.pm
index 74873cc..4915cd2 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -977,7 +977,7 @@ sub GetFirstValidEmailAddress {
 
     my $borrower = Koha::Patrons->find( $borrowernumber );
 
-    return $borrower->FirstValidEmailAddress();
+    return $borrower->first_valid_email_address();
 }
 
 =head2 GetNoticeEmailAddress
diff --git a/Koha/Patron.pm b/Koha/Patron.pm
index 701cb6b..5ca55ef 100644
--- a/Koha/Patron.pm
+++ b/Koha/Patron.pm
@@ -585,14 +585,14 @@ sub holds {
     return Koha::Holds->_new_from_dbic($holds_rs);
 }
 
-=head3 FirstValidEmailAddress
+=head3 first_valid_email_address
 
 =cut
 
-sub FirstValidEmailAddress {
+sub first_valid_email_address {
     my ($self) = @_;
 
-    return $self->email() || $self->emailpro() || $self->b_email() || q{};
+    return $self->email() || $self->emailpro() || $self->B_email() || q{};
 }
 
 =head3 get_club_enrollments
@@ -627,7 +627,7 @@ sub get_enrollable_clubs {
     my $params;
     $params->{is_enrollable_from_opac} = $is_enrollable_from_opac
       if $is_enrollable_from_opac;
-    $params->{is_email_required} = 0 unless $self->FirstValidEmailAddress();
+    $params->{is_email_required} = 0 unless $self->first_valid_email_address();
 
     $params->{borrower} = $self;
 
diff --git a/circ/circulation.pl b/circ/circulation.pl
index d83dd64..5db1001 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -24,13 +24,9 @@
 
 use strict;
 use warnings;
-
 use CGI qw ( -utf8 );
 use DateTime;
 use DateTime::Duration;
-use MARC::Record;
-use CGI::Session;
-
 use C4::Output;
 use C4::Print;
 use C4::Auth qw/:DEFAULT get_session haspermission/;
@@ -40,21 +36,23 @@ use C4::Utils::DataTables::Members;
 use C4::Members;
 use C4::Biblio;
 use C4::Search;
+use MARC::Record;
 use C4::Reserves;
+use Koha::Holds;
 use C4::Context;
+use CGI::Session;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
 use Koha::AuthorisedValues;
+use Koha::Patron;
 use Koha::Patron::Debarments qw(GetDebarments);
 use Koha::DateUtils;
 use Koha::Database;
 use Koha::BiblioFrameworks;
-use Koha::Patrons;
 use Koha::Patron::Messages;
 use Koha::Patron::Images;
 use Koha::SearchEngine;
 use Koha::SearchEngine::Search;
 use Koha::Patron::Modifications;
-use Koha::Holds;
 
 use Date::Calc qw(
   Today
@@ -649,7 +647,6 @@ my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
 $template->param( picture => 1 ) if $patron_image;
 
 my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;
-
 $template->param(
     debt_confirmed            => $debt_confirmed,
     SpecifyDueDate            => $duedatespec_allow,
@@ -659,7 +656,6 @@ $template->param(
     has_modifications         => $has_modifications,
     override_high_holds       => $override_high_holds,
     nopermission              => scalar $query->param('nopermission'),
-    borrower                  => Koha::Patrons->find( $borrowernumber ),
 );
 
 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 1659a99..cd43ffb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -898,8 +898,8 @@ No patron matched <span class="ex">[% message | html %]</span>
         [% END %]
     </li>
 
-    [% SET enrollments = borrower.get_club_enrollments_count %]
-    [% SET enrollable  = borrower.get_enrollable_clubs_count %]
+    [% SET enrollments = patron.get_club_enrollments_count %]
+    [% SET enrollable  = patron.get_enrollable_clubs_count %]
     [% IF CAN_user_clubs && ( enrollable || enrollments ) %]
         <li>
             <a id="clubs-tab-link" href="#clubs-tab">
-- 
2.1.4