From 04548e4c8050ec1d31f8e90adc05124c6ceea37f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 16 Oct 2020 14:22:58 +0100 Subject: [PATCH] Bug 21886: (QA follow-up) Fix QA script errors This patch fixes a perlcritic issue and also replaces tabs with four spaces where appropriate. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 4 ++-- misc/cronjobs/advance_notices.pl | 39 +++++++++++++++++--------------- misc/cronjobs/overdue_notices.pl | 22 +++++++++--------- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b3ec1d48ff..a0ed814606 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2701,7 +2701,7 @@ sub GetUpcomingDueIssues { my $dbh = C4::Context->dbh; my $statement; if($params->{'owning_library'}) { - $statement = <<"END_SQL"; + $statement = <<"END_SQL"; SELECT * FROM ( SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail @@ -2713,7 +2713,7 @@ FROM ( WHERE days_until_due >= 0 AND days_until_due <= ? END_SQL } else { - $statement = <<"END_SQL"; + $statement = <<"END_SQL"; SELECT * FROM ( SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index 39e9171c59..f514c6f916 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -125,7 +125,7 @@ Enabling this flag ensures that the issuing library is the sender of the digested message. It has no effect unless the borrower has chosen 'Digests only' on the advance messages. -=item B<-library> +=item B<--library> select notices for one specific library. Use the value in the branches.branchcode table. This option can be repeated in order @@ -240,7 +240,10 @@ unless ($confirm) { } cronlogaction(); -my %branches = map { $_ => 1 } @branchcodes if @branchcodes; +my %branches = {}; +if (@branchcodes) { + %branches = map { $_ => 1 } @branchcodes; +} # The fields that will be substituted into <> my @item_content_fields = split(/,/,$itemscontent); @@ -294,14 +297,14 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { $due_digest->{ $upcoming->{borrowernumber} }->{count}++; } } else { - my $branchcode; - if($owning_library) { - $branchcode = $upcoming->{'homebranch'}; - } else { - $branchcode = $upcoming->{'branchcode'}; - } - # Skip this DUE if we specify list of libraries and this one is not part of it - next if (@branchcodes && !$branches{$branchcode}); + my $branchcode; + if($owning_library) { + $branchcode = $upcoming->{'homebranch'}; + } else { + $branchcode = $upcoming->{'branchcode'}; + } + # Skip this DUE if we specify list of libraries and this one is not part of it + next if (@branchcodes && !$branches{$branchcode}); my $item = Koha::Items->find( $upcoming->{itemnumber} ); my $letter_type = 'DUE'; @@ -341,14 +344,14 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; } } else { - my $branchcode; - if($owning_library) { - $branchcode = $upcoming->{'homebranch'}; - } else { - $branchcode = $upcoming->{'branchcode'}; - } - # Skip this PREDUE if we specify list of libraries and this one is not part of it - next if (@branchcodes && !$branches{$branchcode}); + my $branchcode; + if($owning_library) { + $branchcode = $upcoming->{'homebranch'}; + } else { + $branchcode = $upcoming->{'branchcode'}; + } + # Skip this PREDUE if we specify list of libraries and this one is not part of it + next if (@branchcodes && !$branches{$branchcode}); my $item = Koha::Items->find( $upcoming->{itemnumber} ); my $letter_type = 'PREDUE'; diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index a698ce5ddc..3bf12387d8 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -341,8 +341,8 @@ if ( defined $csvfilename && $csvfilename =~ /^-/ ) { warn qq(using "$csvfilename" as filename, that seems odd); } -my @overduebranches = C4::Overdues::GetBranchcodesWithOverdueRules(); # Branches with overdue rules -my @branches; # Branches passed as parameter with overdue rules +my @overduebranches = C4::Overdues::GetBranchcodesWithOverdueRules(); # Branches with overdue rules +my @branches; # Branches passed as parameter with overdue rules my $branchcount = scalar(@overduebranches); my $overduebranch_word = scalar @overduebranches > 1 ? 'branches' : 'branch'; @@ -366,8 +366,8 @@ if (@branchcodes) { if (@branches) { - my $branch_word = scalar @branches > 1 ? 'branches' : 'branch'; - $verbose and warn "$branch_word @branches have overdue rules\n"; + my $branch_word = scalar @branches > 1 ? 'branches' : 'branch'; + $verbose and warn "$branch_word @branches have overdue rules\n"; } else { @@ -529,7 +529,7 @@ END_SQL # $letter->{'content'} is the text of the mail that is sent. # this text contains fields that are replaced by their value. Those fields must be written between brackets # The following fields are available : - # itemcount is interpreted here as the number of items in the overdue range defined by the current notice or all overdues < max if(-list-all). + # itemcount is interpreted here as the number of items in the overdue range defined by the current notice or all overdues < max if(-list-all). # my $borrower_sql = <<"END_SQL"; @@ -543,11 +543,11 @@ AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 END_SQL my @borrower_parameters; if ($branchcode) { - if($owning_library) { - $borrower_sql .= ' AND items.homebranch=? '; - } else { - $borrower_sql .= ' AND issues.branchcode=? '; - } + if($owning_library) { + $borrower_sql .= ' AND items.homebranch=? '; + } else { + $borrower_sql .= ' AND issues.branchcode=? '; + } push @borrower_parameters, $branchcode; } if ( $overdue_rules->{categorycode} ) { @@ -557,7 +557,7 @@ END_SQL $borrower_sql .= ' AND categories.overduenoticerequired=1 ORDER BY issues.borrowernumber'; # $sth gets borrower info iff at least one overdue item has triggered the overdue action. - my $sth = $dbh->prepare($borrower_sql); + my $sth = $dbh->prepare($borrower_sql); $sth->execute(@borrower_parameters); $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ". $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows"; -- 2.39.5