Bugzilla – Attachment 77580 Details for
Bug 21180
Allow Talking Tech outbound script to limit based on patron home library branchcode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21180: Allow Talking Tech outbound script to limit based on patron home library branchcode
Bug-21180-Allow-Talking-Tech-outbound-script-to-li.patch (text/plain), 6.31 KB, created by
Kyle M Hall (khall)
on 2018-08-08 17:02:24 UTC
(
hide
)
Description:
Bug 21180: Allow Talking Tech outbound script to limit based on patron home library branchcode
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-08-08 17:02:24 UTC
Size:
6.31 KB
patch
obsolete
>From 85bb4bd1bc0a355d24b491aaf1c05b913db542d8 Mon Sep 17 00:00:00 2001 >From: Martha Fuerst <mfuerst@hmcpl.org> >Date: Wed, 8 Aug 2018 12:51:39 -0400 >Subject: [PATCH] Bug 21180: Allow Talking Tech outbound script to limit based > on patron home library branchcode > >A library system has requested the ability to limit which patrons are sent to Itivia for phone notices. > >Test Plan: >1) Enable phone notices for two patrons with overdues >2) Run the misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl with the new --patron-branchcode option >3) Note only the patron whose homebranch you specified is in the output file >--- > .../thirdparty/TalkingTech_itiva_outbound.pl | 50 +++++++++++++++++----- > 1 file changed, 40 insertions(+), 10 deletions(-) > >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index 5826526c12..d3248e5e98 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -37,6 +37,7 @@ use C4::Letters; > use C4::Overdues; > use Koha::Calendar; > use Koha::DateUtils; >+use Koha::Libraries; > > sub usage { > pod2usage( -verbose => 2 ); >@@ -57,6 +58,7 @@ my @holds_waiting_days_to_call; > my $library_code; > my $help; > my $outfile; >+my $patron_branchcode; > > # maps to convert I-tiva terms to Koha terms > my $type_module_map = { >@@ -72,13 +74,14 @@ my $type_notice_map = { > }; > > GetOptions( >- 'o|output:s' => \$outfile, >- 'v' => \$verbose, >- 'lang:s' => \$language, >- 'type:s' => \@types, >- 'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, >- 'c|code|library-code:s' => \$library_code, >- 'help|h' => \$help, >+ 'o|output:s' => \$outfile, >+ 'v' => \$verbose, >+ 'lang:s' => \$language, >+ 'type:s' => \@types, >+ 'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, >+ 'c|code|library-code:s' => \$library_code, >+ 'pb|patron-branchcode:s' => \$patron_branchcode, >+ 'h|help' => \$help, > ); > > $language = uc($language); >@@ -86,6 +89,11 @@ $library_code ||= ''; > > pod2usage( -verbose => 1 ) if $help; > >+if ($patron_branchcode) { >+ die("Invalid branchcode '$patron_branchcode' passed in -b --branchcode parameter") >+ unless Koha::Libraries->search( { branchcode => $patron_branchcode } )->count; >+} >+ > # output log or STDOUT > my $OUT; > if ( defined $outfile ) { >@@ -105,11 +113,11 @@ foreach my $type (@types) { > > my @loop; > if ( $type eq 'OVERDUE' ) { >- @loop = GetOverdueIssues(); >+ @loop = GetOverdueIssues( $patron_branchcode ); > } elsif ( $type eq 'PREOVERDUE' ) { >- @loop = GetPredueIssues(); >+ @loop = GetPredueIssues( $patron_branchcode ); > } elsif ( $type eq 'RESERVE' ) { >- @loop = GetWaitingHolds(); >+ @loop = GetWaitingHolds( $patron_branchcode ); > } else { > print "Unknown or unsupported message type $type; skipping...\n" > if ( defined $verbose ); >@@ -207,11 +215,22 @@ consortium purposes and apply library specific settings, such as > prompts, to those notices. > This field can be blank if all messages are from a single library. > >+=item B<--patron-branchcode> B<--pb> >+ >+OPTIONAL >+ >+Limits the the patrons to generate notices for based on the patron's home library. >+Items and holds from other libraries will still be included for the given patron. >+ > =back > > =cut > > sub GetOverdueIssues { >+ my ( $patron_branchcode ) = @_; >+ >+ my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = $patron_branchcode" : q{}; >+ > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, > max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3, >@@ -227,6 +246,7 @@ sub GetOverdueIssues { > AND ( (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay1 > OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay2 > OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay3 ) >+ $patron_branchcode_filter > GROUP BY items.itemnumber > "; > my $sth = $dbh->prepare($query); >@@ -249,6 +269,10 @@ sub GetOverdueIssues { > } > > sub GetPredueIssues { >+ my ( $patron_branchcode ) = @_; >+ >+ my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = $patron_branchcode" : q{}; >+ > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, > issues.branchcode as site, branches.branchname as site_name >@@ -262,6 +286,7 @@ sub GetPredueIssues { > WHERE ( TO_DAYS( date_due ) - TO_DAYS( NOW() ) ) = days_in_advance > AND message_transport_type = 'phone' > AND message_name = 'Advance_Notice' >+ $patron_branchcode_filter > "; > my $sth = $dbh->prepare($query); > $sth->execute(); >@@ -274,6 +299,10 @@ sub GetPredueIssues { > } > > sub GetWaitingHolds { >+ my ( $patron_branchcode ) = @_; >+ >+ my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = $patron_branchcode" : q{}; >+ > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, > reserves.branchcode AS site, branches.branchname AS site_name, >@@ -288,6 +317,7 @@ sub GetWaitingHolds { > WHERE ( reserves.found = 'W' ) > AND message_transport_type = 'phone' > AND message_name = 'Hold_Filled' >+ $patron_branchcode_filter > "; > my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay"); > my $sth = $dbh->prepare($query); >-- >2.11.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 21180
:
77580
|
77581
|
81042
|
91921
|
92659