From 5a560d2129df327e3145e6fe0fc9213b7f0018e0 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Wed, 19 Mar 2025 16:54:47 +0100 Subject: [PATCH] Bug 30255: Make tidy --- .../tools/batch_record_modification.tt | 4 +- tools/batch_delete_records.pl | 59 +++++++++++-------- tools/batch_record_modification.pl | 49 +++++++-------- 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt index bdd741f3cdb..b8c9f0a2170 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt @@ -171,9 +171,7 @@
diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl index cf0ef012b2a..3f58b1398f1 100755 --- a/tools/batch_delete_records.pl +++ b/tools/batch_delete_records.pl @@ -60,22 +60,22 @@ my $enqueue_job = sub { try { my $params = { - record_ids => $record_ids, + record_ids => $record_ids, }; my $job_id = - $recordtype eq 'biblio' - ? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) - : Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); + $recordtype eq 'biblio' + ? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) + : Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); $template->param( - op => 'enqueued', + op => 'enqueued', job_id => $job_id, ); } catch { push @messages, { - type => 'error', - code => 'cannot_enqueue_job', + type => 'error', + code => 'cannot_enqueue_job', error => $_, }; $template->param( view => 'errors' ); @@ -83,6 +83,7 @@ my $enqueue_job = sub { }; if ( $op eq 'form' ) { + # Display the form $template->param( op => 'form', @@ -94,6 +95,7 @@ if ( $op eq 'form' ) { ) ); } elsif ( $op eq 'cud-list' || $op eq 'delete_all' ) { + # List all records to process my @record_ids; if ( my $bib_list = $input->param('bib_list') ) { @@ -102,6 +104,7 @@ if ( $op eq 'form' ) { @record_ids = split /\//, $bib_list; $recordtype = 'biblio'; } elsif ( my $uploadfile = $input->param('uploadfile') ) { + # A file of id is given binmode $uploadfile, ':encoding(UTF-8)'; while ( my $content = <$uploadfile> ) { @@ -117,30 +120,32 @@ if ( $op eq 'form' ) { push @record_ids, $biblionumber; } } else { + # The user enters manually the list of id push @record_ids, split( /\s\n/, scalar $input->param('recordnumber_list') ); } if ( $op eq 'delete_all' ) { - $enqueue_job->(\@record_ids, $recordtype); - } - else { + $enqueue_job->( \@record_ids, $recordtype ); + } else { for my $record_id ( uniq @record_ids ) { if ( $recordtype eq 'biblio' ) { + # Retrieve biblio information - my $biblio_object = Koha::Biblios->find( $record_id ); - unless ( $biblio_object ) { + my $biblio_object = Koha::Biblios->find($record_id); + unless ($biblio_object) { push @messages, { - type => 'warning', - code => 'biblio_not_exists', + type => 'warning', + code => 'biblio_not_exists', biblionumber => $record_id, }; next; } my $biblio = $biblio_object->unblessed; my $record = $biblio_object->metadata->record; - $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; - $biblio->{holds_count} = $biblio_object->holds->count; - $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); + $biblio->{itemnumbers} = + [ Koha::Items->search( { biblionumber => $record_id } )->get_column('itemnumber') ]; + $biblio->{holds_count} = $biblio_object->holds->count; + $biblio->{issues_count} = C4::Biblio::CountItemsIssued($record_id); $biblio->{subscriptions_count} = $biblio_object->subscriptions->count; # Respect skip_open_orders @@ -151,34 +156,36 @@ if ( $op eq 'form' ) { push @records, $biblio; } else { + # Retrieve authority information - my $authority = C4::AuthoritiesMarc::GetAuthority( $record_id ); - unless ( $authority ) { + my $authority = C4::AuthoritiesMarc::GetAuthority($record_id); + unless ($authority) { push @messages, { - type => 'warning', - code => 'authority_not_exists', + type => 'warning', + code => 'authority_not_exists', authid => $record_id, }; next; } $authority = { - authid => $record_id, - summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), - count_usage => Koha::Authorities->get_usage_count({ authid => $record_id }), + authid => $record_id, + summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), + count_usage => Koha::Authorities->get_usage_count( { authid => $record_id } ), }; push @records, $authority; } $template->param( records => \@records, - op => 'list', + op => 'list', ); } } } elsif ( $op eq 'cud-delete' ) { + # We want to delete selected records! my @record_ids = $input->multi_param('record_id'); - $enqueue_job->(\@record_ids, $recordtype); + $enqueue_job->( \@record_ids, $recordtype ); } $template->param( diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl index 32a63bdea14..d8a2bf85f7d 100755 --- a/tools/batch_record_modification.pl +++ b/tools/batch_record_modification.pl @@ -55,11 +55,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); - my $enqueue_job = sub { my ( $record_ids, $recordtype ) = @_; try { - my $patron = Koha::Patrons->find( $loggedinuser ); + my $patron = Koha::Patrons->find($loggedinuser); my $params = { mmtid => $mmtid, record_ids => $record_ids, @@ -71,18 +70,18 @@ my $enqueue_job = sub { }; my $job_id = - $recordtype eq 'biblio' - ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params) - : Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue($params); + $recordtype eq 'biblio' + ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params) + : Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue($params); $template->param( - view => 'enqueued', + view => 'enqueued', job_id => $job_id, ); } catch { push @messages, { - type => 'error', - code => 'cannot_enqueue_job', + type => 'error', + code => 'cannot_enqueue_job', error => $_, }; $template->param( view => 'errors' ); @@ -126,7 +125,7 @@ if ( $op eq 'form' ) { ] ) ); -} elsif ( $op eq 'cud-list' || $op eq 'modify_all') { +} elsif ( $op eq 'cud-list' || $op eq 'modify_all' ) { # List all records to process my ( @records, @record_ids ); @@ -158,50 +157,52 @@ if ( $op eq 'form' ) { } if ( $op eq 'modify_all' ) { - $enqueue_job->(\@record_ids, $recordtype); - } - else { + $enqueue_job->( \@record_ids, $recordtype ); + } else { for my $record_id ( uniq @record_ids ) { if ( $recordtype eq 'biblio' ) { + # Retrieve biblio information - my $biblio = Koha::Biblios->find( $record_id ); - unless ( $biblio ) { + my $biblio = Koha::Biblios->find($record_id); + unless ($biblio) { push @messages, { - type => 'warning', - code => 'biblio_not_exists', + type => 'warning', + code => 'biblio_not_exists', biblionumber => $record_id, }; next; } push @records, $biblio; } else { + # Retrieve authority information - my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id ); - unless ( $authority ) { + my $authority = Koha::MetadataRecord::Authority->get_from_authid($record_id); + unless ($authority) { push @messages, { - type => 'warning', - code => 'authority_not_exists', + type => 'warning', + code => 'authority_not_exists', authid => $record_id, }; next; } push @records, { - authid => $record_id, + authid => $record_id, summary => C4::AuthoritiesMarc::BuildSummary( $authority->record, $record_id ), }; } $template->param( records => \@records, - mmtid => $mmtid, - view => 'list', + mmtid => $mmtid, + view => 'list', ); } } } elsif ( $op eq 'cud-modify' ) { + # We want to modify selected records! my @record_ids = $input->multi_param('record_id'); - $enqueue_job->(\@record_ids, $recordtype); + $enqueue_job->( \@record_ids, $recordtype ); } $template->param( -- 2.34.1