Bugzilla – Attachment 86513 Details for
Bug 21886
Add option to send notices from owning library instead of issuing library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21886: Add option to send notices from owning library instead of issuing library
Bug-21886-Add-option-to-send-notices-from-owning-l.patch (text/plain), 10.32 KB, created by
Björn Nylén
on 2019-03-12 12:12:28 UTC
(
hide
)
Description:
Bug 21886: Add option to send notices from owning library instead of issuing library
Filename:
MIME Type:
Creator:
Björn Nylén
Created:
2019-03-12 12:12:28 UTC
Size:
10.32 KB
patch
obsolete
>From a618f8652eb0c8d246a30b73014c1e4dc2f0e2cd Mon Sep 17 00:00:00 2001 >From: Stefan Berndtsson <Stefan Berndtsson> >Date: Tue, 20 Nov 2018 11:35:45 +0100 >Subject: [PATCH] Bug 21886: Add option to send notices from owning library > instead of issuing library >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The provided patch adds the following functionality: > >* Add --owning to both advance_notice.pl and overdue_notice.pl >* Add --library to advance_notice.pl like the way overdue_notice.pl already works > >When specifying "--owning" both scripts will use items.homebranch instead of >issues.branchcode to determine sending library. > >For advance_notice.pl this affects non-digest DUE and PREDUE, but not digest notices. > >To test: > >1. Have a patron who wants advance notices as email with 2 days in advance (not digest) >2. Have the first overdue date set 3 days past due date >3. Have issue for that patron where date_due is 2 days away where the item homebranch differs from the issuing branch >4. Have issue for that patron where date_due is 3 days old >5. Run advance_notices.pl without --owning >6. Run overdue_notices.pl without --owning >7. Confirm that two messages were created for that patron with the sender being the issuing branch >8. Delete messages or create two more issues according to (3) and (4) >9. Run advance_notices.pl with --owning >10. Run overdue_notices.pl with --owning >11. Confirm that the two messages created has the item homebranch as sender > >Extra feature for advance_notices.pl is that it adds a "--library" the same way overdue_notices.pl >has. Adding variants of that flag in steps (5) and (9) above can confirm this option as well. > >Sponsored-by: Gothenburg University Library >Signed-off-by: Björn Nylén <bjorn.nylen@ub.lu.se> >--- > C4/Circulation.pm | 19 +++++++++++++++--- > misc/cronjobs/advance_notices.pl | 43 +++++++++++++++++++++++++++++++++++++--- > misc/cronjobs/overdue_notices.pl | 13 +++++++++++- > 3 files changed, 68 insertions(+), 7 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index ef750cd..2c68b3f 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2598,8 +2598,21 @@ sub GetUpcomingDueIssues { > > $params->{'days_in_advance'} = 7 unless exists $params->{'days_in_advance'}; > my $dbh = C4::Context->dbh; >- >- my $statement = <<END_SQL; >+ my $statement; >+ if($params->{'owning_library'}) { >+ $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 >+ FROM issues >+ LEFT JOIN items USING (itemnumber) >+ LEFT OUTER JOIN branches ON (branches.branchcode = items.homebranch) >+ WHERE returndate is NULL >+) tmp >+WHERE days_until_due >= 0 AND days_until_due <= ? >+END_SQL >+ } else { >+ $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 >@@ -2610,7 +2623,7 @@ FROM ( > ) tmp > WHERE days_until_due >= 0 AND days_until_due <= ? > END_SQL >- >+ } > my @bind_parameters = ( $params->{'days_in_advance'} ); > > my $sth = $dbh->prepare( $statement ); >diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl >index 73697b8..c4ac363 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -109,6 +109,16 @@ defaults to date_due,title,author,barcode > Other possible values come from fields in the biblios, items and > issues tables. > >+=item B<-library> >+ >+select notices for one specific library. Use the value in the >+branches.branchcode table. This option can be repeated in order >+to select notices for a group of libraries. >+ >+=item B<-owning> >+ >+Use the address information from the item homebranch library instead of the issuing library. >+ > =back > > =head1 DESCRIPTION >@@ -174,6 +184,8 @@ my $nomail; # -n: No mai > my $mindays = 0; # -m: Maximum number of days in advance to send notices > my $maxdays = 30; # -e: the End of the time period > my $verbose = 0; # -v: verbose >+my @branchcodes; # Branch(es) passed as parameter >+my $owning_library = 0; > my $itemscontent = join(',',qw( date_due title author barcode )); > > my $help = 0; >@@ -182,6 +194,8 @@ my $man = 0; > GetOptions( > 'help|?' => \$help, > 'man' => \$man, >+ 'library=s' => \@branchcodes, >+ 'owning' => \$owning_library, > 'c' => \$confirm, > 'n' => \$nomail, > 'm:i' => \$maxdays, >@@ -209,11 +223,16 @@ unless ($confirm) { > > cronlogaction(); > >+my %branches = map { $_ => 1 } @branchcodes if @branchcodes; >+ > # The fields that will be substituted into <<items.content>> > my @item_content_fields = split(/,/,$itemscontent); > > warn 'getting upcoming due issues' if $verbose; >-my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $maxdays } ); >+my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { >+ days_in_advance => $maxdays, >+ owning_library => $owning_library >+ } ); > warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; > > # hash of borrowernumber to number of items upcoming >@@ -253,6 +272,15 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > $due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; > $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 $item = Koha::Items->find( $upcoming->{itemnumber} ); > my $letter_type = 'DUE'; > $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); >@@ -265,7 +293,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { > my $letter = parse_letter( { letter_code => $letter_type, > borrowernumber => $upcoming->{'borrowernumber'}, >- branchcode => $upcoming->{'branchcode'}, >+ branchcode => $branchcode, > biblionumber => $item->biblionumber, > itemnumber => $upcoming->{'itemnumber'}, > substitute => { 'items.content' => $titles }, >@@ -286,6 +314,15 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > $upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; > $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 $item = Koha::Items->find( $upcoming->{itemnumber} ); > my $letter_type = 'PREDUE'; > $sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); >@@ -298,7 +335,7 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { > my $letter = parse_letter( { letter_code => $letter_type, > borrowernumber => $upcoming->{'borrowernumber'}, >- branchcode => $upcoming->{'branchcode'}, >+ branchcode => $branchcode, > biblionumber => $item->biblionumber, > itemnumber => $upcoming->{'itemnumber'}, > substitute => { 'items.content' => $titles }, >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 8c42335..adb5d6f 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -74,6 +74,7 @@ overdue_notices.pl > -list-all list all overdues > -date <yyyy-mm-dd> emulate overdues run for this date > -email <email_type> type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable. >+ -owning Send notices from item homebranch library instead of issuing library > > =head1 OPTIONS > >@@ -182,6 +183,10 @@ use it in order to send overdues on a specific date and not Now. Format: YYYY-MM > > Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable. > >+=item B<-owning> >+ >+Use the address information from the item homebranch library instead of the issuing library. >+ > =back > > =head1 DESCRIPTION >@@ -291,6 +296,7 @@ my $verbose = 0; > my $nomail = 0; > my $MAX = 90; > my $test_mode = 0; >+my $owning_library = 0; > my @branchcodes; # Branch(es) passed as parameter > my @emails_to_use; # Emails to use for messaging > my @emails; # Emails given in command-line parameters >@@ -322,6 +328,7 @@ GetOptions( > 'borcat=s' => \@myborcat, > 'borcatout=s' => \@myborcatout, > 'email=s' => \@emails, >+ 'owning' => \$owning_library, > ) or pod2usage(2); > pod2usage(1) if $help; > pod2usage( -verbose => 2 ) if $man; >@@ -526,7 +533,11 @@ AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 > END_SQL > my @borrower_parameters; > if ($branchcode) { >- $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} ) { >-- >2.1.4
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 21886
:
82668
|
86513
|
111581
|
111582
|
111679
|
111711
|
111828
|
111872
|
111873
|
112990
|
114068
|
114069
|
114070
|
114071