Bug 19258: Prevent warn when paying a fine or charge
[koha.git] / members / moremember.pl
index 0649dcf..30e8ce0 100755 (executable)
@@ -36,6 +36,7 @@
 use strict;
 #use warnings; FIXME - Bug 2505
 use CGI qw ( -utf8 );
+use HTML::Entities;
 use C4::Context;
 use C4::Auth;
 use C4::Output;
@@ -116,10 +117,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 my $borrowernumber = $input->param('borrowernumber');
+$borrowernumber = HTML::Entities::encode($borrowernumber);
 my $error = $input->param('error');
 $template->param( error => $error ) if ( $error );
 
 my $patron        = Koha::Patrons->find($borrowernumber);
+unless ( $patron ) {
+    $template->param (unknowuser => 1);
+    output_html_with_http_headers $input, $cookie, $template->output;
+    exit;
+}
+
 my $issues        = $patron->checkouts;
 my $balance       = $patron->account->balance;
 $template->param(
@@ -127,16 +135,8 @@ $template->param(
     fines      => $balance,
 );
 
-
-my $data = GetMember( 'borrowernumber' => $borrowernumber );
-
-if ( not defined $data ) {
-    $template->param (unknowuser => 1);
-       output_html_with_http_headers $input, $cookie, $template->output;
-    exit;
-}
-
-my $category_type = $data->{'category_type'};
+my $category_type = $patron->category->category_type;
+my $data = $patron->unblessed;
 
 $debug and printf STDERR "dates (enrolled,expiry,birthdate) raw: (%s, %s, %s)\n", map {$data->{$_}} qw(dateenrolled dateexpiry dateofbirth);
 foreach (qw(dateenrolled dateexpiry dateofbirth)) {
@@ -279,8 +279,7 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen
 # check to see if patron's image exists in the database
 # basically this gives us a template var to condition the display of
 # patronimage related interface on
-my $patron_image = Koha::Patron::Images->find($data->{borrowernumber});
-$template->param( picture => 1 ) if $patron_image;
+$template->param( picture => 1 ) if $patron->image;
 # Generate CSRF token for upload and delete image buttons
 $template->param(
     csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}),
@@ -333,9 +332,6 @@ if ( C4::Context->preference("ExportCircHistory") ) {
     $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
 }
 
-# in template <TMPL_IF name="I"> => institutional (A for Adult, C for children)
-$template->param( $data->{'categorycode'} => 1 );
-
 # Display the language description instead of the code
 # Note that this is certainly wrong
 my ( $subtag, $region ) = split '-', $patron->lang;
@@ -347,7 +343,7 @@ $template->param(
     detailview      => 1,
     borrowernumber  => $borrowernumber,
     othernames      => $data->{'othernames'},
-    categoryname    => $data->{'description'},
+    categoryname    => $patron->category->description,
     was_renewed     => scalar $input->param('was_renewed') ? 1 : 0,
     todaysdate      => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }),
     totalprice      => sprintf("%.2f", $totalprice),
@@ -356,12 +352,11 @@ $template->param(
     overdues_exist  => $overdues_exist,
     StaffMember     => $category_type eq 'S',
     is_child        => $category_type eq 'C',
+    $category_type  => 1, # [% IF ( I ) %] = institutional/organisation
     samebranch      => $samebranch,
     quickslip       => $quickslip,
     housebound_role => scalar $patron->housebound_role,
     privacy_guarantor_checkouts => $data->{'privacy_guarantor_checkouts'},
-    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
-    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
     RoutingSerials => C4::Context->preference('RoutingSerials'),
     PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
     relatives_issues_count => $relatives_issues_count,