@@ -, +, @@ section optional --- .../search_for_data_inconsistencies.pl | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ a/misc/maintenance/search_for_data_inconsistencies.pl @@ -27,8 +27,51 @@ use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; use C4::Biblio qw( GetMarcFromKohaField ); +use Data::Dumper; -{ + + +my %methods = ( + 1 => \&CheckItemsBranch, + 2 => \&CheckItemsAuthHeader, + 3 => \&CheckItemsStatus, + 4 => \&CheckItemsFramework, + 5 => \&CheckItemsTitle +); + +say " + 1 : Check for items without home or holding library + 2 : Check for authority records with invalid authority type + 3 : Check for bibliographic records and items without an item type or with an invalid item type + 4 : Check for invalid values in fields where the framework limits to an authorized value category + 5 : Check for bibliographic records without a title"; + + +print "Choose method(s) to run (1-5, separated by spaces): "; +my $choices_str = ; +chomp($choices_str); + +# Split the input string into an array of choices +my @choices = split(/\s+/, $choices_str); + + +# Run selected methods +foreach my $choice (@choices) { + if ($choice =~ /^\d+$/ && $choice >= 1 && $choice <= 5) { + if (exists $methods{$choice}) { + $methods{$choice}->(); + } else { + print "Method $choice not found\n"; + } + } else { + print "Invalid choice: $choice\n"; + } +} + + + + +sub CheckItemsBranch { my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }}); if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch")} while ( my $item = $items->next ) { @@ -43,7 +86,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch")} } -{ +sub CheckItemsAuthHeader { # No join possible, FK is missing at DB level my @auth_types = Koha::Authority::Types->search->get_column('authtypecode'); my $authorities = Koha::Authorities->search({authtypecode => { 'not in' => \@auth_types } }); @@ -54,7 +97,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); if ( $authorities->count ) {new_hint("Go to 'Home › Administration › Authority types' to define them")} } -{ +sub CheckItemsStatus { if ( C4::Context->preference('item-level_itypes') ) { my $items_without_itype = Koha::Items->search( { -or => [itype => undef,itype => ''] } ); if ( $items_without_itype->count ) { @@ -192,7 +235,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } -{ +sub CheckItemsFramework { my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); push @framework_codes,""; # The default is not stored in frameworks, we need to force it @@ -273,7 +316,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } -{ +sub CheckItemsTitle { my $biblios = Koha::Biblios->search({ -or => [ title => '', @@ -292,7 +335,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } -{ +sub CheckAgeForCategory { my $aging_patrons = Koha::Patrons->search( { -not => { @@ -326,6 +369,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } + sub new_section { my ( $name ) = @_; say "\n== $name =="; --