-my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber);
-$template->param( issuecount => $issue, fines => $fines );
-
-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'};
-
-$debug and printf STDERR "dates (enrolled,expiry,birthdate) raw: (%s, %s, %s)\n", map {$data->{$_}} qw(dateenrolled dateexpiry dateofbirth);
-foreach (qw(dateenrolled dateexpiry dateofbirth)) {
- my $userdate = $data->{$_};
- unless ($userdate) {
- $debug and warn sprintf "Empty \$data{%12s}", $_;
- $data->{$_} = '';
- next;
- }
- $template->param( $_ => dt_from_string( $userdate ) );
-}
-$data->{'IS_ADULT'} = ( $data->{'categorycode'} ne 'I' );
-
-for (qw(gonenoaddress lost borrowernotes)) {
- $data->{$_} and $template->param(flagged => 1) and last;
-}
-
-if ( Koha::Patrons->find( $borrowernumber )->is_debarred ) {
- $template->param( 'userdebarred' => 1, 'flagged' => 1 );
- my $debar = $data->{'debarred'};
- if ( $debar ne "9999-12-31" ) {
- $template->param( 'userdebarreddate' => output_pref( { dt => dt_from_string( $debar ), dateonly => 1 } ) );
- $template->param( 'debarredcomment' => $data->{debarredcomment} );
- }
-}
+my $patron = Koha::Patrons->find( $borrowernumber );
+my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
+output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );