From dbe5909f49085619a97ba2a24b49465417cf96f0 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. --- 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 236063c01f..9a427fd0e2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2619,7 +2619,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 @@ -2631,7 +2631,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 21b1878189..417dd0c588 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -339,8 +339,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'; @@ -364,8 +364,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 { @@ -527,7 +527,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"; @@ -541,11 +541,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} ) { @@ -555,7 +555,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.20.1