|
Lines 40-88
use Data::Dumper;
Link Here
|
| 40 |
# Option 7: CheckRelationshipsLoop - Check for relationships or dependencies between borrowers in a loop |
40 |
# Option 7: CheckRelationshipsLoop - Check for relationships or dependencies between borrowers in a loop |
| 41 |
|
41 |
|
| 42 |
my %methods = ( |
42 |
my %methods = ( |
| 43 |
1 => \&CheckItemsBranch, |
43 |
1 => \&CheckItemsBranch, |
| 44 |
2 => \&CheckItemsAuthHeader, |
44 |
2 => \&CheckItemsAuthHeader, |
| 45 |
3 => \&CheckItemsStatus, |
45 |
3 => \&CheckItemsStatus, |
| 46 |
4 => \&CheckItemsFramework, |
46 |
4 => \&CheckItemsFramework, |
| 47 |
5 => \&CheckItemsTitle, |
47 |
5 => \&CheckItemsTitle, |
| 48 |
6 => \&CheckAgeForCategory, |
48 |
6 => \&CheckAgeForCategory, |
| 49 |
); |
49 |
); |
| 50 |
|
50 |
|
| 51 |
my @methods_to_run; |
51 |
my @methods_to_run; |
| 52 |
|
52 |
|
| 53 |
if (@ARGV == 0) { |
53 |
if ( @ARGV == 0 ) { |
|
|
54 |
|
| 54 |
# If no arguments are provided, add all methods to the list |
55 |
# If no arguments are provided, add all methods to the list |
| 55 |
@methods_to_run = keys %methods; |
56 |
@methods_to_run = keys %methods; |
| 56 |
} else { |
57 |
} |
|
|
58 |
else { |
| 57 |
foreach my $arg (@ARGV) { |
59 |
foreach my $arg (@ARGV) { |
| 58 |
if ($arg =~ /^(\d+)$/) { |
60 |
if ( $arg =~ /^(\d+)$/ ) { |
| 59 |
my $method_number = $1; |
61 |
my $method_number = $1; |
| 60 |
if ($method_number >= 1 && $method_number <= 7) { |
62 |
if ( $method_number >= 1 && $method_number <= 7 ) { |
| 61 |
push @methods_to_run, $method_number; |
63 |
push @methods_to_run, $method_number; |
| 62 |
} else { |
64 |
} |
|
|
65 |
else { |
| 63 |
print "Invalid method number: $method_number\n"; |
66 |
print "Invalid method number: $method_number\n"; |
| 64 |
} |
67 |
} |
| 65 |
} else { |
68 |
} |
|
|
69 |
else { |
| 66 |
print "Invalid argument: $arg\n"; |
70 |
print "Invalid argument: $arg\n"; |
| 67 |
} |
71 |
} |
| 68 |
} |
72 |
} |
| 69 |
} |
73 |
} |
| 70 |
|
74 |
|
| 71 |
foreach my $choice (@methods_to_run) { |
75 |
foreach my $choice (@methods_to_run) { |
| 72 |
if ($choice =~ /^\d+$/ && $choice >= 1 && $choice <= 7) { |
76 |
if ( $choice =~ /^\d+$/ && $choice >= 1 && $choice <= 7 ) { |
| 73 |
if (exists $methods{$choice}) { |
77 |
if ( exists $methods{$choice} ) { |
| 74 |
$methods{$choice}->(); |
78 |
$methods{$choice}->(); |
| 75 |
} else { |
79 |
} |
|
|
80 |
else { |
| 76 |
print "Method $choice not found\n"; |
81 |
print "Method $choice not found\n"; |
| 77 |
} |
82 |
} |
| 78 |
} else { |
83 |
} |
|
|
84 |
else { |
| 79 |
print "Invalid choice: $choice\n"; |
85 |
print "Invalid choice: $choice\n"; |
| 80 |
} |
86 |
} |
| 81 |
} |
87 |
} |
| 82 |
|
88 |
|
| 83 |
|
|
|
| 84 |
|
| 85 |
|
| 86 |
sub CheckItemsBranch { |
89 |
sub CheckItemsBranch { |
| 87 |
my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); |
90 |
my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); |
| 88 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} |
91 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} |
| 89 |
- |
|
|