| Lines 328-345
          use C4::Biblio qw( GetMarcFromKohaField );
      
      
        Link Here | 
        
          | 328 |  | 328 |  | 
        
          | 329 | { | 329 | { | 
        
          | 330 |     my @loop_borrowers_relationships; | 330 |     my @loop_borrowers_relationships; | 
          
            
              | 331 |     my $relationships      = Koha::Patron::Relationships->search(); | 331 |     my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all(); | 
            
              | 332 |     my @patrons_guarantors = Koha::Patron::Relationships::guarantors($relationships)->as_list; | 332 |     my @guarantee_ids = Koha::Patron::Relationships->_resultset->get_column('guarantee_id')->all(); | 
            
              | 333 |     my @patrons_guarantees = Koha::Patron::Relationships::guarantees($relationships)->as_list; |  |  | 
        
          | 334 |  | 333 |  | 
          
            
              | 335 |     foreach my $patron_guarantor (@patrons_guarantors) { | 334 |     foreach my $guarantor_id (@guarantor_ids) { | 
            
              | 336 |         foreach my $patron_guarantee (@patrons_guarantees) { | 335 |         foreach my $guarantee_id (@guarantee_ids) { | 
            
              | 337 |             if ( $patron_guarantor->borrowernumber == $patron_guarantee->borrowernumber ) { | 336 |             if ( $guarantor_id == $guarantee_id ) { | 
        
          | 338 |  | 337 |  | 
          
            
              | 339 |                 my $guarantor_id; | 338 |                 my $relation_guarantor_id; | 
            
              | 340 |                 my $guarantee_id; | 339 |                 my $relation_guarantee_id; | 
        
          | 341 |                 my $size_list; | 340 |                 my $size_list; | 
          
            
              | 342 |                 my $tmp_garantor_id = $patron_guarantor->borrowernumber; | 341 |                 my $tmp_garantor_id = $guarantor_id; | 
        
          | 343 |                 my @guarantor_ids; | 342 |                 my @guarantor_ids; | 
        
          | 344 |  | 343 |  | 
        
          | 345 |                 do { | 344 |                 do { | 
  
    | Lines 353-397
          use C4::Biblio qw( GetMarcFromKohaField );
      
      
        Link Here | 
        
          | 353 |                     $size_list = scalar @relationship_for_go; | 352 |                     $size_list = scalar @relationship_for_go; | 
        
          | 354 |  | 353 |  | 
        
          | 355 |                     foreach my $relation (@relationship_for_go) { | 354 |                     foreach my $relation (@relationship_for_go) { | 
          
            
              | 356 |                         $guarantor_id = $relation->guarantor_id; | 355 |                         $relation_guarantor_id = $relation->guarantor_id; | 
            
              | 357 |                         unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { | 356 |                         unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) { | 
            
              | 358 |                             push @guarantor_ids, $guarantor_id; | 357 |                             push @guarantor_ids, $relation_guarantor_id; | 
        
          | 359 |                         } | 358 |                         } | 
          
            
              | 360 |                         $guarantee_id = $relation->guarantee_id; | 359 |                         $relation_guarantee_id = $relation->guarantee_id; | 
        
          | 361 |  | 360 |  | 
        
          | 362 |                         my @relationship_for_go = Koha::Patron::Relationships->search( | 361 |                         my @relationship_for_go = Koha::Patron::Relationships->search( | 
        
          | 363 |                             { | 362 |                             { | 
        
          | 364 |                                 -or => [ | 363 |                                 -or => [ | 
          
            
              | 365 |                                     'guarantor_id' => { '=', $guarantee_id }, | 364 |                                     'guarantor_id' => { '=', $relation_guarantee_id }, | 
        
          | 366 |                                 ] | 365 |                                 ] | 
        
          | 367 |                             }, | 366 |                             }, | 
        
          | 368 |                         )->as_list; | 367 |                         )->as_list; | 
        
          | 369 |                         $size_list = scalar @relationship_for_go; | 368 |                         $size_list = scalar @relationship_for_go; | 
        
          | 370 |  | 369 |  | 
          
            
              | 371 |                         if ( $patron_guarantor->borrowernumber == $guarantee_id ) { | 370 |                         if ( $guarantor_id == $relation_guarantee_id ) { | 
        
          | 372 |                             last; | 371 |                             last; | 
        
          | 373 |                         } | 372 |                         } | 
        
          | 374 |  | 373 |  | 
        
          | 375 |                         foreach my $relation (@relationship_for_go) { | 374 |                         foreach my $relation (@relationship_for_go) { | 
          
            
              | 376 |                             $guarantor_id = $relation->guarantor_id; | 375 |                             $relation_guarantor_id = $relation->guarantor_id; | 
            
              | 377 |                             unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { | 376 |                             unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) { | 
            
              | 378 |                                 push @guarantor_ids, $guarantor_id; | 377 |                                 push @guarantor_ids, $relation_guarantor_id; | 
        
          | 379 |                             } | 378 |                             } | 
          
            
              | 380 |                             $guarantee_id = $relation->guarantee_id; | 379 |                             $relation_guarantee_id = $relation->guarantee_id; | 
        
          | 381 |  | 380 |  | 
          
            
              | 382 |                             if ( $patron_guarantor->borrowernumber == $guarantee_id ) { | 381 |                             if ( $guarantor_id == $relation_guarantee_id ) { | 
        
          | 383 |                                 last; | 382 |                                 last; | 
        
          | 384 |                             } | 383 |                             } | 
        
          | 385 |                         } | 384 |                         } | 
          
            
              | 386 |                         if ( $patron_guarantor->borrowernumber == $guarantee_id ) { | 385 |                         if ( $guarantor_id == $relation_guarantee_id ) { | 
        
          | 387 |                             last; | 386 |                             last; | 
        
          | 388 |                         } | 387 |                         } | 
        
          | 389 |                     } | 388 |                     } | 
        
          | 390 |  | 389 |  | 
          
            
              | 391 |                     $tmp_garantor_id = $guarantee_id; | 390 |                     $tmp_garantor_id = $relation_guarantee_id; | 
            
              | 392 |                 } while ( $patron_guarantor->borrowernumber != $guarantee_id && $size_list > 0 ); | 391 |                 } while ( $guarantor_id != $relation_guarantee_id && $size_list > 0 ); | 
        
          | 393 |  | 392 |  | 
          
            
              | 394 |                 if ( $patron_guarantor->borrowernumber == $guarantee_id ) { | 393 |                 if ( $guarantor_id == $relation_guarantee_id ) { | 
        
          | 395 |                     unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) } | 394 |                     unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) } | 
        
          | 396 |                         @loop_borrowers_relationships ) | 395 |                         @loop_borrowers_relationships ) | 
        
          | 397 |                     { | 396 |                     { | 
            
              | 398 | -  |  |  |