From 3621e32bd13a467734894486db73e84a21d7baf6 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 17 Oct 2023 09:24:09 +0000 Subject: [PATCH] Bug 35073: perltidy subscription-batchedit.pl git show -w Signed-off-by: Katrin Fischer Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Tomas Cohen Arazi (cherry picked from commit ffb5022591f6b96c50bf8a9c0409bd01b108a65c) Signed-off-by: Fridolin Somers --- serials/subscription-batchedit.pl | 64 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/serials/subscription-batchedit.pl b/serials/subscription-batchedit.pl index 2c31fa9f12..274bcd4f23 100755 --- a/serials/subscription-batchedit.pl +++ b/serials/subscription-batchedit.pl @@ -21,8 +21,8 @@ use Modern::Perl; use CGI qw( -utf8 ); -use C4::Auth qw( get_template_and_user ); -use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); use C4::Serials qw( can_edit_subscription ); use Koha::Subscriptions; use Koha::Acquisition::Booksellers; @@ -31,12 +31,14 @@ use Koha::DateUtils qw( dt_from_string ); my $cgi = CGI->new; -my ($template, $loggedinuser, $cookie) = get_template_and_user({ - template_name => 'serials/subscription-batchedit.tt', - query => $cgi, - type => 'intranet', - flagsrequired => {serials => 'edit_subscription'}, -}); +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => 'serials/subscription-batchedit.tt', + query => $cgi, + type => 'intranet', + flagsrequired => { serials => 'edit_subscription' }, + } +); my @subscriptionids = $cgi->multi_param('subscriptionid'); @@ -47,46 +49,48 @@ foreach my $subscriptionid (@subscriptionids) { push @subscriptions, $subscription if $subscription; } -my @available_additional_fields = Koha::AdditionalFields->search({tablename => 'subscription'})->as_list; +my @available_additional_fields = Koha::AdditionalFields->search( { tablename => 'subscription' } )->as_list; my $batchedit = $cgi->param('batchedit'); if ($batchedit) { my %params = ( - aqbooksellerid => scalar $cgi->param('booksellerid'), - location => scalar $cgi->param('location'), - branchcode => scalar $cgi->param('branchcode'), - itemtype => scalar $cgi->param('itemtype'), - notes => scalar $cgi->param('notes'), - internalnotes => scalar $cgi->param('internalnotes'), + aqbooksellerid => scalar $cgi->param('booksellerid'), + location => scalar $cgi->param('location'), + branchcode => scalar $cgi->param('branchcode'), + itemtype => scalar $cgi->param('itemtype'), + notes => scalar $cgi->param('notes'), + internalnotes => scalar $cgi->param('internalnotes'), serialsadditems => scalar $cgi->param('serialsadditems'), - enddate => dt_from_string(scalar $cgi->param('enddate')), + enddate => dt_from_string( scalar $cgi->param('enddate') ), ); my $field_values = {}; foreach my $field (@available_additional_fields) { - my $value = $cgi->param('field_' . $field->id); - $field_values->{$field->id} = $value; + my $value = $cgi->param( 'field_' . $field->id ); + $field_values->{ $field->id } = $value; } foreach my $subscription (@subscriptions) { - next unless C4::Serials::can_edit_subscription( $subscription->unblessed ); # This should be moved to Koha::Subscription->can_edit - while (my ($key, $value) = each %params) { - if (defined $value and $value ne '') { + next + unless C4::Serials::can_edit_subscription( $subscription->unblessed ) + ; # This should be moved to Koha::Subscription->can_edit + while ( my ( $key, $value ) = each %params ) { + if ( defined $value and $value ne '' ) { $subscription->$key($value); } } my @additional_field_values; foreach my $field (@available_additional_fields) { - my $value = $field_values->{$field->id}; - if (defined $value and $value ne '') { + my $value = $field_values->{ $field->id }; + if ( defined $value and $value ne '' ) { push @additional_field_values, { - id => $field->id, + id => $field->id, value => $value, }; - }else{ + } else { my $existing = $subscription->additional_field_values->search( { field_id => $field->id } )->last; - if($existing && $existing->value){ + if ( $existing && $existing->value ) { push @additional_field_values, { id => $field->id, value => $existing->value, @@ -94,7 +98,7 @@ if ($batchedit) { } } } - $subscription->set_additional_fields(\@additional_field_values); + $subscription->set_additional_fields( \@additional_field_values ); $subscription->store; } @@ -105,10 +109,10 @@ if ($batchedit) { } $template->param( - subscriptions => \@subscriptions, - booksellers => [ Koha::Acquisition::Booksellers->search->as_list ], + subscriptions => \@subscriptions, + booksellers => [ Koha::Acquisition::Booksellers->search->as_list ], additional_fields => \@available_additional_fields, - referrer => scalar $cgi->param('referrer'), + referrer => scalar $cgi->param('referrer'), ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.39.5