$template->param( flagged => 1 ) if $patron->account_locked;
my @relatives;
-if ( my $guarantor = $patron->guarantor ) {
- $template->param( guarantor => $guarantor );
- push @relatives, $guarantor->borrowernumber;
- push @relatives, $_->borrowernumber for $patron->siblings;
-} elsif ( $patron->contactname || $patron->contactfirstname ) {
- $template->param(
- guarantor => {
- firstname => $patron->contactfirstname,
- surname => $patron->contactname,
- }
- );
-} else {
- my @guarantees = $patron->guarantees;
- $template->param( guarantees => \@guarantees );
- push @relatives, $_->borrowernumber for @guarantees;
+my $guarantor_relationships = $patron->guarantor_relationships;
+my @guarantees = $patron->guarantee_relationships->guarantees;
+my @guarantors = $guarantor_relationships->guarantors;
+if (@guarantors) {
+ push( @relatives, $_->id ) for @guarantors;
+ push( @relatives, $_->id ) for $patron->siblings();
}
+else {
+ push( @relatives, $_->id ) for @guarantees;
+}
+$template->param(
+ guarantor_relationships => $guarantor_relationships,
+ guarantees => \@guarantees,
+);
my $relatives_issues_count =
Koha::Checkouts->count({ borrowernumber => \@relatives });