|
Lines 66-72
GetOptions(
Link Here
|
| 66 |
'skip-loop' => sub { $options{'skip-loop'} = 1 }, |
66 |
'skip-loop' => sub { $options{'skip-loop'} = 1 }, |
| 67 |
'help' => sub { $options{'help'} = 1; }, |
67 |
'help' => sub { $options{'help'} = 1; }, |
| 68 |
) or pod2usage(2); # Print usage if invalid options are provided |
68 |
) or pod2usage(2); # Print usage if invalid options are provided |
| 69 |
|
|
|
| 70 |
# Call handle_invalid_options subroutine if invalid options are provided |
69 |
# Call handle_invalid_options subroutine if invalid options are provided |
| 71 |
Getopt::Long::Configure('pass_through'); |
70 |
Getopt::Long::Configure('pass_through'); |
| 72 |
GetOptions( |
71 |
GetOptions( |
|
Lines 127-142
sub set_skip_options {
Link Here
|
| 127 |
# Set all check options to 1 if none are provided, considering skip options |
126 |
# Set all check options to 1 if none are provided, considering skip options |
| 128 |
sub set_all_check_options_if_none_provided { |
127 |
sub set_all_check_options_if_none_provided { |
| 129 |
my $any_check_option_provided = grep { $options{$_} } grep { /^check-/ } keys %options; |
128 |
my $any_check_option_provided = grep { $options{$_} } grep { /^check-/ } keys %options; |
| 130 |
if ( !$any_check_option_provided ) { |
|
|
| 131 |
foreach my $key ( keys %options ) { |
| 132 |
if ( $key =~ /^check-/ ) { |
| 133 |
my $skip_key = $key; |
| 134 |
$skip_key =~ s/^check-/skip-/; |
| 135 |
|
129 |
|
| 136 |
# Set check option to 1 unless the corresponding skip option indicated |
130 |
if ( !$any_check_option_provided ) { |
| 137 |
$options{$key} = 1 unless $options{$skip_key}; |
131 |
handle_invalid_options("No options selected"); |
| 138 |
} |
132 |
die; |
| 139 |
} |
|
|
| 140 |
} |
133 |
} |
| 141 |
} |
134 |
} |
| 142 |
|
135 |
|
|
Lines 271-289
sub CheckItemsStatus {
Link Here
|
| 271 |
} else { |
264 |
} else { |
| 272 |
$biblioitemnumber = $record->subfield( $biblioitem_tag, $biblioitem_subfield ); |
265 |
$biblioitemnumber = $record->subfield( $biblioitem_tag, $biblioitem_subfield ); |
| 273 |
} |
266 |
} |
| 274 |
if ( $biblionumber != $biblio->biblionumber ) { |
267 |
if (not (defined $biblionumber) and $biblionumber != $biblio->biblionumber ) { |
| 275 |
push @ids_not_in_marc, |
268 |
push @ids_not_in_marc, |
| 276 |
{ |
269 |
{ |
| 277 |
biblionumber => $biblio->biblionumber, |
270 |
biblionumber => $biblio->biblionumber, |
| 278 |
biblionumber_in_marc => $biblionumber, |
271 |
biblionumber_in_marc => $biblionumber, |
| 279 |
}; |
272 |
}; |
| 280 |
} |
273 |
} |
| 281 |
if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) { |
274 |
if ( not (defined $biblioitemnumber) and $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) { |
| 282 |
push @ids_not_in_marc, |
275 |
push @ids_not_in_marc, |
| 283 |
{ |
276 |
{ |
| 284 |
biblionumber => $biblio->biblionumber, |
277 |
biblionumber => $biblio->biblionumber, |
| 285 |
biblioitemnumber => $biblio->biblioitem->biblioitemnumber, |
278 |
biblioitemnumber => $biblio->biblioitem->biblioitemnumber, |
| 286 |
biblioitemnumber_in_marc => $biblionumber, |
279 |
biblioitemnumber_in_marc => $biblionumber, |
| 287 |
}; |
280 |
}; |
| 288 |
} |
281 |
} |
| 289 |
} |
282 |
} |
|
Lines 615-709
sub CheckAgeForCategory {
Link Here
|
| 615 |
} |
608 |
} |
| 616 |
} |
609 |
} |
| 617 |
|
610 |
|
| 618 |
sub CheckRelationshipsLoop { |
|
|
| 619 |
my @loop_borrowers_relationships; |
| 620 |
my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all(); |
| 621 |
my @guarantee_ids = Koha::Patron::Relationships->_resultset->get_column('guarantee_id')->all(); |
| 622 |
|
| 623 |
foreach my $guarantor_id (@guarantor_ids) { |
| 624 |
foreach my $guarantee_id (@guarantee_ids) { |
| 625 |
if ( $guarantor_id == $guarantee_id ) { |
| 626 |
|
| 627 |
my $relation_guarantor_id; |
| 628 |
my $relation_guarantee_id; |
| 629 |
my $size_list; |
| 630 |
my $tmp_garantor_id = $guarantor_id; |
| 631 |
my @guarantor_ids; |
| 632 |
|
| 633 |
do { |
| 634 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
| 635 |
{ |
| 636 |
-or => [ |
| 637 |
'guarantor_id' => { '=', $tmp_garantor_id }, |
| 638 |
] |
| 639 |
}, |
| 640 |
)->as_list; |
| 641 |
$size_list = scalar @relationship_for_go; |
| 642 |
|
| 643 |
foreach my $relation (@relationship_for_go) { |
| 644 |
$relation_guarantor_id = $relation->guarantor_id; |
| 645 |
unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) { |
| 646 |
push @guarantor_ids, $relation_guarantor_id; |
| 647 |
} |
| 648 |
$relation_guarantee_id = $relation->guarantee_id; |
| 649 |
|
| 650 |
my @relationship_for_go = Koha::Patron::Relationships->search( |
| 651 |
{ |
| 652 |
-or => [ |
| 653 |
'guarantor_id' => { '=', $relation_guarantee_id }, |
| 654 |
] |
| 655 |
}, |
| 656 |
)->as_list; |
| 657 |
$size_list = scalar @relationship_for_go; |
| 658 |
|
| 659 |
if ( $guarantor_id == $relation_guarantee_id ) { |
| 660 |
last; |
| 661 |
} |
| 662 |
|
| 663 |
foreach my $relation (@relationship_for_go) { |
| 664 |
$relation_guarantor_id = $relation->guarantor_id; |
| 665 |
unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) { |
| 666 |
push @guarantor_ids, $relation_guarantor_id; |
| 667 |
} |
| 668 |
$relation_guarantee_id = $relation->guarantee_id; |
| 669 |
|
| 670 |
if ( $guarantor_id == $relation_guarantee_id ) { |
| 671 |
last; |
| 672 |
} |
| 673 |
} |
| 674 |
if ( $guarantor_id == $relation_guarantee_id ) { |
| 675 |
last; |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
$tmp_garantor_id = $relation_guarantee_id; |
| 680 |
} while ( $guarantor_id != $relation_guarantee_id && $size_list > 0 ); |
| 681 |
|
| 682 |
if ( $guarantor_id == $relation_guarantee_id ) { |
| 683 |
unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) } |
| 684 |
@loop_borrowers_relationships ) |
| 685 |
{ |
| 686 |
push @loop_borrowers_relationships, \@guarantor_ids; |
| 687 |
} |
| 688 |
} |
| 689 |
} |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
if ( scalar @loop_borrowers_relationships > 0 ) { |
| 694 |
new_section("The list of guarantors who are also guarantee."); |
| 695 |
my $count = 0; |
| 696 |
foreach my $table (@loop_borrowers_relationships) { |
| 697 |
$count++; |
| 698 |
print "Loop $count, borrowers id : "; |
| 699 |
foreach my $borrower_id (@$table) { |
| 700 |
print "$borrower_id , "; |
| 701 |
} |
| 702 |
print "\n"; |
| 703 |
} |
| 704 |
new_hint("Relationships that form guarantor loops must be deleted"); |
| 705 |
} |
| 706 |
} |
| 707 |
|
611 |
|
| 708 |
sub CheckRelationshipsLoop { |
612 |
sub CheckRelationshipsLoop { |
| 709 |
my @loop_borrowers_relationships; |
613 |
my @loop_borrowers_relationships; |
| 710 |
- |
|
|