|
Lines 83-91
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"
Link Here
|
| 83 |
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
83 |
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); |
| 84 |
|
84 |
|
| 85 |
my $category_type = $patron->category->category_type; |
85 |
my $category_type = $patron->category->category_type; |
|
|
86 |
my $data = $patron->unblessed; |
| 86 |
|
87 |
|
| 87 |
for (qw(gonenoaddress lost borrowernotes is_debarred)) { |
88 |
for (qw(gonenoaddress lost borrowernotes)) { |
| 88 |
$patron->$_ and $template->param(flagged => 1) and last; |
89 |
$data->{$_} and $template->param(flagged => 1) and last; |
| 89 |
} |
90 |
} |
| 90 |
|
91 |
|
| 91 |
if ( $patron->is_debarred ) { |
92 |
if ( $patron->is_debarred ) { |
|
Lines 100-106
$template->param( flagged => 1 ) if $patron->account_locked;
Link Here
|
| 100 |
|
101 |
|
| 101 |
my @relatives; |
102 |
my @relatives; |
| 102 |
if ( my $guarantor = $patron->guarantor ) { |
103 |
if ( my $guarantor = $patron->guarantor ) { |
| 103 |
$template->param( guarantor => $guarantor ); |
|
|
| 104 |
push @relatives, $guarantor->borrowernumber; |
104 |
push @relatives, $guarantor->borrowernumber; |
| 105 |
push @relatives, $_->borrowernumber for $patron->siblings; |
105 |
push @relatives, $_->borrowernumber for $patron->siblings; |
| 106 |
} elsif ( $patron->contactname || $patron->contactfirstname ) { |
106 |
} elsif ( $patron->contactname || $patron->contactfirstname ) { |
|
Lines 112-123
if ( my $guarantor = $patron->guarantor ) {
Link Here
|
| 112 |
); |
112 |
); |
| 113 |
} else { |
113 |
} else { |
| 114 |
my @guarantees = $patron->guarantees; |
114 |
my @guarantees = $patron->guarantees; |
| 115 |
$template->param( guarantees => \@guarantees ); |
|
|
| 116 |
push @relatives, $_->borrowernumber for @guarantees; |
115 |
push @relatives, $_->borrowernumber for @guarantees; |
| 117 |
} |
116 |
} |
| 118 |
|
117 |
|
| 119 |
my $relatives_issues_count = |
118 |
my $relatives_issues_count = |
| 120 |
Koha::Checkouts->count({ borrowernumber => \@relatives }); |
119 |
Koha::Database->new()->schema()->resultset('Issue') |
|
|
120 |
->count( { borrowernumber => \@relatives } ); |
| 121 |
my @guarantees = $patron->guarantees; |
| 122 |
my $count = scalar @guarantees; |
| 123 |
if ( $count ) { |
| 124 |
$template->param( isguarantee => 1 ); |
| 125 |
|
| 126 |
my @guaranteedata; |
| 127 |
my $amount; |
| 128 |
my $totalmount = 0; |
| 129 |
|
| 130 |
foreach my $guarantee (@guarantees){ |
| 131 |
|
| 132 |
$totalmount += $guarantee->account->balance; |
| 133 |
|
| 134 |
} |
| 135 |
$template->param( guarantees => @guarantees); |
| 136 |
$template->param( amounttot => sprintf("%.2f",$totalmount)); |
| 137 |
} |
| 138 |
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' ); |
| 139 |
|
| 140 |
if (my $guarantor = $patron->guarantor){ |
| 141 |
$template->param(isguarantor => 1); |
| 142 |
$template->param(guarantor => $guarantor); |
| 143 |
} |
| 144 |
|
| 145 |
my %bor; |
| 146 |
$bor{'borrowernumber'} = $borrowernumber; |
| 147 |
|
| 148 |
# Converts the branchcode to the branch name |
| 149 |
my $samebranch; |
| 150 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 151 |
if ( C4::Context->IsSuperLibrarian() ) { |
| 152 |
$samebranch = 1; |
| 153 |
} |
| 154 |
else { |
| 155 |
my $userenv = C4::Context->userenv; |
| 156 |
$samebranch = ( $data->{'branchcode'} eq $userenv->{branch} ); |
| 157 |
} |
| 158 |
} |
| 159 |
else { |
| 160 |
$samebranch = 1; |
| 161 |
} |
| 162 |
my $library = Koha::Libraries->find( $data->{branchcode})->unblessed; |
| 163 |
@{$data}{keys %$library} = values %$library; # merge in all branch columns # FIXME This is really ugly, we should pass the library instead |
| 164 |
|
| 165 |
# If printing a page, send the account informations to the template |
| 166 |
if (defined $print and $print eq "page") { |
| 167 |
my $accts = Koha::Account::Lines->search( |
| 168 |
{ borrowernumber => $patron->borrowernumber, amountoutstanding => { '>' => 0 } }, |
| 169 |
{ order_by => { -desc => 'accountlines_id' } } |
| 170 |
); |
| 171 |
$template->param( accounts => $accts ); |
| 172 |
} |
| 173 |
|
| 174 |
# Show OPAC privacy preference is system preference is set |
| 175 |
if ( C4::Context->preference('OPACPrivacy') ) { # FIXME Should be moved the the template |
| 176 |
$template->param( OPACPrivacy => 1); |
| 177 |
$template->param( "privacy".$data->{'privacy'} => 1); |
| 178 |
} |
| 179 |
|
| 180 |
my $today = DateTime->now( time_zone => C4::Context->tz); |
| 181 |
$today->truncate(to => 'day'); |
| 182 |
my $overdues_exist = 0; |
| 183 |
my $totalprice = 0; |
| 184 |
|
| 185 |
# Calculate and display patron's age |
| 186 |
if ( $data->{dateofbirth} ) { |
| 187 |
$template->param( age => Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age ); |
| 188 |
} |
| 189 |
|
| 190 |
### ############################################################################### |
| 191 |
# BUILD HTML |
| 192 |
# show all reserves of this borrower, and the position of the reservation .... |
| 193 |
if ($borrowernumber) { |
| 194 |
$template->param( |
| 195 |
holds_count => Koha::Database->new()->schema()->resultset('Reserve') |
| 196 |
->count( { borrowernumber => $borrowernumber } ) ); |
| 197 |
} |
| 121 |
|
198 |
|
| 122 |
# Generate CSRF token for upload and delete image buttons |
199 |
# Generate CSRF token for upload and delete image buttons |
| 123 |
$template->param( |
200 |
$template->param( |