Bugzilla – Attachment 172608 Details for
Bug 10190
Overdue notice triggers based on item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10190: Add comments to overdue_notices and rename variable
Bug-10190-Add-comments-to-overduenotices-and-renam.patch (text/plain), 5.02 KB, created by
Martin Renvoize (ashimema)
on 2024-10-10 14:40:25 UTC
(
hide
)
Description:
Bug 10190: Add comments to overdue_notices and rename variable
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-10 14:40:25 UTC
Size:
5.02 KB
patch
obsolete
>From 0f7acf7bc2537afb13a29b1b173251848bd8460e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 16 Aug 2024 14:08:40 +0100 >Subject: [PATCH] Bug 10190: Add comments to overdue_notices and rename > variable > >Trying to fully understand how this script operates.. this patch adds >some notes to the script for developers and also renames a variable that >I found was being re-used. >--- > misc/cronjobs/overdue_notices.pl | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 1b8b87fbc68..204bef008f3 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -463,6 +463,8 @@ elsif ( defined $text_filename ) { > > my %already_queued; > my %seen = map { $_ => 1 } @branches; >+ >+# Work through branches > foreach my $branchcode (@branches) { > my $calendar; > if ( C4::Context->preference('OverdueNoticeCalendar') ) { >@@ -520,17 +522,19 @@ END_SQL > @itemtypes = Koha::ItemTypes->search()->get_column('itemtype'); > } > >+ # Work through category and itemtype combinations to catch overdue rules for each > for my $category (@categories) { > for my $itemtype (@itemtypes) { > my $i = 0; >+ # Work through triggers until we run out of rules > PERIOD: while (1) { > $i++; >- my $j = $i + 1; >+ my $ii = $i + 1; > my $overdue_rules = Koha::CirculationRules->get_effective_rules( > { > rules => [ > "overdue_$i" . '_delay', "overdue_$i" . '_notice', "overdue_$i" . '_mtt', >- "overdue_$i" . '_restrict', "overdue_$j" . '_delay' >+ "overdue_$i" . '_restrict', "overdue_$ii" . '_delay' > ], > categorycode => $category, > branchcode => $branchcode, >@@ -546,8 +550,8 @@ END_SQL > my $mindays = > $overdue_rules->{ "overdue_$i" . '_delay' }; # the notice will be sent after mindays days (grace period) > my $maxdays = ( >- $overdue_rules->{ "overdue_$j" . '_delay' } >- ? $overdue_rules->{ "overdue_$j" . '_delay' } - 1 >+ $overdue_rules->{ "overdue_$ii" . '_delay' } >+ ? $overdue_rules->{ "overdue_$ii" . '_delay' } - 1 > : ($MAX) > ); # issues being more than maxdays late are managed somewhere else. (borrower probably suspended) > >@@ -565,6 +569,7 @@ END_SQL > # 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). > # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country> > >+ # Fetch all overdue issues where the item is not lost and the borrower category wants overdue notices grouping by borrower > my $borrower_sql = <<"END_SQL"; > SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, phone, cardnumber, date_due > FROM issues,borrowers,categories,items >@@ -589,7 +594,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. >+ # $sth gets borrower info if at least one overdue item has triggered the overdue action. > my $sth = $dbh->prepare($borrower_sql); > $sth->execute(@borrower_parameters); > >@@ -600,6 +605,7 @@ END_SQL > } > $verbose and warn sprintf "Found %s borrowers with overdues\n", $sth->rows; > my $borrowernumber; >+ # Iterate over all overdue issues > while ( my $data = $sth->fetchrow_hashref ) { > > # check the borrower has at least one item that matches >@@ -633,7 +639,10 @@ END_SQL > next; > } > $borrowernumber = $data->{'borrowernumber'}; >+ >+ # Skip duplicate borrowers as we'll have already handled them > next if ( $patron_homelibrary && $already_queued{"$borrowernumber$i"} ); >+ > my $borr = sprintf( "%s%s%s (%s)", > $data->{'surname'} || '', > $data->{'firstname'} && $data->{'surname'} ? ', ' : '', >@@ -700,6 +709,7 @@ END_SQL > > my $j = 0; > my $exceededPrintNoticesMaxLines = 0; >+ # Get each overdue item for this patron > while ( my $item_info = $sth2->fetchrow_hashref() ) { > if ( C4::Context->preference('OverdueNoticeCalendar') ) { > $days_between = >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10190
:
170357
|
170358
|
170359
|
170360
|
170361
|
170362
|
170363
|
170364
|
170365
|
170366
|
170367
|
170368
|
170369
|
170370
|
170371
|
170372
|
170373
|
170374
|
170375
|
170376
|
170380
|
170449
|
171727
|
171728
|
171729
|
171730
|
171731
|
171732
|
171733
|
171734
|
171735
|
171736
|
171737
|
171738
|
171739
|
171740
|
171741
|
171742
|
171743
|
171744
|
171745
|
171746
|
171747
|
171748
|
171749
|
171750
|
171751
|
171752
|
171753
|
171754
|
171755
|
172588
|
172589
|
172590
|
172591
|
172592
|
172593
|
172594
|
172595
|
172596
|
172597
|
172598
|
172599
|
172600
|
172601
|
172602
|
172603
|
172604
|
172605
|
172606
|
172607
|
172608
|
172609
|
172612
|
172614
|
172617
|
172619
|
172621
|
172622
|
172623
|
172624
|
172625
|
172626
|
172630
|
172631
|
172632
|
172633
|
172634
|
172635
|
172636
|
172637
|
172638
|
172639
|
172640
|
172641
|
172642
|
172643
|
172644
|
172645
|
172646
|
172647
|
172648
|
172649
|
172650
|
172651
|
172652
|
172653
|
172654
|
172655
|
172656
|
172657
|
172658
|
172659
|
172660
|
172661
|
172662
|
172663