Lines 326-331
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
326 |
} |
326 |
} |
327 |
} |
327 |
} |
328 |
|
328 |
|
|
|
329 |
{ |
330 |
my @loop_borrowers_relationships; |
331 |
my $relationships = Koha::Patron::Relationships->search(); |
332 |
my @patrons_guarantors = Koha::Patron::Relationships::guarantors($relationships)->as_list; |
333 |
my @patrons_guarantees = Koha::Patron::Relationships::guarantees($relationships)->as_list; |
334 |
|
335 |
foreach my $patron_guarantor (@patrons_guarantors) { |
336 |
foreach my $patron_guarantee (@patrons_guarantees) { |
337 |
if ( $patron_guarantor->borrowernumber == $patron_guarantee->borrowernumber ) { |
338 |
|
339 |
my $guarantor_id; |
340 |
my $guarantee_id; |
341 |
my $size_list; |
342 |
my $tmp_garantor_id = $patron_guarantor->borrowernumber; |
343 |
my @guarantor_ids; |
344 |
|
345 |
do { |
346 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
347 |
{ |
348 |
-or => [ |
349 |
'guarantor_id' => { '=', $tmp_garantor_id }, |
350 |
] |
351 |
}, |
352 |
)->as_list; |
353 |
$size_list = scalar @relationship_for_go; |
354 |
|
355 |
foreach my $relation (@relationship_for_go) { |
356 |
$guarantor_id = $relation->guarantor_id; |
357 |
unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { |
358 |
push @guarantor_ids, $guarantor_id; |
359 |
} |
360 |
$guarantee_id = $relation->guarantee_id; |
361 |
|
362 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
363 |
{ |
364 |
-or => [ |
365 |
'guarantor_id' => { '=', $guarantee_id }, |
366 |
] |
367 |
}, |
368 |
)->as_list; |
369 |
$size_list = scalar @relationship_for_go; |
370 |
|
371 |
if ( $patron_guarantor->borrowernumber == $guarantee_id ) { |
372 |
last; |
373 |
} |
374 |
|
375 |
foreach my $relation (@relationship_for_go) { |
376 |
$guarantor_id = $relation->guarantor_id; |
377 |
unless ( grep { $_ == $guarantor_id } @guarantor_ids ) { |
378 |
push @guarantor_ids, $guarantor_id; |
379 |
} |
380 |
$guarantee_id = $relation->guarantee_id; |
381 |
|
382 |
if ( $patron_guarantor->borrowernumber == $guarantee_id ) { |
383 |
last; |
384 |
} |
385 |
} |
386 |
if ( $patron_guarantor->borrowernumber == $guarantee_id ) { |
387 |
last; |
388 |
} |
389 |
} |
390 |
|
391 |
$tmp_garantor_id = $guarantee_id; |
392 |
} while ( $patron_guarantor->borrowernumber != $guarantee_id && $size_list > 0 ); |
393 |
|
394 |
if ( $patron_guarantor->borrowernumber == $guarantee_id ) { |
395 |
unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) } |
396 |
@loop_borrowers_relationships ) |
397 |
{ |
398 |
push @loop_borrowers_relationships, \@guarantor_ids; |
399 |
} |
400 |
} |
401 |
} |
402 |
} |
403 |
} |
404 |
|
405 |
if ( scalar @loop_borrowers_relationships > 0 ) { |
406 |
new_section("The list of guarantors who are also guarantee."); |
407 |
my $count = 0; |
408 |
foreach my $table (@loop_borrowers_relationships) { |
409 |
$count++; |
410 |
print "Loop $count, borrowers id : "; |
411 |
foreach my $borrower_id (@$table) { |
412 |
print "$borrower_id | "; |
413 |
} |
414 |
print "\n"; |
415 |
} |
416 |
new_hint("Relationships that form guarantor loops must be deleted"); |
417 |
} |
418 |
} |
419 |
|
329 |
sub new_section { |
420 |
sub new_section { |
330 |
my ( $name ) = @_; |
421 |
my ( $name ) = @_; |
331 |
say "\n== $name =="; |
422 |
say "\n== $name =="; |
332 |
- |
|
|