Bug 24545: Fix license statements
[srvgit] / members / housebound.pl
index dba49a7..0584685 100755 (executable)
@@ -4,18 +4,18 @@
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 =head1 housebound.pl
 
@@ -28,7 +28,6 @@ use Modern::Perl;
 use CGI;
 use C4::Auth;
 use C4::Context;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
 use C4::Output;
 use DateTime;
 use Koha::DateUtils;
@@ -56,19 +55,14 @@ my $method = $input->param('method') // q{};
 my $visit_id = $input->param('visit_id') // q{};
 
 # Get patron
-my $patron = eval {
-    my $borrowernumber = $input->param('borrowernumber') // q{};
-    return Koha::Patrons->find($borrowernumber);
-};
-push @messages, { type => 'error', code => 'error_on_patron_load' }
-    if ( $@ or !$patron );
+my $borrowernumber = $input->param('borrowernumber');
+my $logged_in_user = Koha::Patrons->find( $loggedinuser );
+my $patron = Koha::Patrons->find($borrowernumber);
+output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
 
 # Get supporting cast
-my ( $branch, $category, $houseboundprofile, $visit, $patron_image );
-if ( $patron ) {
-    $patron_image = $patron->image;
-    $branch = Koha::Libraries->new->find($patron->branchcode);
-    $category = Koha::Patron::Categories->new->find($patron->categorycode);
+my ( $houseboundprofile, $visit );
+if ( $patron ) { # FIXME This test is not needed - output_and_exit_if_error handles it
     $houseboundprofile = $patron->housebound_profile;
 }
 if ( $visit_id ) {
@@ -160,24 +154,11 @@ if ( $method eq 'updateconfirm' and $houseboundprofile ) {
 $method = 'update_or_create' if ( !$houseboundprofile );
 
 # Ensure template has all patron details.
-$template->param(%{$patron->unblessed}) if ( $patron );
-
-# Load extended patron attributes if necessary (taken from members/files.pl).
-if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) {
-    my $attributes = GetBorrowerAttributes($patron->borrowernumber);
-    $template->param(
-        ExtendedPatronAttributes => 1,
-        extendedattributes => $attributes
-    );
-}
+$template->param( patron => $patron );
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
 $template->param(
-    picture            => $patron_image,
     housebound_profile => $houseboundprofile,
     visit              => $houseboundvisit,
-    branch             => $branch,
-    category           => $category,
     messages           => \@messages,
     method             => $method,
     choosers           => $choosers,