Lines 27-34
use Koha::Items;
Link Here
|
27 |
use Koha::ItemTypes; |
27 |
use Koha::ItemTypes; |
28 |
use Koha::Patrons; |
28 |
use Koha::Patrons; |
29 |
use C4::Biblio qw( GetMarcFromKohaField ); |
29 |
use C4::Biblio qw( GetMarcFromKohaField ); |
|
|
30 |
use Data::Dumper; |
30 |
|
31 |
|
31 |
{ |
32 |
|
|
|
33 |
|
34 |
my %methods = ( |
35 |
1 => \&CheckItemsBranch, |
36 |
2 => \&CheckItemsAuthHeader, |
37 |
3 => \&CheckItemsStatus, |
38 |
4 => \&CheckItemsFramework, |
39 |
5 => \&CheckItemsTitle |
40 |
); |
41 |
|
42 |
say " |
43 |
1 : Check for items without home or holding library |
44 |
2 : Check for authority records with invalid authority type |
45 |
3 : Check for bibliographic records and items without an item type or with an invalid item type |
46 |
4 : Check for invalid values in fields where the framework limits to an authorized value category |
47 |
5 : Check for bibliographic records without a title"; |
48 |
|
49 |
|
50 |
print "Choose method(s) to run (1-5, separated by spaces): "; |
51 |
my $choices_str = <STDIN>; |
52 |
chomp($choices_str); |
53 |
|
54 |
# Split the input string into an array of choices |
55 |
my @choices = split(/\s+/, $choices_str); |
56 |
|
57 |
|
58 |
# Run selected methods |
59 |
foreach my $choice (@choices) { |
60 |
if ($choice =~ /^\d+$/ && $choice >= 1 && $choice <= 5) { |
61 |
if (exists $methods{$choice}) { |
62 |
$methods{$choice}->(); |
63 |
} else { |
64 |
print "Method $choice not found\n"; |
65 |
} |
66 |
} else { |
67 |
print "Invalid choice: $choice\n"; |
68 |
} |
69 |
} |
70 |
|
71 |
|
72 |
|
73 |
|
74 |
sub CheckItemsBranch { |
32 |
my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); |
75 |
my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); |
33 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} |
76 |
if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} |
34 |
while ( my $item = $items->next ) { |
77 |
while ( my $item = $items->next ) { |
Lines 43-49
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
43 |
if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch")} |
86 |
if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch")} |
44 |
} |
87 |
} |
45 |
|
88 |
|
46 |
{ |
89 |
sub CheckItemsAuthHeader { |
47 |
# No join possible, FK is missing at DB level |
90 |
# No join possible, FK is missing at DB level |
48 |
my @auth_types = Koha::Authority::Types->search->get_column('authtypecode'); |
91 |
my @auth_types = Koha::Authority::Types->search->get_column('authtypecode'); |
49 |
my $authorities = Koha::Authorities->search({authtypecode => { 'not in' => \@auth_types } }); |
92 |
my $authorities = Koha::Authorities->search({authtypecode => { 'not in' => \@auth_types } }); |
Lines 54-60
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
54 |
if ( $authorities->count ) {new_hint("Go to 'Home › Administration › Authority types' to define them")} |
97 |
if ( $authorities->count ) {new_hint("Go to 'Home › Administration › Authority types' to define them")} |
55 |
} |
98 |
} |
56 |
|
99 |
|
57 |
{ |
100 |
sub CheckItemsStatus { |
58 |
if ( C4::Context->preference('item-level_itypes') ) { |
101 |
if ( C4::Context->preference('item-level_itypes') ) { |
59 |
my $items_without_itype = Koha::Items->search( { -or => [itype => undef,itype => ''] } ); |
102 |
my $items_without_itype = Koha::Items->search( { -or => [itype => undef,itype => ''] } ); |
60 |
if ( $items_without_itype->count ) { |
103 |
if ( $items_without_itype->count ) { |
Lines 192-198
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
192 |
} |
235 |
} |
193 |
} |
236 |
} |
194 |
|
237 |
|
195 |
{ |
238 |
sub CheckItemsFramework { |
196 |
my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); |
239 |
my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); |
197 |
push @framework_codes,""; # The default is not stored in frameworks, we need to force it |
240 |
push @framework_codes,""; # The default is not stored in frameworks, we need to force it |
198 |
|
241 |
|
Lines 273-279
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
273 |
} |
316 |
} |
274 |
} |
317 |
} |
275 |
|
318 |
|
276 |
{ |
319 |
sub CheckItemsTitle { |
277 |
my $biblios = Koha::Biblios->search({ |
320 |
my $biblios = Koha::Biblios->search({ |
278 |
-or => [ |
321 |
-or => [ |
279 |
title => '', |
322 |
title => '', |
Lines 292-298
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
292 |
} |
335 |
} |
293 |
} |
336 |
} |
294 |
|
337 |
|
295 |
{ |
338 |
sub CheckAgeForCategory { |
296 |
my $aging_patrons = Koha::Patrons->search( |
339 |
my $aging_patrons = Koha::Patrons->search( |
297 |
{ |
340 |
{ |
298 |
-not => { |
341 |
-not => { |
Lines 326-331
use C4::Biblio qw( GetMarcFromKohaField );
Link Here
|
326 |
} |
369 |
} |
327 |
} |
370 |
} |
328 |
|
371 |
|
|
|
372 |
|
329 |
sub new_section { |
373 |
sub new_section { |
330 |
my ( $name ) = @_; |
374 |
my ( $name ) = @_; |
331 |
say "\n== $name =="; |
375 |
say "\n== $name =="; |
332 |
- |
|
|